Class: CookbookBumper::Config
- Inherits:
-
Object
- Object
- CookbookBumper::Config
- Defined in:
- lib/cookbook_bumper/config.rb
Instance Attribute Summary collapse
- #cookbook_path ⇒ Object
- #environment_path ⇒ Object
-
#exclude_environments ⇒ Object
Returns the value of attribute exclude_environments.
-
#knife_path ⇒ Object
Returns the value of attribute knife_path.
-
#repo_root ⇒ Object
Returns the value of attribute repo_root.
Instance Method Summary collapse
- #config_already_read? ⇒ Boolean
- #fetch_chef_config(config_name) ⇒ Object
-
#initialize {|_self| ... } ⇒ Config
constructor
A new instance of Config.
- #read_chef_config ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Config
Returns a new instance of Config.
7 8 9 10 11 12 |
# File 'lib/cookbook_bumper/config.rb', line 7 def initialize @exclude_environments = %w[development] @knife_path = File.('.chef/knife.rb') @repo_root = File.('.') yield(self) if block_given? end |
Instance Attribute Details
#cookbook_path ⇒ Object
14 15 16 |
# File 'lib/cookbook_bumper/config.rb', line 14 def cookbook_path @cookbook_path || Array(fetch_chef_config(:cookbook_path)).map { |p| File.(p) } end |
#environment_path ⇒ Object
18 19 20 |
# File 'lib/cookbook_bumper/config.rb', line 18 def environment_path @environment_path || Array(fetch_chef_config(:environment_path)).map { |p| File.(p) } end |
#exclude_environments ⇒ Object
Returns the value of attribute exclude_environments.
5 6 7 |
# File 'lib/cookbook_bumper/config.rb', line 5 def exclude_environments @exclude_environments end |
#knife_path ⇒ Object
Returns the value of attribute knife_path.
5 6 7 |
# File 'lib/cookbook_bumper/config.rb', line 5 def knife_path @knife_path end |
#repo_root ⇒ Object
Returns the value of attribute repo_root.
5 6 7 |
# File 'lib/cookbook_bumper/config.rb', line 5 def repo_root @repo_root end |
Instance Method Details
#config_already_read? ⇒ Boolean
27 28 29 |
# File 'lib/cookbook_bumper/config.rb', line 27 def config_already_read? @knife_path == @knife_path_read end |
#fetch_chef_config(config_name) ⇒ Object
22 23 24 25 |
# File 'lib/cookbook_bumper/config.rb', line 22 def fetch_chef_config(config_name) read_chef_config unless config_already_read? Chef::Config.send(config_name) end |
#read_chef_config ⇒ Object
31 32 33 34 |
# File 'lib/cookbook_bumper/config.rb', line 31 def read_chef_config Chef::Config.from_file(@knife_path) @knife_path_read = @knife_path end |