Class: Emeril::MetadataChopper

Inherits:
Hash
  • Object
show all
Defined in:
lib/emeril/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.

Instance Method Summary collapse

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



24
25
26
27
28
29
30
31
32
# File 'lib/emeril/metadata_chopper.rb', line 24

def initialize()
  instance_eval(IO.read(), )
  %w[name version].map(&:to_sym).each do |attr|
    next unless self[attr].nil?

    raise MetadataParseError,
      "Missing attribute `#{attr}' must be set in #{metadata_file}"
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &_block) ⇒ Object



34
35
36
# File 'lib/emeril/metadata_chopper.rb', line 34

def method_missing(meth, *args, &_block)
  self[meth] = args.first
end