Sha256: 61a5751ef561a7cedcf42f10c3ba3d894e5b52faa19d7991e942e62695273a06
Contents?: true
Size: 1.14 KB
Versions: 2
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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rodbot-0.5.1 | lib/rodbot/env.rb |
rodbot-0.5.0 | lib/rodbot/env.rb |