Sha256: 43229362ce5a484a8162740085c0223338a9388aca8104d1e93908efdd85fefe

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

module Gush
  class Configuration
    attr_accessor :concurrency, :namespace, :redis_url, :redis_prefix, :environment, :sidekiq_queue,
                  :sidekiq_options

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

    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

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

    def gushfile
      @gushfile.realpath
    end

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gush-mmx-0.4.2 lib/gush/configuration.rb