Class: Gurney::Source::Yarn
Constant Summary collapse
- YARN_LOCK_REGEX =
/^"?(?<name>\S*)@.+?"?:\n\s{2}version "(?<version>.+?)"$/m
Instance Method Summary collapse
- #dependencies ⇒ Object
-
#initialize(yarn_lock:) ⇒ Yarn
constructor
A new instance of Yarn.
- #present? ⇒ Boolean
Constructor Details
#initialize(yarn_lock:) ⇒ Yarn
Returns a new instance of Yarn.
7 8 9 |
# File 'lib/gurney/source/yarn.rb', line 7 def initialize(yarn_lock:) @yarn_lock = yarn_lock end |
Instance Method Details
#dependencies ⇒ Object
15 16 17 18 19 20 |
# 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? ⇒ Boolean
11 12 13 |
# File 'lib/gurney/source/yarn.rb', line 11 def present? !@yarn_lock.nil? end |