class Kitchen::MetadataChopper
A rather insane and questionable class to quickly consume a metadata.rb file and return the cookbook name and version attributes.
@see twitter.com/fnichol/status/281650077901144064 @see gist.github.com/4343327
Public Class Methods
extract(metadata_file)
click to toggle source
Return an Array containing the cookbook name and version attributes, or nil values if they could not be parsed.
@param metadata_file [String] path to a metadata.rb file @return [Array<String>] array containing the cookbook name and version
attributes or nil values if they could not be determined
# File lib/kitchen/metadata_chopper.rb, line 31 def self.extract(metadata_file) mc = new(File.expand_path(metadata_file)) [mc[:name], mc[:version]] end
new(metadata_file)
click to toggle source
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.
@param metadata_file [String] path to a metadata.rb file
# File lib/kitchen/metadata_chopper.rb, line 41 def initialize(metadata_file) instance_eval(IO.read(metadata_file), metadata_file) end
Public Instance Methods
method_missing(meth, *args, &_block)
click to toggle source
# File lib/kitchen/metadata_chopper.rb, line 45 def method_missing(meth, *args, &_block) self[meth] = args.first end