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

Version Path
railties-5.1.7 lib/rails/command/environment_argument.rb
railties-5.1.7.rc1 lib/rails/command/environment_argument.rb
railties-5.1.6.2 lib/rails/command/environment_argument.rb
railties-5.1.6.1 lib/rails/command/environment_argument.rb
railties-5.1.6 lib/rails/command/environment_argument.rb
railties-5.1.5 lib/rails/command/environment_argument.rb
railties-5.1.5.rc1 lib/rails/command/environment_argument.rb
railties-5.1.4 lib/rails/command/environment_argument.rb
railties-5.1.4.rc1 lib/rails/command/environment_argument.rb
railties-5.1.3 lib/rails/command/environment_argument.rb
railties-5.1.3.rc3 lib/rails/command/environment_argument.rb
railties-5.1.3.rc2 lib/rails/command/environment_argument.rb
railties-5.1.3.rc1 lib/rails/command/environment_argument.rb
railties-5.1.2 lib/rails/command/environment_argument.rb
railties-5.1.2.rc1 lib/rails/command/environment_argument.rb
railties-5.1.1 lib/rails/command/environment_argument.rb
railties-5.1.0 lib/rails/command/environment_argument.rb
railties-5.1.0.rc2 lib/rails/command/environment_argument.rb
railties-5.1.0.rc1 lib/rails/command/environment_argument.rb
railties-5.1.0.beta1 lib/rails/command/environment_argument.rb