update_hints 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/History.txt +4 -0
  2. data/lib/update_hints.rb +5 -20
  3. metadata +2 -2
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 1.0.2 / 2011-05-25
2
+
3
+ * Use the Gem::Version for version comparisons
4
+
1
5
  === 1.0.1 / 2011-05-25
2
6
 
3
7
  * End the last line of output with a newline (doh!)
data/lib/update_hints.rb CHANGED
@@ -2,9 +2,10 @@ require "net/http"
2
2
  require "open-uri"
3
3
  require "timeout"
4
4
  require "rexml/document"
5
+ require "rubygems"
5
6
 
6
7
  module UpdateHints
7
- VERSION = '1.0.1'
8
+ VERSION = '1.0.2'
8
9
  GEMCUTTER_URI = "http://rubygems.org/api/v1/gems/%s.xml"
9
10
 
10
11
  # Checks whether rubygems.org has a new version of this specific gem
@@ -22,7 +23,9 @@ module UpdateHints
22
23
 
23
24
  def self.version_check_without_exception_suppression(gem_name, present_version_str, destination)
24
25
  latest_version = extract_version_from_xml(open(GEMCUTTER_URI % gem_name))
25
- int_present, int_available = Version.new(present_version_str), Version.new(latest_version)
26
+ # Gem::Version was known to throw when a frozen string is passed to the constructor, see
27
+ # https://github.com/rubygems/rubygems/commit/48f1d869510dcd325d6566df7d0147a086905380
28
+ int_present, int_available = Gem::Version.new(present_version_str.dup), Gem::Version.new(latest_version.dup)
26
29
  if int_available > int_present
27
30
  destination << "Your version of #{gem_name} is probably out of date\n"
28
31
  destination << "(the current version is #{latest_version}, but you have #{present_version_str}).\n"
@@ -35,24 +38,6 @@ module UpdateHints
35
38
  super
36
39
  end
37
40
 
38
- #:nodoc:
39
- class Version
40
- include Comparable
41
-
42
- attr_reader :major, :minor, :tiny
43
- def initialize(version_str)
44
- @major, @minor, @tiny = version_str.split(".").map{|e| e.to_i }
45
- end
46
-
47
- def <=>(other)
48
- [:major, :minor, :tiny].each do | ver_part |
49
- mine, theirs = send(ver_part), other.send(ver_part)
50
- return mine <=> theirs unless mine == theirs
51
- end
52
- return 0
53
- end
54
- end
55
-
56
41
  def self.extract_version_from_xml(io)
57
42
  doc = REXML::Document.new(io)
58
43
  version_text = doc.elements["rubygem/version"].text
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: update_hints
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.1
5
+ version: 1.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Julik Tarkhanov
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-28 00:00:00 Z
13
+ date: 2011-09-14 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: flexmock