Merge branch 'pr/3593' into staging/electro-release

bug/bundler_fix
darkbushido 2014-08-01 16:01:10 -05:00
commit ceaffce727
No known key found for this signature in database
GPG Key ID: 3922EB70FB80E8DD
2 changed files with 10 additions and 5 deletions

View File

@ -49,8 +49,11 @@ class Metasploit::Framework::Command::Base
parsed_options.environment! parsed_options.environment!
ARGV.replace(parsed_options.positional) ARGV.replace(parsed_options.positional)
# @see https://github.com/rails/rails/blob/v3.2.17/railties/lib/rails/commands.rb#L39-L40 # allow other Rails::Applications to use this command
require Pathname.new(__FILE__).parent.parent.parent.parent.parent.join('config', 'application') if !defined?(Rails) || Rails.application.nil?
# @see https://github.com/rails/rails/blob/v3.2.17/railties/lib/rails/commands.rb#L39-L40
require Pathname.new(__FILE__).parent.parent.parent.parent.parent.join('config', 'application')
end
# have to configure before requiring environment because # have to configure before requiring environment because
# config/environment.rb calls initialize! and the initializers will use # config/environment.rb calls initialize! and the initializers will use

View File

@ -57,7 +57,7 @@ class Metasploit::Framework::ParsedOptions::Base
# #
# @return [void] # @return [void]
def environment! def environment!
if defined?(Rails) && Rails.instance_variable_defined?(:@_env) if defined?(Rails) && Rails.instance_variable_defined?(:@_env) && Rails.env != options.environment
raise "#{self.class}##{__method__} called too late to set RAILS_ENV: Rails.env already memoized" raise "#{self.class}##{__method__} called too late to set RAILS_ENV: Rails.env already memoized"
end end
@ -85,14 +85,16 @@ class Metasploit::Framework::ParsedOptions::Base
options.database.disable = false options.database.disable = false
options.database.migrations_paths = [] options.database.migrations_paths = []
# If RAILS_ENV is set, then it will be used, but if RAILS_ENV is set and the --environment option is given, then
# --environment value will be used to reset ENV[RAILS_ENV].
options.environment = ENV['RAILS_ENV'] || DEFAULT_ENVIRONMENT
options.framework = ActiveSupport::OrderedOptions.new options.framework = ActiveSupport::OrderedOptions.new
options.framework.config = nil options.framework.config = nil
options.modules = ActiveSupport::OrderedOptions.new options.modules = ActiveSupport::OrderedOptions.new
options.modules.path = nil options.modules.path = nil
options.environment = DEFAULT_ENVIRONMENT
@options = options @options = options
end end