Class: Ddenv::Config
- Inherits:
-
Object
- Object
- Ddenv::Config
- Defined in:
- lib/ddenv/config.rb
Class Method Summary collapse
Instance Method Summary collapse
- #goals ⇒ Object
-
#initialize(hash) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(hash) ⇒ Config
Returns a new instance of Config.
5 6 7 |
# File 'lib/ddenv/config.rb', line 5 def initialize(hash) @hash = hash end |
Class Method Details
.read_from_file(filename) ⇒ Object
9 10 11 |
# File 'lib/ddenv/config.rb', line 9 def self.read_from_file(filename) new(YAML.safe_load(File.read(filename))) end |
Instance Method Details
#goals ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ddenv/config.rb', line 13 def goals up = @hash.fetch("up", []) up.map do |element| key, value = case element when Hash [element.keys.first, element.values.first] when String [element, nil] end case key when "homebrew" Goals::HomebrewPackageInstalled.new(value) when "ruby" Goals::RubyInstalled.new when "node" Goals::NodeInstalled.new(value) when "bundle" Goals::BundleInstalled.new when "npm" Goals::NpmPackesInstalled.new else raise "unknown key: #{key}" end end end |