Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
@drbrain drbrain authored
View
4 ChangeLog
@@ -1,5 +1,9 @@
# -*- coding: utf-8 -*-
+2010-02-08 Eric Hodel <drbrain@segment7.net>
+
+ * lib/rubygems/commands/dependency_command.rb: Support --prerelease.
+
2010-02-07 Eric Hodel <drbrain@segment7.net>
* lib/rubygems/dependency_installer.rb: Allow prerelease gems to
View
7 lib/rubygems/commands/dependency_command.rb
@@ -15,6 +15,7 @@ def initialize
add_version_option
add_platform_option
+ add_prerelease_option
add_option('-R', '--[no-]reverse-dependencies',
'Include reverse dependencies in the output') do
@@ -59,6 +60,7 @@ def execute
end
dependency = Gem::Dependency.new pattern, options[:version]
+ dependency.prerelease = options[:prerelease]
if options[:reverse_dependencies] and remote? and not local? then
alert_error 'Only reverse dependencies for local gems are supported.'
@@ -75,7 +77,10 @@ def execute
fetcher = Gem::SpecFetcher.fetcher
begin
- fetcher.find_matching(dependency).each do |spec_tuple, source_uri|
+ specs_and_sources = fetcher.find_matching(dependency, false, true,
+ dependency.prerelease?)
+
+ specs_and_sources.each do |spec_tuple, source_uri|
spec = fetcher.fetch_spec spec_tuple, URI.parse(source_uri)
source_indexes[source_uri].add_spec spec
View
1  lib/rubygems/commands/install_command.rb
@@ -32,6 +32,7 @@ def initialize
add_local_remote_options
add_platform_option
add_version_option
+ add_prerelease_option "to be installed. (Only for listed gems)"
end
def arguments # :nodoc:
View
2  lib/rubygems/commands/update_command.rb
@@ -28,8 +28,8 @@ def initialize
end
add_local_remote_options
-
add_platform_option
+ add_prerelease_option "as update targets"
end
def arguments # :nodoc:
View
7 lib/rubygems/install_update_options.rb
@@ -104,13 +104,6 @@ def add_install_update_options
"dependencies") do |value, options|
options[:development] = true
end
-
- add_option(:"Install/Update", "--prerelease",
- "Install prerelease versions of a gem if",
- "available. Defaults to skipping",
- "prereleases.") do |value, options|
- options[:prerelease] = true
- end
end
##
View
10 lib/rubygems/version_option.rb
@@ -36,6 +36,16 @@ def add_platform_option(task = command, *wrap)
end
##
+ # Add the --prerelease option to the option parser.
+
+ def add_prerelease_option(*wrap)
+ add_option("--[no-]prerelease",
+ "Allow prerelease versions of a gem", *wrap) do |value, options|
+ options[:prerelease] = value
+ end
+ end
+
+ ##
# Add the --version option to the option parser.
def add_version_option(task = command, *wrap)
View
26 test/test_gem_commands_dependency_command.rb
@@ -9,7 +9,7 @@ def setup
@cmd = Gem::Commands::DependencyCommand.new
@cmd.options[:domain] = :local
- util_setup_fake_fetcher
+ util_setup_fake_fetcher true
end
def test_execute
@@ -43,6 +43,8 @@ def test_execute_no_args
expected = <<-EOF
Gem a-1
+Gem a-2.a
+
Gem a-2
Gem a-3.a
@@ -102,6 +104,8 @@ def test_execute_regexp
expected = <<-EOF
Gem a-1
+Gem a-2.a
+
Gem a-2
Gem a-3.a
@@ -188,5 +192,25 @@ def test_execute_remote
assert_equal '', @ui.error
end
+ def test_execute_prerelease
+ @fetcher = Gem::FakeFetcher.new
+ Gem::RemoteFetcher.fetcher = @fetcher
+
+ util_setup_spec_fetcher @a2_pre
+
+ FileUtils.rm File.join(@gemhome, 'specifications', @a2_pre.spec_name)
+
+ @cmd.options[:args] = %w[a]
+ @cmd.options[:domain] = :remote
+ @cmd.options[:prerelease] = true
+
+ use_ui @ui do
+ @cmd.execute
+ end
+
+ assert_equal "Gem a-2.a\n\n", @ui.output
+ assert_equal '', @ui.error
+ end
+
end
View
5 test/test_gem_install_update_options.rb
@@ -19,11 +19,6 @@ def test_add_install_update_options
assert @cmd.handles?(args)
end
- def test_prerelease
- @cmd.handle_options %w[--prerelease]
- assert_equal true, @cmd.options[:prerelease]
- end
-
def test_security_policy
@cmd.handle_options %w[-P HighSecurity]
Please sign in to comment.
Something went wrong with that request. Please try again.