Module: Gem::BundlerVersionFinder
- Defined in:
- lib/rubygems/bundler_version_finder.rb
Class Method Summary collapse
- .bundler_version ⇒ Object
- .bundler_version_with_reason ⇒ Object
- .compatible?(spec) ⇒ Boolean
- .filter!(specs) ⇒ Object
- .missing_version_message ⇒ Object
- .without_filtering ⇒ Object
Class Method Details
.bundler_version ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/rubygems/bundler_version_finder.rb', line 15 def self.bundler_version version, _ = bundler_version_with_reason return unless version Gem::Version.new(version) end |
.bundler_version_with_reason ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rubygems/bundler_version_finder.rb', line 23 def self.bundler_version_with_reason return if @without_filtering if v = ENV["BUNDLER_VERSION"] return [v, "`$BUNDLER_VERSION`"] end if v = bundle_update_bundler_version return if v == true return [v, "`bundle update --bundler`"] end v, lockfile = lockfile_version if v return [v, "your #{lockfile}"] end end |
.compatible?(spec) ⇒ Boolean
48 49 50 51 52 53 54 55 56 |
# File 'lib/rubygems/bundler_version_finder.rb', line 48 def self.compatible?(spec) return true unless spec.name == "bundler".freeze return true unless bundler_version = self.bundler_version if bundler_version.segments.first >= 2 spec.version == bundler_version else # 1.x spec.version.segments.first < 2 end end |
.filter!(specs) ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/rubygems/bundler_version_finder.rb', line 58 def self.filter!(specs) return unless bundler_version = self.bundler_version if bundler_version.segments.first >= 2 specs.reject! { |spec| spec.version != bundler_version } else # 1.x specs.reject! { |spec| spec.version.segments.first >= 2} end end |
.missing_version_message ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/rubygems/bundler_version_finder.rb', line 39 def self. return unless vr = bundler_version_with_reason "Could not find 'bundler' (\#{vr.first}) required by \#{vr.last}.\nTo update to the lastest version installed on your system, run `bundle update --bundler`.\nTo install the missing version, run `gem install bundler:\#{vr.first}`\n" end |
.without_filtering ⇒ Object
8 9 10 11 12 13 |
# File 'lib/rubygems/bundler_version_finder.rb', line 8 def self.without_filtering without_filtering, @without_filtering = true, @without_filtering yield ensure @without_filtering = without_filtering end |