Class: Gush::Configuration
- Inherits:
-
Object
- Object
- Gush::Configuration
- Defined in:
- lib/gush/configuration.rb
Instance Attribute Summary collapse
-
#concurrency ⇒ Object
Returns the value of attribute concurrency.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
-
#redis_url ⇒ Object
Returns the value of attribute redis_url.
Class Method Summary collapse
Instance Method Summary collapse
- #gushfile ⇒ Object
- #gushfile=(path) ⇒ Object
-
#initialize(hash = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(hash = {}) ⇒ Configuration
Returns a new instance of Configuration.
11 12 13 14 15 16 17 |
# File 'lib/gush/configuration.rb', line 11 def initialize(hash = {}) self.concurrency = hash.fetch(:concurrency, 5) self.namespace = hash.fetch(:namespace, 'gush') self.redis_url = hash.fetch(:redis_url, 'redis://localhost:6379') self.gushfile = hash.fetch(:gushfile, 'Gushfile.rb') self.environment = hash.fetch(:environment, 'development') end |
Instance Attribute Details
#concurrency ⇒ Object
Returns the value of attribute concurrency.
5 6 7 |
# File 'lib/gush/configuration.rb', line 5 def concurrency @concurrency end |
#environment ⇒ Object
Returns the value of attribute environment.
5 6 7 |
# File 'lib/gush/configuration.rb', line 5 def environment @environment end |
#namespace ⇒ Object
Returns the value of attribute namespace.
5 6 7 |
# File 'lib/gush/configuration.rb', line 5 def namespace @namespace end |
#redis_url ⇒ Object
Returns the value of attribute redis_url.
5 6 7 |
# File 'lib/gush/configuration.rb', line 5 def redis_url @redis_url end |
Class Method Details
.from_json(json) ⇒ Object
7 8 9 |
# File 'lib/gush/configuration.rb', line 7 def self.from_json(json) new(Yajl::Parser.parse(json, symbolize_keys: true)) end |
Instance Method Details
#gushfile ⇒ Object
23 24 25 26 |
# File 'lib/gush/configuration.rb', line 23 def gushfile raise Thor::Error, "#{@gushfile} not found, please add it to your project".colorize(:red) unless @gushfile.exist? @gushfile.realpath end |
#gushfile=(path) ⇒ Object
19 20 21 |
# File 'lib/gush/configuration.rb', line 19 def gushfile=(path) @gushfile = Pathname(path) end |
#to_hash ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/gush/configuration.rb', line 28 def to_hash { concurrency: concurrency, namespace: namespace, redis_url: redis_url, environment: environment, gushfile: gushfile.to_path } end |
#to_json ⇒ Object
38 39 40 |
# File 'lib/gush/configuration.rb', line 38 def to_json Yajl::Encoder.new.encode(to_hash) end |