gem_require 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -84,7 +84,7 @@ and installs them if necessary.
84
84
  def require_gem(name, version, installer_options)
85
85
 
86
86
  dependency = Gem::Dependency.new(name, version)
87
- installed = Gem.source_index.search(dependency).last
87
+ installed = latest_installed_version_of(dependency)
88
88
 
89
89
  if installed && options[:latest]
90
90
  latest_version = latest_available_version_of(dependency)
@@ -103,6 +103,15 @@ and installs them if necessary.
103
103
 
104
104
  end
105
105
 
106
+ def latest_installed_version_of(dependency)
107
+ if dependency.respond_to?(:matching_specs)
108
+ # Rubygems 1.8+
109
+ dependency.matching_specs.last
110
+ else
111
+ Gem.source_index.search(dependency).last
112
+ end
113
+ end
114
+
106
115
  def latest_available_version_of(dependency)
107
116
  Gem::SpecFetcher.fetcher.fetch(dependency).map { |x| x.first.version }.max
108
117
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: gem_require
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Mike Williams
@@ -10,8 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-19 00:00:00 +11:00
14
- default_executable:
13
+ date: 2011-05-09 00:00:00 Z
15
14
  dependencies: []
16
15
 
17
16
  description: |-
@@ -27,7 +26,6 @@ extra_rdoc_files: []
27
26
  files:
28
27
  - lib/rubygems/commands/require_command.rb
29
28
  - lib/rubygems_plugin.rb
30
- has_rdoc: true
31
29
  homepage: http://github.com/mdub/gem_require
32
30
  licenses: []
33
31
 
@@ -51,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
51
49
  requirements: []
52
50
 
53
51
  rubyforge_project:
54
- rubygems_version: 1.6.1
52
+ rubygems_version: 1.8.1
55
53
  signing_key:
56
54
  specification_version: 3
57
55
  summary: Add the 'gem require' command