rubygems-update 0.8.3

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.

Files changed (96) hide show
  1. data/ChangeLog +2335 -0
  2. data/README +54 -0
  3. data/Rakefile +293 -0
  4. data/Releases +98 -0
  5. data/TODO +7 -0
  6. data/bin/gem +11 -0
  7. data/bin/gem_server +111 -0
  8. data/bin/generate_yaml_index.rb +58 -0
  9. data/bin/update_rubygems +18 -0
  10. data/doc/doc.css +73 -0
  11. data/doc/makedoc.rb +4 -0
  12. data/examples/application/an-app.gemspec +26 -0
  13. data/examples/application/bin/myapp +3 -0
  14. data/examples/application/lib/somefunctionality.rb +3 -0
  15. data/gemspecs/README +4 -0
  16. data/gemspecs/cgikit-1.1.0.gemspec +18 -0
  17. data/gemspecs/jabber4r.gemspec +26 -0
  18. data/gemspecs/linguistics.gemspec +22 -0
  19. data/gemspecs/ook.gemspec +21 -0
  20. data/gemspecs/progressbar.gemspec +22 -0
  21. data/gemspecs/redcloth.gemspec +22 -0
  22. data/gemspecs/rublog.gemspec +23 -0
  23. data/gemspecs/ruby-doom.gemspec +21 -0
  24. data/gemspecs/rubyjdwp.gemspec +21 -0
  25. data/gemspecs/statistics.gemspec +21 -0
  26. data/lib/rubygems.rb +353 -0
  27. data/lib/rubygems/builder.rb +54 -0
  28. data/lib/rubygems/cmd_manager.rb +127 -0
  29. data/lib/rubygems/command.rb +191 -0
  30. data/lib/rubygems/config_file.rb +57 -0
  31. data/lib/rubygems/doc_manager.rb +94 -0
  32. data/lib/rubygems/format.rb +65 -0
  33. data/lib/rubygems/gem_commands.rb +925 -0
  34. data/lib/rubygems/gem_runner.rb +23 -0
  35. data/lib/rubygems/installer.rb +621 -0
  36. data/lib/rubygems/loadpath_manager.rb +108 -0
  37. data/lib/rubygems/old_format.rb +150 -0
  38. data/lib/rubygems/open-uri.rb +604 -0
  39. data/lib/rubygems/package.rb +740 -0
  40. data/lib/rubygems/remote_installer.rb +499 -0
  41. data/lib/rubygems/rubygems_version.rb +6 -0
  42. data/lib/rubygems/source_index.rb +130 -0
  43. data/lib/rubygems/specification.rb +613 -0
  44. data/lib/rubygems/user_interaction.rb +176 -0
  45. data/lib/rubygems/validator.rb +148 -0
  46. data/lib/rubygems/version.rb +279 -0
  47. data/lib/ubygems.rb +4 -0
  48. data/pkgs/sources/lib/sources.rb +6 -0
  49. data/pkgs/sources/sources.gemspec +14 -0
  50. data/post-install.rb +75 -0
  51. data/redist/session.gem +433 -0
  52. data/scripts/buildtests.rb +25 -0
  53. data/scripts/gemdoc.rb +62 -0
  54. data/scripts/runtest.rb +17 -0
  55. data/scripts/specdoc.rb +164 -0
  56. data/setup.rb +1360 -0
  57. data/test/bogussources.rb +5 -0
  58. data/test/data/legacy/keyedlist-0.4.0.ruby +11 -0
  59. data/test/data/legacy/keyedlist-0.4.0.yaml +16 -0
  60. data/test/data/lib/code.rb +1 -0
  61. data/test/data/one/README.one +1 -0
  62. data/test/data/one/lib/one.rb +3 -0
  63. data/test/data/one/one.gemspec +17 -0
  64. data/test/data/one/one.yaml +40 -0
  65. data/test/functional.rb +145 -0
  66. data/test/gemenvironment.rb +45 -0
  67. data/test/gemutilities.rb +18 -0
  68. data/test/insure_session.rb +46 -0
  69. data/test/mock/gems/gems/sources-0.0.1/lib/sources.rb +5 -0
  70. data/test/mock/gems/specifications/sources-0.0.1.gemspec +8 -0
  71. data/test/mockgemui.rb +45 -0
  72. data/test/onegem.rb +23 -0
  73. data/test/simple_gem.rb +66 -0
  74. data/test/test_builder.rb +13 -0
  75. data/test/test_cached_fetcher.rb +60 -0
  76. data/test/test_check_command.rb +28 -0
  77. data/test/test_command.rb +130 -0
  78. data/test/test_configfile.rb +36 -0
  79. data/test/test_format.rb +70 -0
  80. data/test/test_gemloadpaths.rb +45 -0
  81. data/test/test_gempaths.rb +115 -0
  82. data/test/test_loadmanager.rb +40 -0
  83. data/test/test_local_cache.rb +157 -0
  84. data/test/test_package.rb +600 -0
  85. data/test/test_parse_commands.rb +179 -0
  86. data/test/test_process_commands.rb +21 -0
  87. data/test/test_remote_fetcher.rb +162 -0
  88. data/test/test_remote_installer.rb +154 -0
  89. data/test/test_source_index.rb +58 -0
  90. data/test/test_specification.rb +286 -0
  91. data/test/test_validator.rb +53 -0
  92. data/test/test_version_comparison.rb +204 -0
  93. data/test/testgem.rc +6 -0
  94. data/test/user_capture.rb +1 -0
  95. data/test/yaml_data.rb +59 -0
  96. metadata +151 -0
