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
data/bin/geminstaller
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
dir = File.dirname(__FILE__)
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'geminstaller'
|
7
|
+
rescue LoadError
|
8
|
+
require 'rubygems'
|
9
|
+
begin
|
10
|
+
# try load path
|
11
|
+
require 'geminstaller'
|
12
|
+
rescue LoadError
|
13
|
+
begin
|
14
|
+
# try lib subdir (TODO: is this necessary?)
|
15
|
+
require 'lib/geminstaller'
|
16
|
+
rescue LoadError
|
17
|
+
# try lib dir as peer of current dir
|
18
|
+
require "#{dir}/../lib/geminstaller"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
geminstaller_executable ||= File.join(File.expand_path(dir), 'geminstaller')
|
24
|
+
|
25
|
+
if ARGV.include?('--geminstaller-exec-path')
|
26
|
+
print "geminstaller_exec_path=#{geminstaller_executable}"
|
27
|
+
exit 0
|
28
|
+
end
|
29
|
+
|
30
|
+
exit GemInstaller.install(ARGV, geminstaller_executable)
|
data/cruise_config.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Project-specific configuration for CruiseControl.rb
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
Project.configure do |project|
|
5
|
+
project.email_notifier.emails = ['thewoolleyman@gmail.com']
|
6
|
+
if project.name =~ /rubygems[_-](.*)$/ # geminstaller_using_rubygems_0-9-4
|
7
|
+
rubygems_version = $1
|
8
|
+
rubygems_version.gsub!('-','.')
|
9
|
+
ENV['RUBYGEMS_VERSION'] = rubygems_version
|
10
|
+
end
|
11
|
+
if project.name =~ /smoketest/i # smoketest project
|
12
|
+
project.rake_task = project.name
|
13
|
+
end
|
14
|
+
end
|
data/focused_spec.sh
ADDED
@@ -0,0 +1,2 @@
|
|
1
|
+
# warning - experimental
|
2
|
+
ruby -I spec/lib/ruby-debug-0.10.0/cli:spec/lib/ruby-debug-0.10.0/bin:spec/lib/ruby-debug-base-0.10.0/lib:spec/lib/ruby-debug-0.10.0/bin/rdebug:spec/lib/rspec-1.1.1/lib spec/lib/ruby-debug-0.10.0/bin/rdebug spec/lib/rspec-1.1.1/bin/spec -- $1 --line=$2
|
data/geminstaller.yml
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
---
|
2
|
+
# GemInstaller config file which specifies the actual build, test, and doc dependencies for GemInstaller itself.
|
3
|
+
defaults:
|
4
|
+
install_options: --include-dependencies
|
5
|
+
fix_dependencies: true
|
6
|
+
gems:
|
7
|
+
- name: diff-lcs
|
8
|
+
version: '>= 1.1.2'
|
9
|
+
- name: hoe
|
10
|
+
version: '= 1.8.3'
|
11
|
+
- name: open4
|
12
|
+
version: '>= 0.9.6'
|
13
|
+
- name: rake
|
14
|
+
version: '>= 0.7.1'
|
15
|
+
- name: rcov
|
16
|
+
version: '>= 0.7.0.1'
|
17
|
+
platform: <%= RUBY_PLATFORM =~ /mswin/ ? 'mswin32' : 'ruby'%>
|
18
|
+
- name: RedCloth
|
19
|
+
# version: '= 3.0.4'
|
20
|
+
version: '= 4.0.4'
|
21
|
+
- name: rspec
|
22
|
+
version: '>= 1.1.12'
|
23
|
+
- name: cmdparse
|
24
|
+
version: '>= 2.0.2'
|
25
|
+
- name: ruby-debug
|
26
|
+
version: '>= 0.9.3'
|
27
|
+
- name: webgen
|
28
|
+
version: '= 0.5.5'
|
29
|
+
# - name: gettalong-webgen
|
30
|
+
# version: '>= 0.5.5.20081001'
|
31
|
+
<% if RUBY_PLATFORM =~ /mswin/ %>
|
32
|
+
- name: win32-process
|
33
|
+
version: '>= 0.5.5'
|
34
|
+
platform: 'mswin32'
|
35
|
+
- name: win32console
|
36
|
+
version: '>= 1.0.8'
|
37
|
+
platform: 'mswin32'
|
38
|
+
- name: win32-open3
|
39
|
+
version: '>= 0.2.5'
|
40
|
+
platform: 'mswin32'
|
41
|
+
<% end %>
|
42
|
+
|
data/lib/geminstaller.rb
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
dir = File.dirname(__FILE__)
|
2
|
+
require File.expand_path("#{dir}/geminstaller/requires.rb")
|
3
|
+
|
4
|
+
module GemInstaller
|
5
|
+
def self.install(args = [], geminstaller_executable = nil)
|
6
|
+
args_copy = args.dup
|
7
|
+
args_copy = args_copy.split(' ') unless args.respond_to? :join
|
8
|
+
# recursively call script with sudo, if --sudo option is specified
|
9
|
+
if platform_supports_sudo? and (args_copy.include?("-s") or args_copy.include?("--sudo"))
|
10
|
+
result = reinvoke_with_sudo(args_copy, geminstaller_executable)
|
11
|
+
if result != 0 and (args_copy.include?("-e") or args_copy.include?("--exceptions"))
|
12
|
+
message = "Error: GemInstaller failed while being invoked with --sudo option. See prior output for error, and use '--geminstaller-output=all --rubygems-output=all' options to get more details."
|
13
|
+
raise GemInstaller::GemInstallerError.new(message)
|
14
|
+
end
|
15
|
+
return result
|
16
|
+
else
|
17
|
+
app = create_application(args_copy)
|
18
|
+
app.install
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.run(args = [], geminstaller_executable = nil)
|
23
|
+
# run is now an alias for install
|
24
|
+
install(args, geminstaller_executable)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.autogem(args = [])
|
28
|
+
args_copy = args.dup
|
29
|
+
args_copy = args_copy.split(' ') unless args.respond_to? :join
|
30
|
+
# TODO: should explicitly remove all args not applicable to autogem (anything but config, silent, and geminstaller_output)
|
31
|
+
args_without_sudo = strip_sudo(args_copy)
|
32
|
+
app = create_application(args_without_sudo)
|
33
|
+
app.autogem
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.version
|
37
|
+
"0.5.2"
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.create_application(args = [], registry = nil)
|
41
|
+
registry ||= create_registry
|
42
|
+
app = registry.app
|
43
|
+
app.args = args
|
44
|
+
app
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.create_registry
|
48
|
+
GemInstaller::Registry.new
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.parse_config_paths(config_paths)
|
52
|
+
return nil unless config_paths
|
53
|
+
return config_paths unless config_paths.respond_to? :join
|
54
|
+
return config_paths.join(',')
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.platform_supports_sudo?
|
58
|
+
return true unless RUBY_PLATFORM =~ /mswin/
|
59
|
+
return false
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.reinvoke_with_sudo(args, geminstaller_executable)
|
63
|
+
# Sudo support is a hack, better to use other alternatives.
|
64
|
+
geminstaller_executable ||= find_geminstaller_executable
|
65
|
+
args_without_sudo = strip_sudo(args)
|
66
|
+
args_without_sudo << '--redirect-stderr-to-stdout'
|
67
|
+
cmd = "sudo ruby #{geminstaller_executable} #{args_without_sudo.join(' ')}"
|
68
|
+
# TODO: this eats any output. There currently is no standard way to get a return code AND stdin AND stdout.
|
69
|
+
# Some non-standard packages like Open4 handle this, but not synchronously. The Simplest Thing That Could
|
70
|
+
# Possibly Work is to have a command line option which will cause all stderr output to be redirected to stdout.
|
71
|
+
result = system(cmd)
|
72
|
+
return 1 unless result
|
73
|
+
return $?.exitstatus
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.strip_sudo(args)
|
77
|
+
return args.reject {|arg| arg == "-s" || arg == "--sudo"}
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.find_geminstaller_executable
|
81
|
+
possible_locations = [
|
82
|
+
'ruby -S geminstaller',
|
83
|
+
'ruby /usr/local/bin/geminstaller',
|
84
|
+
'ruby /usr/bin/geminstaller',
|
85
|
+
'ruby ./bin/geminstaller'
|
86
|
+
]
|
87
|
+
path_key = 'geminstaller_exec_path='
|
88
|
+
possible_locations.each do |possible_location|
|
89
|
+
cmd = "#{possible_location} --geminstaller-exec-path"
|
90
|
+
|
91
|
+
$stderr_backup = $stderr.dup
|
92
|
+
$stderr.reopen("/dev/null", "w")
|
93
|
+
io = IO.popen(cmd)
|
94
|
+
$stderr.reopen($stderr_backup)
|
95
|
+
STDERR.reopen($stderr_backup) # Why are these not the same? It is an old question: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/47596
|
96
|
+
output = io.read
|
97
|
+
next unless output =~ /#{path_key}/
|
98
|
+
path = output.sub(path_key,'')
|
99
|
+
return path
|
100
|
+
end
|
101
|
+
raise GemInstaller::GemInstallerError.new("Error: Unable to locate the geminstaller executable. Specify it explicitly, or don't use the sudo option.")
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
module GemInstaller
|
2
|
+
class Application
|
3
|
+
# we have accessors instead of just writers so that we can ensure it is assembled correctly in the dependency injector test
|
4
|
+
attr_accessor :config_builder, :install_processor, :output_filter, :arg_parser, :args, :options, :rogue_gem_finder
|
5
|
+
attr_writer :autogem
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@args = nil
|
9
|
+
end
|
10
|
+
|
11
|
+
def install
|
12
|
+
begin
|
13
|
+
exit_flag_and_return_code = handle_args
|
14
|
+
if exit_flag_and_return_code[0]
|
15
|
+
return exit_flag_and_return_code[1]
|
16
|
+
end
|
17
|
+
gems = create_gems_from_config
|
18
|
+
if @options[:print_rogue_gems]
|
19
|
+
@rogue_gem_finder.print_rogue_gems(gems, @config_builder.config_file_paths_array)
|
20
|
+
return 0
|
21
|
+
end
|
22
|
+
if gems.size == 0
|
23
|
+
message = "No gems found in config file. Try the --print-rogue-gems option to help populate your config file."
|
24
|
+
@output_filter.geminstaller_output(:info,message + "\n")
|
25
|
+
else
|
26
|
+
process_gems(gems)
|
27
|
+
end
|
28
|
+
rescue Exception => e
|
29
|
+
handle_exception(e)
|
30
|
+
return 1
|
31
|
+
end
|
32
|
+
return 0
|
33
|
+
end
|
34
|
+
|
35
|
+
def autogem
|
36
|
+
begin
|
37
|
+
# TODO: do some validation that args only contains --config option, especially not print_rogue_gems since this would mask a missing file error
|
38
|
+
exit_flag_and_return_code = handle_args
|
39
|
+
if exit_flag_and_return_code[0]
|
40
|
+
return exit_flag_and_return_code[1]
|
41
|
+
end
|
42
|
+
gems = create_gems_from_config
|
43
|
+
message = "GemInstaller is automatically requiring gems: "
|
44
|
+
print_startup_message(gems, message)
|
45
|
+
return @autogem.autogem(gems)
|
46
|
+
rescue Exception => e
|
47
|
+
handle_exception(e)
|
48
|
+
return 1
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def handle_exception(e)
|
53
|
+
message = e.message
|
54
|
+
message += "\n"
|
55
|
+
@output_filter.geminstaller_output(:error,message)
|
56
|
+
backtrace_as_string = e.backtrace.join("\n")
|
57
|
+
@output_filter.geminstaller_output(:debug,"#{backtrace_as_string}\n")
|
58
|
+
raise e if @options[:exceptions]
|
59
|
+
end
|
60
|
+
|
61
|
+
def create_gems_from_config
|
62
|
+
begin
|
63
|
+
config = @config_builder.build_config
|
64
|
+
rescue GemInstaller::MissingFileError => e
|
65
|
+
# if user wants to print rogue gems and they have no config at all, don't show an error
|
66
|
+
return [] if @options[:print_rogue_gems] && (@config_builder.config_file_paths_array.size == 1)
|
67
|
+
missing_path = e.message
|
68
|
+
error_message = "Error: A GemInstaller config file is missing at #{missing_path}. You can generate one with the --print-rogue-gems option. See the GemInstaller docs at http://geminstaller.rubyforge.org for more info."
|
69
|
+
raise GemInstaller::MissingFileError.new(error_message)
|
70
|
+
end
|
71
|
+
config.gems
|
72
|
+
end
|
73
|
+
|
74
|
+
def process_gems(gems)
|
75
|
+
message = "GemInstaller is verifying gem installation: "
|
76
|
+
print_startup_message(gems, message)
|
77
|
+
@install_processor.process(gems)
|
78
|
+
end
|
79
|
+
|
80
|
+
def handle_args
|
81
|
+
return_code = @arg_parser.parse(@args)
|
82
|
+
arg_parser_output = @arg_parser.output
|
83
|
+
if (arg_parser_output && arg_parser_output != '')
|
84
|
+
if return_code == 0
|
85
|
+
@output_filter.geminstaller_output(:info,arg_parser_output)
|
86
|
+
else
|
87
|
+
@output_filter.geminstaller_output(:error,arg_parser_output)
|
88
|
+
end
|
89
|
+
return [true, return_code]
|
90
|
+
end
|
91
|
+
config_file_paths = @options[:config_paths]
|
92
|
+
@config_builder.config_file_paths = config_file_paths if config_file_paths
|
93
|
+
return [false, 0]
|
94
|
+
end
|
95
|
+
|
96
|
+
def print_startup_message(gems, message)
|
97
|
+
gems.each_with_index do |gem, index|
|
98
|
+
gem_info = "#{gem.name} #{gem.version}"
|
99
|
+
message += gem_info
|
100
|
+
message += ", " if index + 1 < gems.size
|
101
|
+
end
|
102
|
+
@output_filter.geminstaller_output(:debug,message + "\n")
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
module GemInstaller
|
2
|
+
class ArgParser
|
3
|
+
attr_reader :output
|
4
|
+
attr_writer :options
|
5
|
+
|
6
|
+
VALID_GEMINSTALLER_OUTPUT_FLAGS = [:none,:error,:install,:info,:commandecho,:debug,:all]
|
7
|
+
VALID_RUBYGEMS_OUTPUT_FLAGS = [:none,:stdout,:stderr,:all]
|
8
|
+
|
9
|
+
def parse(args = [])
|
10
|
+
raise GemInstaller::GemInstallerError.new("Args must be passed as an array.") unless args.nil? or args.respond_to? :shift
|
11
|
+
args = ARGV if args.nil? || args == []
|
12
|
+
# check to see if args is an array of (nothing but) gems here... if so, set args as [@options[:gems] and return
|
13
|
+
|
14
|
+
raise GemInstaller::GemInstallerError.new("Error: An array of options to be populated must be injected prior to calling GemInstaller::ArgParser.parse") unless @options
|
15
|
+
@options[:exceptions] = false
|
16
|
+
@options[:redirect_stderr_to_stdout] = false
|
17
|
+
@options[:silent] = false
|
18
|
+
@options[:sudo] = false
|
19
|
+
@options[:geminstaller_output] = [:error,:install,:info]
|
20
|
+
@options[:rubygems_output] = [:stderr]
|
21
|
+
@output = ""
|
22
|
+
@unparsed_geminstaller_output_flags = nil
|
23
|
+
@unparsed_rubygems_output_flags = nil
|
24
|
+
opts = OptionParser.new do |opts|
|
25
|
+
opts.banner = "Usage: geminstaller [options]"
|
26
|
+
|
27
|
+
opts.separator ""
|
28
|
+
|
29
|
+
config_msg = "Comma-delimited path(s) to GemInstaller config file(s)."
|
30
|
+
exceptions_msg = "Raise any exceptions, rather than just printing them and exiting\n" +
|
31
|
+
" with a non-zero return code."
|
32
|
+
redirect_stderr_to_stdout_msg = "Redirect all STDERR output to STDOUT. Useful to get all output when\n" +
|
33
|
+
" invoking GemInstaller via system()."
|
34
|
+
geminstaller_output_msg = "Comma-delimited list of output types to show from GemInstaller.\n" +
|
35
|
+
" Examples:\n" +
|
36
|
+
" --gall\n" +
|
37
|
+
" --geminstaller-output=error,install,commandecho\n" +
|
38
|
+
" Default: error,install,info\n" +
|
39
|
+
" Valid types:\n" +
|
40
|
+
" - none: print only fatal errors\n" +
|
41
|
+
" - error: print error messages\n" +
|
42
|
+
" - install: print install messages\n" +
|
43
|
+
" - info: print informational messages\n" +
|
44
|
+
" - commandecho: print rubygems commands as they are invoked\n" +
|
45
|
+
" - debug: print debug messages\n" +
|
46
|
+
" - all: print all messages"
|
47
|
+
help_msg = "Show this message."
|
48
|
+
print_rogue_gems_msg = "Print a report of all locally installed gems which are not specified\n" +
|
49
|
+
" in the geminstaller config file."
|
50
|
+
rubygems_output_msg = "Comma-delimited list of output types to show from internal:\n" +
|
51
|
+
" RubyGems command invocation.\n" +
|
52
|
+
" Examples:\n" +
|
53
|
+
" --rall\n" +
|
54
|
+
" --rubygems-output=stderr\n" +
|
55
|
+
" Default: stderr\n" +
|
56
|
+
" Valid types:\n" +
|
57
|
+
" - none: print no output\n" +
|
58
|
+
" - stdout: print standard output stream\n" +
|
59
|
+
" - stderr: print standard error stream\n" +
|
60
|
+
" - all: print all output"
|
61
|
+
sudo_msg = "Perform all gem operations under sudo (as root). Will only work on\n" +
|
62
|
+
" correctly configured, supported systems. See docs for more info."
|
63
|
+
silent_msg = "Suppress all output except fatal exceptions, and output from\n" +
|
64
|
+
" rogue-gems option."
|
65
|
+
version_msg = "Show GemInstaller version and exit."
|
66
|
+
|
67
|
+
opts.on("-cCONFIGPATHS", "--config=CONFIGPATHS", String, config_msg) do |config_paths|
|
68
|
+
@options[:config_paths] = config_paths
|
69
|
+
end
|
70
|
+
|
71
|
+
opts.on("-e", "--exceptions", exceptions_msg) do
|
72
|
+
@options[:exceptions] = true
|
73
|
+
end
|
74
|
+
|
75
|
+
opts.on("-d", "--redirect-stderr-to-stdout", redirect_stderr_to_stdout_msg) do
|
76
|
+
@options[:redirect_stderr_to_stdout] = true
|
77
|
+
end
|
78
|
+
|
79
|
+
opts.on("-gTYPES", "--geminstaller-output=TYPES", String, geminstaller_output_msg) do |geminstaller_output_flags|
|
80
|
+
@unparsed_geminstaller_output_flags = geminstaller_output_flags
|
81
|
+
end
|
82
|
+
|
83
|
+
opts.on("-h", "--help", help_msg) do
|
84
|
+
@output = opts.to_s
|
85
|
+
end
|
86
|
+
|
87
|
+
opts.on("-p", "--print-rogue-gems", print_rogue_gems_msg) do
|
88
|
+
@options[:print_rogue_gems] = true
|
89
|
+
end
|
90
|
+
|
91
|
+
opts.on("-rTYPES", "--rubygems-output=TYPES", String, rubygems_output_msg) do |rubygems_output_flags|
|
92
|
+
@unparsed_rubygems_output_flags = rubygems_output_flags
|
93
|
+
end
|
94
|
+
|
95
|
+
opts.on("-s", "--sudo", sudo_msg) do
|
96
|
+
@options[:sudo] = true
|
97
|
+
end
|
98
|
+
|
99
|
+
opts.on("-t", "--silent", silent_msg) do
|
100
|
+
@options[:silent] = true
|
101
|
+
end
|
102
|
+
|
103
|
+
opts.on("-v", "--version", version_msg) do
|
104
|
+
@output = "#{GemInstaller::version}\n"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
begin
|
109
|
+
opts.parse!(args)
|
110
|
+
rescue(OptionParser::InvalidOption)
|
111
|
+
@output << opts.to_s
|
112
|
+
return 1
|
113
|
+
end
|
114
|
+
|
115
|
+
if @options[:silent] and (@unparsed_geminstaller_output_flags or @unparsed_rubygems_output_flags)
|
116
|
+
@output = "The rubygems-output or geminstaller-output option cannot be specified if the silent option is true."
|
117
|
+
return 1
|
118
|
+
end
|
119
|
+
|
120
|
+
if (@options[:sudo])
|
121
|
+
@output = "The sudo option is not (yet) supported when invoking GemInstaller programatically. It is only supported when using the command line 'geminstaller' executable. See the docs for more info."
|
122
|
+
return 1
|
123
|
+
end
|
124
|
+
|
125
|
+
# TODO: remove duplication
|
126
|
+
if @unparsed_geminstaller_output_flags
|
127
|
+
flags = @unparsed_geminstaller_output_flags.split(',')
|
128
|
+
flags.delete_if {|flag| flag == nil or flag == ''}
|
129
|
+
flags.map! {|flag| flag.downcase}
|
130
|
+
flags.sort!
|
131
|
+
flags.uniq!
|
132
|
+
flags.map! {|flag| flag.to_sym}
|
133
|
+
geminstaller_output_valid = true
|
134
|
+
flags.each do |flag|
|
135
|
+
unless VALID_GEMINSTALLER_OUTPUT_FLAGS.include?(flag)
|
136
|
+
@output = "Invalid geminstaller-output flag: #{flag}\n"
|
137
|
+
geminstaller_output_valid = false
|
138
|
+
end
|
139
|
+
end
|
140
|
+
@options[:geminstaller_output] = flags if geminstaller_output_valid
|
141
|
+
end
|
142
|
+
|
143
|
+
if @unparsed_rubygems_output_flags
|
144
|
+
flags = @unparsed_rubygems_output_flags.split(',')
|
145
|
+
flags.delete_if {|flag| flag == nil or flag == ''}
|
146
|
+
flags.map! {|flag| flag.downcase}
|
147
|
+
flags.sort!
|
148
|
+
flags.uniq!
|
149
|
+
flags.map! {|flag| flag.to_sym}
|
150
|
+
rubygems_output_valid = true
|
151
|
+
flags.each do |flag|
|
152
|
+
unless VALID_RUBYGEMS_OUTPUT_FLAGS.include?(flag)
|
153
|
+
@output = "Invalid rubygems-output flag: #{flag}\n"
|
154
|
+
rubygems_output_valid = false
|
155
|
+
end
|
156
|
+
end
|
157
|
+
@options[:rubygems_output] = flags if rubygems_output_valid
|
158
|
+
end
|
159
|
+
|
160
|
+
# nil out @output if there was no output
|
161
|
+
@output = nil if @output == ""
|
162
|
+
return 0
|
163
|
+
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|