Module: Spice::Config
- Included in:
- Spice
- Defined in:
- lib/spice/config.rb
Constant Summary collapse
- DEFAULT_SERVER_URL =
The default Chef server URL
"http://localhost:4000"- DEFAULT_CHEF_VERSION =
The default Chef version (changing this will enable disable certain features)
"0.10.10"- DEFAULT_USER_AGENT =
The default Spice User-Agent header
"Spice #{Spice::VERSION}"- DEFAULT_CONNECTION_OPTIONS =
Default connection options
{}
- DEFAULT_CLIENT_NAME =
Default client name
""- DEFAULT_CLIENT_KEY =
Default key file
""- VALID_OPTIONS_KEYS =
An array of valid config options
[ :server_url, :client_name, :client_key, :chef_version, :user_agent, :connection_options, :middleware ]
- DEFAULT_MIDDLEWARE =
Default middleware stack
Proc.new do |builder| builder.use Spice::Response::ParseJSON builder.use Spice::Response::ClientError builder.adapter Faraday.default_adapter end
Class Method Summary collapse
-
.extended(base) ⇒ Object
Reset all config options to default when the module is extended.
Instance Method Summary collapse
-
#options ⇒ Object
Create an options hash from valid options keys.
-
#reset ⇒ Object
Reset all config options to their defaults.
-
#setup {|Spice| ... } ⇒ Object
Convenience method to configure Spice in a block.
Class Method Details
.extended(base) ⇒ Object
Reset all config options to default when the module is extended
51 52 53 |
# File 'lib/spice/config.rb', line 51 def self.extended(base) base.reset end |
Instance Method Details
#options ⇒ Object
Create an options hash from valid options keys
70 71 72 73 74 |
# File 'lib/spice/config.rb', line 70 def = {} VALID_OPTIONS_KEYS.each{|k| [k] = send(k)} end |
#reset ⇒ Object
Reset all config options to their defaults
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/spice/config.rb', line 77 def reset self.user_agent = DEFAULT_USER_AGENT self.server_url = DEFAULT_SERVER_URL self.chef_version = DEFAULT_CHEF_VERSION self.client_name = DEFAULT_CLIENT_NAME self.client_key = DEFAULT_CLIENT_KEY self. = DEFAULT_CONNECTION_OPTIONS self.middleware = DEFAULT_MIDDLEWARE self end |
#setup {|Spice| ... } ⇒ Object
Convenience method to configure Spice in a block
64 65 66 67 |
# File 'lib/spice/config.rb', line 64 def setup yield self self end |