public
Last active

Rubygems 1.8.1 Deprecate Warning Patch

  • Download Gist
rubygems-warning.patch
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
diff --git a/Manifest.txt b/Manifest.txt
index 6e79ebd..6a2f480 100644
--- a/Manifest.txt
+++ b/Manifest.txt
@@ -121,6 +121,7 @@ test/rubygems/rubygems_plugin.rb
test/rubygems/sff/discover.rb
test/rubygems/simple_gem.rb
test/rubygems/test_config.rb
+test/rubygems/test_deprecate.rb
test/rubygems/test_gem.rb
test/rubygems/test_gem_builder.rb
test/rubygems/test_gem_command.rb
diff --git a/lib/rubygems/deprecate.rb b/lib/rubygems/deprecate.rb
index 4827a05..c8783e8 100644
--- a/lib/rubygems/deprecate.rb
+++ b/lib/rubygems/deprecate.rb
@@ -23,7 +23,7 @@
module Deprecate
def self.skip # :nodoc:
- @skip ||= false
+ @skip.nil? ? (@skip = true) : @skip
end
def self.skip= v # :nodoc:
@@ -33,8 +33,8 @@ module Deprecate
##
# Temporarily turn off warnings. Intended for tests only.
- def skip_during
- Deprecate.skip, original = true, Deprecate.skip
+ def skip_during(will_skip = true)
+ Deprecate.skip, original = will_skip, Deprecate.skip
yield
ensure
Deprecate.skip = original
diff --git a/lib/rubygems/install_update_options.rb b/lib/rubygems/install_update_options.rb
index 3ee6432..eea930b 100644
--- a/lib/rubygems/install_update_options.rb
+++ b/lib/rubygems/install_update_options.rb
@@ -115,6 +115,11 @@ module Gem::InstallUpdateOptions
"meeting version requirement") do |value, options|
options[:conservative] = true
end
+
+ add_option(:"Install/Update", "--[no-]warnings",
+ "Display warnings about deprecated methods") do |value, options|
+ Deprecate.skip = !value
+ end
end
##
diff --git a/test/rubygems/test_deprecate.rb b/test/rubygems/test_deprecate.rb
new file mode 100644
index 0000000..08d0744
--- /dev/null
+++ b/test/rubygems/test_deprecate.rb
@@ -0,0 +1,46 @@
+require 'rubygems/test_case'
+require 'rubygems/builder'
+require 'rubygems/package'
+
+require 'rubygems/deprecate'
+
+class TestDeprecate < Gem::TestCase
+
+ def test_defaults
+ assert_equal true, Deprecate.skip
+ end
+
+ def test_assignment
+ Deprecate.skip = false
+
+ assert_equal false, Deprecate.skip
+
+ Deprecate.skip = nil
+
+ assert_equal true, Deprecate.skip
+
+ Deprecate.skip = false
+
+ assert_equal false, Deprecate.skip
+
+ Deprecate.skip = nil
+ end
+
+ def test_skip
+ Deprecate.skip = false
+
+ Deprecate.skip_during do
+ assert_equal true, Deprecate.skip
+ end
+
+ Deprecate.skip_during(false) do
+ assert_equal false, Deprecate.skip
+ end
+
+ Deprecate.skip_during(nil) do
+ assert_equal true, Deprecate.skip
+ end
+
+ Deprecate.skip = nil
+ end
+end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.