Class: GemfileLocker::Locker

Inherits:
GemfileProcessor show all
Defined in:
lib/gemfile_locker/locker.rb

Constant Summary collapse

SEGMENTS_COUNT =
{
  major: 1,
  minor: 2,
  patch: 3,
  full: 100,
}.freeze

Instance Attribute Summary collapse

Attributes inherited from GemfileProcessor

#options, #path

Instance Method Summary collapse

Methods inherited from GemfileProcessor

#call

Constructor Details

#initialize(lockfile, *args) ⇒ Locker

Returns a new instance of Locker.



14
15
16
17
# File 'lib/gemfile_locker/locker.rb', line 14

def initialize(lockfile, *args)
  @lockfile = lockfile
  super(*args)
end

Instance Attribute Details

#lockfileObject (readonly)

Returns the value of attribute lockfile.



12
13
14
# File 'lib/gemfile_locker/locker.rb', line 12

def lockfile
  @lockfile
end

Instance Method Details

#bundler_specsObject



19
20
21
# File 'lib/gemfile_locker/locker.rb', line 19

def bundler_specs
  @bundler_specs ||= Bundler::LockfileParser.new(lockfile).specs
end

#process_gem(gem_entry) ⇒ Object



23
24
25
26
27
28
# File 'lib/gemfile_locker/locker.rb', line 23

def process_gem(gem_entry)
  name = gem_entry.name
  spec = bundler_specs.find { |x| x.name == name }
  return unless spec
  gem_entry.lock(version: prepare_version(spec.version), git_ref: prepare_git_ref(spec))
end

#skip_gem?(gem_entry) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/gemfile_locker/locker.rb', line 30

def skip_gem?(gem_entry)
  super || gem_entry.locked? && !options[:force]
end