Sha256: 14bbc8e5e3e4eaf558c7076bddd6dce0acae275c3b82601c0f7669ec4dd08307
Contents?: true
Size: 1.16 KB
Versions: 3
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true module Spandx module Rubygems module Parsers class GemfileLock < ::Spandx::Core::Parser STRIP_BUNDLED_WITH = /^BUNDLED WITH$(\r?\n) (?<major>\d+)\.\d+\.\d+/m.freeze def self.matches?(filename) filename.match?(/Gemfile.*\.lock/) || filename.match?(/gems.*\.lock/) end def parse(lockfile) content = IO.read(lockfile) dependencies_from(content).map do |specification| ::Spandx::Core::Dependency.new( name: specification.name, version: specification.version.to_s, licenses: licenses_for(specification) ) end end private def dependencies_from(content) ::Bundler::LockfileParser .new(content.sub(STRIP_BUNDLED_WITH, '')) .specs end def licenses_for(specification) rubygems .licenses_for(specification.name, specification.version.to_s) .map { |x| catalogue[x] } end def rubygems @rubygems ||= Spandx::Rubygems::Gateway.new end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
spandx-0.8.0 | lib/spandx/rubygems/parsers/gemfile_lock.rb |
spandx-0.7.0 | lib/spandx/rubygems/parsers/gemfile_lock.rb |
spandx-0.6.0 | lib/spandx/rubygems/parsers/gemfile_lock.rb |