Class: HealthInspector::Checklists::Environments

Inherits:
Base
  • Object
show all
Defined in:
lib/health_inspector/checklists/environments.rb

Instance Method Summary collapse

Methods inherited from Base

#all_item_names, #banner, #indent, #initialize, #load_ruby_or_json_from_local, #load_validate, option, #print_failures, #print_failures_from_hash, #print_key, #print_success, #print_value_diff, run, #run, title, #ui, underscored_class, #validate_item

Methods included from HealthInspector::Color

#color

Constructor Details

This class inherits a constructor from HealthInspector::Checklists::Base

Instance Method Details

#load_item(name) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/health_inspector/checklists/environments.rb', line 18

def load_item(name)
  Environment.new(@context,
                  name: name,
                  server: load_item_from_server(name),
                  local: load_item_from_local(name)
  )
end

#load_item_from_local(name) ⇒ Object



42
43
44
# File 'lib/health_inspector/checklists/environments.rb', line 42

def load_item_from_local(name)
  load_ruby_or_json_from_local(Chef::Environment, 'environments', name)
end

#load_item_from_server(name) ⇒ Object



36
37
38
39
40
# File 'lib/health_inspector/checklists/environments.rb', line 36

def load_item_from_server(name)
  Chef::Environment.load(name).to_hash
rescue
  nil
end

#local_itemsObject



30
31
32
33
34
# File 'lib/health_inspector/checklists/environments.rb', line 30

def local_items
  Dir["#{@context.repo_path}/environments/**/*.{rb,json,js}"].map do |e|
    File.basename(e, '.*')
  end
end

#server_itemsObject



26
27
28
# File 'lib/health_inspector/checklists/environments.rb', line 26

def server_items
  @server_items ||= Chef::Environment.list.keys
end