module GCEMetadata::Dummy

Constants

ENV_SPECIFIED_PATH
YAML_FILENAME
YAML_SEARCH_DIRS

Public Class Methods

load_yaml(path) click to toggle source
# File lib/gce_metadata/dummy.rb, line 28
def load_yaml(path)
        erb = ERB.new(IO.read(path))
        erb.filename = path
        text = erb.result
        GCEMetadata.from_hash(YAML.load(text))
        @loaded_yaml_path = path
end
loaded_yaml_path() click to toggle source
# File lib/gce_metadata/dummy.rb, line 36
def loaded_yaml_path
        @loaded_yaml_path
end
search_and_load_yaml() click to toggle source
# File lib/gce_metadata/dummy.rb, line 23
def search_and_load_yaml
        paths = Dir.glob(yaml_paths.map{|path| File.expand_path(path) rescue nil}.compact)
        load_yaml(paths.first) unless paths.empty?
end
yaml_paths() click to toggle source
# File lib/gce_metadata/dummy.rb, line 11
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