Class: NoidsClient::IntegrationTest::NoidServerRunner
- Inherits:
-
Object
- Object
- NoidsClient::IntegrationTest::NoidServerRunner
- Defined in:
- lib/noids_client/integration_test.rb
Overview
A utility class to help running a NOIDs server within the context
Constant Summary collapse
- SECONDS_TO_WAIT =
5
Instance Attribute Summary collapse
-
#file_utils ⇒ Object
readonly
Returns the value of attribute file_utils.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#noids_command ⇒ Object
readonly
Returns the value of attribute noids_command.
-
#seconds_to_wait ⇒ Object
readonly
Returns the value of attribute seconds_to_wait.
-
#storage_dir ⇒ Object
readonly
Returns the value of attribute storage_dir.
Instance Method Summary collapse
-
#initialize(**kwargs) ⇒ NoidServerRunner
constructor
A new instance of NoidServerRunner.
- #run ⇒ Object
Constructor Details
#initialize(**kwargs) ⇒ NoidServerRunner
Returns a new instance of NoidServerRunner.
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/noids_client/integration_test.rb', line 59 def initialize(**kwargs) @logger = kwargs.fetch(:logger) { IntegrationTest.default_logger } logger.debug("logger: #{logger.inspect}") @storage_dir = kwargs.fetch(:storage_dir) { default_storage_dir } logger.debug("storage_dir: #{storage_dir.inspect}") @file_utils = kwargs.fetch(:file_utils) { default_file_utils } logger.debug("file_utils: #{file_utils.inspect}") @noids_command = kwargs.fetch(:noids_command) { default_noids_command } logger.debug("noids_command: #{noids_command.inspect}") @seconds_to_wait = kwargs.fetch(:seconds_to_wait) { SECONDS_TO_WAIT } logger.debug("seconds_to_wait: #{seconds_to_wait}") end |
Instance Attribute Details
#file_utils ⇒ Object (readonly)
Returns the value of attribute file_utils.
72 73 74 |
# File 'lib/noids_client/integration_test.rb', line 72 def file_utils @file_utils end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
72 73 74 |
# File 'lib/noids_client/integration_test.rb', line 72 def logger @logger end |
#noids_command ⇒ Object (readonly)
Returns the value of attribute noids_command.
72 73 74 |
# File 'lib/noids_client/integration_test.rb', line 72 def noids_command @noids_command end |
#seconds_to_wait ⇒ Object (readonly)
Returns the value of attribute seconds_to_wait.
72 73 74 |
# File 'lib/noids_client/integration_test.rb', line 72 def seconds_to_wait @seconds_to_wait end |
#storage_dir ⇒ Object (readonly)
Returns the value of attribute storage_dir.
72 73 74 |
# File 'lib/noids_client/integration_test.rb', line 72 def storage_dir @storage_dir end |
Instance Method Details
#run ⇒ Object
92 93 94 95 96 97 98 99 100 101 |
# File 'lib/noids_client/integration_test.rb', line 92 def run clean_storage! process_id = Process.spawn("#{noids_command} --storage #{storage_dir}") Process.detach(process_id) logger.debug("Waiting #{seconds_to_wait} seconds for noids to start") sleep(seconds_to_wait) yield if block_given? ensure stop_noids!(process_id: process_id) end |