Sha256: e306ecd9cdf830e60cf987cb7d3612554559c79dc238726d3aa2b545250570af

Contents?: true

Size: 966 Bytes

Versions: 19

Compression:

Stored size: 966 Bytes

Contents

require 'hashie'
require 'pathname'

module RooOnRails
  class Config < Hashie::Mash
    class << self
      def load
        path = Pathname '.roo_on_rails.yml'
        path.exist? ? super(path) : new
      end

      def sidekiq_enabled?
        enabled? 'SIDEKIQ_ENABLED'
      end

      def google_auth_enabled?
        enabled? 'GOOGLE_AUTH_ENABLED', default: false
      end

      def google_auth_path_prefix
        ENV.fetch('GOOGLE_AUTH_PATH_PREFIX')
      end

      def google_auth_controller
        ENV.fetch('GOOGLE_AUTH_CONTROLLER')
      end

      def routemaster_enabled?
        enabled? 'ROUTEMASTER_ENABLED', default: false
      end

      def routemaster_publishing_enabled?
        enabled? 'ROUTEMASTER_PUBLISHING_ENABLED', default: false
      end

      private

      ENABLED_PATTERN = /\A(YES|TRUE|ON|1)\Z/i

      def enabled?(var, default: 'true')
        ENABLED_PATTERN === ENV.fetch(var, default).to_s
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
roo_on_rails-2.0.0.pre.pre.1 lib/roo_on_rails/config.rb
roo_on_rails-1.22.0 lib/roo_on_rails/config.rb
roo_on_rails-1.21.0 lib/roo_on_rails/config.rb
roo_on_rails-1.20.0 lib/roo_on_rails/config.rb
roo_on_rails-1.19.0 lib/roo_on_rails/config.rb
roo_on_rails-1.18.0 lib/roo_on_rails/config.rb
roo_on_rails-1.17.0 lib/roo_on_rails/config.rb
roo_on_rails-1.16.2 lib/roo_on_rails/config.rb
roo_on_rails-1.16.1 lib/roo_on_rails/config.rb
roo_on_rails-1.16.0 lib/roo_on_rails/config.rb
roo_on_rails-1.15.0 lib/roo_on_rails/config.rb
roo_on_rails-1.14.0 lib/roo_on_rails/config.rb
roo_on_rails-1.13.1 lib/roo_on_rails/config.rb
roo_on_rails-1.13.0 lib/roo_on_rails/config.rb
roo_on_rails-1.12.0 lib/roo_on_rails/config.rb
roo_on_rails-1.11.1 lib/roo_on_rails/config.rb
roo_on_rails-1.11.0 lib/roo_on_rails/config.rb
roo_on_rails-1.10.0 lib/roo_on_rails/config.rb
roo_on_rails-1.9.0 lib/roo_on_rails/config.rb