Class: Gush::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/gush/configuration.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ Configuration

Returns a new instance of Configuration.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/gush/configuration.rb', line 10

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.redis_prefix   = hash.fetch(:redis_prefix, 'gush')
  self.sidekiq_queue   = hash.fetch(:sidekiq_queue, 'gush')
  self.gushfile    = hash.fetch(:gushfile, 'Gushfile.rb')
  self.environment = hash.fetch(:environment, 'development')

  # sidekiq
  self.sidekiq_options = hash.fetch(:sidekiq_options, '')
end

Instance Attribute Details

#concurrencyObject

Returns the value of attribute concurrency.



3
4
5
# File 'lib/gush/configuration.rb', line 3

def concurrency
  @concurrency
end

#environmentObject

Returns the value of attribute environment.



3
4
5
# File 'lib/gush/configuration.rb', line 3

def environment
  @environment
end

#namespaceObject

Returns the value of attribute namespace.



3
4
5
# File 'lib/gush/configuration.rb', line 3

def namespace
  @namespace
end

#redis_prefixObject

Returns the value of attribute redis_prefix.



3
4
5
# File 'lib/gush/configuration.rb', line 3

def redis_prefix
  @redis_prefix
end

#redis_urlObject

Returns the value of attribute redis_url.



3
4
5
# File 'lib/gush/configuration.rb', line 3

def redis_url
  @redis_url
end

#sidekiq_optionsObject

Returns the value of attribute sidekiq_options.



3
4
5
# File 'lib/gush/configuration.rb', line 3

def sidekiq_options
  @sidekiq_options
end

#sidekiq_queueObject

Returns the value of attribute sidekiq_queue.



3
4
5
# File 'lib/gush/configuration.rb', line 3

def sidekiq_queue
  @sidekiq_queue
end

Class Method Details

.from_json(json) ⇒ Object



6
7
8
# File 'lib/gush/configuration.rb', line 6

def self.from_json(json)
  new(Gush::JSON.decode(json, symbolize_keys: true))
end

Instance Method Details

#gushfileObject



27
28
29
# File 'lib/gush/configuration.rb', line 27

def gushfile
  @gushfile.realpath
end

#gushfile=(path) ⇒ Object



23
24
25
# File 'lib/gush/configuration.rb', line 23

def gushfile=(path)
  @gushfile = Pathname(path)
end

#to_hashObject



31
32
33
34
35
36
37
38
39
40
# File 'lib/gush/configuration.rb', line 31

def to_hash
  {
    concurrency: concurrency,
    namespace:   namespace,
    redis_url:   redis_url,
    redis_prefix:   redis_prefix,
    sidekiq_queue:   sidekiq_queue,
    environment: environment
  }
end

#to_jsonObject



42
43
44
# File 'lib/gush/configuration.rb', line 42

def to_json
  Gush::JSON.encode(to_hash)
end