Class: HealthInspector::Checklists::Environments
- Inherits:
-
Base
- Object
- Base
- HealthInspector::Checklists::Environments
show all
- Defined in:
- lib/health_inspector/checklists/environments.rb
Defined Under Namespace
Classes: Environment
Instance Method Summary
collapse
Methods inherited from Base
add_check, #banner, #checks, #chef_rest, #indent, #initialize, #load_ruby_or_json_from_local, #print_failures, #print_failures_from_hash, #print_key, #print_success, #print_value_diff, #run, run, #run_check, #run_checks
#color
Instance Method Details
#each_item ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/health_inspector/checklists/environments.rb', line 25
def each_item
server_items = items_on_server
local_items = items_in_repo
all_item_names = ( server_items + local_items ).uniq.sort
all_item_names.each do |name|
item = Environment.new.tap do |item|
item.name = name
item.server = load_item_from_server(name)
item.local = load_item_from_local(name)
end
yield item
end
end
|
#items_in_repo ⇒ Object
45
46
47
48
49
|
# File 'lib/health_inspector/checklists/environments.rb', line 45
def items_in_repo
Dir.chdir("#{@context.repo_path}/environments") do
Dir["*.{rb,json,js}"].map { |e| e.gsub(/\.(rb|json|js)/,"") }
end
end
|
#items_on_server ⇒ Object
41
42
43
|
# File 'lib/health_inspector/checklists/environments.rb', line 41
def items_on_server
@items_on_server ||= Chef::Environment.list.keys
end
|
#load_item_from_local(name) ⇒ Object
58
59
60
|
# File 'lib/health_inspector/checklists/environments.rb', line 58
def load_item_from_local(name)
load_ruby_or_json_from_local(Chef::Environment, "environments", name)
end
|
#load_item_from_server(name) ⇒ Object
51
52
53
54
55
56
|
# File 'lib/health_inspector/checklists/environments.rb', line 51
def load_item_from_server(name)
env = Chef::Environment.load(name)
env.to_hash
rescue
nil
end
|