Class: Bundler::AsOf::VersionFinder
- Inherits:
-
Object
- Object
- Bundler::AsOf::VersionFinder
- Defined in:
- lib/bundler/as_of.rb
Instance Method Summary collapse
- #gem_releases ⇒ Object
- #gem_url ⇒ Object
-
#initialize(dependency, as_of_date) ⇒ VersionFinder
constructor
A new instance of VersionFinder.
- #releases ⇒ Object
- #resolve ⇒ Object
Constructor Details
#initialize(dependency, as_of_date) ⇒ VersionFinder
Returns a new instance of VersionFinder.
80 81 82 83 |
# File 'lib/bundler/as_of.rb', line 80 def initialize(dependency, as_of_date) @dependency = dependency @as_of_date = as_of_date end |
Instance Method Details
#gem_releases ⇒ Object
100 101 102 103 104 |
# File 'lib/bundler/as_of.rb', line 100 def gem_releases @gem_releases ||= JSON.parse(::URI.parse(gem_url).open.read) .map { |r| ReleaseWrapper.new(@dependency.name, r) } end |
#gem_url ⇒ Object
106 107 108 |
# File 'lib/bundler/as_of.rb', line 106 def gem_url @gem_url ||= "https://rubygems.org/api/v1/versions/#{@dependency.name}.json" end |
#releases ⇒ Object
93 94 95 96 97 98 |
# File 'lib/bundler/as_of.rb', line 93 def releases gem_releases .select { |r| r.date <= @as_of_date } .sort_by { |r| [r.date, r.version] } .reverse end |
#resolve ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/bundler/as_of.rb', line 85 def resolve releases.each do |release| next if release.prerelease return release if @dependency.requirement.satisfied_by?(release.version) end nil end |