Class: Package::Audit::CommandParser
- Inherits:
-
Object
- Object
- Package::Audit::CommandParser
- Defined in:
- lib/package/audit/services/command_parser.rb
Instance Method Summary collapse
-
#initialize(dir, options, report) ⇒ CommandParser
constructor
A new instance of CommandParser.
-
#run ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity.
Constructor Details
#initialize(dir, options, report) ⇒ CommandParser
Returns a new instance of CommandParser.
17 18 19 20 21 22 23 24 25 |
# File 'lib/package/audit/services/command_parser.rb', line 17 def initialize(dir, , report) @dir = dir = @report = report @config = parse_config_file @groups = [Enum::Option::GROUP] @technologies = parse_technologies @spinner = Util::Spinner.new('Evaluating packages and their dependencies...') end |
Instance Method Details
#run ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/package/audit/services/command_parser.rb', line 27 def run # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity mutex = Mutex.new cumulative_pkgs = [] thread_index = 0 @spinner.start threads = @technologies.map.with_index do |technology, technology_index| Thread.new do all_pkgs, ignored_pkgs = PackageFinder.new(@config, @dir, @report, @groups).run(technology) ignored_pkgs = [] if [Enum::Option::INCLUDE_IGNORED] cumulative_pkgs += all_pkgs || [] sleep 0.1 while technology_index != thread_index # print each technology in order mutex.synchronize do @spinner.stop print_results(technology, (all_pkgs || []) - (ignored_pkgs || []), ignored_pkgs || []) thread_index += 1 @spinner.start end rescue StandardError => e Thread.current[:exception] = e end end threads.each do |thread| thread.join raise thread[:exception] if thread[:exception] end cumulative_pkgs.any? ? 1 : 0 ensure @spinner.stop end |