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

Constants inherited from GemfileProcessor

GemfileProcessor::GEM_LINE_REGEX, GemfileProcessor::GEM_MATCH_FIELDS

Instance Attribute Summary collapse

Attributes inherited from GemfileProcessor

#options, #path

Instance Method Summary collapse

Methods inherited from GemfileProcessor

#call, #process_gems, #set_gem_version

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(data) ⇒ Object



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

def process_gem(data)
  name = data[:name]
  locked = bundler_specs.find { |x| x.name == name }
  locked && set_gem_version(data, prepare_version(locked.version))
end

#skip_gem?(data) ⇒ Boolean

Returns:

  • (Boolean)


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

def skip_gem?(data)
  super || data[:version] && !options[:force]
end