rubygems-update 1.3.5 → 1.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of rubygems-update might be problematic. Click here for more details.

Files changed (146) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +8 -1
  3. data/ChangeLog +164 -0
  4. data/History.txt +52 -1
  5. data/Manifest.txt +8 -8
  6. data/README +3 -2
  7. data/Rakefile +49 -5
  8. data/bin/gem +2 -2
  9. data/bin/update_rubygems +9 -11
  10. data/cruise_config.rb +4 -3
  11. data/hide_lib_for_update/note.txt +5 -0
  12. data/lib/rbconfig/datadir.rb +10 -14
  13. data/lib/rubygems.rb +117 -140
  14. data/lib/rubygems/builder.rb +4 -2
  15. data/lib/rubygems/command.rb +51 -48
  16. data/lib/rubygems/command_manager.rb +2 -0
  17. data/lib/rubygems/commands/dependency_command.rb +10 -5
  18. data/lib/rubygems/commands/environment_command.rb +1 -1
  19. data/lib/rubygems/commands/fetch_command.rb +6 -5
  20. data/lib/rubygems/commands/install_command.rb +1 -0
  21. data/lib/rubygems/commands/mirror_command.rb +8 -8
  22. data/lib/rubygems/commands/owner_command.rb +75 -0
  23. data/lib/rubygems/commands/pristine_command.rb +1 -1
  24. data/lib/rubygems/commands/push_command.rb +45 -0
  25. data/lib/rubygems/commands/query_command.rb +4 -1
  26. data/lib/rubygems/commands/rdoc_command.rb +24 -9
  27. data/lib/rubygems/commands/server_command.rb +6 -0
  28. data/lib/rubygems/commands/setup_command.rb +14 -4
  29. data/lib/rubygems/commands/unpack_command.rb +2 -2
  30. data/lib/rubygems/commands/update_command.rb +2 -2
  31. data/lib/rubygems/commands/which_command.rb +7 -9
  32. data/lib/rubygems/config_file.rb +100 -26
  33. data/lib/rubygems/defaults.rb +1 -1
  34. data/lib/rubygems/dependency.rb +133 -75
  35. data/lib/rubygems/dependency_installer.rb +28 -10
  36. data/lib/rubygems/dependency_list.rb +41 -12
  37. data/lib/rubygems/doc_manager.rb +7 -0
  38. data/lib/rubygems/format.rb +16 -20
  39. data/lib/rubygems/gem_openssl.rb +1 -1
  40. data/lib/rubygems/gem_path_searcher.rb +10 -12
  41. data/lib/rubygems/gemcutter_utilities.rb +49 -0
  42. data/lib/rubygems/indexer.rb +2 -2
  43. data/lib/rubygems/install_update_options.rb +1 -9
  44. data/lib/rubygems/installer.rb +35 -76
  45. data/lib/rubygems/local_remote_options.rb +1 -2
  46. data/lib/rubygems/package.rb +0 -1
  47. data/lib/rubygems/package/tar_input.rb +3 -1
  48. data/lib/rubygems/package_task.rb +16 -11
  49. data/lib/rubygems/remote_fetcher.rb +22 -8
  50. data/lib/rubygems/requirement.rb +78 -100
  51. data/lib/rubygems/server.rb +41 -10
  52. data/lib/rubygems/source_index.rb +5 -5
  53. data/lib/rubygems/spec_fetcher.rb +2 -2
  54. data/lib/rubygems/specification.rb +66 -16
  55. data/lib/rubygems/test_utilities.rb +33 -4
  56. data/lib/rubygems/uninstaller.rb +3 -3
  57. data/lib/rubygems/user_interaction.rb +45 -0
  58. data/lib/rubygems/validator.rb +6 -7
  59. data/lib/rubygems/version.rb +206 -149
  60. data/lib/rubygems/version_option.rb +16 -0
  61. data/test/fake_certlib/openssl.rb +1 -1
  62. data/test/functional.rb +0 -7
  63. data/test/gem_installer_test_case.rb +4 -4
  64. data/test/gem_package_tar_test_case.rb +1 -1
  65. data/test/gemutilities.rb +35 -31
  66. data/test/insure_session.rb +0 -8
  67. data/test/mockgemui.rb +0 -8
  68. data/test/simple_gem.rb +2 -8
  69. data/test/test_config.rb +3 -10
  70. data/test/test_gem.rb +9 -14
  71. data/test/test_gem_builder.rb +1 -7
  72. data/test/test_gem_command.rb +1 -8
  73. data/test/test_gem_command_manager.rb +1 -7
  74. data/test/test_gem_commands_build_command.rb +4 -4
  75. data/test/test_gem_commands_cert_command.rb +1 -2
  76. data/test/test_gem_commands_check_command.rb +1 -7
  77. data/test/test_gem_commands_contents_command.rb +1 -1
  78. data/test/test_gem_commands_dependency_command.rb +17 -31
  79. data/test/test_gem_commands_environment_command.rb +1 -1
  80. data/test/test_gem_commands_fetch_command.rb +14 -12
  81. data/test/test_gem_commands_generate_index_command.rb +1 -1
  82. data/test/test_gem_commands_install_command.rb +22 -20
  83. data/test/test_gem_commands_list_command.rb +1 -1
  84. data/test/test_gem_commands_lock_command.rb +1 -1
  85. data/test/test_gem_commands_mirror_command.rb +5 -5
  86. data/test/test_gem_commands_outdated_command.rb +3 -5
  87. data/test/test_gem_commands_owner_command.rb +105 -0
  88. data/test/test_gem_commands_pristine_command.rb +2 -2
  89. data/test/test_gem_commands_push_command.rb +61 -0
  90. data/test/test_gem_commands_query_command.rb +23 -56
  91. data/test/test_gem_commands_server_command.rb +1 -1
  92. data/test/test_gem_commands_sources_command.rb +1 -70
  93. data/test/test_gem_commands_specification_command.rb +3 -4
  94. data/test/test_gem_commands_stale_command.rb +1 -1
  95. data/test/test_gem_commands_uninstall_command.rb +3 -4
  96. data/test/test_gem_commands_unpack_command.rb +1 -1
  97. data/test/test_gem_commands_update_command.rb +13 -13
  98. data/test/test_gem_commands_which_command.rb +66 -0
  99. data/test/test_gem_config_file.rb +13 -7
  100. data/test/test_gem_dependency.rb +82 -134
  101. data/test/test_gem_dependency_installer.rb +55 -30
  102. data/test/test_gem_dependency_list.rb +28 -7
  103. data/test/test_gem_doc_manager.rb +1 -7
  104. data/test/test_gem_ext_configure_builder.rb +2 -2
  105. data/test/test_gem_ext_ext_conf_builder.rb +1 -1
  106. data/test/test_gem_ext_rake_builder.rb +1 -1
  107. data/test/test_gem_format.rb +14 -11
  108. data/test/test_gem_gem_path_searcher.rb +12 -1
  109. data/test/test_gem_gem_runner.rb +1 -1
  110. data/test/test_gem_gemcutter_utilities.rb +103 -0
  111. data/test/test_gem_indexer.rb +44 -51
  112. data/test/test_gem_install_update_options.rb +1 -7
  113. data/test/test_gem_installer.rb +22 -82
  114. data/test/test_gem_local_remote_options.rb +1 -1
  115. data/test/test_gem_package_tar_header.rb +1 -8
  116. data/test/test_gem_package_tar_input.rb +1 -8
  117. data/test/test_gem_package_tar_output.rb +1 -8
  118. data/test/test_gem_package_tar_reader.rb +1 -8
  119. data/test/test_gem_package_tar_reader_entry.rb +1 -8
  120. data/test/test_gem_package_tar_writer.rb +1 -8
  121. data/test/test_gem_package_task.rb +1 -25
  122. data/test/test_gem_platform.rb +4 -4
  123. data/test/test_gem_remote_fetcher.rb +31 -21
  124. data/test/test_gem_requirement.rb +210 -140
  125. data/test/test_gem_server.rb +36 -1
  126. data/test/test_gem_source_index.rb +7 -13
  127. data/test/test_gem_spec_fetcher.rb +17 -47
  128. data/test/test_gem_specification.rb +7 -20
  129. data/test/test_gem_stream_ui.rb +21 -1
  130. data/test/test_gem_uninstaller.rb +1 -2
  131. data/test/test_gem_validator.rb +2 -8
  132. data/test/test_gem_version.rb +110 -254
  133. data/test/test_gem_version_option.rb +1 -1
  134. data/test/test_kernel.rb +1 -7
  135. data/util/CL2notes +1 -1
  136. data/util/gem_prelude.rb.template +64 -41
  137. metadata +33 -71
  138. metadata.gz.sig +0 -0
  139. data/lib/rubygems/digest/digest_adapter.rb +0 -49
  140. data/lib/rubygems/digest/md5.rb +0 -23
  141. data/lib/rubygems/digest/sha1.rb +0 -22
  142. data/lib/rubygems/digest/sha2.rb +0 -22
  143. data/lib/rubygems/timer.rb +0 -28
  144. data/test/test_gem_digest.rb +0 -46
  145. data/test/test_gem_source_info_cache.rb +0 -447
  146. data/test/test_gem_source_info_cache_entry.rb +0 -78
