Sha256: 8ee4fae48a44319b70734c30adffc6aed0494f5450948254fb1df37ee6bb1d82

Contents?: true

Size: 582 Bytes

Versions: 12

Compression:

Stored size: 582 Bytes

Contents

module Gurney
  module Source
    class Yarn < Base

     YARN_LOCK_REGEX = /^"?(?<name>\S*)@.+?"?:\n\s{2}version "(?<version>.+?)"$/m

     def initialize(yarn_lock:)
       @yarn_lock = yarn_lock
     end

     def present?
       !@yarn_lock.nil?
     end

     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

     private

     attr_reader :yarn_lock

    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
gurney_client-0.4.0 lib/gurney/source/yarn.rb
gurney_client-0.3.0 lib/gurney/source/yarn.rb
gurney_client-0.2.3 lib/gurney/source/yarn.rb
gurney_client-0.2.2 lib/gurney/source/yarn.rb
gurney_client-0.2.1 lib/gurney/source/yarn.rb
gurney_client-0.2.0 lib/gurney/source/yarn.rb
gurney_client-0.1.6 lib/gurney/source/yarn.rb
gurney_client-0.1.5 lib/gurney/source/yarn.rb
gurney_client-0.1.4 lib/gurney/source/yarn.rb
gurney_client-0.1.3 lib/gurney/source/yarn.rb
gurney_client-0.1.2 lib/gurney/source/yarn.rb
gurney_client-0.1.1 lib/gurney/source/yarn.rb