File tree Expand file tree Collapse file tree
health_inspector/checklists Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,5 +30,6 @@ Gem::Specification.new do |s|
3030
3131 s . add_runtime_dependency 'chef' , chef_version
3232 s . add_runtime_dependency 'yajl-ruby' , '~> 1.2'
33- s . add_runtime_dependency 'parallel' , '~> 1.3'
33+ s . add_runtime_dependency 'parallel' , '~> 1.3'
34+ s . add_runtime_dependency 'inflecto' , '~> 0.0.2'
3435end
Original file line number Diff line number Diff line change @@ -13,25 +13,33 @@ class Inspect < Knife
1313
1414 banner 'knife inspect'
1515
16- CHECKLISTS . map do |checklist |
17- opt_name = checklist . downcase . to_sym
18- option opt_name ,
19- :long => "--[no-]#{ opt_name } " ,
16+ CHECKLISTS . each do |checklist |
17+ checklist = HealthInspector ::Checklists . const_get ( checklist )
18+
19+ option checklist . option ,
20+ :long => "--[no-]#{ checklist . option } " ,
2021 :boolean => true ,
2122 :default => true ,
22- :description => "Add or exclude #{ opt_name } from inspection"
23+ :description => "Add or exclude #{ checklist . title } from inspection"
2324 end
2425
2526 def run
26- results = CHECKLISTS . select do |checklist |
27- opt_name = checklist . downcase . to_sym
28- config [ opt_name ] or config [ opt_name ] . nil?
29- end . map do |checklist |
27+ results = checklists_to_run . map do |checklist |
3028 HealthInspector ::Checklists . const_get ( checklist ) . run ( self )
3129 end
3230
3331 exit !results . include? ( false )
3432 end
33+
34+ private
35+
36+ def checklists_to_run
37+ CHECKLISTS . select do |checklist |
38+ checklist = HealthInspector ::Checklists . const_get ( checklist )
39+
40+ config [ checklist . option ]
41+ end
42+ end
3543 end
3644 end
3745end
Original file line number Diff line number Diff line change 22require 'pathname'
33require 'yajl'
44require 'parallel'
5+ require 'inflecto'
56
67module HealthInspector
78 module Checklists
89 class Base
910 include Color
1011
1112 class << self
12- attr_reader :title
13-
14- def title ( val = nil )
15- val . nil? ? @title : @title = val
13+ def title
14+ Inflecto . humanize (
15+ Inflecto . underscore (
16+ Inflecto . demodulize ( self . to_s )
17+ )
18+ ) . downcase
1619 end
1720 end
1821
1922 def self . run ( knife )
2023 new ( knife ) . run
2124 end
2225
26+ def self . option
27+ Inflecto . dasherize (
28+ Inflecto . underscore (
29+ Inflecto . demodulize ( self . to_s )
30+ )
31+ ) . to_sym
32+ end
33+
2334 def initialize ( knife )
2435 @context = Context . new ( knife )
2536 end
Original file line number Diff line number Diff line change @@ -88,8 +88,6 @@ def checksum_cookbook_file(filepath)
8888 end
8989
9090 class Cookbooks < Base
91- title 'cookbooks'
92-
9391 def load_item ( name )
9492 Cookbook . new ( @context ,
9593 name : name ,
Original file line number Diff line number Diff line change @@ -9,8 +9,6 @@ class DataBagItem < Pairing
99 end
1010
1111 class DataBagItems < Base
12- title 'data bag items'
13-
1412 def load_item ( name )
1513 DataBagItem . new ( @context ,
1614 name : name ,
Original file line number Diff line number Diff line change @@ -7,8 +7,6 @@ class DataBag < Pairing
77 end
88
99 class DataBags < Base
10- title 'data bags'
11-
1210 def load_item ( name )
1311 DataBag . new ( @context ,
1412 name : name ,
Original file line number Diff line number Diff line change @@ -15,8 +15,6 @@ def validate_local_copy_exists
1515 end
1616
1717 class Environments < Base
18- title 'environments'
19-
2018 def load_item ( name )
2119 Environment . new ( @context ,
2220 name : name ,
Original file line number Diff line number Diff line change @@ -8,8 +8,6 @@ class Role < Pairing
88 end
99
1010 class Roles < Base
11- title 'roles'
12-
1311 def load_item ( name )
1412 Role . new ( @context ,
1513 name : name ,
You can’t perform that action at this time.
0 commit comments