Module: Kitchen::Pantry
- Defined in:
- lib/kitchen/pantry.rb,
lib/kitchen/pantry/version.rb
Constant Summary collapse
- VERSION =
'0.2.0'
Class Method Summary collapse
- .load_config(file) ⇒ Object
- .method_missing(method_sym, *_arguments, &_block) ⇒ Object
- .respond_to?(method_sym, include_private = false) ⇒ Boolean
- .tags(cb_name, user) ⇒ Object
Class Method Details
.load_config(file) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/kitchen/pantry.rb', line 23 def self.load_config(file) begin @config_path = File.(File.dirname(file)) rescue ArguementError => e puts "You provided #{ENV['KITCHEN_CONFIG']}" raise 'Please define valid KITCHEN_CONFIG in your shell.' end @config = YAML.load_file("#{@config_path}/config.yml") end |
.method_missing(method_sym, *_arguments, &_block) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/kitchen/pantry.rb', line 10 def self.method_missing(method_sym, *_arguments, &_block) if @config.nil? self.load_config(ENV['KITCHEN_CONFIG']) end if @config.keys.include?(method_sym) @config[method_sym] else raise 'Undefined method or variable, '\ "received #{method_sym}, availabile #{@config.keys}" end end |
.respond_to?(method_sym, include_private = false) ⇒ Boolean
33 34 35 |
# File 'lib/kitchen/pantry.rb', line 33 def self.respond_to?(method_sym, include_private = false) @config.keys.include?(method_sym) ? true : super end |
.tags(cb_name, user) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/kitchen/pantry.rb', line 37 def self.(cb_name, user) " tags:\n" \ " Name: \"Chef Tester\"\n" \ " Apps: \"#{cb_name} cookbook test\"\n" \ " App Owner: \"#{user}\"" end |