libgems 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. data/ChangeLog +5811 -0
  2. data/History.txt +887 -0
  3. data/LICENSE.txt +51 -0
  4. data/README.md +87 -0
  5. data/Rakefile +113 -0
  6. data/lib/gauntlet_libgems.rb +50 -0
  7. data/lib/libgems.rb +1246 -0
  8. data/lib/libgems/builder.rb +102 -0
  9. data/lib/libgems/command.rb +534 -0
  10. data/lib/libgems/command_manager.rb +182 -0
  11. data/lib/libgems/commands/build_command.rb +53 -0
  12. data/lib/libgems/commands/cert_command.rb +86 -0
  13. data/lib/libgems/commands/check_command.rb +80 -0
  14. data/lib/libgems/commands/cleanup_command.rb +106 -0
  15. data/lib/libgems/commands/contents_command.rb +98 -0
  16. data/lib/libgems/commands/dependency_command.rb +195 -0
  17. data/lib/libgems/commands/environment_command.rb +133 -0
  18. data/lib/libgems/commands/fetch_command.rb +67 -0
  19. data/lib/libgems/commands/generate_index_command.rb +133 -0
  20. data/lib/libgems/commands/help_command.rb +172 -0
  21. data/lib/libgems/commands/install_command.rb +178 -0
  22. data/lib/libgems/commands/list_command.rb +35 -0
  23. data/lib/libgems/commands/lock_command.rb +110 -0
  24. data/lib/libgems/commands/mirror_command.rb +111 -0
  25. data/lib/libgems/commands/outdated_command.rb +33 -0
  26. data/lib/libgems/commands/owner_command.rb +75 -0
  27. data/lib/libgems/commands/pristine_command.rb +93 -0
  28. data/lib/libgems/commands/push_command.rb +56 -0
  29. data/lib/libgems/commands/query_command.rb +280 -0
  30. data/lib/libgems/commands/rdoc_command.rb +91 -0
  31. data/lib/libgems/commands/search_command.rb +31 -0
  32. data/lib/libgems/commands/server_command.rb +86 -0
  33. data/lib/libgems/commands/sources_command.rb +157 -0
  34. data/lib/libgems/commands/specification_command.rb +125 -0
  35. data/lib/libgems/commands/stale_command.rb +27 -0
  36. data/lib/libgems/commands/uninstall_command.rb +83 -0
  37. data/lib/libgems/commands/unpack_command.rb +121 -0
  38. data/lib/libgems/commands/update_command.rb +160 -0
  39. data/lib/libgems/commands/which_command.rb +86 -0
  40. data/lib/libgems/config_file.rb +345 -0
  41. data/lib/libgems/custom_require.rb +44 -0
  42. data/lib/libgems/defaults.rb +101 -0
  43. data/lib/libgems/dependency.rb +227 -0
  44. data/lib/libgems/dependency_installer.rb +286 -0
  45. data/lib/libgems/dependency_list.rb +208 -0
  46. data/lib/libgems/doc_manager.rb +242 -0
  47. data/lib/libgems/errors.rb +35 -0
  48. data/lib/libgems/exceptions.rb +91 -0
  49. data/lib/libgems/ext.rb +18 -0
  50. data/lib/libgems/ext/builder.rb +56 -0
  51. data/lib/libgems/ext/configure_builder.rb +25 -0
  52. data/lib/libgems/ext/ext_conf_builder.rb +24 -0
  53. data/lib/libgems/ext/rake_builder.rb +39 -0
  54. data/lib/libgems/format.rb +81 -0
  55. data/lib/libgems/gem_openssl.rb +92 -0
  56. data/lib/libgems/gem_path_searcher.rb +100 -0
  57. data/lib/libgems/gem_runner.rb +79 -0
  58. data/lib/libgems/gemcutter_utilities.rb +49 -0
  59. data/lib/libgems/indexer.rb +720 -0
  60. data/lib/libgems/install_update_options.rb +125 -0
  61. data/lib/libgems/installer.rb +604 -0
  62. data/lib/libgems/local_remote_options.rb +135 -0
  63. data/lib/libgems/old_format.rb +153 -0
  64. data/lib/libgems/package.rb +97 -0
  65. data/lib/libgems/package/f_sync_dir.rb +23 -0
  66. data/lib/libgems/package/tar_header.rb +266 -0
  67. data/lib/libgems/package/tar_input.rb +222 -0
  68. data/lib/libgems/package/tar_output.rb +144 -0
  69. data/lib/libgems/package/tar_reader.rb +106 -0
  70. data/lib/libgems/package/tar_reader/entry.rb +141 -0
  71. data/lib/libgems/package/tar_writer.rb +241 -0
  72. data/lib/libgems/package_task.rb +126 -0
  73. data/lib/libgems/platform.rb +183 -0
  74. data/lib/libgems/remote_fetcher.rb +414 -0
  75. data/lib/libgems/require_paths_builder.rb +18 -0
  76. data/lib/libgems/requirement.rb +153 -0
  77. data/lib/libgems/security.rb +814 -0
  78. data/lib/libgems/server.rb +872 -0
  79. data/lib/libgems/source_index.rb +597 -0
  80. data/lib/libgems/source_info_cache.rb +395 -0
  81. data/lib/libgems/source_info_cache_entry.rb +56 -0
  82. data/lib/libgems/spec_fetcher.rb +337 -0
  83. data/lib/libgems/specification.rb +1487 -0
  84. data/lib/libgems/test_utilities.rb +147 -0
  85. data/lib/libgems/text.rb +65 -0
  86. data/lib/libgems/uninstaller.rb +278 -0
  87. data/lib/libgems/user_interaction.rb +527 -0
  88. data/lib/libgems/validator.rb +240 -0
  89. data/lib/libgems/version.rb +316 -0
  90. data/lib/libgems/version_option.rb +65 -0
  91. data/lib/rbconfig/datadir.rb +20 -0
  92. data/test/bogussources.rb +8 -0
  93. data/test/data/gem-private_key.pem +27 -0
  94. data/test/data/gem-public_cert.pem +20 -0
  95. data/test/fake_certlib/openssl.rb +7 -0
  96. data/test/foo/discover.rb +0 -0
  97. data/test/gem_installer_test_case.rb +97 -0
  98. data/test/gem_package_tar_test_case.rb +132 -0
  99. data/test/gemutilities.rb +605 -0
  100. data/test/insure_session.rb +43 -0
  101. data/test/mockgemui.rb +56 -0
  102. data/test/plugin/exception/libgems_plugin.rb +2 -0
  103. data/test/plugin/load/libgems_plugin.rb +1 -0
  104. data/test/plugin/standarderror/libgems_plugin.rb +2 -0
  105. data/test/private_key.pem +27 -0
  106. data/test/public_cert.pem +20 -0
  107. data/test/rubygems_plugin.rb +21 -0
  108. data/test/simple_gem.rb +66 -0
  109. data/test/test_config.rb +12 -0
  110. data/test/test_gem.rb +780 -0
  111. data/test/test_gem_builder.rb +27 -0
  112. data/test/test_gem_command.rb +178 -0
  113. data/test/test_gem_command_manager.rb +207 -0
  114. data/test/test_gem_commands_build_command.rb +74 -0
  115. data/test/test_gem_commands_cert_command.rb +124 -0
  116. data/test/test_gem_commands_check_command.rb +18 -0
  117. data/test/test_gem_commands_contents_command.rb +156 -0
  118. data/test/test_gem_commands_dependency_command.rb +216 -0
  119. data/test/test_gem_commands_environment_command.rb +144 -0
  120. data/test/test_gem_commands_fetch_command.rb +76 -0
  121. data/test/test_gem_commands_generate_index_command.rb +135 -0
  122. data/test/test_gem_commands_install_command.rb +315 -0
  123. data/test/test_gem_commands_list_command.rb +36 -0
  124. data/test/test_gem_commands_lock_command.rb +68 -0
  125. data/test/test_gem_commands_mirror_command.rb +60 -0
  126. data/test/test_gem_commands_outdated_command.rb +40 -0
  127. data/test/test_gem_commands_owner_command.rb +105 -0
  128. data/test/test_gem_commands_pristine_command.rb +108 -0
  129. data/test/test_gem_commands_push_command.rb +81 -0
  130. data/test/test_gem_commands_query_command.rb +426 -0
  131. data/test/test_gem_commands_server_command.rb +59 -0
  132. data/test/test_gem_commands_sources_command.rb +209 -0
  133. data/test/test_gem_commands_specification_command.rb +139 -0
  134. data/test/test_gem_commands_stale_command.rb +38 -0
  135. data/test/test_gem_commands_uninstall_command.rb +83 -0
  136. data/test/test_gem_commands_unpack_command.rb +199 -0
  137. data/test/test_gem_commands_update_command.rb +207 -0
  138. data/test/test_gem_commands_which_command.rb +66 -0
  139. data/test/test_gem_config_file.rb +287 -0
  140. data/test/test_gem_dependency.rb +149 -0
  141. data/test/test_gem_dependency_installer.rb +661 -0
  142. data/test/test_gem_dependency_list.rb +230 -0
  143. data/test/test_gem_doc_manager.rb +31 -0
  144. data/test/test_gem_ext_configure_builder.rb +84 -0
  145. data/test/test_gem_ext_ext_conf_builder.rb +173 -0
  146. data/test/test_gem_ext_rake_builder.rb +81 -0
  147. data/test/test_gem_format.rb +70 -0
  148. data/test/test_gem_gem_path_searcher.rb +78 -0
  149. data/test/test_gem_gem_runner.rb +45 -0
  150. data/test/test_gem_gemcutter_utilities.rb +103 -0
  151. data/test/test_gem_indexer.rb +673 -0
  152. data/test/test_gem_install_update_options.rb +68 -0
  153. data/test/test_gem_installer.rb +857 -0
  154. data/test/test_gem_local_remote_options.rb +97 -0
  155. data/test/test_gem_package_tar_header.rb +130 -0
  156. data/test/test_gem_package_tar_input.rb +112 -0
  157. data/test/test_gem_package_tar_output.rb +97 -0
  158. data/test/test_gem_package_tar_reader.rb +46 -0
  159. data/test/test_gem_package_tar_reader_entry.rb +109 -0
  160. data/test/test_gem_package_tar_writer.rb +144 -0
  161. data/test/test_gem_package_task.rb +59 -0
  162. data/test/test_gem_platform.rb +264 -0
  163. data/test/test_gem_remote_fetcher.rb +740 -0
  164. data/test/test_gem_requirement.rb +292 -0
  165. data/test/test_gem_server.rb +356 -0
  166. data/test/test_gem_silent_ui.rb +113 -0
  167. data/test/test_gem_source_index.rb +461 -0
  168. data/test/test_gem_spec_fetcher.rb +410 -0
  169. data/test/test_gem_specification.rb +1334 -0
  170. data/test/test_gem_stream_ui.rb +218 -0
  171. data/test/test_gem_text.rb +43 -0
  172. data/test/test_gem_uninstaller.rb +146 -0
  173. data/test/test_gem_validator.rb +63 -0
  174. data/test/test_gem_version.rb +181 -0
  175. data/test/test_gem_version_option.rb +89 -0
  176. data/test/test_kernel.rb +59 -0
  177. metadata +402 -0
