Sha256: 0e318a5e372f417d2c7ce94e1ee2aced0dcca2daa22cb88edeea3b463acfdb7f

Contents?: true

Size: 1.04 KB

Versions: 24

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module Dsu
  class << self
    def env # rubocop:disable Metrics/MethodLength
      @env ||= Struct.new(:env) do
        def test?
          env.fetch('DSU_ENV', nil) == 'test'
        end

        def development?
          env.fetch('DSU_ENV', nil) == 'development'
        end

        def local?
          test? || development?
        end

        def production?
          env.fetch('DSU_ENV', 'production') == 'production'
        end

        def screen_shot_mode?
          development? && (env.fetch('SCREEN_SHOT_USERNAME', '').present? ||
            env.fetch('SCREEN_SHOT_HOSTNAME', '').present?)
        end

        def screen_shot_prompt
          username = screen_shot_username
          hostname = screen_shot_hostname
          "#{username}@#{hostname}:~ $"
        end

        def screen_shot_username
          env.fetch('SCREEN_SHOT_USERNAME', 'username')
        end

        def screen_shot_hostname
          env.fetch('SCREEN_SHOT_HOSTNAME', 'hostname')
        end
      end.new(ENV)
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
dsu-3.0.5 lib/dsu/env.rb
dsu-3.0.4 lib/dsu/env.rb
dsu-3.0.3 lib/dsu/env.rb
dsu-3.0.1 lib/dsu/env.rb
dsu-3.0.0 lib/dsu/env.rb
dsu-3.0.0.beta.3 lib/dsu/env.rb
dsu-3.0.0.beta.2 lib/dsu/env.rb
dsu-3.0.0.beta.1 lib/dsu/env.rb
dsu-3.0.0.beta.0 lib/dsu/env.rb
dsu-3.0.0.alpha.12 lib/dsu/env.rb
dsu-3.0.0.alpha.11 lib/dsu/env.rb
dsu-3.0.0.alpha.10 lib/dsu/env.rb
dsu-3.0.0.alpha.9 lib/dsu/env.rb
dsu-3.0.0.alpha.8 lib/dsu/env.rb
dsu-3.0.0.alpha.7 lib/dsu/env.rb
dsu-3.0.0.alpha.6 lib/dsu/env.rb
dsu-3.0.0.alpha.5 lib/dsu/env.rb
dsu-3.0.0.alpha.4 lib/dsu/env.rb
dsu-3.0.0.alpha.3 lib/dsu/env.rb
dsu-3.0.0.alpha.2 lib/dsu/env.rb