Sha256: 54201b4866e1c56cacb48e1cf47df953834dac39709f9672626691e4b3668cc7
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
module Ec2Metadata module Dummy YAML_FILENAME = 'ec2_metadata.yml'.freeze YAML_SEARCH_DIRS = ['./config', '.', '~', '/etc'].freeze ENV_SPECIFIED_PATH = "EC2_METADATA_DUMMY_YAML".freeze class << self def yaml_paths dirs = YAML_SEARCH_DIRS.dup if Module.constants.include?('RAILS_ROOT') dirs.unshift(File.join(Module.const_get('RAILS_ROOT'), 'config')) end result = dirs.map{|d| File.join(d, YAML_FILENAME)} if specified_path = ENV[ENV_SPECIFIED_PATH] result.unshift(specified_path) end result end def search_and_load_yaml paths = Dir.glob(yaml_paths.map{|path| File.expand_path(path)}) load_yaml(paths.first) unless paths.empty? end def load_yaml(path) erb = ERB.new(IO.read(path)) erb.filename = path text = erb.result Ec2Metadata.from_hash(YAML.load(text)) @loaded_yaml_path = path end def loaded_yaml_path @loaded_yaml_path end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ec2-metadata-0.2.0 | lib/ec2_metadata/dummy.rb |