Sha256: af2af37ee163c62e22c2eab65c5855d73290935f5586fdc075e99af887680aac
Contents?: true
Size: 948 Bytes
Versions: 20
Compression:
Stored size: 948 Bytes
Contents
require "active_support" module Rails module Command module EnvironmentArgument #:nodoc: extend ActiveSupport::Concern included do argument :environment, optional: true, banner: "environment" end private def extract_environment_option_from_argument if environment self.options = options.merge(environment: acceptable_environment(environment)) elsif !options[:environment] self.options = options.merge(environment: Rails::Command.environment) end end def acceptable_environment(env = nil) if available_environments.include? env env else %w( production development test ).detect { |e| e =~ /^#{env}/ } || env end end def available_environments Dir["config/environments/*.rb"].map { |fname| File.basename(fname, ".*") } end end end end
Version data entries
20 entries across 20 versions & 1 rubygems