class Gurney::Source::Yarn

Constants

YARN_LOCK_REGEX

Attributes

yarn_lock[R]

Public Class Methods

new(yarn_lock:) click to toggle source
# File lib/gurney/source/yarn.rb, line 7
def initialize(yarn_lock:)
  @yarn_lock = yarn_lock
end

Public Instance Methods

dependencies() click to toggle source
# File lib/gurney/source/yarn.rb, line 15
def dependencies
  if present?
    dependencies = @yarn_lock.scan(YARN_LOCK_REGEX).map{|match| { name: match[0], version: match[1] } }
    dependencies.map { |dependency| Dependency.new(ecosystem: 'npm', **dependency) }
  end
end
present?() click to toggle source
# File lib/gurney/source/yarn.rb, line 11
def present?
  !@yarn_lock.nil?
end