rubygems-update 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rubygems-update might be problematic. Click here for more details.
- data/ChangeLog +587 -0
- data/README +0 -1
- data/Rakefile +39 -12
- data/TODO +0 -5
- data/bin/gem +7 -7
- data/bin/update_rubygems +1 -1
- data/examples/application/an-app.gemspec +1 -1
- data/gemspecs/cgikit-1.1.0.gemspec +1 -2
- data/gemspecs/jabber4r.gemspec +1 -1
- data/gemspecs/linguistics.gemspec +1 -1
- data/gemspecs/ook.gemspec +1 -1
- data/gemspecs/progressbar.gemspec +1 -1
- data/gemspecs/redcloth.gemspec +1 -1
- data/gemspecs/rublog.gemspec +1 -1
- data/gemspecs/ruby-doom.gemspec +1 -1
- data/gemspecs/rubyjdwp.gemspec +1 -1
- data/gemspecs/statistics.gemspec +1 -1
- data/lib/rubygems.rb +167 -105
- data/lib/rubygems/builder.rb +12 -10
- data/lib/rubygems/command.rb +177 -60
- data/lib/rubygems/command_manager.rb +30 -38
- data/lib/rubygems/commands/build_command.rb +42 -46
- data/lib/rubygems/commands/cert_command.rb +72 -69
- data/lib/rubygems/commands/check_command.rb +63 -63
- data/lib/rubygems/commands/cleanup_command.rb +25 -7
- data/lib/rubygems/commands/contents_command.rb +70 -62
- data/lib/rubygems/commands/dependency_command.rb +131 -86
- data/lib/rubygems/commands/environment_command.rb +67 -46
- data/lib/rubygems/commands/fetch_command.rb +62 -0
- data/lib/rubygems/commands/generate_index_command.rb +57 -0
- data/lib/rubygems/commands/help_command.rb +163 -73
- data/lib/rubygems/commands/install_command.rb +114 -128
- data/lib/rubygems/commands/list_command.rb +10 -8
- data/lib/rubygems/commands/lock_command.rb +101 -0
- data/lib/rubygems/commands/mirror_command.rb +105 -0
- data/lib/rubygems/commands/outdated_command.rb +24 -15
- data/lib/rubygems/commands/pristine_command.rb +118 -88
- data/lib/rubygems/commands/query_command.rb +109 -77
- data/lib/rubygems/commands/rdoc_command.rb +13 -10
- data/lib/rubygems/commands/search_command.rb +10 -8
- data/lib/rubygems/commands/server_command.rb +48 -0
- data/lib/rubygems/commands/sources_command.rb +104 -83
- data/lib/rubygems/commands/specification_command.rb +65 -51
- data/lib/rubygems/commands/uninstall_command.rb +17 -12
- data/lib/rubygems/commands/unpack_command.rb +68 -68
- data/lib/rubygems/commands/update_command.rb +72 -25
- data/lib/rubygems/commands/which_command.rb +86 -0
- data/lib/rubygems/config_file.rb +202 -78
- data/lib/rubygems/custom_require.rb +7 -88
- data/lib/rubygems/dependency.rb +65 -0
- data/lib/rubygems/dependency_installer.rb +232 -0
- data/lib/rubygems/dependency_list.rb +133 -105
- data/lib/rubygems/digest/md5.rb +4 -1
- data/lib/rubygems/digest/sha2.rb +1 -1
- data/lib/rubygems/doc_manager.rb +41 -19
- data/lib/rubygems/exceptions.rb +63 -0
- data/lib/rubygems/ext.rb +18 -0
- data/lib/rubygems/ext/builder.rb +56 -0
- data/lib/rubygems/ext/configure_builder.rb +24 -0
- data/lib/rubygems/ext/ext_conf_builder.rb +23 -0
- data/lib/rubygems/ext/rake_builder.rb +27 -0
- data/lib/rubygems/format.rb +16 -6
- data/lib/rubygems/gem_openssl.rb +43 -6
- data/lib/rubygems/gem_path_searcher.rb +84 -0
- data/lib/rubygems/gem_runner.rb +20 -5
- data/lib/rubygems/indexer.rb +163 -0
- data/lib/rubygems/indexer/abstract_index_builder.rb +80 -0
- data/lib/rubygems/indexer/marshal_index_builder.rb +17 -0
- data/lib/rubygems/indexer/master_index_builder.rb +53 -0
- data/lib/rubygems/indexer/quick_index_builder.rb +48 -0
- data/lib/rubygems/install_update_options.rb +87 -0
- data/lib/rubygems/installer.rb +316 -562
- data/lib/rubygems/local_remote_options.rb +106 -0
- data/lib/rubygems/old_format.rb +5 -13
- data/lib/rubygems/open-uri.rb +2 -0
- data/lib/rubygems/package.rb +28 -32
- data/lib/rubygems/platform.rb +187 -0
- data/lib/rubygems/remote_fetcher.rb +46 -29
- data/lib/rubygems/remote_installer.rb +11 -18
- data/lib/rubygems/requirement.rb +157 -0
- data/lib/rubygems/rubygems_version.rb +1 -1
- data/lib/rubygems/security.rb +715 -457
- data/lib/rubygems/server.rb +77 -59
- data/lib/rubygems/source_index.rb +154 -83
- data/lib/rubygems/source_info_cache.rb +73 -30
- data/lib/rubygems/source_info_cache_entry.rb +12 -3
- data/lib/rubygems/specification.rb +378 -145
- data/lib/rubygems/uninstaller.rb +183 -0
- data/lib/rubygems/user_interaction.rb +38 -9
- data/lib/rubygems/validator.rb +53 -24
- data/lib/rubygems/version.rb +126 -289
- data/lib/rubygems/version_option.rb +49 -0
- data/pkgs/sources/lib/sources.rb +1 -4
- data/pkgs/sources/sources.gemspec +3 -3
- data/scripts/gemdoc.rb +0 -1
- data/setup.rb +166 -1505
- data/test/bogussources.rb +0 -1
- data/test/data/gem-private_key.pem +27 -0
- data/test/data/gem-public_cert.pem +20 -0
- data/test/functional.rb +3 -105
- data/test/gemutilities.rb +145 -24
- data/test/insure_session.rb +0 -1
- data/test/{test_datadir.rb → test_config.rb} +7 -13
- data/test/test_gem.rb +360 -9
- data/test/test_gem_builder.rb +34 -0
- data/test/{test_command.rb → test_gem_command.rb} +119 -62
- data/test/{test_parse_commands.rb → test_gem_command_manager.rb} +64 -40
- data/test/test_gem_commands_build_command.rb +75 -0
- data/test/test_gem_commands_cert_command.rb +122 -0
- data/test/test_gem_commands_check_command.rb +25 -0
- data/test/test_gem_commands_contents_command.rb +92 -0
- data/test/test_gem_commands_dependency_command.rb +108 -0
- data/test/test_gem_commands_environment_command.rb +117 -0
- data/test/test_gem_commands_fetch_command.rb +34 -0
- data/test/test_gem_commands_generate_index_command.rb +32 -0
- data/test/test_gem_commands_install_command.rb +160 -0
- data/test/test_gem_commands_mirror_command.rb +56 -0
- data/test/test_gem_commands_pristine_command.rb +100 -0
- data/test/test_gem_commands_query_command.rb +82 -0
- data/test/test_gem_commands_sources_command.rb +147 -0
- data/test/test_gem_commands_specification_command.rb +93 -0
- data/test/test_gem_commands_unpack_command.rb +55 -0
- data/test/test_gem_config_file.rb +210 -0
- data/test/test_gem_dependency.rb +89 -0
- data/test/test_gem_dependency_installer.rb +542 -0
- data/test/test_gem_dependency_list.rb +212 -0
- data/test/test_gem_doc_manager.rb +32 -0
- data/test/test_gem_ext_configure_builder.rb +13 -17
- data/test/test_gem_ext_ext_conf_builder.rb +9 -9
- data/test/test_gem_ext_rake_builder.rb +23 -11
- data/test/test_gem_format.rb +69 -0
- data/test/test_gem_gem_path_searcher.rb +57 -0
- data/test/test_gem_gem_runner.rb +35 -0
- data/test/test_gem_indexer.rb +119 -0
- data/test/test_gem_install_update_options.rb +40 -0
- data/test/test_gem_installer.rb +796 -0
- data/test/test_gem_local_remote_options.rb +84 -0
- data/test/test_gem_outdated_command.rb +11 -9
- data/test/test_gem_platform.rb +240 -0
- data/test/{test_remote_fetcher.rb → test_gem_remote_fetcher.rb} +124 -55
- data/test/{test_remote_installer.rb → test_gem_remote_installer.rb} +3 -4
- data/test/test_gem_requirement.rb +223 -0
- data/test/test_gem_server.rb +71 -0
- data/test/test_gem_source_index.rb +429 -0
- data/test/test_gem_source_info_cache.rb +79 -17
- data/test/test_gem_source_info_cache_entry.rb +11 -9
- data/test/test_gem_specification.rb +738 -0
- data/test/test_gem_stream_ui.rb +117 -0
- data/test/test_gem_validator.rb +70 -0
- data/test/test_gem_version.rb +191 -0
- data/test/test_gem_version_option.rb +77 -0
- data/test/{test_require_gem.rb → test_kernel.rb} +19 -12
- data/test/test_open_uri.rb +1 -2
- data/test/test_package.rb +45 -34
- metadata +116 -141
- data/Releases +0 -127
- data/bin/gem_mirror +0 -73
- data/bin/gem_server +0 -6
- data/bin/gemlock +0 -127
- data/bin/gemri +0 -24
- data/bin/gemwhich +0 -89
- data/bin/index_gem_repository.rb +0 -302
- data/lib/gemconfigure.rb +0 -24
- data/lib/rubygems/gem_commands.rb +0 -273
- data/pkgs/sources/sources-0.0.1.gem +0 -0
- data/post-install.rb +0 -121
- data/test/brokenbuildgem.rb +0 -35
- data/test/data/PostMessage-0.0.1.gem +0 -0
- data/test/data/a-0.0.1.gem +0 -0
- data/test/data/a-0.0.2.gem +0 -0
- data/test/data/b-0.0.2.gem +0 -0
- data/test/data/broken-1.0.0.gem +0 -0
- data/test/data/broken_build/broken-build.gemspec +0 -20
- data/test/data/broken_build/ext/extconf.rb +0 -3
- data/test/data/broken_build/ext/foo.c +0 -1
- data/test/data/c-1.2.gem +0 -0
- data/test/data/gemhome/cache/a-0.0.1.gem +0 -0
- data/test/data/gemhome/cache/a-0.0.2.gem +0 -0
- data/test/data/gemhome/cache/b-0.0.2.gem +0 -0
- data/test/data/gemhome/cache/c-1.2.gem +0 -0
- data/test/data/gemhome/gems/a-0.0.1/lib/code.rb +0 -1
- data/test/data/gemhome/gems/a-0.0.2/lib/code.rb +0 -1
- data/test/data/gemhome/gems/b-0.0.2/lib/code.rb +0 -1
- data/test/data/gemhome/gems/c-1.2/lib/code.rb +0 -1
- data/test/data/gemhome/specifications/a-0.0.1.gemspec +0 -8
- data/test/data/gemhome/specifications/a-0.0.2.gemspec +0 -8
- data/test/data/gemhome/specifications/b-0.0.2.gemspec +0 -8
- data/test/data/gemhome/specifications/c-1.2.gemspec +0 -8
- data/test/data/legacy/keyedlist-0.4.0.ruby +0 -11
- data/test/data/legacy/keyedlist-0.4.0.yaml +0 -16
- data/test/data/lib/code.rb +0 -1
- data/test/data/one/README.one +0 -1
- data/test/data/one/lib/one.rb +0 -9
- data/test/data/one/one-0.0.1.gem +0 -0
- data/test/data/one/one.gemspec +0 -17
- data/test/data/one/one.yaml +0 -40
- data/test/data/post_install.gemspec +0 -19
- data/test/functional_extension_gems.rb +0 -48
- data/test/functional_generate_yaml_index.rb +0 -104
- data/test/gemenvironment.rb +0 -59
- data/test/io_capture.rb +0 -33
- data/test/mock/gems/gems/sources-0.0.1/lib/sources.rb +0 -11
- data/test/mock/gems/specifications/sources-0.0.1.gemspec +0 -8
- data/test/onegem.rb +0 -35
- data/test/test_builder.rb +0 -34
- data/test/test_check_command.rb +0 -34
- data/test/test_configfile.rb +0 -42
- data/test/test_dependency_list.rb +0 -169
- data/test/test_file_list.rb +0 -101
- data/test/test_format.rb +0 -49
- data/test/test_gem_sources_command.rb +0 -135
- data/test/test_gemloadpaths.rb +0 -51
- data/test/test_gempaths.rb +0 -170
- data/test/test_installer.rb +0 -369
- data/test/test_loadmanager.rb +0 -48
- data/test/test_process_commands.rb +0 -52
- data/test/test_source_index.rb +0 -231
- data/test/test_specific_extras.rb +0 -46
- data/test/test_specification.rb +0 -565
- data/test/test_user_interaction.rb +0 -48
- data/test/test_validator.rb +0 -59
- data/test/test_version_comparison.rb +0 -321
- data/test/testgem.rc +0 -7
- data/test/user_capture.rb +0 -7
- data/test/yaml_data.rb +0 -63
@@ -1,86 +1,118 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
1
|
+
require 'rubygems/command'
|
2
|
+
require 'rubygems/local_remote_options'
|
3
|
+
require 'rubygems/source_info_cache'
|
4
|
+
|
5
|
+
class Gem::Commands::QueryCommand < Gem::Command
|
6
|
+
|
7
|
+
include Gem::LocalRemoteOptions
|
8
|
+
|
9
|
+
def initialize(name = 'query',
|
10
|
+
summary = 'Query gem information in local or remote repositories')
|
11
|
+
super name, summary,
|
12
|
+
:name => /.*/, :domain => :local, :details => false, :versions => true
|
13
|
+
|
14
|
+
add_option('-n', '--name-matches REGEXP',
|
15
|
+
'Name of gem(s) to query on matches the',
|
16
|
+
'provided REGEXP') do |value, options|
|
17
|
+
options[:name] = /#{value}/i
|
18
|
+
end
|
19
|
+
|
20
|
+
add_option('-d', '--[no-]details',
|
21
|
+
'Display detailed information of gem(s)') do |value, options|
|
22
|
+
options[:details] = value
|
23
|
+
end
|
24
|
+
|
25
|
+
add_option( '--[no-]versions',
|
26
|
+
'Display only gem names') do |value, options|
|
27
|
+
options[:versions] = value
|
28
|
+
options[:details] = false unless value
|
29
|
+
end
|
30
|
+
|
31
|
+
add_local_remote_options
|
32
|
+
end
|
33
|
+
|
34
|
+
def defaults_str # :nodoc:
|
35
|
+
"--local --name-matches '.*' --no-details --versions"
|
36
|
+
end
|
37
|
+
|
38
|
+
def execute
|
39
|
+
name = options[:name]
|
40
|
+
|
41
|
+
if local? then
|
42
|
+
say
|
43
|
+
say "*** LOCAL GEMS ***"
|
44
|
+
say
|
45
|
+
output_query_results Gem.cache.search(name)
|
46
|
+
end
|
47
|
+
|
48
|
+
if remote? then
|
49
|
+
say
|
50
|
+
say "*** REMOTE GEMS ***"
|
51
|
+
say
|
52
|
+
output_query_results Gem::SourceInfoCache.search(name)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def output_query_results(gemspecs)
|
59
|
+
output = []
|
60
|
+
gem_list_with_version = {}
|
61
|
+
|
62
|
+
gemspecs.flatten.each do |gemspec|
|
63
|
+
gem_list_with_version[gemspec.name] ||= []
|
64
|
+
gem_list_with_version[gemspec.name] << gemspec
|
65
|
+
end
|
66
|
+
|
67
|
+
gem_list_with_version = gem_list_with_version.sort_by do |name, spec|
|
68
|
+
name.downcase
|
69
|
+
end
|
70
|
+
|
71
|
+
gem_list_with_version.each do |gem_name, list_of_matching|
|
72
|
+
list_of_matching = list_of_matching.sort_by { |x| x.version.to_ints }.reverse
|
73
|
+
seen_versions = {}
|
74
|
+
|
75
|
+
list_of_matching.delete_if do |item|
|
76
|
+
if seen_versions[item.version] then
|
77
|
+
true
|
78
|
+
else
|
79
|
+
seen_versions[item.version] = true
|
80
|
+
false
|
16
81
|
end
|
17
|
-
add_local_remote_options
|
18
82
|
end
|
19
83
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
def execute
|
25
|
-
if local?
|
26
|
-
say
|
27
|
-
say "*** LOCAL GEMS ***"
|
28
|
-
output_query_results(Gem::cache.search(options[:name]))
|
29
|
-
end
|
30
|
-
if remote?
|
31
|
-
say
|
32
|
-
say "*** REMOTE GEMS ***"
|
33
|
-
output_query_results(Gem::SourceInfoCache.search(options[:name]))
|
34
|
-
end
|
84
|
+
entry = gem_name.dup
|
85
|
+
if options[:versions] then
|
86
|
+
entry << " (#{list_of_matching.map{|gem| gem.version.to_s}.join(", ")})"
|
35
87
|
end
|
36
88
|
|
37
|
-
|
89
|
+
entry << "\n" << format_text(list_of_matching[0].summary, 68, 4) if
|
90
|
+
options[:details]
|
91
|
+
output << entry
|
92
|
+
end
|
38
93
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
true
|
56
|
-
else
|
57
|
-
seen_versions << item.version
|
58
|
-
false
|
59
|
-
end
|
60
|
-
end
|
61
|
-
say "#{gem_name} (#{list_of_matching.map{|gem| gem.version.to_s}.join(", ")})"
|
62
|
-
say format_text(list_of_matching[0].summary, 68, 4)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
##
|
67
|
-
# Used for wrapping and indenting text
|
68
|
-
#
|
69
|
-
def format_text(text, wrap, indent=0)
|
70
|
-
result = []
|
71
|
-
pattern = Regexp.new("^(.{0,#{wrap}})[ \n]")
|
72
|
-
work = text.dup
|
73
|
-
while work.length > wrap
|
74
|
-
if work =~ pattern
|
75
|
-
result << $1
|
76
|
-
work.slice!(0, $&.length)
|
77
|
-
else
|
78
|
-
result << work.slice!(0, wrap)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
result << work if work.length.nonzero?
|
82
|
-
result.join("\n").gsub(/^/, " " * indent)
|
94
|
+
say output.join(options[:details] ? "\n\n" : "\n")
|
95
|
+
end
|
96
|
+
|
97
|
+
##
|
98
|
+
# Used for wrapping and indenting text
|
99
|
+
#
|
100
|
+
def format_text(text, wrap, indent=0)
|
101
|
+
result = []
|
102
|
+
work = text.dup
|
103
|
+
|
104
|
+
while work.length > wrap
|
105
|
+
if work =~ /^(.{0,#{wrap}})[ \n]/o then
|
106
|
+
result << $1
|
107
|
+
work.slice!(0, $&.length)
|
108
|
+
else
|
109
|
+
result << work.slice!(0, wrap)
|
83
110
|
end
|
84
111
|
end
|
112
|
+
|
113
|
+
result << work if work.length.nonzero?
|
114
|
+
result.join("\n").gsub(/^/, " " * indent)
|
85
115
|
end
|
86
|
-
|
116
|
+
|
117
|
+
end
|
118
|
+
|
@@ -1,14 +1,17 @@
|
|
1
|
+
require 'rubygems/command'
|
2
|
+
require 'rubygems/version_option'
|
3
|
+
require 'rubygems/doc_manager'
|
4
|
+
|
1
5
|
module Gem
|
2
6
|
module Commands
|
3
7
|
class RdocCommand < Command
|
4
8
|
include VersionOption
|
5
|
-
include CommandAids
|
6
9
|
|
7
10
|
def initialize
|
8
11
|
super('rdoc',
|
9
12
|
'Generates RDoc for pre-installed gems',
|
10
13
|
{
|
11
|
-
:version =>
|
14
|
+
:version => Gem::Requirement.default,
|
12
15
|
:include_rdoc => true,
|
13
16
|
:include_ri => true,
|
14
17
|
})
|
@@ -27,19 +30,19 @@ module Gem
|
|
27
30
|
) do |value, options|
|
28
31
|
options[:include_ri] = value
|
29
32
|
end
|
30
|
-
add_version_option
|
33
|
+
add_version_option
|
31
34
|
end
|
32
35
|
|
33
|
-
def
|
34
|
-
"
|
36
|
+
def arguments # :nodoc:
|
37
|
+
"GEMNAME gem to generate documentation for (unless --all)"
|
35
38
|
end
|
36
39
|
|
37
|
-
def
|
38
|
-
"#{
|
40
|
+
def defaults_str # :nodoc:
|
41
|
+
"--version '#{Gem::Requirement.default}' --rdoc --ri"
|
39
42
|
end
|
40
43
|
|
41
|
-
def
|
42
|
-
"
|
44
|
+
def usage # :nodoc:
|
45
|
+
"#{program_name} [args]"
|
43
46
|
end
|
44
47
|
|
45
48
|
def execute
|
@@ -72,4 +75,4 @@ module Gem
|
|
72
75
|
end
|
73
76
|
|
74
77
|
end
|
75
|
-
end
|
78
|
+
end
|
@@ -1,8 +1,10 @@
|
|
1
|
+
require 'rubygems/command'
|
2
|
+
require 'rubygems/commands/query_command'
|
3
|
+
|
1
4
|
module Gem
|
2
5
|
module Commands
|
3
6
|
|
4
7
|
class SearchCommand < QueryCommand
|
5
|
-
include CommandAids
|
6
8
|
|
7
9
|
def initialize
|
8
10
|
super(
|
@@ -12,16 +14,16 @@ module Gem
|
|
12
14
|
remove_option('--name-matches')
|
13
15
|
end
|
14
16
|
|
15
|
-
def
|
16
|
-
"
|
17
|
+
def arguments # :nodoc:
|
18
|
+
"STRING fragment of gem name to search for"
|
17
19
|
end
|
18
20
|
|
19
|
-
def
|
20
|
-
"
|
21
|
+
def defaults_str # :nodoc:
|
22
|
+
"--local --no-details"
|
21
23
|
end
|
22
24
|
|
23
|
-
def
|
24
|
-
"STRING
|
25
|
+
def usage # :nodoc:
|
26
|
+
"#{program_name} [STRING]"
|
25
27
|
end
|
26
28
|
|
27
29
|
def execute
|
@@ -32,4 +34,4 @@ module Gem
|
|
32
34
|
end
|
33
35
|
|
34
36
|
end
|
35
|
-
end
|
37
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rubygems/command'
|
2
|
+
require 'rubygems/server'
|
3
|
+
|
4
|
+
class Gem::Commands::ServerCommand < Gem::Command
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
super 'server', 'Documentation and gem repository HTTP server',
|
8
|
+
:port => 8808, :gemdir => Gem.dir, :daemon => false
|
9
|
+
|
10
|
+
add_option '-p', '--port=PORT',
|
11
|
+
'port to listen on' do |port, options|
|
12
|
+
options[:port] = port
|
13
|
+
end
|
14
|
+
|
15
|
+
add_option '-d', '--dir=GEMDIR',
|
16
|
+
'directory from which to serve gems' do |gemdir, options|
|
17
|
+
options[:gemdir] = gemdir
|
18
|
+
end
|
19
|
+
|
20
|
+
add_option '--[no]-daemon', 'run as a daemon' do |daemon, options|
|
21
|
+
options[:daemon] = daemon
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def defaults_str # :nodoc:
|
26
|
+
"--port 8808 --dir #{Gem.dir} --no-daemon"
|
27
|
+
end
|
28
|
+
|
29
|
+
def description # :nodoc:
|
30
|
+
<<-EOF
|
31
|
+
The server command starts up a web server that hosts the RDoc for your
|
32
|
+
installed gems and can operate as a server for installation of gems on other
|
33
|
+
machines.
|
34
|
+
|
35
|
+
The cache files for installed gems must exist to use the server as a source
|
36
|
+
for gem installation.
|
37
|
+
|
38
|
+
To install gems from a running server, use `gem install GEMNAME --source
|
39
|
+
http://gem_server_host:8808`
|
40
|
+
EOF
|
41
|
+
end
|
42
|
+
|
43
|
+
def execute
|
44
|
+
Gem::Server.run options
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
@@ -1,94 +1,115 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
require 'rubygems/command'
|
2
|
+
require 'rubygems/remote_fetcher'
|
3
|
+
require 'rubygems/source_info_cache'
|
4
|
+
require 'rubygems/source_info_cache_entry'
|
5
|
+
|
6
|
+
class Gem::Commands::SourcesCommand < Gem::Command
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
super 'sources',
|
10
|
+
'Manage the sources and cache file RubyGems uses to search for gems'
|
11
|
+
|
12
|
+
add_option '-a', '--add SOURCE_URI', 'Add source' do |value, options|
|
13
|
+
options[:add] = value
|
14
|
+
end
|
15
|
+
|
16
|
+
add_option '-l', '--list', 'List sources' do |value, options|
|
17
|
+
options[:list] = value
|
18
|
+
end
|
19
|
+
|
20
|
+
add_option '-r', '--remove SOURCE_URI', 'Remove source' do |value, options|
|
21
|
+
options[:remove] = value
|
22
|
+
end
|
23
|
+
|
24
|
+
add_option '-u', '--update', 'Update source cache' do |value, options|
|
25
|
+
options[:update] = 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
|
+
end
|
33
|
+
|
34
|
+
def defaults_str
|
35
|
+
'--list'
|
36
|
+
end
|
37
|
+
|
38
|
+
def execute
|
39
|
+
options[:list] = !(options[:add] || options[:remove] || options[:clear_all] || options[:update])
|
40
|
+
|
41
|
+
if options[:clear_all] then
|
42
|
+
remove_cache_file("user", Gem::SourceInfoCache.user_cache_file)
|
43
|
+
remove_cache_file("system", Gem::SourceInfoCache.system_cache_file)
|
44
|
+
end
|
45
|
+
|
46
|
+
if options[:add] then
|
47
|
+
source_uri = options[:add]
|
48
|
+
|
49
|
+
sice = Gem::SourceInfoCacheEntry.new nil, nil
|
50
|
+
begin
|
51
|
+
sice.refresh source_uri
|
52
|
+
|
53
|
+
Gem::SourceInfoCache.cache_data[source_uri] = sice
|
54
|
+
Gem::SourceInfoCache.cache.update
|
55
|
+
Gem::SourceInfoCache.cache.flush
|
56
|
+
|
57
|
+
Gem.sources << source_uri
|
58
|
+
Gem.configuration.write
|
59
|
+
|
60
|
+
say "#{source_uri} added to sources"
|
61
|
+
rescue URI::Error, ArgumentError
|
62
|
+
say "#{source_uri} is not a URI"
|
63
|
+
rescue Gem::RemoteFetcher::FetchError => e
|
64
|
+
say "Error fetching #{source_uri}:\n\t#{e.message}"
|
65
|
+
end
|
66
|
+
end
|
5
67
|
|
6
|
-
|
7
|
-
|
68
|
+
if options[:update] then
|
69
|
+
Gem::SourceInfoCache.cache.refresh
|
70
|
+
Gem::SourceInfoCache.cache.flush
|
8
71
|
|
9
|
-
|
10
|
-
|
11
|
-
end
|
72
|
+
say "source cache successfully updated"
|
73
|
+
end
|
12
74
|
|
13
|
-
|
14
|
-
|
15
|
-
end
|
75
|
+
if options[:remove] then
|
76
|
+
source_uri = options[:remove]
|
16
77
|
|
17
|
-
|
18
|
-
|
19
|
-
|
78
|
+
unless Gem.sources.include? source_uri then
|
79
|
+
say "source #{source_uri} not present in cache"
|
80
|
+
else
|
81
|
+
Gem::SourceInfoCache.cache_data.delete source_uri
|
82
|
+
Gem::SourceInfoCache.cache.update
|
83
|
+
Gem::SourceInfoCache.cache.flush
|
84
|
+
Gem.sources.delete source_uri
|
85
|
+
Gem.configuration.write
|
20
86
|
|
21
|
-
|
22
|
-
options[:clear_all] = value
|
23
|
-
end
|
87
|
+
say "#{source_uri} removed from sources"
|
24
88
|
end
|
89
|
+
end
|
25
90
|
|
26
|
-
|
27
|
-
|
28
|
-
|
91
|
+
if options[:list] then
|
92
|
+
say "*** CURRENT SOURCES ***"
|
93
|
+
say
|
29
94
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
if options[:clear_all] then
|
34
|
-
remove_cache_file("user", Gem::SourceInfoCache.user_cache_file)
|
35
|
-
remove_cache_file("system", Gem::SourceInfoCache.system_cache_file)
|
36
|
-
end
|
37
|
-
|
38
|
-
if options[:add] then
|
39
|
-
source_uri = options[:add]
|
40
|
-
|
41
|
-
sice = Gem::SourceInfoCacheEntry.new nil, nil
|
42
|
-
begin
|
43
|
-
sice.refresh source_uri
|
44
|
-
rescue ArgumentError
|
45
|
-
say "#{source_uri} is not a URI"
|
46
|
-
rescue Gem::RemoteFetcher::FetchError => e
|
47
|
-
say "Error fetching #{source_uri}:\n\t#{e.message}"
|
48
|
-
else
|
49
|
-
Gem::SourceInfoCache.cache_data[source_uri] = sice
|
50
|
-
Gem::SourceInfoCache.cache.update
|
51
|
-
Gem::SourceInfoCache.cache.flush
|
52
|
-
|
53
|
-
say "#{source_uri} added to sources"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
if options[:remove] then
|
58
|
-
source_uri = options[:remove]
|
59
|
-
|
60
|
-
unless Gem::SourceInfoCache.cache_data.include? source_uri then
|
61
|
-
say "source #{source_uri} not present in cache"
|
62
|
-
else
|
63
|
-
Gem::SourceInfoCache.cache_data.delete source_uri
|
64
|
-
Gem::SourceInfoCache.cache.update
|
65
|
-
Gem::SourceInfoCache.cache.flush
|
66
|
-
say "#{source_uri} removed from sources"
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
if options[:list] then
|
71
|
-
say "*** CURRENT SOURCES ***"
|
72
|
-
say
|
73
|
-
|
74
|
-
Gem::SourceInfoCache.cache_data.keys.each do |source_uri|
|
75
|
-
say source_uri
|
76
|
-
end
|
77
|
-
end
|
95
|
+
Gem.sources.each do |source_uri|
|
96
|
+
say source_uri
|
78
97
|
end
|
98
|
+
end
|
99
|
+
end
|
79
100
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
101
|
+
private
|
102
|
+
|
103
|
+
def remove_cache_file(desc, fn)
|
104
|
+
FileUtils.rm_rf fn rescue nil
|
105
|
+
if ! File.exist?(fn)
|
106
|
+
say "*** Removed #{desc} source cache ***"
|
107
|
+
elsif ! File.writable?(fn)
|
108
|
+
say "*** Unable to remove #{desc} source cache (write protected) ***"
|
109
|
+
else
|
110
|
+
say "*** Unable to remove #{desc} source cache ***"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
91
115
|
|
92
|
-
end # class SourcesCommand
|
93
|
-
end # module Commands
|
94
|
-
end # module Gem
|