metadata.gz.sig CHANGED
Binary file
@@ -1,49 +0,0 @@
1
- #--
2
- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
3
- # All rights reserved.
4
- # See LICENSE.txt for permissions.
5
- #++
6
-
7
- require 'rubygems'
8
-
9
- ##
10
- # There is an incompatibility between the way Ruby 1.8.5 and 1.8.6 handles
11
- # digests. This DigestAdapter will take a pre-1.8.6 digest and adapt it to
12
- # the 1.8.6 API.
13
- #
14
- # Note that only the digest and hexdigest methods are adapted, since these
15
- # are the only functions used by RubyGems.
16
-
17
- class Gem::DigestAdapter
18
-
19
- ##
20
- # Initialize a digest adapter.
21
-
22
- def initialize(digest_class)
23
- @digest_class = digest_class
24
- end
25
-
26
- ##
27
- # Return a new digester. Since we are only implementing the stateless
28
- # methods, we will return ourself as the instance.
29
-
30
- def new
31
- self
32
- end
33
-
34
- ##
35
- # Return the digest of +string+ as a hex string.
36
-
37
- def hexdigest(string)
38
- @digest_class.new(string).hexdigest
39
- end
40
-
41
- ##
42
- # Return the digest of +string+ as a binary string.
43
-
44
- def digest(string)
45
- @digest_class.new(string).digest
46
- end
47
-
48
- end
49
-
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #--
3
- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
4
- # All rights reserved.
5
- # See LICENSE.txt for permissions.
6
- #++
7
-
8
- require 'digest/md5'
9
-
10
- # :stopdoc:
11
- module Gem
12
- if RUBY_VERSION >= '1.8.6'
13
- MD5 = Digest::MD5
14
- else
15
- require 'rubygems/digest/digest_adapter'
16
- MD5 = DigestAdapter.new(Digest::MD5)
17
- def MD5.md5(string)
18
- self.hexdigest(string)
19
- end
20
- end
21
- end
22
- # :startdoc:
23
-
@@ -1,22 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #--
3
- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
4
- # All rights reserved.
5
- # See LICENSE.txt for permissions.
6
- #++
7
-
8
- require 'digest/sha1'
9
-
10
- # :stopdoc:
11
- module Gem
12
-
13
- if RUBY_VERSION >= '1.8.6'
14
- SHA1 = Digest::SHA1
15
- else
16
- require 'rubygems/digest/digest_adapter'
17
- SHA1 = DigestAdapter.new(Digest::SHA1)
18
- end
19
-
20
- end
21
- # :startdoc:
22
-
@@ -1,22 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #--
3
- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
4
- # All rights reserved.
5
- # See LICENSE.txt for permissions.
6
- #++
7
-
8
- require 'digest/sha2'
9
-
10
- # :stopdoc:
11
- module Gem
12
-
13
- if RUBY_VERSION >= '1.8.6'
14
- SHA256 = Digest::SHA256
15
- else
16
- require 'rubygems/digest/digest_adapter'
17
- SHA256 = DigestAdapter.new(Digest::SHA256)
18
- end
19
-
20
- end
21
- # :startdoc:
22
-
@@ -1,28 +0,0 @@
1
- #
2
- # This file defines a $log variable for logging, and a time() method for
3
- # recording timing information.
4
- #
5
- #--
6
- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
7
- # All rights reserved.
8
- # See LICENSE.txt for permissions.
9
- #++
10
-
11
- require 'rubygems'
12
-
13
- file, lineno = Gem.location_of_caller
14
-
15
- warn "#{file}:#{lineno}:Warning: RubyGems' lib/rubygems/timer.rb deprecated and will be removed on or after June 2009."
16
-
17
- $log = Object.new
18
-
19
- # :stopdoc:
20
- def $log.debug(message)
21
- Gem.debug message
22
- end
23
-
24
- def time(msg, width=25, &block)
25
- Gem.time(msg, width, &block)
26
- end
27
- # :startdoc:
28
-
@@ -1,46 +0,0 @@
1
- #--
2
- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
3
- # All rights reserved.
4
- # See LICENSE.txt for permissions.
5
- #++
6
-
7
- require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
8
- require "rubygems/digest/md5"
9
- require "rubygems/digest/sha1"
10
- require "rubygems/digest/sha2"
11
-
12
- class TestRubygemsGemDigest < RubyGemTestCase
13
-
14
- def test_sha256_hex_digest_works
15
- digester = Gem::SHA256.new
16
- assert_equal "b5d4045c3f466fa91fe2cc6abe79232a1a57cdf104f7a26e716e0a1e2789df78", digester.hexdigest("ABC")
17
- end
18
-
19
- def test_sha256_digest_works
20
- digester = Gem::SHA256.new
21
- assert_equal "\265\324\004\\?Fo\251\037\342\314j\276y#*\032W\315\361\004\367\242nqn\n\036'\211\337x",
22
- digester.digest("ABC")
23
- end
24
-
25
- def test_sha1_hex_digest_works
26
- digester = Gem::SHA1.new
27
- assert_equal "3c01bdbb26f358bab27f267924aa2c9a03fcfdb8", digester.hexdigest("ABC")
28
- end
29
-
30
- def test_sha1_digest_works
31
- digester = Gem::SHA1.new
32
- assert_equal "<\001\275\273&\363X\272\262\177&y$\252,\232\003\374\375\270", digester.digest("ABC")
33
- end
34
-
35
- def test_md5_hex_digest_works
36
- digester = Gem::MD5.new
37
- assert_equal "902fbdd2b1df0c4f70b4a5d23525e932", digester.hexdigest("ABC")
38
- end
39
-
40
- def test_md5_digest_works
41
- digester = Gem::MD5.new
42
- assert_equal "\220/\275\322\261\337\fOp\264\245\3225%\3512", digester.digest("ABC")
43
- end
44
-
45
- end
46
-
@@ -1,447 +0,0 @@
1
- #--
2
- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
3
- # All rights reserved.
4
- # See LICENSE.txt for permissions.
5
- #++
6
-
7
- require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
8
- require 'rubygems/source_info_cache'
9
-
10
- class Gem::SourceIndex
11
- public :gems
12
- end
13
-
14
- class TestGemSourceInfoCache < RubyGemTestCase
15
-
16
- def setup
17
- @original_sources = Gem.sources
18
-
19
- super
20
-
21
- util_setup_fake_fetcher
22
-
23
- @sic = Gem::SourceInfoCache.new
24
- @sic.instance_variable_set :@fetcher, @fetcher
25
-
26
- @si_new = Gem::SourceIndex.new
27
- @sice_new = Gem::SourceInfoCacheEntry.new @si_new, 0
28
-
29
- prep_cache_files @sic
30
-
31
- @sic.reset_cache_data
32
- end
33
-
34
- def teardown
35
- super
36
- Gem.sources.replace @original_sources
37
- Gem::SourceInfoCache.instance_variable_set :@cache, nil
38
- end
39
-
40
- def test_self_cache_refreshes
41
- Gem.configuration.update_sources = true #true by default
42
- si = Gem::SourceIndex.new
43
- si.add_spec @a1
44
-
45
- @fetcher.data["#{@gem_repo}Marshal.#{@marshal_version}"] = si.dump
46
-
47
- Gem.sources.replace %W[#{@gem_repo}]
48
-
49
- use_ui @ui do
50
- refute_nil Gem::SourceInfoCache.cache
51
- assert_kind_of Gem::SourceInfoCache, Gem::SourceInfoCache.cache
52
- assert_equal Gem::SourceInfoCache.cache.object_id,
53
- Gem::SourceInfoCache.cache.object_id
54
- end
55
-
56
- assert_match %r|Bulk updating|, @ui.output
57
- end
58
-
59
- def test_self_cache_skips_refresh_based_on_configuration
60
- Gem.configuration.update_sources = false
61
- si = Gem::SourceIndex.new
62
- si.add_spec @a1
63
-
64
- @fetcher.data["#{@gem_repo}Marshal.#{@marshal_version}"] = si.dump
65
-
66
- Gem.sources.replace %w[#{@gem_repo}]
67
-
68
- use_ui @ui do
69
- refute_nil Gem::SourceInfoCache.cache
70
- assert_kind_of Gem::SourceInfoCache, Gem::SourceInfoCache.cache
71
- assert_equal Gem::SourceInfoCache.cache.object_id,
72
- Gem::SourceInfoCache.cache.object_id
73
- refute_match %r|Bulk updating|, @ui.output
74
- end
75
- end
76
-
77
- def test_self_cache_data
78
- si = Gem::SourceIndex.new
79
- si.add_spec @a1
80
-
81
- @fetcher.data["#{@gem_repo}Marshal.#{@marshal_version}"] = si.dump
82
-
83
- Gem::SourceInfoCache.instance_variable_set :@cache, nil
84
- sice = Gem::SourceInfoCacheEntry.new si, 0
85
-
86
- use_ui @ui do
87
- gems = Gem::SourceInfoCache.cache_data[@gem_repo].source_index.gems
88
- gem_names = gems.map { |_, spec| spec.full_name }
89
-
90
- assert_equal si.gems.map { |_,spec| spec.full_name }, gem_names
91
- end
92
- end
93
-
94
- def test_cache_data
95
- assert_equal [[@gem_repo, @usr_sice]], @sic.cache_data.to_a.sort
96
- end
97
-
98
- def test_cache_data_dirty
99
- def @sic.dirty() @dirty; end
100
- assert_equal false, @sic.dirty, 'clean on init'
101
- @sic.cache_data
102
- assert_equal false, @sic.dirty, 'clean on fetch'
103
- @sic.update
104
- @sic.cache_data
105
- assert_equal true, @sic.dirty, 'still dirty'
106
- end
107
-
108
- def test_cache_data_irreparable
109
- @fetcher.data["#{@gem_repo}Marshal.#{@marshal_version}"] = @source_index.dump
110
-
111
- data = { @gem_repo => { 'totally' => 'borked' } }
112
-
113
- cache_files = [
114
- @sic.system_cache_file,
115
- @sic.latest_system_cache_file,
116
- @sic.user_cache_file,
117
- @sic.latest_user_cache_file
118
- ]
119
-
120
- cache_files.each do |fn|
121
- FileUtils.mkdir_p File.dirname(fn)
122
- open(fn, "wb") { |f| f.write Marshal.dump(data) }
123
- end
124
-
125
- @sic.instance_eval { @cache_data = nil }
126
-
127
- fetched = use_ui @ui do @sic.cache_data end
128
-
129
- fetched_si = fetched["#{@gem_repo}"].source_index
130
-
131
- assert_equal @source_index.index_signature, fetched_si.index_signature
132
- end
133
-
134
- def test_cache_data_none_readable
135
- FileUtils.chmod 0222, @sic.system_cache_file
136
- FileUtils.chmod 0222, @sic.latest_system_cache_file
137
- FileUtils.chmod 0222, @sic.user_cache_file
138
- FileUtils.chmod 0222, @sic.latest_user_cache_file
139
- return if (File.stat(@sic.system_cache_file).mode & 0222) != 0222
140
- return if (File.stat(@sic.user_cache_file).mode & 0222) != 0222
141
- # HACK for systems that don't support chmod
142
- assert_equal({}, @sic.cache_data)
143
- end
144
-
145
- def test_cache_data_none_writable
146
- FileUtils.chmod 0444, @sic.system_cache_file
147
- FileUtils.chmod 0444, @sic.user_cache_file
148
- e = assert_raises RuntimeError do
149
- @sic.cache_data
150
- end
151
- assert_equal 'unable to locate a writable cache file', e.message
152
- end
153
-
154
- def test_cache_data_nonexistent
155
- FileUtils.rm @sic.system_cache_file
156
- FileUtils.rm @sic.latest_system_cache_file
157
- FileUtils.rm @sic.user_cache_file
158
- FileUtils.rm @sic.latest_user_cache_file
159
-
160
- # TODO test verbose output
161
- assert_equal [], @sic.cache_data.to_a.sort
162
- end
163
-
164
- def test_cache_data_repair
165
- data = {
166
- @gem_repo => {
167
- 'cache' => Gem::SourceIndex.new,
168
- 'size' => 0,
169
- }
170
- }
171
- [@sic.system_cache_file, @sic.user_cache_file].each do |fn|
172
- FileUtils.mkdir_p File.dirname(fn)
173
- open(fn, "wb") { |f| f.write Marshal.dump(data) }
174
- end
175
-
176
- @sic.instance_eval { @cache_data = nil }
177
-
178
- expected = {
179
- @gem_repo =>
180
- Gem::SourceInfoCacheEntry.new(Gem::SourceIndex.new, 0)
181
- }
182
- assert_equal expected, @sic.cache_data
183
- end
184
-
185
- def test_cache_data_user_fallback
186
- FileUtils.chmod 0444, @sic.system_cache_file
187
-
188
- assert_equal [[@gem_repo, @usr_sice]], @sic.cache_data.to_a.sort
189
- end
190
-
191
- def test_cache_file
192
- assert_equal @gemcache, @sic.cache_file
193
- end
194
-
195
- def test_cache_file_user_fallback
196
- FileUtils.chmod 0444, @sic.system_cache_file
197
- assert_equal @usrcache, @sic.cache_file
198
- end
199
-
200
- def test_cache_file_none_writable
201
- FileUtils.chmod 0444, @sic.system_cache_file
202
- FileUtils.chmod 0444, @sic.user_cache_file
203
- e = assert_raises RuntimeError do
204
- @sic.cache_file
205
- end
206
- assert_equal 'unable to locate a writable cache file', e.message
207
- end
208
-
209
- def test_flush
210
- @sic.cache_data[@gem_repo] = @sice_new
211
- @sic.update
212
- @sic.flush
213
-
214
- assert_equal [[@gem_repo, @sice_new]],
215
- read_cache(@sic.system_cache_file).to_a.sort
216
- end
217
-
218
- def test_latest_cache_data
219
- util_make_gems
220
-
221
- sice = Gem::SourceInfoCacheEntry.new @source_index, 0
222
-
223
- @sic.set_cache_data @gem_repo => sice
224
- latest = @sic.latest_cache_data
225
- beginning_with_a = Gem::Dependency.new(/^a/, Gem::Requirement.default)
226
- gems = latest[@gem_repo].source_index.search(beginning_with_a).map { |s| s.full_name }
227
-
228
- assert_equal %w[a-2 a_evil-9], gems
229
- end
230
-
231
- def test_latest_cache_file
232
- latest_cache_file = File.join File.dirname(@gemcache),
233
- "latest_#{File.basename @gemcache}"
234
- assert_equal latest_cache_file, @sic.latest_cache_file
235
- end
236
-
237
- def test_latest_system_cache_file
238
- assert_equal File.join(Gem.dir, "latest_source_cache"),
239
- @sic.latest_system_cache_file
240
- end
241
-
242
- def test_latest_user_cache_file
243
- assert_equal @latest_usrcache, @sic.latest_user_cache_file
244
- end
245
-
246
- def test_read_system_cache
247
- assert_equal [[@gem_repo, @sys_sice]], @sic.cache_data.to_a.sort
248
- end
249
-
250
- def test_read_user_cache
251
- FileUtils.chmod 0444, @sic.user_cache_file
252
- FileUtils.chmod 0444, @sic.latest_user_cache_file
253
-
254
- @si = Gem::SourceIndex.new
255
- @si.add_specs @a1, @a2
256
-
257
- @sice = Gem::SourceInfoCacheEntry.new @si, 0
258
-
259
- @sic.set_cache_data({ @gem_repo => @sice })
260
- @sic.update
261
- @sic.write_cache
262
- @sic.reset_cache_data
263
-
264
- user_cache_data = @sic.cache_data.to_a.sort
265
-
266
- assert_equal 1, user_cache_data.length
267
- user_cache_data = user_cache_data.first
268
-
269
- assert_equal @gem_repo, user_cache_data.first
270
-
271
- gems = user_cache_data.last.source_index.map { |_,spec| spec.full_name }
272
- assert_equal [@a2.full_name], gems
273
- end
274
-
275
- def test_search
276
- si = Gem::SourceIndex.new
277
- si.add_spec @a1
278
- cache_data = { @gem_repo => Gem::SourceInfoCacheEntry.new(si, nil) }
279
- @sic.instance_variable_set :@cache_data, cache_data
280
-
281
- assert_equal [@a1], @sic.search(//)
282
- end
283
-
284
- def test_search_all
285
- util_make_gems
286
-
287
- sice = Gem::SourceInfoCacheEntry.new @source_index, 0
288
-
289
- @sic.set_cache_data @gem_repo => sice
290
- @sic.update
291
- @sic.instance_variable_set :@only_latest, false
292
- @sic.write_cache
293
- @sic.reset_cache_data
294
-
295
- gem_names = @sic.search(//, false, true).map { |spec| spec.full_name }
296
-
297
- assert_equal %w[a-1 a-2 a-3.a a_evil-9 c-1.2], gem_names
298
- end
299
-
300
- def test_search_dependency
301
- si = Gem::SourceIndex.new
302
- si.add_spec @a1
303
- cache_data = { @gem_repo => Gem::SourceInfoCacheEntry.new(si, nil) }
304
- @sic.instance_variable_set :@cache_data, cache_data
305
-
306
- dep = Gem::Dependency.new @a1.name, @a1.version
307
-
308
- assert_equal [@a1], @sic.search(dep)
309
- end
310
-
311
- def test_search_no_matches
312
- si = Gem::SourceIndex.new
313
- si.add_spec @a1
314
- cache_data = { @gem_repo => Gem::SourceInfoCacheEntry.new(si, nil) }
315
- @sic.instance_variable_set :@cache_data, cache_data
316
-
317
- assert_equal [], @sic.search(/nonexistent/)
318
- end
319
-
320
- def test_search_no_matches_in_source
321
- si = Gem::SourceIndex.new
322
- si.add_spec @a1
323
- cache_data = { @gem_repo => Gem::SourceInfoCacheEntry.new(si, nil) }
324
- @sic.instance_variable_set :@cache_data, cache_data
325
- Gem.sources.replace %w[more-gems.example.com]
326
-
327
- assert_equal [], @sic.search(/nonexistent/)
328
- end
329
-
330
- def test_search_with_source
331
- si = Gem::SourceIndex.new
332
- si.add_spec @a1
333
- cache_data = { @gem_repo => Gem::SourceInfoCacheEntry.new(si, nil) }
334
- @sic.instance_variable_set :@cache_data, cache_data
335
-
336
- assert_equal [[@a1, @gem_repo]],
337
- @sic.search_with_source(//)
338
- end
339
-
340
- def test_system_cache_file
341
- assert_equal File.join(Gem.dir, "source_cache"), @sic.system_cache_file
342
- end
343
-
344
- def test_user_cache_file
345
- assert_equal @usrcache, @sic.user_cache_file
346
- end
347
-
348
- def test_write_cache
349
- @sic.cache_data[@gem_repo] = @sice_new
350
- @sic.write_cache
351
-
352
- assert_equal [[@gem_repo, @sice_new]],
353
- read_cache(@sic.system_cache_file).to_a.sort
354
- assert_equal [[@gem_repo, @usr_sice]],
355
- read_cache(@sic.user_cache_file).to_a.sort
356
- end
357
-
358
- def test_write_cache_user
359
- FileUtils.chmod 0444, @sic.system_cache_file
360
- @sic.set_cache_data({@gem_repo => @sice_new})
361
- @sic.update
362
- @sic.write_cache
363
- @sic.instance_variable_set :@only_latest, false
364
-
365
- assert File.exist?(@sic.user_cache_file), 'user_cache_file'
366
- assert File.exist?(@sic.latest_user_cache_file),
367
- 'latest_user_cache_file exists'
368
-
369
- assert_equal [[@gem_repo, @sys_sice]],
370
- read_cache(@sic.system_cache_file).to_a.sort
371
- assert_equal [[@gem_repo, @sice_new]],
372
- read_cache(@sic.user_cache_file).to_a.sort
373
- end
374
-
375
- def test_write_cache_user_from_scratch
376
- FileUtils.rm_rf @sic.user_cache_file
377
- FileUtils.rm_rf @sic.latest_user_cache_file
378
-
379
- FileUtils.chmod 0444, @sic.system_cache_file
380
- FileUtils.chmod 0444, @sic.latest_system_cache_file
381
-
382
- @si = Gem::SourceIndex.new
383
- @si.add_specs @a1, @a2
384
-
385
- @sice = Gem::SourceInfoCacheEntry.new @si, 0
386
-
387
- @sic.set_cache_data({ @gem_repo => @sice })
388
- @sic.update
389
-
390
- @sic.write_cache
391
-
392
- assert File.exist?(@sic.user_cache_file), 'system_cache_file'
393
- assert File.exist?(@sic.latest_user_cache_file),
394
- 'latest_system_cache_file'
395
-
396
- user_cache_data = read_cache(@sic.user_cache_file).to_a.sort
397
- assert_equal 1, user_cache_data.length, 'user_cache_data length'
398
- user_cache_data = user_cache_data.first
399
-
400
- assert_equal @gem_repo, user_cache_data.first
401
-
402
- gems = user_cache_data.last.source_index.map { |_,spec| spec.full_name }
403
- assert_equal [@a1.full_name, @a2.full_name], gems.sort
404
-
405
- user_cache_data = read_cache(@sic.latest_user_cache_file).to_a.sort
406
- assert_equal 1, user_cache_data.length
407
- user_cache_data = user_cache_data.first
408
-
409
- assert_equal @gem_repo, user_cache_data.first
410
-
411
- gems = user_cache_data.last.source_index.map { |_,spec| spec.full_name }
412
- assert_equal [@a2.full_name], gems
413
- end
414
-
415
- def test_write_cache_user_no_directory
416
- FileUtils.rm_rf File.dirname(@sic.user_cache_file)
417
- FileUtils.chmod 0444, @sic.system_cache_file
418
- @sic.set_cache_data({ @gem_repo => @sice_new })
419
- @sic.update
420
- @sic.write_cache
421
-
422
- assert_equal [[@gem_repo, @sys_sice]],
423
- read_cache(@sic.system_cache_file).to_a.sort
424
- assert_equal [[@gem_repo, @sys_sice]],
425
- read_cache(@sic.user_cache_file).to_a.sort
426
- assert_equal [[@gem_repo, @sice_new]],
427
- read_cache(@sic.latest_user_cache_file).to_a.sort
428
- end
429
-
430
- def test_write_cache_user_only_latest
431
- FileUtils.chmod 0444, @sic.system_cache_file
432
- @sic.set_cache_data({@gem_repo => @sice_new})
433
- @sic.update
434
- @sic.write_cache
435
-
436
- assert File.exist?(@sic.user_cache_file), 'user_cache_file'
437
- assert File.exist?(@sic.latest_user_cache_file),
438
- 'latest_user_cache_file exists'
439
-
440
- assert_equal [[@gem_repo, @sys_sice]],
441
- read_cache(@sic.system_cache_file).to_a.sort
442
- assert_equal [[@gem_repo, @sice_new]],
443
- read_cache(@sic.user_cache_file).to_a.sort
444
- end
445
-
446
- end
447
-