Sha256: 207b0642a5f429a7bbeeb8aa9b80bb48f19d2b1ccc68a5e616954d809c9f8edc
Contents?: true
Size: 1.18 KB
Versions: 4
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true module Spandx module Cli module Commands class Scan < Spandx::Cli::Command attr_reader :scan_path def initialize(scan_path, options) @scan_path = ::Pathname.new(scan_path) @options = options end def execute(output: $stdout) report = ::Spandx::Core::Report.new each_file_in(scan_path) do |file| each_dependency_from(file) do |dependency| report.add(dependency) end end output.puts report.to_json end private def recursive? @options['recursive'] end def each_file_in(dir, &block) files = File.directory?(dir) ? Dir.glob(File.join(dir, '*')) : [dir] files.each do |file| if File.directory?(file) each_file_in(file, &block) if recursive? else block.call(file) end end end def each_dependency_from(file) ::Spandx::Core::Parser .for(file) .parse(file) .each { |dependency| yield dependency } end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
spandx-0.10.1 | lib/spandx/cli/commands/scan.rb |
spandx-0.10.0 | lib/spandx/cli/commands/scan.rb |
spandx-0.9.0 | lib/spandx/cli/commands/scan.rb |
spandx-0.8.0 | lib/spandx/cli/commands/scan.rb |