@@ -0,0 +1,179 @@
1
+ require 'test/unit'
2
+ $:.unshift '../lib'
3
+ require 'rubygems'
4
+ require 'test/mockgemui'
5
+ Gem::manage_gems
6
+
7
+ class TestParseCommands < Test::Unit::TestCase
8
+ include Gem::DefaultUserInteraction
9
+
10
+ def setup
11
+ @cmd_manager = Gem::CommandManager.new
12
+ end
13
+
14
+ def test_parsing_bad_options
15
+ use_ui(MockGemUi.new) do
16
+ assert_raises(MockGemUi::TermError) {
17
+ @cmd_manager.process_args("--bad-arg")
18
+ }
19
+ assert_match /invalid option: --bad-arg/i, ui.error
20
+ end
21
+ end
22
+
23
+ def test_parsing_install_options
24
+ #capture all install options
25
+ use_ui(MockGemUi.new) do
26
+ check_options = nil
27
+ @cmd_manager['install'].when_invoked do |options|
28
+ check_options = options
29
+ true
30
+ end
31
+
32
+ #check defaults
33
+ @cmd_manager.process_args("install")
34
+ assert_equal false, check_options[:test]
35
+ assert_equal true, check_options[:generate_rdoc]
36
+ assert_equal false, check_options[:force]
37
+ assert_equal :both, check_options[:domain]
38
+ assert_equal "> 0", check_options[:version]
39
+ assert_equal Gem.dir, check_options[:install_dir]
40
+
41
+ #check settings
42
+ check_options = nil
43
+ @cmd_manager.process_args(
44
+ "install --force --test --local --rdoc --install-dir . --version 3.0")
45
+ assert_equal true, check_options[:test]
46
+ assert_equal true, check_options[:generate_rdoc]
47
+ assert_equal true, check_options[:force]
48
+ assert_equal :local, check_options[:domain]
49
+ assert_equal '3.0', check_options[:version]
50
+ assert_equal '.', check_options[:install_dir]
51
+
52
+ #check remote domain
53
+ check_options = nil
54
+ @cmd_manager.process_args("install --remote")
55
+ assert_equal :remote, check_options[:domain]
56
+
57
+ #check both domain
58
+ check_options = nil
59
+ @cmd_manager.process_args("install --both")
60
+ assert_equal :both, check_options[:domain]
61
+
62
+ #check both domain
63
+ check_options = nil
64
+ @cmd_manager.process_args("install --both")
65
+ assert_equal :both, check_options[:domain]
66
+ end
67
+ end
68
+
69
+ def test_parsing_uninstall_options
70
+ #capture all uninstall options
71
+ check_options = nil
72
+ @cmd_manager['uninstall'].when_invoked do |options|
73
+ check_options = options
74
+ true
75
+ end
76
+
77
+ #check defaults
78
+ @cmd_manager.process_args("uninstall")
79
+ assert_equal "> 0", check_options[:version]
80
+
81
+ #check settings
82
+ check_options = nil
83
+ @cmd_manager.process_args("uninstall foobar --version 3.0")
84
+ assert_equal "foobar", check_options[:args].first
85
+ assert_equal "3.0", check_options[:version]
86
+ end
87
+
88
+ def test_parsing_check_options
89
+ #capture all check options
90
+ check_options = nil
91
+ @cmd_manager['check'].when_invoked do |options|
92
+ check_options = options
93
+ true
94
+ end
95
+
96
+ #check defaults
97
+ @cmd_manager.process_args("check")
98
+ assert_equal false, check_options[:verify]
99
+ assert_equal false, check_options[:alien]
100
+
101
+ #check settings
102
+ check_options = nil
103
+ @cmd_manager.process_args("check --verify foobar --alien")
104
+ assert_equal "foobar", check_options[:verify]
105
+ assert_equal true, check_options[:alien]
106
+ end
107
+
108
+ def test_parsing_build_options
109
+ #capture all build options
110
+ check_options = nil
111
+ @cmd_manager['build'].when_invoked do |options|
112
+ check_options = options
113
+ true
114
+ end
115
+
116
+ #check defaults
117
+ @cmd_manager.process_args("build")
118
+ #NOTE: Currently no defaults
119
+
120
+ #check settings
121
+ check_options = nil
122
+ @cmd_manager.process_args("build foobar.rb")
123
+ assert_equal 'foobar.rb', check_options[:args].first
124
+ end
125
+
126
+ def test_parsing_query_options
127
+ #capture all query options
128
+ check_options = nil
129
+ @cmd_manager['query'].when_invoked do |options|
130
+ check_options = options
131
+ true
132
+ end
133
+
134
+ #check defaults
135
+ @cmd_manager.process_args("query")
136
+ assert_equal /.*/, check_options[:name]
137
+ assert_equal :local, check_options[:domain]
138
+ assert_equal false, check_options[:details]
139
+
140
+ #check settings
141
+ check_options = nil
142
+ @cmd_manager.process_args("query --name foobar --local --details")
143
+ assert_equal /foobar/i, check_options[:name]
144
+ assert_equal :local, check_options[:domain]
145
+ assert_equal true, check_options[:details]
146
+
147
+ #remote domain
148
+ check_options = nil
149
+ @cmd_manager.process_args("query --remote")
150
+ assert_equal :remote, check_options[:domain]
151
+
152
+ #both (local/remote) domains
153
+ check_options = nil
154
+ @cmd_manager.process_args("query --both")
155
+ assert_equal :both, check_options[:domain]
156
+ end
157
+
158
+ def test_parsing_update_options
159
+ #capture all update options
160
+ check_options = nil
161
+ @cmd_manager['update'].when_invoked do |options|
162
+ check_options = options
163
+ true
164
+ end
165
+
166
+ #check defaults
167
+ @cmd_manager.process_args("update")
168
+ assert_equal true, check_options[:generate_rdoc]
169
+
170
+ #check settings
171
+ check_options = nil
172
+ @cmd_manager.process_args("update --force --test --rdoc --install-dir .")
173
+ assert_equal true, check_options[:test]
174
+ assert_equal true, check_options[:generate_rdoc]
175
+ assert_equal true, check_options[:force]
176
+ assert_equal '.', check_options[:install_dir]
177
+ end
178
+
179
+ end
@@ -0,0 +1,21 @@
1
+ require 'test/unit'
2
+ $:.unshift '../lib'
3
+ require 'rubygems'
4
+ Gem::manage_gems
5
+
6
+ require 'test/mockgemui'
7
+
8
+ class TestProcessCommands < Test::Unit::TestCase
9
+ include Gem::DefaultUserInteraction
10
+
11
+ def setup
12
+ @cmd_manager = Gem::CommandManager.new
13
+ end
14
+
15
+ def test_query_command
16
+ use_ui(MockGemUi.new) do
17
+ @cmd_manager.process_args "query"
18
+ assert_match /LOCAL GEMS/, ui.output
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,162 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ require 'zlib'
5
+ require 'webrick'
6
+ require 'rubygems'
7
+
8
+ require 'test/mockgemui'
9
+ require 'test/yaml_data'
10
+
11
+ Gem.manage_gems
12
+ include WEBrick
13
+
14
+ class TestRemoteFetcher < Test::Unit::TestCase
15
+ include Gem::DefaultUserInteraction
16
+
17
+ def setup
18
+ self.class.start_servers
19
+ self.class.enable_yaml = true
20
+ self.class.enable_zip = false
21
+ ENV['http_proxy'] = nil
22
+ ENV['HTTP_PROXY'] = nil
23
+ end
24
+
25
+
26
+ def test_no_proxy
27
+ use_ui(MockGemUi.new) do
28
+ fetcher = Gem::RemoteSourceFetcher.new("http://localhost:12344", nil)
29
+ assert_equal YAML_DATA, fetcher.fetch_path("/yaml")
30
+ assert_equal YAML_DATA.size, fetcher.size
31
+ source_index = fetcher.source_index
32
+ gems = source_index.search('rake', "= 0.4.11")
33
+ assert_equal 1, gems.size
34
+ assert_equal "rake", gems.first.name
35
+ end
36
+ end
37
+
38
+ def test_explicit_proxy
39
+ use_ui(MockGemUi.new) do
40
+ fetcher = Gem::RemoteSourceFetcher.new("http://localhost:12344", "http://localhost:12345")
41
+ assert_equal PROXY_DATA.size, fetcher.size
42
+ assert_equal PROXY_DATA, fetcher.fetch_path("/yaml")
43
+ source_index = fetcher.source_index
44
+ gems = source_index.search('rake', "= 0.4.2")
45
+ assert_equal 1, gems.size
46
+ assert_equal "rake", gems.first.name
47
+ end
48
+ end
49
+
50
+ def test_implicit_proxy
51
+ use_ui(MockGemUi.new) do
52
+ ENV['http_proxy'] = 'http://localhost:12345'
53
+ fetcher = Gem::RemoteSourceFetcher.new("http://localhost:12344", true)
54
+ assert_equal PROXY_DATA, fetcher.fetch_path("/yaml")
55
+ end
56
+ end
57
+
58
+ def test_implicit_upper_case_proxy
59
+ use_ui(MockGemUi.new) do
60
+ ENV['HTTP_PROXY'] = 'http://localhost:12345'
61
+ fetcher = Gem::RemoteSourceFetcher.new("http://localhost:12344", true)
62
+ assert_equal PROXY_DATA, fetcher.fetch_path("/yaml")
63
+ end
64
+ end
65
+
66
+ def test_implicit_proxy_no_env
67
+ use_ui(MockGemUi.new) do
68
+ fetcher = Gem::RemoteSourceFetcher.new("http://localhost:12344", true)
69
+ assert_equal YAML_DATA, fetcher.fetch_path("/yaml")
70
+ end
71
+ end
72
+
73
+ def test_zip
74
+ use_ui(MockGemUi.new) do
75
+ self.class.enable_zip = true
76
+ fetcher = Gem::RemoteSourceFetcher.new("http://localhost:12344", nil)
77
+ assert_equal YAML_DATA.size, fetcher.size
78
+ zip_data = fetcher.fetch_path("/yaml.Z")
79
+ assert zip_data.size < YAML_DATA.size
80
+ end
81
+ end
82
+
83
+ def test_no_zip
84
+ use_ui(MockGemUi.new) do
85
+ fetcher = Gem::RemoteSourceFetcher.new("http://localhost:12344", nil)
86
+ assert_error { fetcher.fetch_path("/yaml.Z") }
87
+ end
88
+ end
89
+
90
+ def test_yaml_error_on_size
91
+ use_ui(MockGemUi.new) do
92
+ self.class.enable_yaml = false
93
+ fetcher = Gem::RemoteSourceFetcher.new("http://localhost:12344", nil)
94
+ assert_error { fetcher.size }
95
+ end
96
+ end
97
+
98
+ def assert_error(exception_class=Exception)
99
+ got_exception = false
100
+ begin
101
+ yield
102
+ rescue exception_class => ex
103
+ got_exception = true
104
+ end
105
+ assert got_exception, "Expected exception conforming to #{exception_class}"
106
+ end
107
+
108
+ class << self
109
+ attr_reader :normal_server, :proxy_server
110
+ attr_accessor :enable_zip, :enable_yaml
111
+
112
+ def start_servers
113
+ @normal_server ||= start_server(12344, YAML_DATA)
114
+ @proxy_server ||= start_server(12345, PROXY_DATA)
115
+ @enable_yaml = true
116
+ @enable_zip = false
117
+ sleep 1
118
+ end
119
+
120
+ private
121
+
122
+ def start_server(port, data)
123
+ Thread.new do
124
+ begin
125
+ null_logger = Log.new('/dev/null')
126
+ s = HTTPServer.new(
127
+ :Port => port,
128
+ :DocumentRoot => ".",
129
+ :Logger => null_logger,
130
+ :AccessLog => null_logger
131
+ )
132
+ s.mount_proc("/kill") { |req, res| s.shutdown }
133
+ s.mount_proc("/yaml") { |req, res|
134
+ if @enable_yaml
135
+ res.body = data
136
+ res['Content-Type'] = 'text/plain'
137
+ res['content-length'] = data.size
138
+ else
139
+ res.code = "404"
140
+ res.body = "<h1>NOT FOUND</h1>"
141
+ res['Content-Type'] = 'text/html'
142
+ end
143
+ }
144
+ s.mount_proc("/yaml.Z") { |req, res|
145
+ if @enable_zip
146
+ res.body = Zlib::Deflate.deflate(data)
147
+ res['Content-Type'] = 'text/plain'
148
+ else
149
+ res.code = "404"
150
+ res.body = "<h1>NOT FOUND</h1>"
151
+ res['Content-Type'] = 'text/html'
152
+ end
153
+ }
154
+ s.start
155
+ rescue Exception => ex
156
+ puts "ERROR during server thread: #{ex.message}"
157
+ end
158
+ end
159
+ end
160
+ end
161
+
162
+ end
@@ -0,0 +1,154 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ Gem::manage_gems
4
+ require 'net/http'
5
+ require 'yaml'
6
+ require 'test/onegem'
7
+
8
+ class MockFetcher
9
+ def initialize(uri, proxy)
10
+ @uri = uri
11
+ end
12
+
13
+ def size
14
+ 1000
15
+ end
16
+
17
+ def source_index
18
+ if @uri =~ /non.existent.url/
19
+ fail Gem::RemoteSourceException,
20
+ "Error fetching remote gem cache: Mock Socket Exception"
21
+ end
22
+ result = {
23
+ 'foo-1.2.3' => Gem::Specification.new do |s|
24
+ s.name = 'foo'
25
+ s.version = "1.2.3"
26
+ s.summary = "This is a cool package"
27
+ end
28
+ }
29
+ result
30
+ end
31
+
32
+ def fetch_path(path)
33
+ end
34
+
35
+ def self.finish
36
+ end
37
+ end
38
+
39
+ class TestRemoteInstaller < Test::Unit::TestCase
40
+
41
+ PROPER_SOURCES = %w( http://gems.rubyforge.org )
42
+
43
+ def setup
44
+ Gem.clear_paths
45
+ @installer = Gem::RemoteInstaller.new
46
+ @installer.instance_variable_set("@fetcher_class", MockFetcher)
47
+ end
48
+
49
+ def test_create
50
+ assert_not_nil(@installer)
51
+ end
52
+
53
+ # Make sure that the installer knows the proper list of places to go
54
+ # to get packages.
55
+ def test_source_list
56
+ assert_equal PROPER_SOURCES, @installer.sources
57
+ end
58
+
59
+ def test_source_index_hash
60
+ source_hash = @installer.source_index_hash
61
+ assert source_hash.has_key?("http://gems.rubyforge.org")
62
+ assert_equal 1, source_hash.size
63
+ gem_hash = source_hash['http://gems.rubyforge.org']
64
+ spec = gem_hash['foo-1.2.3']
65
+ assert_equal 'foo', spec.name
66
+ assert_equal '1.2.3', spec.version.to_s
67
+ end
68
+
69
+ def test_missing_source_exception
70
+ @installer.instance_variable_set("@sources", ["http://non.existent.url"])
71
+ assert_raise(Gem::RemoteSourceException) {
72
+ info = @installer.source_index_hash
73
+ }
74
+ end
75
+ end
76
+
77
+ # This test suite has a number of TODOs in the test cases. The
78
+ # TestRemoteInstaller test suite is a reworking of this class from
79
+ # scratch.
80
+ class RemoteInstallerTest < Test::Unit::TestCase
81
+ class RInst < Gem::RemoteInstaller
82
+ include Test::Unit::Assertions
83
+
84
+ attr_accessor :expected_destination_files
85
+ attr_accessor :expected_bodies
86
+ attr_accessor :caches
87
+ attr_accessor :responses
88
+
89
+ def source_index_hash
90
+ @caches
91
+ end
92
+
93
+ def fetch(uri)
94
+ @reponses ||= {}
95
+ @responses[uri]
96
+ end
97
+
98
+ def write_gem_to_file(body, destination_file)
99
+ expected_destination_file = expected_destination_files.pop
100
+ expected_body = expected_bodies.pop
101
+ assert_equal expected_body, body, "Unexpected body"
102
+ assert_equal expected_destination_file, destination_file, "Unexpected destination file"
103
+ end
104
+
105
+ def new_installer(gem)
106
+ return MockInstaller.new(gem)
107
+ end
108
+ end
109
+
110
+ CACHE_SOURCES = ["http://gems.rubyforge.org"]
111
+
112
+ def setup
113
+ Gem.clear_paths
114
+ @remote_installer = Gem::RemoteInstaller.new
115
+ @remote_installer.instance_eval { @fetcher_class = MockFetcher }
116
+ end
117
+
118
+ def test_sources
119
+ assert_equal CACHE_SOURCES, @remote_installer.sources
120
+ end
121
+
122
+ def test_source_index_hash
123
+ source_index_hash = @remote_installer.source_index_hash
124
+ assert_equal 1, source_index_hash.keys.size
125
+ end
126
+
127
+ def test_find_latest_valid_package_in_caches(cache)
128
+ end
129
+
130
+ def test_download_file
131
+ end
132
+
133
+ SAMPLE_SPEC = Gem::Specification.new do |s|
134
+ s.name = 'foo'
135
+ s.version = "1.2.3"
136
+ s.platform = Gem::Platform::RUBY
137
+ s.summary = "This is a cool package"
138
+ s.files = []
139
+ end
140
+ SAMPLE_CACHE = { 'foo-1.2.3' => SAMPLE_SPEC }
141
+ SAMPLE_CACHE_YAML = SAMPLE_CACHE.to_yaml
142
+
143
+ FOO_GEM = '' # TODO
144
+ CACHE_DIR = File.join(Gem.dir, 'cache')
145
+
146
+ # Disable this test for now. We will come back to revisit this.
147
+ def disable_test_install
148
+ Gem.use_paths("test/data/gemhome")
149
+ result = @remote_installer.install('foo')
150
+ assert_equal [nil], result
151
+ end
152
+
153
+ end
154
+