Sha256: 47c43b2672b00b53783ee28d035ad07efe56c825fa536c9a71103b4c5e13a04b
Contents?: true
Size: 952 Bytes
Versions: 2
Compression:
Stored size: 952 Bytes
Contents
require 'yaml' module SimpleProvision class Configuration MissingServerType = Class.new(StandardError) MissingServerConfiguration = Class.new(StandardError) attr_reader :options attr_reader :profile def initialize(profile) @profile = profile read_and_parse_server_options end private def default_options begin YAML.load(File.read(server_file)) rescue Errno::ENOENT {} end end def server_options begin YAML.load(File.read(server_file)) rescue Errno::ENOENT raise MissingServerConfiguration, "Please create a configuration file './#{server_file}'" end end def server_file "provision/servers/#{profile}.yml" end def read_and_parse_server_options options_string_hash = default_options.merge(server_options) @options = Hash[options_string_hash.map{ |(k,v)| [k.to_sym, v] }] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
simple_provision-0.99.10 | lib/simple_provision/configuration.rb |
simple_provision-0.99.9 | lib/simple_provision/configuration.rb |