Module: Brakecheck
- Defined in:
- lib/brakecheck.rb,
lib/brakecheck/version.rb
Constant Summary collapse
- RUBYGEMS_HOST =
"https://rubygems.org"- LOCK =
Bundler.default_lockfile
- VERSION =
"0.2.2"
Class Method Summary collapse
Class Method Details
.compare(gem_name) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/brakecheck.rb', line 18 def self.compare(gem_name) return [false, "#{gem_name} not found in #{LOCK.basename}"] unless local = local(gem_name) return [false, "#{gem_name} not found on #{RUBYGEMS_HOST}"] unless latest = latest(gem_name) if latest == local [true, "Latest #{gem_name} #{latest} installed"] else [false, "Local version #{local} of #{gem_name} is not the latest version #{latest}"] end end |
.latest(gem_name) ⇒ Object
8 9 10 |
# File 'lib/brakecheck.rb', line 8 def self.latest(gem_name) Gem.latest_version_for(gem_name) end |
.local(gem_name) ⇒ Object
12 13 14 15 16 |
# File 'lib/brakecheck.rb', line 12 def self.local(gem_name) lock = Bundler::LockfileParser.new(Bundler.read_file(LOCK)) return unless spec = lock.specs.detect { |s| s.name == gem_name } spec.version end |