Sha256: 5a15406b46c2b46a34406f49af3e80d291b7623bfe601c140e03139dc764dc12
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
# frozen-string-literal: true module Rodbot # Environment the bot is currently living in # # @note Use the +Rodbot.env+ shortcut to access these methods! class Env # Supported environments ENVS = %w(production development test).freeze # @return [Pathname] root directory attr_reader :root # @return [Pathname] root directory attr_reader :tmp # @return [Pathname] gem root directory attr_reader :gem # @return [String] current environment - any of {ENVS} attr_reader :current # @param root [Pathname, String] root path (default: current directory) def initialize(root: nil) @root = root ? Pathname(root).realpath : Pathname.pwd @tmp = @root.join('tmp') @gem = Pathname(__dir__).join('..', '..').realpath @current = ENV['RODBOT_ENV'] || ENV['APP_ENV'] @current = 'development' unless ENVS.include? @current end # @!method production? # @!method development? # @!method test? # # Inquire the env based on RODBOT_ENV # # @return [Boolean] ENVS.each do |env| define_method "#{env}?" do env == current end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rodbot-0.4.4 | lib/rodbot/env.rb |