Class: Console::Configuration

Inherits:
Object
  • Object
show all
Includes:
ActiveSupport::Configurable
Defined in:
lib/console/configuration.rb

Overview

:nodoc:

Constant Summary collapse

Builtin =
{
  :openshift => {
    :url => 'https://openshift.redhat.com/broker/rest',
    :suffix => 'rhcloud.com'
  },
  :local => {
    :url => 'https://localhost/broker/rest',
    :suffix => 'dev.rhcloud.com'
  }
}

Instance Method Summary collapse

Instance Method Details

#apiObject



82
83
84
# File 'lib/console/configuration.rb', line 82

def api
  @api
end

#api=(config) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/console/configuration.rb', line 50

def api=(config)
  config = case
    when Builtin[config]
      source = config
      Builtin[config]
    when config == :external
      source = '~/.openshift/console.conf'
      api_config_from(Console::ConfigFile.new(source))
    when config.respond_to?(:[])
      source = 'object in config'
      Builtin[:openshift].with_indifferent_access.merge(config)
    else
      raise InvalidConfiguration, "Invalid argument to Console.config.api #{config.inspect}"
    end

  unless config[:url]
    raise InvalidConfiguration, <<-EXCEPTION.strip_heredoc
      The console requires that Console.config.api be set to a symbol or endpoint configuration object.  Active configuration is #{Rails.env}

      '#{config.inspect}' via #{source} is not valid.

      Valid symbols: #{Builtin.each_key.collect {|k| ":#{k}"}.concat([:external]).join(', ')}
      Valid api object:
        {
          :url => '' # A URL pointing to the root of the REST API, e.g. 
                     # https://openshift.redhat.com/broker/rest
        }
    EXCEPTION
  end

  freeze_api(config, source)
end

#cartridge_type_metadataObject



86
87
88
# File 'lib/console/configuration.rb', line 86

def 
  @cartridge_type_metadata || File.expand_path(File.join('config', 'cartridge_types.yml'), Console::Engine.root)
end

#user_agentObject



90
91
92
# File 'lib/console/configuration.rb', line 90

def user_agent
  @user_agent ||= "openshift_console/#{Console::VERSION::STRING} (ruby #{RUBY_VERSION}; #{RUBY_PLATFORM})"
end

#user_agent=(agent) ⇒ Object



93
94
95
# File 'lib/console/configuration.rb', line 93

def user_agent=(agent)
  @user_agent = agent
end