Class: Kitchen::MetadataChopper

Inherits:
Hash
  • Object
show all
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

Instance Method Summary collapse

Methods included from HashRecursiveMerge

#rmerge, #rmerge!

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.

Parameters:

  • metadata_file (String)

    path to a metadata.rb file



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.

Parameters:

  • metadata_file (String)

    path to a metadata.rb file

Returns:

  • (Array<String>)

    array containing the cookbook name and version attributes or nil values if they could not be determined



31
32
33
34
# File 'lib/kitchen/metadata_chopper.rb', line 31

def self.extract()
  mc = new(File.expand_path())
  [mc[:name], mc[:version]]
end