aruba 0.11.0.pre → 0.11.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/History.md +21 -1
- data/aruba.gemspec +1 -0
- data/features/api/command/find_command.feature +83 -0
- data/features/api/command/last_command_started.feature +50 -0
- data/features/api/command/last_command_stopped.feature +89 -0
- data/features/api/command/run.feature +259 -0
- data/features/api/command/stop.feature +53 -1
- data/features/api/text/replace_variables.feature +1 -1
- data/features/getting_started/run_commands.feature +177 -0
- data/features/matchers/file/be_existing_executable.feature +87 -0
- data/features/{integration/rspec/getting_started.feature → rspec/integration.feature} +31 -0
- data/fixtures/getting-started-app/Gemfile +1 -1
- data/lib/aruba.rb +0 -19
- data/lib/aruba/api.rb +2 -0
- data/lib/aruba/api/command.rb +103 -44
- data/lib/aruba/api/core.rb +13 -8
- data/lib/aruba/api/deprecated.rb +26 -4
- data/lib/aruba/api/environment.rb +21 -13
- data/lib/aruba/api/filesystem.rb +13 -0
- data/lib/aruba/api/rvm.rb +5 -0
- data/lib/aruba/api/text.rb +7 -1
- data/lib/aruba/aruba_path.rb +6 -0
- data/lib/aruba/basic_configuration.rb +35 -3
- data/lib/aruba/basic_configuration/option.rb +7 -0
- data/lib/aruba/cli.rb +4 -0
- data/lib/aruba/command.rb +47 -1
- data/lib/aruba/config.rb +15 -2
- data/lib/aruba/config_wrapper.rb +49 -8
- data/lib/aruba/console.rb +4 -1
- data/lib/aruba/console/help.rb +2 -0
- data/lib/aruba/contracts/absolute_path.rb +7 -0
- data/lib/aruba/contracts/enum.rb +5 -0
- data/lib/aruba/contracts/is_power_of_two.rb +9 -2
- data/lib/aruba/contracts/relative_path.rb +7 -0
- data/lib/aruba/cucumber/command.rb +6 -9
- data/lib/aruba/cucumber/file.rb +1 -1
- data/lib/aruba/cucumber/hooks.rb +36 -29
- data/lib/aruba/errors.rb +16 -1
- data/lib/aruba/events.rb +39 -0
- data/lib/aruba/extensions/string/strip.rb +1 -0
- data/lib/aruba/file_size.rb +11 -0
- data/lib/aruba/hooks.rb +2 -0
- data/lib/aruba/in_config_wrapper.rb +24 -0
- data/lib/aruba/in_process.rb +2 -0
- data/lib/aruba/initializer.rb +37 -0
- data/lib/aruba/matchers/base/base_matcher.rb +2 -0
- data/lib/aruba/matchers/base/object_formatter.rb +4 -0
- data/lib/aruba/matchers/collection/all.rb +2 -0
- data/lib/aruba/matchers/collection/include_an_object.rb +2 -0
- data/lib/aruba/matchers/command/have_exit_status.rb +1 -1
- data/lib/aruba/matchers/command/have_finished_in_time.rb +1 -10
- data/lib/aruba/matchers/command/have_output.rb +1 -10
- data/lib/aruba/matchers/command/have_output_on_stderr.rb +1 -10
- data/lib/aruba/matchers/command/have_output_on_stdout.rb +1 -10
- data/lib/aruba/matchers/file/be_an_existing_executable.rb +37 -0
- data/lib/aruba/platform.rb +4 -0
- data/lib/aruba/platforms/announcer.rb +225 -0
- data/lib/aruba/platforms/aruba_file_creator.rb +4 -0
- data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +4 -0
- data/lib/aruba/{aruba_logger.rb → platforms/aruba_logger.rb} +4 -0
- data/lib/aruba/platforms/command_monitor.rb +229 -0
- data/lib/aruba/platforms/determine_disk_usage.rb +5 -0
- data/lib/aruba/platforms/determine_file_size.rb +9 -0
- data/lib/aruba/platforms/disk_usage_calculator.rb +9 -0
- data/lib/aruba/platforms/local_environment.rb +12 -0
- data/lib/aruba/platforms/simple_table.rb +11 -0
- data/lib/aruba/platforms/unix_command_string.rb +3 -0
- data/lib/aruba/platforms/unix_environment_variables.rb +3 -0
- data/lib/aruba/platforms/unix_platform.rb +20 -2
- data/lib/aruba/platforms/unix_which.rb +6 -2
- data/lib/aruba/platforms/windows_command_string.rb +7 -0
- data/lib/aruba/platforms/windows_environment_variables.rb +2 -0
- data/lib/aruba/platforms/windows_platform.rb +3 -0
- data/lib/aruba/platforms/windows_which.rb +6 -2
- data/lib/aruba/processes/basic_process.rb +20 -5
- data/lib/aruba/processes/debug_process.rb +3 -1
- data/lib/aruba/processes/in_process.rb +18 -2
- data/lib/aruba/processes/spawn_process.rb +14 -13
- data/lib/aruba/rspec.rb +34 -23
- data/lib/aruba/runtime.rb +65 -6
- data/lib/aruba/setup.rb +87 -0
- data/lib/aruba/version.rb +1 -1
- data/spec/aruba/api_spec.rb +13 -36
- data/spec/aruba/{config_wrapper_spec.rb → in_config_wrapper_spec.rb} +1 -1
- data/spec/aruba/spawn_process_spec.rb +9 -14
- data/spec/support/configs/pry.rb +3 -0
- data/spec/support/shared_contexts/aruba.rb +1 -0
- metadata +40 -14
- data/features/getting_started/supported_programming_languages.feature +0 -89
- data/lib/aruba/announcer.rb +0 -219
- data/lib/aruba/matchers/rspec.rb +0 -0
- data/lib/aruba/process_monitor.rb +0 -201
- data/lib/aruba/processes/null_process.rb +0 -26
@@ -1,8 +1,12 @@
|
|
1
1
|
require 'aruba/platform'
|
2
2
|
|
3
|
+
# Aruba
|
3
4
|
module Aruba
|
5
|
+
# Platforms
|
4
6
|
module Platforms
|
5
7
|
# Implement `which(command)` for UNIX/Linux
|
8
|
+
#
|
9
|
+
# @private
|
6
10
|
class UnixWhich
|
7
11
|
# Bail out because this should never be reached
|
8
12
|
class DefaultWhich
|
@@ -22,7 +26,7 @@ module Aruba
|
|
22
26
|
end
|
23
27
|
|
24
28
|
def call(program, path)
|
25
|
-
return File.expand_path(program) if Aruba.platform.
|
29
|
+
return File.expand_path(program) if Aruba.platform.executable?(program)
|
26
30
|
|
27
31
|
nil
|
28
32
|
end
|
@@ -43,7 +47,7 @@ module Aruba
|
|
43
47
|
next unless Aruba.platform.exist?(dir) # In case of bogus second argument
|
44
48
|
|
45
49
|
found = Dir[File.join(dir, program)].first
|
46
|
-
return found if found && Aruba.platform.
|
50
|
+
return found if found && Aruba.platform.executable?(found)
|
47
51
|
end
|
48
52
|
|
49
53
|
nil
|
@@ -1,13 +1,20 @@
|
|
1
1
|
require 'delegate'
|
2
2
|
|
3
|
+
# Aruba
|
3
4
|
module Aruba
|
5
|
+
# Platforms
|
4
6
|
module Platforms
|
5
7
|
# This is a command which should be run
|
8
|
+
#
|
9
|
+
# This adds `cmd.exec` in front of commmand
|
10
|
+
#
|
11
|
+
# @private
|
6
12
|
class WindowsCommandString < SimpleDelegator
|
7
13
|
def initialize(cmd)
|
8
14
|
__setobj__ format('%s /c "%s"', Aruba.platform.which('cmd.exe'), cmd)
|
9
15
|
end
|
10
16
|
|
17
|
+
# Convert to array
|
11
18
|
def to_a
|
12
19
|
Shellwords.split __getobj__
|
13
20
|
end
|
@@ -5,6 +5,7 @@ require 'aruba/platforms/windows_command_string'
|
|
5
5
|
require 'aruba/platforms/windows_environment_variables'
|
6
6
|
require 'aruba/platforms/windows_which'
|
7
7
|
|
8
|
+
# Aruba
|
8
9
|
module Aruba
|
9
10
|
# This abstracts OS-specific things
|
10
11
|
module Platforms
|
@@ -15,6 +16,8 @@ module Aruba
|
|
15
16
|
# any further notice.
|
16
17
|
#
|
17
18
|
# This includes all methods for the Windows platform
|
19
|
+
#
|
20
|
+
# @private
|
18
21
|
class WindowsPlatform < UnixPlatform
|
19
22
|
def self.match?
|
20
23
|
FFI::Platform.windows?
|
@@ -1,8 +1,12 @@
|
|
1
1
|
require 'aruba/platform'
|
2
2
|
|
3
|
+
# Aruba
|
3
4
|
module Aruba
|
5
|
+
# Platforms
|
4
6
|
module Platforms
|
5
7
|
# Implement `which(command)` for windows
|
8
|
+
#
|
9
|
+
# @private
|
6
10
|
class WindowsWhich
|
7
11
|
# Bail out because this should never be reached
|
8
12
|
class DefaultWhich
|
@@ -25,7 +29,7 @@ module Aruba
|
|
25
29
|
# Expand `#path_exts`
|
26
30
|
found = Dir[program].first
|
27
31
|
|
28
|
-
return File.expand_path(found) if found && Aruba.platform.
|
32
|
+
return File.expand_path(found) if found && Aruba.platform.executable?(found)
|
29
33
|
nil
|
30
34
|
end
|
31
35
|
end
|
@@ -53,7 +57,7 @@ module Aruba
|
|
53
57
|
found = Dir[file].first
|
54
58
|
|
55
59
|
# Convert all forward slashes to backslashes if supported
|
56
|
-
if found && Aruba.platform.
|
60
|
+
if found && Aruba.platform.executable?(found)
|
57
61
|
found.tr!(File::SEPARATOR, File::ALT_SEPARATOR)
|
58
62
|
return found
|
59
63
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'aruba/platform'
|
2
2
|
require 'shellwords'
|
3
3
|
|
4
|
+
# Aruba
|
4
5
|
module Aruba
|
6
|
+
# Processes
|
5
7
|
module Processes
|
6
8
|
# Basic Process
|
7
9
|
#
|
@@ -9,9 +11,9 @@ module Aruba
|
|
9
11
|
#
|
10
12
|
# @private
|
11
13
|
class BasicProcess
|
12
|
-
attr_reader :exit_status, :environment, :startup_wait_time
|
14
|
+
attr_reader :exit_status, :environment, :working_directory, :main_class, :io_wait_timeout, :exit_timeout, :startup_wait_time
|
13
15
|
|
14
|
-
def initialize(cmd, exit_timeout,
|
16
|
+
def initialize(cmd, exit_timeout, io_wait_timeout, working_directory, environment = ENV.to_hash.dup, main_class = nil, stop_signal = nil, startup_wait_time = 0)
|
15
17
|
@cmd = cmd
|
16
18
|
@working_directory = working_directory
|
17
19
|
@environment = environment
|
@@ -20,8 +22,10 @@ module Aruba
|
|
20
22
|
@stop_signal = stop_signal
|
21
23
|
@startup_wait_time = startup_wait_time
|
22
24
|
|
23
|
-
@exit_timeout
|
24
|
-
@
|
25
|
+
@exit_timeout = exit_timeout
|
26
|
+
@io_wait_timeout = io_wait_timeout
|
27
|
+
|
28
|
+
@started = false
|
25
29
|
end
|
26
30
|
|
27
31
|
# Return command line
|
@@ -67,9 +71,20 @@ module Aruba
|
|
67
71
|
NotImplementedError
|
68
72
|
end
|
69
73
|
|
74
|
+
# Restart a command
|
75
|
+
def restart
|
76
|
+
stop
|
77
|
+
start
|
78
|
+
end
|
79
|
+
|
70
80
|
# Was process already stopped
|
71
81
|
def stopped?
|
72
|
-
@
|
82
|
+
@started == false
|
83
|
+
end
|
84
|
+
|
85
|
+
# Was process already started
|
86
|
+
def started?
|
87
|
+
@started == true
|
73
88
|
end
|
74
89
|
|
75
90
|
# Does the process failed to stop in time
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'aruba/processes/spawn_process'
|
2
2
|
|
3
|
+
# Aruba
|
3
4
|
module Aruba
|
5
|
+
# Processes
|
4
6
|
module Processes
|
5
7
|
# Run your command in `systemd()` to make debugging it easier
|
6
8
|
#
|
@@ -57,7 +59,7 @@ module Aruba
|
|
57
59
|
|
58
60
|
# Stop process
|
59
61
|
def stop(*)
|
60
|
-
@
|
62
|
+
@started = false
|
61
63
|
|
62
64
|
@exit_status
|
63
65
|
end
|
@@ -3,7 +3,9 @@ require 'stringio'
|
|
3
3
|
require 'aruba/processes/basic_process'
|
4
4
|
require 'aruba/platform'
|
5
5
|
|
6
|
+
# Aruba
|
6
7
|
module Aruba
|
8
|
+
# Platforms
|
7
9
|
module Processes
|
8
10
|
# Run command in your ruby process
|
9
11
|
#
|
@@ -20,6 +22,9 @@ module Aruba
|
|
20
22
|
|
21
23
|
attr_reader :exit_status
|
22
24
|
|
25
|
+
# Fake Kernel module of ruby
|
26
|
+
#
|
27
|
+
# @private
|
23
28
|
class FakeKernel
|
24
29
|
attr_reader :exitstatus
|
25
30
|
|
@@ -40,7 +45,7 @@ module Aruba
|
|
40
45
|
# @private
|
41
46
|
attr_reader :main_class
|
42
47
|
|
43
|
-
def initialize(cmd, exit_timeout,
|
48
|
+
def initialize(cmd, exit_timeout, io_wait_timeout, working_directory, environment = ENV.to_hash.dup, main_class = nil, stop_signal = nil, startup_wait_time = 0)
|
44
49
|
@cmd = cmd
|
45
50
|
@argv = arguments
|
46
51
|
@stdin = StringIO.new
|
@@ -51,6 +56,7 @@ module Aruba
|
|
51
56
|
super
|
52
57
|
end
|
53
58
|
|
59
|
+
# Start command
|
54
60
|
def start
|
55
61
|
fail "You need to call aruba.config.main_class = YourMainClass" unless main_class
|
56
62
|
|
@@ -67,33 +73,43 @@ module Aruba
|
|
67
73
|
end
|
68
74
|
end
|
69
75
|
|
76
|
+
# Stop command
|
70
77
|
def stop(*)
|
71
|
-
@
|
78
|
+
@started = false
|
72
79
|
@exit_status = @kernel.exitstatus
|
73
80
|
end
|
74
81
|
|
82
|
+
# Access stdin
|
75
83
|
def stdin
|
76
84
|
@stdin.string
|
77
85
|
end
|
78
86
|
|
87
|
+
# Access stdout
|
79
88
|
def stdout(*)
|
80
89
|
@stdout.string
|
81
90
|
end
|
82
91
|
|
92
|
+
# Access stderr
|
83
93
|
def stderr(*)
|
84
94
|
@stderr.string
|
85
95
|
end
|
86
96
|
|
97
|
+
# Write strint to stdin
|
98
|
+
#
|
99
|
+
# @param [String] input
|
100
|
+
# Write string to stdin in
|
87
101
|
def write(input)
|
88
102
|
@stdin.write input
|
89
103
|
end
|
90
104
|
|
105
|
+
# Close io
|
91
106
|
def close_io(name)
|
92
107
|
fail ArgumentError, 'Only stdin stdout and stderr are allowed to close' unless [:stdin, :stdout, :stderr].include? name
|
93
108
|
|
94
109
|
get_instance_variable(name.to_sym).close
|
95
110
|
end
|
96
111
|
|
112
|
+
# Terminate program
|
97
113
|
def terminate
|
98
114
|
stop
|
99
115
|
end
|
@@ -6,7 +6,9 @@ require 'aruba/errors'
|
|
6
6
|
require 'aruba/processes/basic_process'
|
7
7
|
require 'aruba/platform'
|
8
8
|
|
9
|
+
# Aruba
|
9
10
|
module Aruba
|
11
|
+
# Platforms
|
10
12
|
module Processes
|
11
13
|
# Spawn a process for command
|
12
14
|
#
|
@@ -29,12 +31,12 @@ module Aruba
|
|
29
31
|
# @params [Integer] exit_timeout
|
30
32
|
# The timeout until we expect the command to be finished
|
31
33
|
#
|
32
|
-
# @params [Integer]
|
34
|
+
# @params [Integer] io_wait_timeout
|
33
35
|
# The timeout until we expect the io to be finished
|
34
36
|
#
|
35
37
|
# @params [String] working_directory
|
36
38
|
# The directory where the command will be executed
|
37
|
-
def initialize(cmd, exit_timeout,
|
39
|
+
def initialize(cmd, exit_timeout, io_wait_timeout, working_directory, environment = ENV.to_hash.dup, main_class = nil, stop_signal = nil, startup_wait_time = 0)
|
38
40
|
super
|
39
41
|
|
40
42
|
@process = nil
|
@@ -50,6 +52,12 @@ module Aruba
|
|
50
52
|
# rubocop:disable Metrics/MethodLength
|
51
53
|
# rubocop:disable Metrics/CyclomaticComplexity
|
52
54
|
def start
|
55
|
+
# rubocop:disable Metrics/LineLength
|
56
|
+
fail CommandAlreadyStartedError, %(Command "#{commandline}" has already been started. Please `#stop` the command first and `#start` it again. Alternatively use `#restart`.\n#{caller.join("\n")}) if started?
|
57
|
+
# rubocop:enable Metrics/LineLength
|
58
|
+
|
59
|
+
@started = true
|
60
|
+
|
53
61
|
# gather fully qualified path
|
54
62
|
cmd = Aruba.platform.which(command, environment['PATH'])
|
55
63
|
|
@@ -157,6 +165,7 @@ module Aruba
|
|
157
165
|
self
|
158
166
|
end
|
159
167
|
|
168
|
+
# Close io
|
160
169
|
def close_io(name)
|
161
170
|
return if stopped?
|
162
171
|
|
@@ -167,8 +176,8 @@ module Aruba
|
|
167
176
|
end
|
168
177
|
end
|
169
178
|
|
170
|
-
#
|
171
|
-
def stop(
|
179
|
+
# Stop command
|
180
|
+
def stop(*)
|
172
181
|
return @exit_status if stopped?
|
173
182
|
|
174
183
|
begin
|
@@ -178,15 +187,7 @@ module Aruba
|
|
178
187
|
end
|
179
188
|
|
180
189
|
terminate
|
181
|
-
|
182
|
-
if reader
|
183
|
-
reader.announce :stdout, @stdout_cache
|
184
|
-
reader.announce :stderr, @stderr_cache
|
185
|
-
end
|
186
|
-
|
187
|
-
@exit_status
|
188
190
|
end
|
189
|
-
# rubocop:enable Metrics/MethodLength
|
190
191
|
|
191
192
|
# Wait for command to finish
|
192
193
|
def wait
|
@@ -216,7 +217,7 @@ module Aruba
|
|
216
217
|
# @stdout_file = nil
|
217
218
|
# @stderr_file = nil
|
218
219
|
|
219
|
-
@
|
220
|
+
@started = false
|
220
221
|
|
221
222
|
@exit_status
|
222
223
|
end
|
data/lib/aruba/rspec.rb
CHANGED
@@ -21,6 +21,9 @@ RSpec.configure do |config|
|
|
21
21
|
end
|
22
22
|
|
23
23
|
example.run
|
24
|
+
|
25
|
+
next unless self.class.include? Aruba::Api
|
26
|
+
stop_all_commands
|
24
27
|
end
|
25
28
|
|
26
29
|
if Aruba::VERSION >= '1.0.0'
|
@@ -42,37 +45,45 @@ RSpec.configure do |config|
|
|
42
45
|
next unless self.class.include?(Aruba::Api)
|
43
46
|
|
44
47
|
if example.metadata[:announce_environment]
|
45
|
-
Aruba.platform.deprecated 'announce_environment is deprecated. Use
|
48
|
+
Aruba.platform.deprecated 'announce_environment is deprecated. Use announce_changed_environment instead'
|
49
|
+
|
50
|
+
aruba.announcer.activate(:changed_environment)
|
51
|
+
end
|
52
|
+
|
53
|
+
aruba.announcer.activate(:full_environment) if example.metadata[:announce_full_environment]
|
54
|
+
aruba.announcer.activate(:changed_environment) if example.metadata[:announce_changed_environment]
|
55
|
+
|
56
|
+
if example.metadata[:announce_modified_environment]
|
57
|
+
Aruba.platform.deprecated 'announce_modified_environment is deprecated. Use announce_changed_environment instead'
|
46
58
|
|
47
|
-
announcer.activate(:
|
59
|
+
aruba.announcer.activate(:changed_environment)
|
48
60
|
end
|
49
61
|
|
50
|
-
announcer.activate(:
|
51
|
-
announcer.activate(:
|
52
|
-
announcer.activate(:
|
53
|
-
announcer.activate(:
|
54
|
-
announcer.activate(:stdout) if example.metadata[:announce_stdout]
|
55
|
-
announcer.activate(:
|
56
|
-
announcer.activate(:timeout) if example.metadata[:announce_timeout]
|
57
|
-
announcer.activate(:wait_time) if example.metadata[:announce_wait_time]
|
58
|
-
announcer.activate(:stop_signal) if example.metadata[:announce_stop_signal]
|
62
|
+
aruba.announcer.activate(:command) if example.metadata[:announce_command]
|
63
|
+
aruba.announcer.activate(:directory) if example.metadata[:announce_directory]
|
64
|
+
aruba.announcer.activate(:full_environment) if example.metadata[:announce_full_environment]
|
65
|
+
aruba.announcer.activate(:stderr) if example.metadata[:announce_stderr]
|
66
|
+
aruba.announcer.activate(:stdout) if example.metadata[:announce_stdout]
|
67
|
+
aruba.announcer.activate(:stop_signal) if example.metadata[:announce_stop_signal]
|
68
|
+
aruba.announcer.activate(:timeout) if example.metadata[:announce_timeout]
|
69
|
+
aruba.announcer.activate(:wait_time) if example.metadata[:announce_wait_time]
|
59
70
|
|
60
71
|
if example.metadata[:announce_output]
|
61
|
-
announcer.activate(:stderr)
|
62
|
-
announcer.activate(:stdout)
|
72
|
+
aruba.announcer.activate(:stderr)
|
73
|
+
aruba.announcer.activate(:stdout)
|
63
74
|
end
|
64
75
|
|
65
76
|
if example.metadata[:announce]
|
66
|
-
announcer.activate(:
|
67
|
-
announcer.activate(:
|
68
|
-
announcer.activate(:
|
69
|
-
announcer.activate(:
|
70
|
-
announcer.activate(:full_environment)
|
71
|
-
announcer.activate(:
|
72
|
-
announcer.activate(:
|
73
|
-
announcer.activate(:stop_signal)
|
74
|
-
announcer.activate(:timeout)
|
75
|
-
announcer.activate(:wait_time)
|
77
|
+
aruba.announcer.activate(:changed_environment)
|
78
|
+
aruba.announcer.activate(:command)
|
79
|
+
aruba.announcer.activate(:directory)
|
80
|
+
aruba.announcer.activate(:environment)
|
81
|
+
aruba.announcer.activate(:full_environment)
|
82
|
+
aruba.announcer.activate(:stderr)
|
83
|
+
aruba.announcer.activate(:stdout)
|
84
|
+
aruba.announcer.activate(:stop_signal)
|
85
|
+
aruba.announcer.activate(:timeout)
|
86
|
+
aruba.announcer.activate(:wait_time)
|
76
87
|
end
|
77
88
|
end
|
78
89
|
|
data/lib/aruba/runtime.rb
CHANGED
@@ -1,18 +1,77 @@
|
|
1
1
|
require 'aruba/config'
|
2
|
-
require 'aruba/
|
2
|
+
require 'aruba/aruba_path'
|
3
|
+
require 'aruba/config_wrapper'
|
4
|
+
require 'aruba/events'
|
5
|
+
require 'event/bus'
|
3
6
|
|
4
7
|
module Aruba
|
8
|
+
# Runtime of aruba
|
9
|
+
#
|
10
|
+
# Most methods are considered private. Please look for `(private)` in the
|
11
|
+
# attribute descriptions. Only a few like `#current_directory`,
|
12
|
+
# '#root_directory` and `#config` are considered to be part of the public
|
13
|
+
# API.
|
5
14
|
class Runtime
|
6
|
-
|
15
|
+
# @!attribute [r] current_directory
|
16
|
+
# Returns the current working directory
|
17
|
+
#
|
18
|
+
# @!attribute [r] root_directory
|
19
|
+
# Returns the root directory of aruba
|
20
|
+
attr_reader :current_directory, :root_directory
|
21
|
+
|
22
|
+
# @!attribute [r] config
|
23
|
+
# Access configuration of aruba
|
24
|
+
#
|
25
|
+
# @!attribute [r] environment
|
26
|
+
# Access environment of aruba (private)
|
27
|
+
#
|
28
|
+
# @!attribute [r] logger
|
29
|
+
# Logger of aruba (private)
|
30
|
+
#
|
31
|
+
# @!attribute [r] command_monitor
|
32
|
+
# Handler started commands (private)
|
33
|
+
#
|
34
|
+
# @!attribute [r] announcer
|
35
|
+
# Announce information
|
36
|
+
#
|
37
|
+
# @!attribute [r] event_bus
|
38
|
+
# Handle events (private)
|
39
|
+
#
|
40
|
+
attr_accessor :config, :environment, :logger, :command_monitor, :announcer, :event_bus
|
41
|
+
|
42
|
+
def initialize(opts = {})
|
43
|
+
@environment = opts.fetch(:environment, Aruba.platform.environment_variables)
|
44
|
+
@event_bus = ::Event::Bus.new(::Event::NameResolver.new(Aruba::Events))
|
45
|
+
@announcer = opts.fetch(:announcer, Aruba.platform.announcer.new)
|
7
46
|
|
8
|
-
|
9
|
-
@config = Aruba.config.make_copy
|
47
|
+
@config = opts.fetch(:config, ConfigWrapper.new(Aruba.config.make_copy, @event_bus))
|
10
48
|
@current_directory = ArubaPath.new(@config.working_directory)
|
11
49
|
@root_directory = ArubaPath.new(@config.root_directory)
|
12
|
-
@environment = Aruba.platform.environment_variables
|
13
50
|
|
14
|
-
|
51
|
+
if Aruba::VERSION < '1'
|
52
|
+
@command_monitor = opts.fetch(:command_monitor, Aruba.platform.command_monitor.new(:announcer => @announcer))
|
53
|
+
else
|
54
|
+
@command_monitor = opts.fetch(:command_monitor, Aruba.platform.command_monitor.new)
|
55
|
+
end
|
56
|
+
|
57
|
+
@logger = opts.fetch(:logger, Aruba.platform.logger.new)
|
15
58
|
@logger.mode = @config.log_level
|
59
|
+
|
60
|
+
@setup_done = false
|
61
|
+
end
|
62
|
+
|
63
|
+
# @private
|
64
|
+
#
|
65
|
+
# Setup of aruba is finshed. Should be used only internally.
|
66
|
+
def setup_done
|
67
|
+
@setup_done = true
|
68
|
+
end
|
69
|
+
|
70
|
+
# @private
|
71
|
+
#
|
72
|
+
# Has aruba already been setup. Should be used only internally.
|
73
|
+
def setup_already_done?
|
74
|
+
@setup_done == true
|
16
75
|
end
|
17
76
|
|
18
77
|
# The path to the directory which contains fixtures
|