Class: InspecPlugins::Parallelism::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/plugins/inspec-parallel/lib/inspec-parallel/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cli_options_to_parallel_cmd, default_profile, sub_cmd = "exec") ⇒ Command

Returns a new instance of Command.



14
15
16
17
18
19
20
21
# File 'lib/plugins/inspec-parallel/lib/inspec-parallel/command.rb', line 14

def initialize(cli_options_to_parallel_cmd, default_profile, sub_cmd = "exec")
  @default_profile = default_profile
  @cli_options_to_parallel_cmd = cli_options_to_parallel_cmd
  @sub_cmd = sub_cmd
  @logger  = Inspec::Log
  @invocations = read_options_file
  @run_in_background = cli_options_to_parallel_cmd["bg"]
end

Instance Attribute Details

#cli_options_to_parallel_cmdObject

Returns the value of attribute cli_options_to_parallel_cmd.



12
13
14
# File 'lib/plugins/inspec-parallel/lib/inspec-parallel/command.rb', line 12

def cli_options_to_parallel_cmd
  @cli_options_to_parallel_cmd
end

#default_profileObject

Returns the value of attribute default_profile.



12
13
14
# File 'lib/plugins/inspec-parallel/lib/inspec-parallel/command.rb', line 12

def default_profile
  @default_profile
end

#invocationsObject

Returns the value of attribute invocations.



12
13
14
# File 'lib/plugins/inspec-parallel/lib/inspec-parallel/command.rb', line 12

def invocations
  @invocations
end

#run_in_backgroundObject

Returns the value of attribute run_in_background.



12
13
14
# File 'lib/plugins/inspec-parallel/lib/inspec-parallel/command.rb', line 12

def run_in_background
  @run_in_background
end

#sub_cmdObject

Returns the value of attribute sub_cmd.



12
13
14
# File 'lib/plugins/inspec-parallel/lib/inspec-parallel/command.rb', line 12

def sub_cmd
  @sub_cmd
end

Instance Method Details

#dry_runObject



31
32
33
34
# File 'lib/plugins/inspec-parallel/lib/inspec-parallel/command.rb', line 31

def dry_run
  validate_invocations!
  dry_run_commands
end

#runObject



23
24
25
26
27
28
29
# File 'lib/plugins/inspec-parallel/lib/inspec-parallel/command.rb', line 23

def run
  validate_thor_options
  validate_invocations!
  runner = Runner.new(invocations, cli_options_to_parallel_cmd, sub_cmd)
  catch_ctl_c_and_exit(runner) unless run_in_background
  runner.run
end