Class: Reviewer::Setup::GemfileLock

Inherits:
Object
  • Object
show all
Defined in:
lib/reviewer/setup/gemfile_lock.rb

Overview

Parses a Gemfile.lock to extract gem names from the specs section

Constant Summary collapse

SPEC_LINE =

Spec lines are indented with 4 spaces: “ gem-name (version)”

/\A {4}(\S+)\s/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ GemfileLock

Creates a parser for extracting gem names from a Gemfile.lock

Parameters:

  • path (Pathname)

    the path to the Gemfile.lock file



16
17
18
# File 'lib/reviewer/setup/gemfile_lock.rb', line 16

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



10
11
12
# File 'lib/reviewer/setup/gemfile_lock.rb', line 10

def path
  @path
end

Instance Method Details

#gem_namesSet<String>

Returns the set of gem names found in the specs section

Returns:

  • (Set<String>)

    gem names



23
24
25
26
27
# File 'lib/reviewer/setup/gemfile_lock.rb', line 23

def gem_names
  return Set.new unless path.exist?

  parse_specs
end