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 instance and loads in the contents of the metadata.rb file.
-
#method_missing(meth, *args, &_block) ⇒ Object
private
Captures any attribute call made while evaluating the metadata file, storing its first argument under the attribute name.
Methods included from HashRecursiveMerge
Constructor Details
#initialize(metadata_file) ⇒ MetadataChopper
Creates a new instance and loads in the contents of the metadata.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(File.read(), ) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &_block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Captures any attribute call made while evaluating the metadata file, storing its first argument under the attribute name.
52 53 54 |
# File 'lib/kitchen/metadata_chopper.rb', line 52 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 |