Class: RuboCop::Lockfile Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/lockfile.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Encapsulation of a lockfile for use when checking for gems. Does not actually resolve gems, just parses the lockfile.

Instance Method Summary collapse

Instance Method Details

#dependenciesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Gems that the bundle depends on



9
10
11
12
13
# File 'lib/rubocop/lockfile.rb', line 9

def dependencies
  return [] unless parser

  parser.dependencies.values
end

#gemsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

All activated gems, including transitive dependencies



16
17
18
19
20
21
22
# File 'lib/rubocop/lockfile.rb', line 16

def gems
  return [] unless parser

  # `Bundler::LockfileParser` returns `Bundler::LazySpecification` objects
  # which are not resolved, so extract the dependencies from them
  parser.dependencies.values.concat(parser.specs.flat_map(&:dependencies))
end

#includes_gem?(name) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


24
25
26
# File 'lib/rubocop/lockfile.rb', line 24

def includes_gem?(name)
  gems.any? { |gem| gem.name == name }
end