Class: Kitchen::MetadataChopper
- Defined in:
- lib/kitchen/metadata_chopper.rb
Overview
A rather insane and questionable class to quickly consume a metadata.rb file and return the cookbook name and version attributes.
Class Method Summary collapse
-
.extract(metadata_file) ⇒ Array<String>
Return an Array containing the cookbook name and version attributes, or nil values if they could not be parsed.
Instance Method Summary collapse
-
#initialize(metadata_file) ⇒ MetadataChopper
constructor
Creates a new instances and loads in the contents of the metdata.rb file.
- #method_missing(meth, *args, &_block) ⇒ Object
Methods included from HashRecursiveMerge
Constructor Details
#initialize(metadata_file) ⇒ MetadataChopper
Creates a new instances and loads in the contents of the metdata.rb file. If you value your life, you may want to avoid reading the implementation.
41 42 43 |
# File 'lib/kitchen/metadata_chopper.rb', line 41 def initialize() instance_eval(IO.read(), ) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &_block) ⇒ Object
45 46 47 |
# File 'lib/kitchen/metadata_chopper.rb', line 45 def method_missing(meth, *args, &_block) self[meth] = args.first end |
Class Method Details
.extract(metadata_file) ⇒ Array<String>
Return an Array containing the cookbook name and version attributes, or nil values if they could not be parsed.
31 32 33 34 |
# File 'lib/kitchen/metadata_chopper.rb', line 31 def self.extract() mc = new(File.()) [mc[:name], mc[:version]] end |