britt-geminstaller 0.5.2 → 0.5.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.loadpath +5 -0
- data/COPYING +1 -0
- data/History.txt +69 -0
- data/LICENSE +21 -0
- data/Manifest.txt +78 -0
- data/README.txt +64 -0
- data/Rakefile +184 -0
- data/TODO.txt +138 -0
- data/bin/geminstaller +30 -0
- data/cruise_config.rb +14 -0
- data/focused_spec.sh +2 -0
- data/focused_spec_debug.sh +2 -0
- data/geminstaller.yml +42 -0
- data/lib/geminstaller.rb +103 -0
- data/lib/geminstaller/application.rb +105 -0
- data/lib/geminstaller/arg_parser.rb +166 -0
- data/lib/geminstaller/autogem.rb +46 -0
- data/lib/geminstaller/backward_compatibility.rb +10 -0
- data/lib/geminstaller/config.rb +68 -0
- data/lib/geminstaller/config_builder.rb +65 -0
- data/lib/geminstaller/enhanced_stream_ui.rb +71 -0
- data/lib/geminstaller/exact_match_list_command.rb +16 -0
- data/lib/geminstaller/file_reader.rb +31 -0
- data/lib/geminstaller/gem_arg_processor.rb +44 -0
- data/lib/geminstaller/gem_command_manager.rb +74 -0
- data/lib/geminstaller/gem_interaction_handler.rb +41 -0
- data/lib/geminstaller/gem_list_checker.rb +55 -0
- data/lib/geminstaller/gem_runner_proxy.rb +62 -0
- data/lib/geminstaller/gem_source_index_proxy.rb +21 -0
- data/lib/geminstaller/gem_spec_manager.rb +53 -0
- data/lib/geminstaller/geminstaller_access_error.rb +4 -0
- data/lib/geminstaller/geminstaller_error.rb +13 -0
- data/lib/geminstaller/hoe_extensions.rb +9 -0
- data/lib/geminstaller/install_processor.rb +71 -0
- data/lib/geminstaller/missing_dependency_finder.rb +46 -0
- data/lib/geminstaller/missing_file_error.rb +4 -0
- data/lib/geminstaller/noninteractive_chooser.rb +114 -0
- data/lib/geminstaller/output_filter.rb +49 -0
- data/lib/geminstaller/output_listener.rb +33 -0
- data/lib/geminstaller/output_observer.rb +36 -0
- data/lib/geminstaller/output_proxy.rb +36 -0
- data/lib/geminstaller/registry.rb +127 -0
- data/lib/geminstaller/requires.rb +81 -0
- data/lib/geminstaller/rogue_gem_finder.rb +195 -0
- data/lib/geminstaller/ruby_gem.rb +58 -0
- data/lib/geminstaller/rubygems_exit.rb +5 -0
- data/lib/geminstaller/rubygems_extensions.rb +9 -0
- data/lib/geminstaller/rubygems_version_checker.rb +15 -0
- data/lib/geminstaller/rubygems_version_warnings.rb +38 -0
- data/lib/geminstaller/source_index_search_adapter.rb +41 -0
- data/lib/geminstaller/unauthorized_dependency_prompt_error.rb +4 -0
- data/lib/geminstaller/unexpected_prompt_error.rb +4 -0
- data/lib/geminstaller/valid_platform_selector.rb +49 -0
- data/lib/geminstaller/version_specifier.rb +24 -0
- data/lib/geminstaller/yaml_loader.rb +22 -0
- data/lib/geminstaller_rails_preinitializer.rb +46 -0
- data/start_local_gem_server.sh +1 -0
- data/test/test_all.rb +36 -0
- data/test/test_all_smoketests.rb +21 -0
- data/website/config.yaml +11 -0
- data/website/src/analytics.page +6 -0
- data/website/src/code/ci.virtual +5 -0
- data/website/src/code/coverage/index.virtual +5 -0
- data/website/src/code/index.page +88 -0
- data/website/src/code/rdoc/index.virtual +6 -0
- data/website/src/community/index.page +14 -0
- data/website/src/community/links.page +11 -0
- data/website/src/community/rubyforge.virtual +4 -0
- data/website/src/default.css +175 -0
- data/website/src/default.template +42 -0
- data/website/src/documentation/documentation.page +476 -0
- data/website/src/documentation/index.page +53 -0
- data/website/src/documentation/tutorials.page +337 -0
- data/website/src/download.page +12 -0
- data/website/src/faq.page +36 -0
- data/website/src/index.page +92 -0
- data/website/src/metainfo +54 -0
- data/website/src/webgen.css +112 -0
- metadata +80 -3
@@ -0,0 +1,46 @@
|
|
1
|
+
module GemInstaller
|
2
|
+
class Autogem
|
3
|
+
attr_writer :gem_command_manager, :gem_source_index_proxy
|
4
|
+
def autogem(gems)
|
5
|
+
@gem_source_index_proxy.refresh!
|
6
|
+
@completed_names = []
|
7
|
+
@completed_gems = []
|
8
|
+
gems.each do |gem|
|
9
|
+
process_gem(gem)
|
10
|
+
end
|
11
|
+
@completed_gems
|
12
|
+
end
|
13
|
+
|
14
|
+
def process_gem(gem)
|
15
|
+
name = gem.name
|
16
|
+
version = gem.version
|
17
|
+
unless @completed_names.index(name) or gem.no_autogem
|
18
|
+
begin
|
19
|
+
invoke_require_gem_command(name, version)
|
20
|
+
rescue Gem::LoadError => load_error
|
21
|
+
load_error_message = load_error.message
|
22
|
+
load_error_message.strip!
|
23
|
+
error_message = "Error: GemInstaller attempted to load gem '#{name}', version '#{version}', but that version is not installed. Use GemInstaller to install the gem. Original Gem::LoadError was: '#{load_error_message}'"
|
24
|
+
raise GemInstaller::GemInstallerError.new(error_message)
|
25
|
+
end
|
26
|
+
@completed_names << name
|
27
|
+
@completed_gems << gem
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def invoke_require_gem_command(name, version)
|
32
|
+
if GemInstaller::RubyGemsVersionChecker.matches?('< 0.9')
|
33
|
+
require_gem(name, version)
|
34
|
+
else
|
35
|
+
begin
|
36
|
+
result = gem(name, version)
|
37
|
+
rescue Gem::Exception => e
|
38
|
+
exception_message = e.message
|
39
|
+
exception_message.strip!
|
40
|
+
error_message = "Error: GemInstaller failed to actiate gem '#{name}', version '#{version}'. This is probably because GemInstaller processes gems in order (was alphabetical prior to 0.5.0), and an earlier gem in your geminstaller.yml config already activated another version. Use the 'gem dependency [-R]' command to track this down, and reorder/edit your config as necessary. Original Gem::Exception was: '#{exception_message}'"
|
41
|
+
raise GemInstaller::GemInstallerError.new(error_message)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# this file supports backward compatibility for prior versions of RubyGems
|
2
|
+
|
3
|
+
# 0.9.3 reorganized commands to Gem::Commands:: module from Gem::
|
4
|
+
if GemInstaller::RubyGemsVersionChecker.matches?('<0.9.3')
|
5
|
+
LIST_COMMAND_CLASS = Gem::ListCommand
|
6
|
+
QUERY_COMMAND_CLASS = Gem::QueryCommand
|
7
|
+
else
|
8
|
+
LIST_COMMAND_CLASS = Gem::Commands::ListCommand
|
9
|
+
QUERY_COMMAND_CLASS = Gem::Commands::QueryCommand
|
10
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module GemInstaller
|
2
|
+
class Config
|
3
|
+
def initialize(yaml)
|
4
|
+
@yaml = yaml
|
5
|
+
@default_install_options_string = nil
|
6
|
+
end
|
7
|
+
|
8
|
+
def gems
|
9
|
+
parse_defaults
|
10
|
+
gem_defs = @yaml["gems"]
|
11
|
+
gems = []
|
12
|
+
gem_defs.each do |gem_def|
|
13
|
+
name = gem_def['name']
|
14
|
+
version = gem_def['version'].to_s
|
15
|
+
platform = gem_def['platform'].to_s
|
16
|
+
# get install_options for specific gem, if specified
|
17
|
+
install_options_string = gem_def['install_options'].to_s
|
18
|
+
# if no install_options were specified for specific gem, and default install_options were specified...
|
19
|
+
if install_options_string.empty? &&
|
20
|
+
!@default_install_options_string.nil? &&
|
21
|
+
!@default_install_options_string.empty? then
|
22
|
+
# then use the default install_options
|
23
|
+
install_options_string = @default_install_options_string
|
24
|
+
end
|
25
|
+
install_options_array = []
|
26
|
+
# if there was an install options string specified, default or gem-specific, parse it to an array
|
27
|
+
install_options_array = install_options_string.split(" ") unless install_options_string.empty?
|
28
|
+
|
29
|
+
check_for_upgrade = gem_def['check_for_upgrade']
|
30
|
+
if check_for_upgrade.nil? && defined? @default_check_for_upgrade then
|
31
|
+
check_for_upgrade = @default_check_for_upgrade
|
32
|
+
end
|
33
|
+
|
34
|
+
fix_dependencies = gem_def['fix_dependencies']
|
35
|
+
if fix_dependencies.nil? && defined? @default_fix_dependencies then
|
36
|
+
fix_dependencies = @default_fix_dependencies
|
37
|
+
end
|
38
|
+
|
39
|
+
no_autogem = gem_def['no_autogem']
|
40
|
+
if no_autogem.nil? && defined? @default_no_autogem then
|
41
|
+
no_autogem = @default_no_autogem
|
42
|
+
end
|
43
|
+
|
44
|
+
gem = GemInstaller::RubyGem.new(
|
45
|
+
name,
|
46
|
+
:version => version,
|
47
|
+
:platform => platform,
|
48
|
+
:install_options => install_options_array,
|
49
|
+
:check_for_upgrade => check_for_upgrade,
|
50
|
+
:no_autogem => no_autogem,
|
51
|
+
:fix_dependencies => fix_dependencies)
|
52
|
+
gems << gem
|
53
|
+
end
|
54
|
+
return gems
|
55
|
+
end
|
56
|
+
|
57
|
+
protected
|
58
|
+
|
59
|
+
def parse_defaults
|
60
|
+
defaults = @yaml["defaults"]
|
61
|
+
return if defaults.nil?
|
62
|
+
@default_install_options_string = defaults['install_options']
|
63
|
+
@default_check_for_upgrade = defaults['check_for_upgrade']
|
64
|
+
@default_fix_dependencies = defaults['fix_dependencies']
|
65
|
+
@default_no_autogem = defaults['no_autogem']
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
dir = File.dirname(__FILE__)
|
2
|
+
require File.expand_path("#{dir}/requires.rb")
|
3
|
+
|
4
|
+
module GemInstaller
|
5
|
+
class ConfigBuilder
|
6
|
+
attr_reader :config_file_paths_array
|
7
|
+
attr_writer :file_reader, :yaml_loader, :config_file_paths, :output_filter
|
8
|
+
|
9
|
+
def initialize(default_config_file_paths_array = ['geminstaller.yml','config/geminstaller.yml'])
|
10
|
+
@default_config_file_paths_array = default_config_file_paths_array
|
11
|
+
end
|
12
|
+
|
13
|
+
def build_config
|
14
|
+
@config_file_paths_array = @config_file_paths ? @config_file_paths.split(",") : @default_config_file_paths_array
|
15
|
+
merged_defaults = {}
|
16
|
+
merged_gems_in_order = []
|
17
|
+
merged_gems_by_key = {}
|
18
|
+
file_found = false
|
19
|
+
@config_file_paths_array.reverse.each do |path| # reverse because last config files win
|
20
|
+
if File.exists?(path)
|
21
|
+
file_found = true
|
22
|
+
else
|
23
|
+
next
|
24
|
+
end
|
25
|
+
file_contents = @file_reader.read(path)
|
26
|
+
next unless file_contents
|
27
|
+
next if file_contents.empty?
|
28
|
+
expanded_path = File.expand_path(path)
|
29
|
+
@output_filter.geminstaller_output(:debug,"Found GemInstaller config file at: #{expanded_path}\n")
|
30
|
+
erb = ERB.new(%{#{file_contents}})
|
31
|
+
erb_result = nil
|
32
|
+
Dir.chdir(File.dirname(expanded_path)) do |yaml_file_dir|
|
33
|
+
erb_result = erb.result(include_config_binding)
|
34
|
+
end
|
35
|
+
yaml = @yaml_loader.load(erb_result)
|
36
|
+
merged_defaults.merge!(yaml['defaults']) unless yaml['defaults'].nil?
|
37
|
+
next unless yaml['gems']
|
38
|
+
yaml['gems'].each do |new_gem|
|
39
|
+
gem_key = [new_gem['name'],new_gem['version'],new_gem['platform']].join('-')
|
40
|
+
existing_gem = merged_gems_by_key[gem_key]
|
41
|
+
unless existing_gem
|
42
|
+
merged_gems_in_order << new_gem
|
43
|
+
merged_gems_by_key[gem_key] = new_gem
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
raise GemInstaller::MissingFileError.new("No config files found at any of these paths: #{@config_file_paths_array.join(', ')}") unless file_found
|
48
|
+
merged_yaml = {}
|
49
|
+
merged_yaml['defaults'] = merged_defaults
|
50
|
+
merged_yaml['gems'] = merged_gems_in_order
|
51
|
+
config = GemInstaller::Config.new(merged_yaml)
|
52
|
+
config
|
53
|
+
end
|
54
|
+
|
55
|
+
def include_config_binding
|
56
|
+
def include_config(config_file)
|
57
|
+
Dir.chdir(File.dirname(config_file)) do |yaml_file_dir|
|
58
|
+
erb = File.open(config_file) { |io| ERB.new(io.read) }
|
59
|
+
erb.result(include_config_binding)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
binding
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module GemInstaller
|
2
|
+
class EnhancedStreamUI < Gem::StreamUI
|
3
|
+
attr_writer :outs, :errs
|
4
|
+
attr_writer :gem_interaction_handler if GemInstaller::RubyGemsVersionChecker.matches?('<=0.9.4')
|
5
|
+
|
6
|
+
def initialize()
|
7
|
+
# override default constructor to have no args
|
8
|
+
end
|
9
|
+
|
10
|
+
def ask_yes_no(question, default=nil)
|
11
|
+
if GemInstaller::RubyGemsVersionChecker.matches?('<=0.9.4')
|
12
|
+
# Using defaults, we expect no interactive prompts RubyGems >= 0.9.5
|
13
|
+
begin
|
14
|
+
@gem_interaction_handler.handle_ask_yes_no(question)
|
15
|
+
rescue Exception => e
|
16
|
+
@outs.print(question)
|
17
|
+
@outs.flush
|
18
|
+
raise e
|
19
|
+
end
|
20
|
+
end
|
21
|
+
raise_unexpected_prompt_error(question)
|
22
|
+
end
|
23
|
+
|
24
|
+
def ask(question)
|
25
|
+
raise_unexpected_prompt_error(question)
|
26
|
+
end
|
27
|
+
|
28
|
+
def choose_from_list(question, list)
|
29
|
+
if GemInstaller::RubyGemsVersionChecker.matches?('<=0.9.4')
|
30
|
+
# Using defaults, we expect no interactive prompts RubyGems >= 0.9.5
|
31
|
+
@gem_interaction_handler.handle_choose_from_list(question, list)
|
32
|
+
else
|
33
|
+
list_string = list.join("\n")
|
34
|
+
question_and_list = "#{question}\n#{list_string}"
|
35
|
+
raise_unexpected_prompt_error(question_and_list)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
if GemInstaller::RubyGemsVersionChecker.matches?('<=1.0.1')
|
40
|
+
# explicit exit in terminate_interation was removed after 1.0.1
|
41
|
+
def terminate_interaction!(status=-1)
|
42
|
+
raise_error(status)
|
43
|
+
end
|
44
|
+
|
45
|
+
def terminate_interaction(status=0)
|
46
|
+
raise_error(status) unless status == 0
|
47
|
+
raise GemInstaller::RubyGemsExit.new(status)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def alert_error(statement, question=nil)
|
52
|
+
# if alert_error got called due to a GemInstaller::UnexpectedPromptError, re-throw it
|
53
|
+
last_exception = $!
|
54
|
+
if last_exception.class == GemInstaller::UnauthorizedDependencyPromptError || last_exception.class == GemInstaller::RubyGemsExit
|
55
|
+
raise last_exception
|
56
|
+
end
|
57
|
+
# otherwise let alert_error continue normally...
|
58
|
+
super(statement, question)
|
59
|
+
end
|
60
|
+
|
61
|
+
protected
|
62
|
+
def raise_error(status)
|
63
|
+
raise GemInstaller::GemInstallerError.new("RubyGems exited abnormally. Status: #{status}\n")
|
64
|
+
end
|
65
|
+
|
66
|
+
def raise_unexpected_prompt_error(question)
|
67
|
+
raise GemInstaller::UnexpectedPromptError.new("GemInstaller Internal Error - Unexpected prompt received from RubyGems: '#{question}'.")
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module GemInstaller
|
2
|
+
class ExactMatchListCommand < LIST_COMMAND_CLASS
|
3
|
+
def execute
|
4
|
+
string = get_one_optional_argument || ''
|
5
|
+
# This overrides the default RubyGems ListCommand behavior of doing a wildcard match. This caused problems
|
6
|
+
# when some gems (ActiveRecord-JDBC) caused exceptions during a remote list, causing a remote list
|
7
|
+
# of other gems (activerecord) to fail as well
|
8
|
+
options[:name] = /^#{string}$/i
|
9
|
+
# Do a little metaprogramming magic to avoid calling the problematic execute method on the ListCommand
|
10
|
+
# superclass, and instead directly call the method on the QueryCommand grandparent 'supersuperclass'
|
11
|
+
unbound_execute_method = QUERY_COMMAND_CLASS.instance_method(:execute)
|
12
|
+
bound_execute_method = unbound_execute_method.bind(self)
|
13
|
+
bound_execute_method.call
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module GemInstaller
|
2
|
+
class FileReader
|
3
|
+
def read(file_path)
|
4
|
+
file_contents = nil
|
5
|
+
if !File.exist?(file_path) then
|
6
|
+
raise GemInstaller::MissingFileError.new("#{file_path}")
|
7
|
+
end
|
8
|
+
|
9
|
+
file = nil
|
10
|
+
begin
|
11
|
+
file = do_open(file_path)
|
12
|
+
rescue
|
13
|
+
raise GemInstaller::GemInstallerError.new("Error: Unable open file #{file_path}. Please ensure that this file can be opened.\n")
|
14
|
+
end
|
15
|
+
|
16
|
+
begin
|
17
|
+
do_read(file)
|
18
|
+
rescue
|
19
|
+
raise GemInstaller::GemInstallerError.new("Error: Unable read file #{file_path}. Please ensure that this file can be read.\n")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def do_open(file_path)
|
24
|
+
File.open(file_path)
|
25
|
+
end
|
26
|
+
|
27
|
+
def do_read(file)
|
28
|
+
file.read
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module GemInstaller
|
2
|
+
class GemArgProcessor
|
3
|
+
#Common Options:
|
4
|
+
# --source URL Use URL as the remote source for gems
|
5
|
+
# -p, --[no-]http-proxy [URL] Use HTTP proxy for remote operations
|
6
|
+
# -h, --help Get help on this command
|
7
|
+
# -v, --verbose Set the verbose level of output
|
8
|
+
# --config-file FILE Use this config file instead of default
|
9
|
+
# --backtrace Show stack backtrace on errors
|
10
|
+
# --debug Turn on Ruby debugging
|
11
|
+
GEM_COMMON_OPTIONS_WITHOUT_ARG = ['--no-http-proxy','-v','--verbose','--backtrace','--debug']
|
12
|
+
GEM_COMMON_OPTIONS_WITH_ARG = ['--source','-p','--http_proxy','--config-file']
|
13
|
+
|
14
|
+
# take an array of args, and strip all args that are not common gem command args
|
15
|
+
def strip_non_common_gem_args(args)
|
16
|
+
# I can't figure out a way to elegantly do this, so I hardcoded the options. Here's how you print them
|
17
|
+
# Gem::Command.common_options.each do |option|
|
18
|
+
# p option[0]
|
19
|
+
# end
|
20
|
+
|
21
|
+
common_args = []
|
22
|
+
i = 0
|
23
|
+
loop do
|
24
|
+
break if i == args.size
|
25
|
+
arg = args[i]
|
26
|
+
if GEM_COMMON_OPTIONS_WITHOUT_ARG.include?(arg)
|
27
|
+
common_args << arg
|
28
|
+
else
|
29
|
+
GEM_COMMON_OPTIONS_WITH_ARG.each do |option|
|
30
|
+
if arg.include?(option)
|
31
|
+
common_args << arg
|
32
|
+
unless arg.include?('=')
|
33
|
+
i += 1
|
34
|
+
common_args << args[i]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
i += 1
|
40
|
+
end
|
41
|
+
common_args
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module GemInstaller
|
2
|
+
class GemCommandManager
|
3
|
+
attr_writer :gem_spec_manager, :gem_runner_proxy
|
4
|
+
attr_writer :gem_interaction_handler if GemInstaller::RubyGemsVersionChecker.matches?('<=0.9.4')
|
5
|
+
|
6
|
+
def list_remote_gem(gem, additional_options)
|
7
|
+
run_args = ["list",gem.name,"--remote","--details"]
|
8
|
+
run_args << "--all" if GemInstaller::RubyGemsVersionChecker.matches?('>1.0.1')
|
9
|
+
run_args += additional_options
|
10
|
+
@gem_runner_proxy.run(run_args)
|
11
|
+
end
|
12
|
+
|
13
|
+
def uninstall_gem(gem)
|
14
|
+
return if !@gem_spec_manager.is_gem_installed?(gem)
|
15
|
+
init_gem_interaction_handler(gem)
|
16
|
+
run_gem_command('uninstall', gem, gem.uninstall_options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def install_gem(gem, force_reinstall = false)
|
20
|
+
return [] if @gem_spec_manager.is_gem_installed?(gem) && !force_reinstall
|
21
|
+
init_gem_interaction_handler(gem)
|
22
|
+
run_gem_command('install', gem, gem.install_options)
|
23
|
+
end
|
24
|
+
|
25
|
+
def init_gem_interaction_handler(gem)
|
26
|
+
@gem_interaction_handler.dependent_gem = gem if GemInstaller::RubyGemsVersionChecker.matches?('<=0.9.4')
|
27
|
+
end
|
28
|
+
|
29
|
+
def dependency(name, version, additional_options = [])
|
30
|
+
# rubygems has bug up to 0.9.4 where the pipe options uses 'puts', instead of 'say', so we can't capture it
|
31
|
+
# with enhanced_stream_ui. Patched: http://rubyforge.org/tracker/index.php?func=detail&aid=9020&group_id=126&atid=577
|
32
|
+
# TODO: use pipe option on later versions which support it
|
33
|
+
|
34
|
+
name_regexp = "^#{name}$"
|
35
|
+
name_regexp = "/#{name_regexp}/" if GemInstaller::RubyGemsVersionChecker.matches?('>=1.2.0')
|
36
|
+
run_args = ["dependency", name_regexp, "--version", version]
|
37
|
+
run_args += additional_options
|
38
|
+
output_lines = @gem_runner_proxy.run(run_args)
|
39
|
+
p output_lines
|
40
|
+
# dependency output has all lines in the first element
|
41
|
+
output_array = output_lines[0].split("\n")
|
42
|
+
# drop the first line which just echoes the dependent gem
|
43
|
+
output_array.shift
|
44
|
+
# drop the line containing 'requires' (rubygems < 0.9.0)
|
45
|
+
if output_array[0] == ' Requires'
|
46
|
+
output_array.shift
|
47
|
+
end
|
48
|
+
# drop all empty lines
|
49
|
+
output_array.reject! { |line| line == "" }
|
50
|
+
# strip leading space
|
51
|
+
output_array.each { |line| line.strip! }
|
52
|
+
# convert into gems
|
53
|
+
output_gems = output_array.collect do |line|
|
54
|
+
name = line.split(' ')[0]
|
55
|
+
version_spec = line.split(/[(,)]/)[1]
|
56
|
+
GemInstaller::RubyGem.new(name, :version => version_spec)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def run_gem_command(gem_command, gem, options)
|
61
|
+
run_args = [gem_command,gem.name,"--version", "#{gem.version}"]
|
62
|
+
if GemInstaller::RubyGemsVersionChecker.matches?('>=0.9.5')
|
63
|
+
run_args += ['--platform', "#{gem.platform}"] if gem.platform && !gem.platform.empty?
|
64
|
+
end
|
65
|
+
run_args += options
|
66
|
+
@gem_runner_proxy.run(run_args)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module GemInstaller
|
2
|
+
class GemInteractionHandler
|
3
|
+
attr_writer :dependent_gem, :noninteractive_chooser_class, :valid_platform_selector
|
4
|
+
DEPENDENCY_PROMPT = 'Install required dependency'
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
check_rubygems_version
|
8
|
+
end
|
9
|
+
|
10
|
+
def handle_ask_yes_no(question)
|
11
|
+
return unless question.index(DEPENDENCY_PROMPT)
|
12
|
+
message = "Error: RubyGems is prompting to install a required dependency, and you have not " +
|
13
|
+
"specified the '--install-dependencies' option for the current gem. You must modify your " +
|
14
|
+
"geminstaller config file to either specify the '--install-depencencies' (-y) " +
|
15
|
+
"option, or explicitly add an entry for the dependency gem earlier in the file.\n"
|
16
|
+
raise GemInstaller::UnauthorizedDependencyPromptError.new(message)
|
17
|
+
end
|
18
|
+
|
19
|
+
def handle_choose_from_list(question, list, noninteractive_chooser = nil)
|
20
|
+
noninteractive_chooser ||= @noninteractive_chooser_class.new
|
21
|
+
valid_platforms = nil
|
22
|
+
if dependent_gem_with_platform_specified?(list, noninteractive_chooser) or noninteractive_chooser.uninstall_list_type?(question)
|
23
|
+
valid_platforms = [@dependent_gem.platform]
|
24
|
+
else
|
25
|
+
valid_platforms = @valid_platform_selector.select(@dependent_gem.platform)
|
26
|
+
end
|
27
|
+
noninteractive_chooser.choose(question, list, @dependent_gem.name, @dependent_gem.version, valid_platforms)
|
28
|
+
end
|
29
|
+
|
30
|
+
def dependent_gem_with_platform_specified?(list, noninteractive_chooser)
|
31
|
+
noninteractive_chooser.dependent_gem?(@dependent_gem.name, list) and @dependent_gem.platform
|
32
|
+
end
|
33
|
+
|
34
|
+
def check_rubygems_version
|
35
|
+
if GemInstaller::RubyGemsVersionChecker.matches?('>=0.9.5')
|
36
|
+
# gem_interaction_handler is not used for RubyGems >= 0.9.5
|
37
|
+
raise RuntimeError.new("Internal GemInstaller Error: GemInteractionHandler should not be used for RubyGems >= 0.9.5")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|