Class: Periphery::Runner
- Inherits:
-
Object
- Object
- Periphery::Runner
- Defined in:
- lib/periphery/runner.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#binary_path ⇒ Object
readonly
Returns the value of attribute binary_path.
-
#verbose ⇒ Object
readonly
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#initialize(binary_path, on_spawn: nil, verbose: false) ⇒ Runner
constructor
A new instance of Runner.
- #scan(options) ⇒ Object
- #scan_arguments(options) ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(binary_path, on_spawn: nil, verbose: false) ⇒ Runner
Returns a new instance of Runner.
11 12 13 14 15 |
# File 'lib/periphery/runner.rb', line 11 def initialize(binary_path, on_spawn: nil, verbose: false) @binary_path = binary_path || 'periphery' @on_spawn = on_spawn @verbose = verbose end |
Instance Attribute Details
#binary_path ⇒ Object (readonly)
Returns the value of attribute binary_path.
9 10 11 |
# File 'lib/periphery/runner.rb', line 9 def binary_path @binary_path end |
#verbose ⇒ Object (readonly)
Returns the value of attribute verbose.
9 10 11 |
# File 'lib/periphery/runner.rb', line 9 def verbose @verbose end |
Instance Method Details
#scan(options) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/periphery/runner.rb', line 17 def scan() arguments = [binary_path, 'scan'] + scan_arguments() stdout, stderr, status = capture_output(arguments) validate_subprocess_status!(arguments, status, stderr) stdout.string end |
#scan_arguments(options) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/periphery/runner.rb', line 25 def scan_arguments() args = [] .each do |key, value| next unless value next if key == :build_args value = nil if value.is_a?(TrueClass) args << "--#{key.to_s.tr('_', '-')}" if value.is_a?(Array) if Gem::Version.new(version) >= Gem::Version.new('2.18.0') args.push(*value.map(&:to_s)) else args << value.join(',') end elsif value args << value&.to_s end end args += ['--', [:build_args]] if [:build_args] args end |
#version ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/periphery/runner.rb', line 48 def version arguments = [binary_path, 'version'] stdout, stderr, status = capture_output(arguments) validate_subprocess_status!(arguments, status, stderr) stdout.string.strip end |