Sha256: 7a470697ef0f53e78ba3d392a3758e7fb35e5af5db353d8843ec699f38e49ac0

Contents?: true

Size: 920 Bytes

Versions: 10

Compression:

Stored size: 920 Bytes

Contents

require 'yajl'

module Gush
  class Configuration
    attr_accessor :concurrency, :namespace, :redis_url, :environment

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

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

    def gushfile
      @gushfile.realpath
    end

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

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
gush-0.3.2 lib/gush/configuration.rb
gush-0.3.1 lib/gush/configuration.rb
gush-0.3 lib/gush/configuration.rb
gush-0.2.3 lib/gush/configuration.rb
gush-0.2.2 lib/gush/configuration.rb
gush-0.2.1 lib/gush/configuration.rb
gush-0.2.0 lib/gush/configuration.rb
gush-0.1.2 lib/gush/configuration.rb
gush-0.1.1 lib/gush/configuration.rb
gush-0.1 lib/gush/configuration.rb