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
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
3
|
+
require 'rubygems/commands/fetch_command'
|
4
|
+
|
5
|
+
class TestGemCommandsFetchCommand < RubyGemTestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
|
10
|
+
@cmd = Gem::Commands::FetchCommand.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_execute
|
14
|
+
util_setup_fake_fetcher
|
15
|
+
|
16
|
+
util_build_gem @gem1
|
17
|
+
@fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] =
|
18
|
+
@source_index.dump
|
19
|
+
@fetcher.data["#{@gem_repo}/gems/#{@gem1.full_name}.gem"] =
|
20
|
+
File.read(File.join(@gemhome, 'cache', "#{@gem1.full_name}.gem"))
|
21
|
+
|
22
|
+
@cmd.options[:args] = [@gem1.name]
|
23
|
+
|
24
|
+
use_ui @ui do
|
25
|
+
Dir.chdir @tempdir do
|
26
|
+
@cmd.execute
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
assert File.exist?(File.join(@tempdir, "#{@gem1.full_name}.gem"))
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
3
|
+
require 'rubygems/indexer'
|
4
|
+
require 'rubygems/commands/generate_index_command'
|
5
|
+
|
6
|
+
class TestGemCommandsGenerateIndexCommand < RubyGemTestCase
|
7
|
+
|
8
|
+
def setup
|
9
|
+
super
|
10
|
+
|
11
|
+
@cmd = Gem::Commands::GenerateIndexCommand.new
|
12
|
+
@cmd.options[:directory] = @gemhome
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_execute
|
16
|
+
use_ui @ui do
|
17
|
+
@cmd.execute
|
18
|
+
end
|
19
|
+
|
20
|
+
yaml = File.join @gemhome, 'yaml'
|
21
|
+
yaml_z = File.join @gemhome, 'yaml.Z'
|
22
|
+
quick_index = File.join @gemhome, 'quick', 'index'
|
23
|
+
quick_index_rz = File.join @gemhome, 'quick', 'index.rz'
|
24
|
+
|
25
|
+
assert File.exist?(yaml), yaml
|
26
|
+
assert File.exist?(yaml_z), yaml_z
|
27
|
+
assert File.exist?(quick_index), quick_index
|
28
|
+
assert File.exist?(quick_index_rz), quick_index_rz
|
29
|
+
end
|
30
|
+
|
31
|
+
end if ''.respond_to? :to_xs
|
32
|
+
|
@@ -0,0 +1,160 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
3
|
+
require 'rubygems/commands/install_command'
|
4
|
+
|
5
|
+
class TestGemCommandsInstallCommand < RubyGemTestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
|
10
|
+
@cmd = Gem::Commands::InstallCommand.new
|
11
|
+
@cmd.options[:generate_rdoc] = false
|
12
|
+
@cmd.options[:generate_ri] = false
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_execute_include_dependencies
|
16
|
+
@cmd.options[:include_dependencies] = true
|
17
|
+
@cmd.options[:args] = []
|
18
|
+
|
19
|
+
assert_raise Gem::CommandLineError do
|
20
|
+
use_ui @ui do
|
21
|
+
@cmd.execute
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
output = @ui.output.split "\n"
|
26
|
+
assert_equal "INFO: `gem install -y` is now default and will be removed",
|
27
|
+
output.shift
|
28
|
+
assert_equal "INFO: use --ignore-dependencies to install only the gems you list",
|
29
|
+
output.shift
|
30
|
+
assert output.empty?, output.inspect
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_execute_local
|
34
|
+
util_setup_fake_fetcher
|
35
|
+
@cmd.options[:domain] = :local
|
36
|
+
|
37
|
+
gem1 = quick_gem 'gem_one'
|
38
|
+
util_build_gem gem1
|
39
|
+
FileUtils.mv File.join(@gemhome, 'cache', "#{@gem1.full_name}.gem"),
|
40
|
+
File.join(@tempdir)
|
41
|
+
|
42
|
+
@cmd.options[:args] = [gem1.name]
|
43
|
+
|
44
|
+
use_ui @ui do
|
45
|
+
orig_dir = Dir.pwd
|
46
|
+
begin
|
47
|
+
Dir.chdir @tempdir
|
48
|
+
@cmd.execute
|
49
|
+
ensure
|
50
|
+
Dir.chdir orig_dir
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
out = @ui.output.split "\n"
|
55
|
+
assert_equal "Successfully installed #{@gem1.full_name}", out.shift
|
56
|
+
assert_equal "1 gem installed", out.shift
|
57
|
+
assert out.empty?, out.inspect
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_execute_local_missing
|
61
|
+
util_setup_fake_fetcher
|
62
|
+
@cmd.options[:domain] = :local
|
63
|
+
|
64
|
+
@cmd.options[:args] = %w[gem_one]
|
65
|
+
|
66
|
+
use_ui @ui do
|
67
|
+
@cmd.execute
|
68
|
+
end
|
69
|
+
|
70
|
+
# HACK no repository was checked
|
71
|
+
assert_equal "ERROR: could not find gem_one locally or in a repository\n",
|
72
|
+
@ui.error
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_execute_no_gem
|
76
|
+
@cmd.options[:args] = %w[]
|
77
|
+
|
78
|
+
assert_raise Gem::CommandLineError do
|
79
|
+
@cmd.execute
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_execute_nonexistent
|
84
|
+
util_setup_fake_fetcher
|
85
|
+
@fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] =
|
86
|
+
@source_index.dump
|
87
|
+
|
88
|
+
@cmd.options[:args] = %w[nonexistent]
|
89
|
+
|
90
|
+
use_ui @ui do
|
91
|
+
@cmd.execute
|
92
|
+
end
|
93
|
+
|
94
|
+
assert_equal "ERROR: could not find nonexistent locally or in a repository\n",
|
95
|
+
@ui.error
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_execute_remote
|
99
|
+
@cmd.options[:generate_rdoc] = true
|
100
|
+
@cmd.options[:generate_ri] = true
|
101
|
+
util_setup_fake_fetcher
|
102
|
+
|
103
|
+
util_build_gem @gem1
|
104
|
+
@fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] =
|
105
|
+
@source_index.dump
|
106
|
+
@fetcher.data["#{@gem_repo}/gems/gem_one-0.0.2.gem"] =
|
107
|
+
File.read(File.join(@gemhome, 'cache', "#{@gem1.full_name}.gem"))
|
108
|
+
|
109
|
+
@cmd.options[:args] = [@gem1.name]
|
110
|
+
|
111
|
+
use_ui @ui do
|
112
|
+
@cmd.execute
|
113
|
+
end
|
114
|
+
|
115
|
+
out = @ui.output.split "\n"
|
116
|
+
assert_match %r|Bulk updating|, out.shift
|
117
|
+
assert_equal "Successfully installed #{@gem1.full_name}", out.shift
|
118
|
+
assert_equal "1 gem installed", out.shift
|
119
|
+
assert_equal "Installing ri documentation for #{@gem1.full_name}...",
|
120
|
+
out.shift
|
121
|
+
assert_equal "Installing RDoc documentation for #{@gem1.full_name}...",
|
122
|
+
out.shift
|
123
|
+
assert out.empty?, out.inspect
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_execute_two
|
127
|
+
util_setup_fake_fetcher
|
128
|
+
@cmd.options[:domain] = :local
|
129
|
+
|
130
|
+
gem1 = quick_gem 'gem_one'
|
131
|
+
util_build_gem gem1
|
132
|
+
FileUtils.mv File.join(@gemhome, 'cache', "#{@gem1.full_name}.gem"),
|
133
|
+
File.join(@tempdir)
|
134
|
+
|
135
|
+
gem2 = quick_gem 'gem_two'
|
136
|
+
util_build_gem gem2
|
137
|
+
FileUtils.mv File.join(@gemhome, 'cache', "#{@gem2.full_name}.gem"),
|
138
|
+
File.join(@tempdir)
|
139
|
+
|
140
|
+
@cmd.options[:args] = [gem1.name, gem2.name]
|
141
|
+
|
142
|
+
use_ui @ui do
|
143
|
+
orig_dir = Dir.pwd
|
144
|
+
begin
|
145
|
+
Dir.chdir @tempdir
|
146
|
+
@cmd.execute
|
147
|
+
ensure
|
148
|
+
Dir.chdir orig_dir
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
out = @ui.output.split "\n"
|
153
|
+
assert_equal "Successfully installed #{@gem1.full_name}", out.shift
|
154
|
+
assert_equal "Successfully installed #{@gem2.full_name}", out.shift
|
155
|
+
assert_equal "2 gems installed", out.shift
|
156
|
+
assert out.empty?, out.inspect
|
157
|
+
end
|
158
|
+
|
159
|
+
end
|
160
|
+
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
3
|
+
require 'rubygems/indexer'
|
4
|
+
require 'rubygems/commands/mirror_command'
|
5
|
+
|
6
|
+
class TestGemCommandsMirrorCommand < RubyGemTestCase
|
7
|
+
|
8
|
+
def setup
|
9
|
+
super
|
10
|
+
|
11
|
+
@cmd = Gem::Commands::MirrorCommand.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_execute
|
15
|
+
util_make_gems
|
16
|
+
|
17
|
+
gems_dir = File.join @tempdir, 'gems'
|
18
|
+
mirror = File.join @tempdir, 'mirror'
|
19
|
+
|
20
|
+
FileUtils.mkdir_p gems_dir
|
21
|
+
FileUtils.mkdir_p mirror
|
22
|
+
|
23
|
+
Dir[File.join(@gemhome, 'cache', '*.gem')].each do |gem|
|
24
|
+
FileUtils.mv gem, gems_dir
|
25
|
+
end
|
26
|
+
|
27
|
+
use_ui @ui do
|
28
|
+
Gem::Indexer.new(@tempdir).generate_index
|
29
|
+
end
|
30
|
+
|
31
|
+
orig_HOME = ENV['HOME']
|
32
|
+
ENV['HOME'] = @tempdir
|
33
|
+
Gem.instance_variable_set :@user_home, nil
|
34
|
+
|
35
|
+
File.open File.join(Gem.user_home, '.gemmirrorrc'), 'w' do |fp|
|
36
|
+
fp.puts "---"
|
37
|
+
fp.puts "- from: file://#{@tempdir}"
|
38
|
+
fp.puts " to: #{mirror}"
|
39
|
+
end
|
40
|
+
|
41
|
+
use_ui @ui do
|
42
|
+
@cmd.execute
|
43
|
+
end
|
44
|
+
|
45
|
+
assert File.exist?(File.join(mirror, 'gems', "#{@a0_0_1.full_name}.gem"))
|
46
|
+
assert File.exist?(File.join(mirror, 'gems', "#{@a0_0_2.full_name}.gem"))
|
47
|
+
assert File.exist?(File.join(mirror, 'gems', "#{@b0_0_2.full_name}.gem"))
|
48
|
+
assert File.exist?(File.join(mirror, 'gems', "#{@c1_2.full_name}.gem"))
|
49
|
+
assert File.exist?(File.join(mirror, "Marshal.#{@marshal_version}"))
|
50
|
+
ensure
|
51
|
+
orig_HOME.nil? ? ENV.delete('HOME') : ENV['HOME'] = orig_HOME
|
52
|
+
Gem.instance_variable_set :@user_home, nil
|
53
|
+
end
|
54
|
+
|
55
|
+
end if ''.respond_to? :to_xs
|
56
|
+
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
3
|
+
require 'rubygems/commands/pristine_command'
|
4
|
+
|
5
|
+
class TestGemCommandsPristineCommand < RubyGemTestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
@cmd = Gem::Commands::PristineCommand.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_execute
|
13
|
+
a = quick_gem 'a' do |s| s.executables = %w[foo] end
|
14
|
+
FileUtils.mkdir_p File.join(@tempdir, 'bin')
|
15
|
+
File.open File.join(@tempdir, 'bin', 'foo'), 'w' do |fp|
|
16
|
+
fp.puts "#!/usr/bin/ruby"
|
17
|
+
end
|
18
|
+
|
19
|
+
install_gem a
|
20
|
+
|
21
|
+
@cmd.options[:args] = %w[a]
|
22
|
+
|
23
|
+
use_ui @ui do
|
24
|
+
@cmd.execute
|
25
|
+
end
|
26
|
+
|
27
|
+
out = @ui.output.split "\n"
|
28
|
+
|
29
|
+
assert_equal "Restoring gem(s) to pristine condition...", out.shift
|
30
|
+
assert_equal "#{a.full_name} is in pristine condition", out.shift
|
31
|
+
assert out.empty?, out.inspect
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_execute_all
|
35
|
+
a = quick_gem 'a' do |s| s.executables = %w[foo] end
|
36
|
+
FileUtils.mkdir_p File.join(@tempdir, 'bin')
|
37
|
+
File.open File.join(@tempdir, 'bin', 'foo'), 'w' do |fp|
|
38
|
+
fp.puts "#!/usr/bin/ruby"
|
39
|
+
end
|
40
|
+
|
41
|
+
install_gem a
|
42
|
+
|
43
|
+
gem_bin = File.join @gemhome, 'gems', "#{a.full_name}", 'bin', 'foo'
|
44
|
+
|
45
|
+
FileUtils.rm gem_bin
|
46
|
+
|
47
|
+
@cmd.handle_options %w[--all]
|
48
|
+
|
49
|
+
use_ui @ui do
|
50
|
+
@cmd.execute
|
51
|
+
end
|
52
|
+
|
53
|
+
out = @ui.output.split "\n"
|
54
|
+
|
55
|
+
assert_equal "Restoring gem(s) to pristine condition...", out.shift
|
56
|
+
assert_equal "Restoring 1 file to #{a.full_name}...", out.shift
|
57
|
+
assert_equal " #{gem_bin}", out.shift
|
58
|
+
assert out.empty?, out.inspect
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_execute_missing_cache_gem
|
62
|
+
a = quick_gem 'a' do |s| s.executables = %w[foo] end
|
63
|
+
FileUtils.mkdir_p File.join(@tempdir, 'bin')
|
64
|
+
File.open File.join(@tempdir, 'bin', 'foo'), 'w' do |fp|
|
65
|
+
fp.puts "#!/usr/bin/ruby"
|
66
|
+
end
|
67
|
+
|
68
|
+
install_gem a
|
69
|
+
|
70
|
+
FileUtils.rm File.join(@gemhome, 'cache', "#{a.full_name}.gem")
|
71
|
+
|
72
|
+
@cmd.options[:args] = %w[a]
|
73
|
+
|
74
|
+
use_ui @ui do
|
75
|
+
@cmd.execute
|
76
|
+
end
|
77
|
+
|
78
|
+
out = @ui.output.split "\n"
|
79
|
+
|
80
|
+
assert_equal "Restoring gem\(s\) to pristine condition...", out.shift
|
81
|
+
assert out.empty?, out.inspect
|
82
|
+
|
83
|
+
assert_equal "ERROR: Cached gem for #{a.full_name} not found, use `gem install` to restore\n",
|
84
|
+
@ui.error
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_execute_no_gem
|
88
|
+
@cmd.options[:args] = %w[]
|
89
|
+
|
90
|
+
e = assert_raise Gem::CommandLineError do
|
91
|
+
use_ui @ui do
|
92
|
+
@cmd.execute
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
assert_match %r|specify a gem name|, e.message
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
3
|
+
require 'rubygems/commands/query_command'
|
4
|
+
|
5
|
+
class TestGemCommandsQueryCommand < RubyGemTestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
|
10
|
+
@foo_gem = quick_gem 'foo' do |spec|
|
11
|
+
spec.summary = 'This is a lot of text. ' * 5
|
12
|
+
end
|
13
|
+
@bar_gem = quick_gem 'bar'
|
14
|
+
|
15
|
+
@cmd = Gem::Commands::QueryCommand.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_execute
|
19
|
+
util_setup_source_info_cache @foo_gem
|
20
|
+
|
21
|
+
@cmd.handle_options %w[-r]
|
22
|
+
|
23
|
+
use_ui @ui do
|
24
|
+
@cmd.execute
|
25
|
+
end
|
26
|
+
|
27
|
+
expected = <<-EOF
|
28
|
+
|
29
|
+
*** REMOTE GEMS ***
|
30
|
+
|
31
|
+
foo (0.0.2)
|
32
|
+
EOF
|
33
|
+
|
34
|
+
assert_equal expected, @ui.output
|
35
|
+
assert_equal '', @ui.error
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_execute_details
|
39
|
+
util_setup_source_info_cache @foo_gem
|
40
|
+
|
41
|
+
@cmd.handle_options %w[-r -d]
|
42
|
+
|
43
|
+
use_ui @ui do
|
44
|
+
@cmd.execute
|
45
|
+
end
|
46
|
+
|
47
|
+
expected = <<-EOF
|
48
|
+
|
49
|
+
*** REMOTE GEMS ***
|
50
|
+
|
51
|
+
foo (0.0.2)
|
52
|
+
This is a lot of text. This is a lot of text. This is a lot of
|
53
|
+
text. This is a lot of text. This is a lot of text.
|
54
|
+
EOF
|
55
|
+
|
56
|
+
assert_equal expected, @ui.output
|
57
|
+
assert_equal '', @ui.error
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_execute_no_versions
|
61
|
+
util_setup_source_info_cache @foo_gem, @bar_gem
|
62
|
+
|
63
|
+
@cmd.handle_options %w[-r --no-versions]
|
64
|
+
|
65
|
+
use_ui @ui do
|
66
|
+
@cmd.execute
|
67
|
+
end
|
68
|
+
|
69
|
+
expected = <<-EOF
|
70
|
+
|
71
|
+
*** REMOTE GEMS ***
|
72
|
+
|
73
|
+
bar
|
74
|
+
foo
|
75
|
+
EOF
|
76
|
+
|
77
|
+
assert_equal expected, @ui.output
|
78
|
+
assert_equal '', @ui.error
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|