Sha256: 6601595dac3728de4ac2d7c417392cf12b4d89e892d91650602b8ac720a52d14
Contents?: true
Size: 1.21 KB
Versions: 80
Compression:
Stored size: 1.21 KB
Contents
require 'logger' require 'rubber/environment' require 'rubber/instance' require 'rubber/generator' module Rubber module Configuration @@configurations = {} def self.get_configuration(env=nil, root=nil) key = "#{env}-#{root}" @@configurations[key] ||= ConfigHolder.new(env, root) end def self.rubber_env raise "This convenience method needs RUBBER_ENV to be set" unless RUBBER_ENV cfg = Rubber::Configuration.get_configuration(RUBBER_ENV) host = cfg.environment.current_host roles = cfg.instance[host].role_names rescue nil cfg.environment.bind(roles, host) end def self.rubber_instances raise "This convenience method needs RUBBER_ENV to be set" unless RUBBER_ENV Rubber::Configuration.get_configuration(RUBBER_ENV).instance end class ConfigHolder def initialize(env=nil, root=nil) root = "#{RUBBER_ROOT}/config/rubber" unless root instance_cfg = "#{root}/instance" + (env ? "-#{env}.yml" : ".yml") @environment = Environment.new("#{root}") @instance = Instance.new(instance_cfg) end def environment @environment end def instance @instance end end end end
Version data entries
80 entries across 80 versions & 7 rubygems