Class: Stilts::Configuration
- Inherits:
-
Object
- Object
- Stilts::Configuration
- Defined in:
- lib/stilts/configuration.rb
Overview
Used to set up and modify settings for the notifier.
Constant Summary collapse
- OPTIONS =
[:api_key, :host, :http_open_timeout, :http_read_timeout, :project_root, :port, :protocol, :secure, :framework].freeze
Instance Attribute Summary collapse
-
#api_key ⇒ Object
The API key for your project, found on the project edit form.
-
#cdn_host ⇒ Object
The CDN host to connect to.
-
#framework ⇒ Object
The framework is configured to use.
-
#host ⇒ Object
The host to connect to.
-
#http_open_timeout ⇒ Object
The HTTP open timeout in seconds (defaults to 2).
-
#http_read_timeout ⇒ Object
The HTTP read timeout in seconds (defaults to 5).
-
#logger ⇒ Object
The logger used by.
-
#port ⇒ Object
The port on which your server runs (defaults to 443 for secure connections, 80 for insecure connections).
-
#project_root ⇒ Object
The path to the project in which the error occurred, such as the RAILS_ROOT.
-
#secure ⇒ Object
(also: #secure?)
true
for https connections,false
for http connections.
Instance Method Summary collapse
-
#[](option) ⇒ Object
Allows config options to be read like a hash.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#merge(hash) ⇒ Object
Returns a hash of all configurable options merged with
hash
. - #protocol ⇒ Object
-
#to_hash ⇒ Object
Returns a hash of all configurable options.
- #url ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/stilts/configuration.rb', line 41 def initialize @secure = false # @host = 'stilts.developmentnow.com' # @port = 80 @host = "localhost" @port = 3000 @cdn_host = 'd15ceu2kbcb932.cloudfront.net' @framework = 'Standalone' @protocol = protocol @http_open_timeout = 2 @http_read_timeout = 10 end |
Instance Attribute Details
#api_key ⇒ Object
The API key for your project, found on the project edit form.
9 10 11 |
# File 'lib/stilts/configuration.rb', line 9 def api_key @api_key end |
#cdn_host ⇒ Object
The CDN host to connect to
15 16 17 |
# File 'lib/stilts/configuration.rb', line 15 def cdn_host @cdn_host end |
#framework ⇒ Object
The framework is configured to use
31 32 33 |
# File 'lib/stilts/configuration.rb', line 31 def framework @framework end |
#host ⇒ Object
The host to connect to
12 13 14 |
# File 'lib/stilts/configuration.rb', line 12 def host @host end |
#http_open_timeout ⇒ Object
The HTTP open timeout in seconds (defaults to 2).
34 35 36 |
# File 'lib/stilts/configuration.rb', line 34 def http_open_timeout @http_open_timeout end |
#http_read_timeout ⇒ Object
The HTTP read timeout in seconds (defaults to 5).
37 38 39 |
# File 'lib/stilts/configuration.rb', line 37 def http_read_timeout @http_read_timeout end |
#logger ⇒ Object
The logger used by
28 29 30 |
# File 'lib/stilts/configuration.rb', line 28 def logger @logger end |
#port ⇒ Object
The port on which your server runs (defaults to 443 for secure connections, 80 for insecure connections).
19 20 21 |
# File 'lib/stilts/configuration.rb', line 19 def port @port end |
#project_root ⇒ Object
The path to the project in which the error occurred, such as the RAILS_ROOT
25 26 27 |
# File 'lib/stilts/configuration.rb', line 25 def project_root @project_root end |
#secure ⇒ Object Also known as: secure?
true
for https connections, false
for http connections.
22 23 24 |
# File 'lib/stilts/configuration.rb', line 22 def secure @secure end |
Instance Method Details
#[](option) ⇒ Object
Allows config options to be read like a hash
57 58 59 |
# File 'lib/stilts/configuration.rb', line 57 def [](option) send(option) end |
#merge(hash) ⇒ Object
Returns a hash of all configurable options merged with hash
80 81 82 |
# File 'lib/stilts/configuration.rb', line 80 def merge(hash) to_hash.merge(hash) end |
#protocol ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/stilts/configuration.rb', line 88 def protocol if secure? 'https' else 'http' end end |
#to_hash ⇒ Object
Returns a hash of all configurable options
71 72 73 74 75 |
# File 'lib/stilts/configuration.rb', line 71 def to_hash OPTIONS.inject({}) do |hash, option| hash.merge(option.to_sym => send(option)) end end |
#url ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/stilts/configuration.rb', line 61 def url url = URI::HTTP.build({ :host => @host, :scheme => protocol, :path => "/", :port => @port }) end |