Skip to content

Commit a99e60e

Browse files
committed
clean up indented blocks, Hash#index is deprecated on 1.9
1 parent 722d393 commit a99e60e

2 files changed

Lines changed: 21 additions & 23 deletions

File tree

‎chef-server-webui/app/controllers/clients.rb‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ class Clients < Application
2525

2626
# GET /clients
2727
def index
28-
@clients_list = begin
29-
Chef::ApiClient.list()
30-
rescue => e
31-
Chef::Log.error("#{e}\n#{e.backtrace.join("\n")}")
32-
@_message = {:error => "Could not list clients"}
33-
{}
34-
end.keys.sort
28+
begin
29+
@clients_list = Chef::ApiClient.list().keys.sort
30+
rescue => e
31+
Chef::Log.error("#{e}\n#{e.backtrace.join("\n")}")
32+
@_message = {:error => "Could not list clients"}
33+
@clients_list = []
34+
end
3535
render
3636
end
3737

‎chef-server-webui/app/controllers/nodes.rb‎

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,25 @@ class Nodes < Application
2727
before :login_required
2828

2929
def index
30-
node_hash = begin
31-
Chef::Node.list
32-
rescue => e
33-
Chef::Log.error("#{e}\n#{e.backtrace.join("\n")}")
34-
@_message = {:error => "Could not list nodes"}
35-
{}
36-
end
37-
@node_list = node_hash.values.sort.map do |node_url|
38-
node_hash.index(node_url)
30+
begin
31+
node_hash = Chef::Node.list
32+
@node_list = node_hash.keys.sort_by {|a,b| node_hash[a] <=> node_hash[b]}
33+
rescue => e
34+
Chef::Log.error("#{e}\n#{e.backtrace.join("\n")}")
35+
@_message = {:error => "Could not list nodes"}
36+
@node_hash = {}
3937
end
4038
render
4139
end
4240

4341
def show
44-
@node = begin
45-
Chef::Node.load(params[:id])
46-
rescue => e
47-
Chef::Log.error("#{e}\n#{e.backtrace.join("\n")}")
48-
@_message = {:error => "Could not load node #{params[:id]}"}
49-
Chef::Node.new
50-
end
42+
begin
43+
@node =Chef::Node.load(params[:id])
44+
rescue => e
45+
Chef::Log.error("#{e}\n#{e.backtrace.join("\n")}")
46+
@_message = {:error => "Could not load node #{params[:id]}"}
47+
@node = Chef::Node.new
48+
end
5149
render
5250
end
5351

0 commit comments

Comments
 (0)