Skip to content
This repository
Browse code

Support --prerelease for gem dep

git-svn-id: svn+ssh://rubyforge.org/var/svn/rubygems/trunk@2371 3d4018f9-ac1a-0410-99e9-8a154d859a19
  • Loading branch information...
commit 217c884d03f71657665888ad0153f7879d5bc0c4 1 parent 240822f
Eric Hodel drbrain authored
4 ChangeLog
... ... @@ -1,5 +1,9 @@
1 1 # -*- coding: utf-8 -*-
2 2
  3 +2010-02-08 Eric Hodel <drbrain@segment7.net>
  4 +
  5 + * lib/rubygems/commands/dependency_command.rb: Support --prerelease.
  6 +
3 7 2010-02-07 Eric Hodel <drbrain@segment7.net>
4 8
5 9 * lib/rubygems/dependency_installer.rb: Allow prerelease gems to
7 lib/rubygems/commands/dependency_command.rb
@@ -15,6 +15,7 @@ def initialize
15 15
16 16 add_version_option
17 17 add_platform_option
  18 + add_prerelease_option
18 19
19 20 add_option('-R', '--[no-]reverse-dependencies',
20 21 'Include reverse dependencies in the output') do
@@ -59,6 +60,7 @@ def execute
59 60 end
60 61
61 62 dependency = Gem::Dependency.new pattern, options[:version]
  63 + dependency.prerelease = options[:prerelease]
62 64
63 65 if options[:reverse_dependencies] and remote? and not local? then
64 66 alert_error 'Only reverse dependencies for local gems are supported.'
@@ -75,7 +77,10 @@ def execute
75 77 fetcher = Gem::SpecFetcher.fetcher
76 78
77 79 begin
78   - fetcher.find_matching(dependency).each do |spec_tuple, source_uri|
  80 + specs_and_sources = fetcher.find_matching(dependency, false, true,
  81 + dependency.prerelease?)
  82 +
  83 + specs_and_sources.each do |spec_tuple, source_uri|
79 84 spec = fetcher.fetch_spec spec_tuple, URI.parse(source_uri)
80 85
81 86 source_indexes[source_uri].add_spec spec
1  lib/rubygems/commands/install_command.rb
@@ -32,6 +32,7 @@ def initialize
32 32 add_local_remote_options
33 33 add_platform_option
34 34 add_version_option
  35 + add_prerelease_option "to be installed. (Only for listed gems)"
35 36 end
36 37
37 38 def arguments # :nodoc:
2  lib/rubygems/commands/update_command.rb
@@ -28,8 +28,8 @@ def initialize
28 28 end
29 29
30 30 add_local_remote_options
31   -
32 31 add_platform_option
  32 + add_prerelease_option "as update targets"
33 33 end
34 34
35 35 def arguments # :nodoc:
7 lib/rubygems/install_update_options.rb
@@ -104,13 +104,6 @@ def add_install_update_options
104 104 "dependencies") do |value, options|
105 105 options[:development] = true
106 106 end
107   -
108   - add_option(:"Install/Update", "--prerelease",
109   - "Install prerelease versions of a gem if",
110   - "available. Defaults to skipping",
111   - "prereleases.") do |value, options|
112   - options[:prerelease] = true
113   - end
114 107 end
115 108
116 109 ##
10 lib/rubygems/version_option.rb
@@ -36,6 +36,16 @@ def add_platform_option(task = command, *wrap)
36 36 end
37 37
38 38 ##
  39 + # Add the --prerelease option to the option parser.
  40 +
  41 + def add_prerelease_option(*wrap)
  42 + add_option("--[no-]prerelease",
  43 + "Allow prerelease versions of a gem", *wrap) do |value, options|
  44 + options[:prerelease] = value
  45 + end
  46 + end
  47 +
  48 + ##
39 49 # Add the --version option to the option parser.
40 50
41 51 def add_version_option(task = command, *wrap)
26 test/test_gem_commands_dependency_command.rb
@@ -9,7 +9,7 @@ def setup
9 9 @cmd = Gem::Commands::DependencyCommand.new
10 10 @cmd.options[:domain] = :local
11 11
12   - util_setup_fake_fetcher
  12 + util_setup_fake_fetcher true
13 13 end
14 14
15 15 def test_execute
@@ -43,6 +43,8 @@ def test_execute_no_args
43 43 expected = <<-EOF
44 44 Gem a-1
45 45
  46 +Gem a-2.a
  47 +
46 48 Gem a-2
47 49
48 50 Gem a-3.a
@@ -102,6 +104,8 @@ def test_execute_regexp
102 104 expected = <<-EOF
103 105 Gem a-1
104 106
  107 +Gem a-2.a
  108 +
105 109 Gem a-2
106 110
107 111 Gem a-3.a
@@ -188,5 +192,25 @@ def test_execute_remote
188 192 assert_equal '', @ui.error
189 193 end
190 194
  195 + def test_execute_prerelease
  196 + @fetcher = Gem::FakeFetcher.new
  197 + Gem::RemoteFetcher.fetcher = @fetcher
  198 +
  199 + util_setup_spec_fetcher @a2_pre
  200 +
  201 + FileUtils.rm File.join(@gemhome, 'specifications', @a2_pre.spec_name)
  202 +
  203 + @cmd.options[:args] = %w[a]
  204 + @cmd.options[:domain] = :remote
  205 + @cmd.options[:prerelease] = true
  206 +
  207 + use_ui @ui do
  208 + @cmd.execute
  209 + end
  210 +
  211 + assert_equal "Gem a-2.a\n\n", @ui.output
  212 + assert_equal '', @ui.error
  213 + end
  214 +
191 215 end
192 216
5 test/test_gem_install_update_options.rb
@@ -19,11 +19,6 @@ def test_add_install_update_options
19 19 assert @cmd.handles?(args)
20 20 end
21 21
22   - def test_prerelease
23   - @cmd.handle_options %w[--prerelease]
24   - assert_equal true, @cmd.options[:prerelease]
25   - end
26   -
27 22 def test_security_policy
28 23 @cmd.handle_options %w[-P HighSecurity]
29 24

0 comments on commit 217c884

Please sign in to comment.
Something went wrong with that request. Please try again.