@@ -0,0 +1,86 @@
1
+ require 'libgems/command'
2
+ require 'libgems/server'
3
+
4
+ class LibGems::Commands::ServerCommand < LibGems::Command
5
+
6
+ def initialize
7
+ super 'server', 'Documentation and gem repository HTTP server',
8
+ :port => 8808, :gemdir => [], :daemon => false
9
+
10
+ OptionParser.accept :Port do |port|
11
+ if port =~ /\A\d+\z/ then
12
+ port = Integer port
13
+ raise OptionParser::InvalidArgument, "#{port}: not a port number" if
14
+ port > 65535
15
+
16
+ port
17
+ else
18
+ begin
19
+ Socket.getservbyname port
20
+ rescue SocketError
21
+ raise OptionParser::InvalidArgument, "#{port}: no such named service"
22
+ end
23
+ end
24
+ end
25
+
26
+ add_option '-p', '--port=PORT', :Port,
27
+ 'port to listen on' do |port, options|
28
+ options[:port] = port
29
+ end
30
+
31
+ add_option '-d', '--dir=GEMDIR',
32
+ 'directories from which to serve gems',
33
+ 'multiple directories may be provided' do |gemdir, options|
34
+ options[:gemdir] << File.expand_path(gemdir)
35
+ end
36
+
37
+ add_option '--[no-]daemon', 'run as a daemon' do |daemon, options|
38
+ options[:daemon] = daemon
39
+ end
40
+
41
+ add_option '-b', '--bind=HOST,HOST',
42
+ 'addresses to bind', Array do |address, options|
43
+ options[:addresses] ||= []
44
+ options[:addresses].push(*address)
45
+ end
46
+
47
+ add_option '-l', '--launch[=COMMAND]',
48
+ 'launches a browser window',
49
+ "COMMAND defaults to 'start' on Windows",
50
+ "and 'open' on all other platforms" do |launch, options|
51
+ launch ||= LibGems.win_platform? ? 'start' : 'open'
52
+ options[:launch] = launch
53
+ end
54
+ end
55
+
56
+ def defaults_str # :nodoc:
57
+ "--port 8808 --dir #{LibGems.dir} --no-daemon"
58
+ end
59
+
60
+ def description # :nodoc:
61
+ <<-EOF
62
+ The server command starts up a web server that hosts the RDoc for your
63
+ installed gems and can operate as a server for installation of gems on other
64
+ machines.
65
+
66
+ The cache files for installed gems must exist to use the server as a source
67
+ for gem installation.
68
+
69
+ To install gems from a running server, use `gem install GEMNAME --source
70
+ http://gem_server_host:8808`
71
+
72
+ You can set up a shortcut to gem server documentation using the URL:
73
+
74
+ http://localhost:8808/rdoc?q=%s - Firefox
75
+ http://localhost:8808/rdoc?q=* - LaunchBar
76
+
77
+ EOF
78
+ end
79
+
80
+ def execute
81
+ options[:gemdir] << LibGems.dir if options[:gemdir].empty?
82
+ LibGems::Server.run options
83
+ end
84
+
85
+ end
86
+
@@ -0,0 +1,157 @@
1
+ require 'fileutils'
2
+ require 'libgems/command'
3
+ require 'libgems/remote_fetcher'
4
+ require 'libgems/source_info_cache'
5
+ require 'libgems/spec_fetcher'
6
+ require 'libgems/local_remote_options'
7
+
8
+ class LibGems::Commands::SourcesCommand < LibGems::Command
9
+
10
+ include LibGems::LocalRemoteOptions
11
+
12
+ def initialize
13
+ super 'sources',
14
+ "Manage the sources and cache file #{LibGems::NAME} uses to search for gems"
15
+
16
+ add_option '-a', '--add SOURCE_URI', 'Add source' do |value, options|
17
+ options[:add] = value
18
+ end
19
+
20
+ add_option '-l', '--list', 'List sources' do |value, options|
21
+ options[:list] = value
22
+ end
23
+
24
+ add_option '-r', '--remove SOURCE_URI', 'Remove source' do |value, options|
25
+ options[:remove] = value
26
+ end
27
+
28
+ add_option '-c', '--clear-all',
29
+ 'Remove all sources (clear the cache)' do |value, options|
30
+ options[:clear_all] = value
31
+ end
32
+
33
+ add_option '-u', '--update', 'Update source cache' do |value, options|
34
+ options[:update] = value
35
+ end
36
+
37
+ add_proxy_option
38
+ end
39
+
40
+ def defaults_str
41
+ '--list'
42
+ end
43
+
44
+ def execute
45
+ options[:list] = !(options[:add] ||
46
+ options[:clear_all] ||
47
+ options[:remove] ||
48
+ options[:update])
49
+
50
+ if options[:clear_all] then
51
+ path = LibGems::SpecFetcher.fetcher.dir
52
+ FileUtils.rm_rf path
53
+
54
+ if not File.exist?(path) then
55
+ say "*** Removed specs cache ***"
56
+ elsif not File.writable?(path) then
57
+ say "*** Unable to remove source cache (write protected) ***"
58
+ else
59
+ say "*** Unable to remove source cache ***"
60
+ end
61
+
62
+ sic = LibGems::SourceInfoCache
63
+ remove_cache_file 'user', sic.user_cache_file
64
+ remove_cache_file 'latest user', sic.latest_user_cache_file
65
+ remove_cache_file 'system', sic.system_cache_file
66
+ remove_cache_file 'latest system', sic.latest_system_cache_file
67
+ end
68
+
69
+ if options[:add] then
70
+ source_uri = options[:add]
71
+ uri = URI.parse source_uri
72
+
73
+ begin
74
+ LibGems::SpecFetcher.fetcher.load_specs uri, 'specs'
75
+ LibGems.sources << source_uri
76
+ LibGems.configuration.write
77
+
78
+ say "#{source_uri} added to sources"
79
+ rescue URI::Error, ArgumentError
80
+ say "#{source_uri} is not a URI"
81
+ rescue LibGems::RemoteFetcher::FetchError => e
82
+ yaml_uri = uri + 'yaml'
83
+ gem_repo = LibGems::RemoteFetcher.fetcher.fetch_size yaml_uri rescue false
84
+
85
+ if e.uri =~ /specs\.#{Regexp.escape LibGems.marshal_version}\.gz$/ and
86
+ gem_repo then
87
+
88
+ alert_warning <<-EOF
89
+ #{LibGems::NAME} 1.2+ index not found for:
90
+ \t#{source_uri}
91
+
92
+ Will cause #{LibGems::NAME} to revert to legacy indexes, degrading performance.
93
+ EOF
94
+
95
+ say "#{source_uri} added to sources"
96
+ else
97
+ say "Error fetching #{source_uri}:\n\t#{e.message}"
98
+ end
99
+ end
100
+ end
101
+
102
+ if options[:remove] then
103
+ source_uri = options[:remove]
104
+
105
+ unless LibGems.sources.include? source_uri then
106
+ say "source #{source_uri} not present in cache"
107
+ else
108
+ LibGems.sources.delete source_uri
109
+ LibGems.configuration.write
110
+
111
+ say "#{source_uri} removed from sources"
112
+ end
113
+ end
114
+
115
+ if options[:update] then
116
+ fetcher = LibGems::SpecFetcher.fetcher
117
+
118
+ if fetcher.legacy_repos.empty? then
119
+ LibGems.sources.each do |update_uri|
120
+ update_uri = URI.parse update_uri
121
+ fetcher.load_specs update_uri, 'specs'
122
+ fetcher.load_specs update_uri, 'latest_specs'
123
+ end
124
+ else
125
+ LibGems::SourceInfoCache.cache true
126
+ LibGems::SourceInfoCache.cache.flush
127
+ end
128
+
129
+ say "source cache successfully updated"
130
+ end
131
+
132
+ if options[:list] then
133
+ say "*** CURRENT SOURCES ***"
134
+ say
135
+
136
+ LibGems.sources.each do |source|
137
+ say source
138
+ end
139
+ end
140
+ end
141
+
142
+ private
143
+
144
+ def remove_cache_file(desc, path)
145
+ FileUtils.rm_rf path
146
+
147
+ if not File.exist?(path) then
148
+ say "*** Removed #{desc} source cache ***"
149
+ elsif not File.writable?(path) then
150
+ say "*** Unable to remove #{desc} source cache (write protected) ***"
151
+ else
152
+ say "*** Unable to remove #{desc} source cache ***"
153
+ end
154
+ end
155
+
156
+ end
157
+
@@ -0,0 +1,125 @@
1
+ require 'libgems/command'
2
+ require 'libgems/local_remote_options'
3
+ require 'libgems/version_option'
4
+ require 'libgems/source_info_cache'
5
+ require 'libgems/format'
6
+
7
+ class LibGems::Commands::SpecificationCommand < LibGems::Command
8
+
9
+ include LibGems::LocalRemoteOptions
10
+ include LibGems::VersionOption
11
+
12
+ def initialize
13
+ LibGems.load_yaml
14
+
15
+ super 'specification', 'Display gem specification (in yaml)',
16
+ :domain => :local, :version => LibGems::Requirement.default,
17
+ :format => :yaml
18
+
19
+ add_version_option('examine')
20
+ add_platform_option
21
+
22
+ add_option('--all', 'Output specifications for all versions of',
23
+ 'the gem') do |value, options|
24
+ options[:all] = true
25
+ end
26
+
27
+ add_option('--ruby', 'Output ruby format') do |value, options|
28
+ options[:format] = :ruby
29
+ end
30
+
31
+ add_option('--yaml', 'Output RUBY format') do |value, options|
32
+ options[:format] = :yaml
33
+ end
34
+
35
+ add_option('--marshal', 'Output Marshal format') do |value, options|
36
+ options[:format] = :marshal
37
+ end
38
+
39
+ add_local_remote_options
40
+ end
41
+
42
+ def arguments # :nodoc:
43
+ <<-ARGS
44
+ GEMFILE name of gem to show the gemspec for
45
+ FIELD name of gemspec field to show
46
+ ARGS
47
+ end
48
+
49
+ def defaults_str # :nodoc:
50
+ "--local --version '#{LibGems::Requirement.default}' --yaml"
51
+ end
52
+
53
+ def usage # :nodoc:
54
+ "#{program_name} [GEMFILE] [FIELD]"
55
+ end
56
+
57
+ def execute
58
+ specs = []
59
+ gem = options[:args].shift
60
+
61
+ unless gem then
62
+ raise LibGems::CommandLineError,
63
+ "Please specify a gem name or file on the command line"
64
+ end
65
+
66
+ dep = LibGems::Dependency.new gem, options[:version]
67
+
68
+ field = get_one_optional_argument
69
+
70
+ if field then
71
+ field = field.intern
72
+
73
+ if options[:format] == :ruby then
74
+ raise LibGems::CommandLineError, "--ruby and FIELD are mutually exclusive"
75
+ end
76
+
77
+ unless LibGems::Specification.attribute_names.include? field then
78
+ raise LibGems::CommandLineError,
79
+ "no field %p on LibGems::Specification" % field.to_s
80
+ end
81
+ end
82
+
83
+ if local? then
84
+ if File.exist? gem then
85
+ specs << LibGems::Format.from_file_by_path(gem).spec rescue nil
86
+ end
87
+
88
+ if specs.empty? then
89
+ specs.push(*LibGems.source_index.search(dep))
90
+ end
91
+ end
92
+
93
+ if remote? then
94
+ found = LibGems::SpecFetcher.fetcher.fetch dep
95
+
96
+ specs.push(*found.map { |spec,| spec })
97
+ end
98
+
99
+ if specs.empty? then
100
+ alert_error "Unknown gem '#{gem}'"
101
+ terminate_interaction 1
102
+ end
103
+
104
+ output = lambda do |s|
105
+ s = s.send field if field
106
+
107
+ say case options[:format]
108
+ when :ruby then s.to_ruby
109
+ when :marshal then Marshal.dump s
110
+ else s.to_yaml
111
+ end
112
+
113
+ say "\n"
114
+ end
115
+
116
+ if options[:all] then
117
+ specs.each(&output)
118
+ else
119
+ spec = specs.sort_by { |s| s.version }.last
120
+ output[spec]
121
+ end
122
+ end
123
+
124
+ end
125
+
@@ -0,0 +1,27 @@
1
+ require 'libgems/command'
2
+
3
+ class LibGems::Commands::StaleCommand < LibGems::Command
4
+ def initialize
5
+ super('stale', 'List gems along with access times')
6
+ end
7
+
8
+ def usage # :nodoc:
9
+ "#{program_name}"
10
+ end
11
+
12
+ def execute
13
+ gem_to_atime = {}
14
+ LibGems.source_index.each do |name, spec|
15
+ Dir["#{spec.full_gem_path}/**/*.*"].each do |file|
16
+ next if File.directory?(file)
17
+ stat = File.stat(file)
18
+ gem_to_atime[name] ||= stat.atime
19
+ gem_to_atime[name] = stat.atime if gem_to_atime[name] < stat.atime
20
+ end
21
+ end
22
+
23
+ gem_to_atime.sort_by { |_, atime| atime }.each do |name, atime|
24
+ say "#{name} at #{atime.strftime '%c'}"
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,83 @@
1
+ require 'libgems/command'
2
+ require 'libgems/version_option'
3
+ require 'libgems/uninstaller'
4
+
5
+ ##
6
+ # LibGems uninstaller command line tool
7
+ #
8
+ # See `gem help uninstall`
9
+
10
+ class LibGems::Commands::UninstallCommand < LibGems::Command
11
+
12
+ include LibGems::VersionOption
13
+
14
+ def initialize
15
+ super 'uninstall', 'Uninstall gems from the local repository',
16
+ :version => LibGems::Requirement.default, :user_install => true
17
+
18
+ add_option('-a', '--[no-]all',
19
+ 'Uninstall all matching versions'
20
+ ) do |value, options|
21
+ options[:all] = value
22
+ end
23
+
24
+ add_option('-I', '--[no-]ignore-dependencies',
25
+ 'Ignore dependency requirements while',
26
+ 'uninstalling') do |value, options|
27
+ options[:ignore] = value
28
+ end
29
+
30
+ add_option('-x', '--[no-]executables',
31
+ 'Uninstall applicable executables without',
32
+ 'confirmation') do |value, options|
33
+ options[:executables] = value
34
+ end
35
+
36
+ add_option('-i', '--install-dir DIR',
37
+ 'Directory to uninstall gem from') do |value, options|
38
+ options[:install_dir] = File.expand_path(value)
39
+ end
40
+
41
+ add_option('-n', '--bindir DIR',
42
+ 'Directory to remove binaries from') do |value, options|
43
+ options[:bin_dir] = File.expand_path(value)
44
+ end
45
+
46
+ add_option('--[no-]user-install',
47
+ 'Uninstall from user\'s home directory',
48
+ 'in addition to GEM_HOME.') do |value, options|
49
+ options[:user_install] = value
50
+ end
51
+
52
+ add_version_option
53
+ add_platform_option
54
+ end
55
+
56
+ def arguments # :nodoc:
57
+ "GEMNAME name of gem to uninstall"
58
+ end
59
+
60
+ def defaults_str # :nodoc:
61
+ "--version '#{LibGems::Requirement.default}' --no-force " \
62
+ "--install-dir #{LibGems.dir}\n" \
63
+ "--user-install"
64
+ end
65
+
66
+ def usage # :nodoc:
67
+ "#{program_name} GEMNAME [GEMNAME ...]"
68
+ end
69
+
70
+ def execute
71
+ get_all_gem_names.each do |gem_name|
72
+ begin
73
+ LibGems::Uninstaller.new(gem_name, options).uninstall
74
+ rescue LibGems::GemNotInHomeException => e
75
+ spec = e.spec
76
+ alert("In order to remove #{spec.name}, please execute:\n" \
77
+ "\tgem uninstall #{spec.name} --install-dir=#{spec.installation_path}")
78
+ end
79
+ end
80
+ end
81
+
82
+ end
83
+