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.
42 43 44 |
# File 'lib/kitchen/metadata_chopper.rb', line 42 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
46 47 48 |
# File 'lib/kitchen/metadata_chopper.rb', line 46 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.
32 33 34 35 |
# File 'lib/kitchen/metadata_chopper.rb', line 32 def self.extract() mc = new(File.()) [mc[:name], mc[:version]] end |