aruba 1.0.0.pre.alpha.2 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.github/PULL_REQUEST_TEMPLATE.md +2 -1
- data/.rspec +0 -1
- data/.rubocop.yml +46 -182
- data/.rubocop_todo.yml +216 -0
- data/.simplecov +7 -5
- data/.travis.yml +56 -40
- data/.yardopts +3 -0
- data/CHANGELOG.md +1312 -0
- data/CONTRIBUTING.md +175 -83
- data/Gemfile +5 -69
- data/LICENSE +1 -1
- data/README.md +58 -21
- data/Rakefile +27 -54
- data/appveyor.yml +7 -10
- data/aruba.gemspec +38 -19
- data/bin/console +3 -12
- data/cucumber.yml +4 -22
- data/exe/aruba +1 -1
- data/fixtures/cli-app/README.md +1 -1
- data/fixtures/cli-app/Rakefile +1 -1
- data/fixtures/cli-app/bin/aruba-test-cli +1 -1
- data/fixtures/cli-app/cli-app.gemspec +4 -4
- data/fixtures/cli-app/lib/cli/app.rb +1 -1
- data/fixtures/cli-app/lib/cli/app/suppress_simple_cov_output.rb +3 -3
- data/fixtures/cli-app/lib/cli/app/version.rb +1 -1
- data/fixtures/cli-app/spec/spec_helper.rb +3 -2
- data/fixtures/empty-app/Rakefile +1 -1
- data/fixtures/empty-app/cli-app.gemspec +4 -4
- data/fixtures/empty-app/lib/cli/app.rb +0 -2
- data/fixtures/empty-app/lib/cli/app/version.rb +1 -1
- data/fixtures/getting-started-app/Gemfile +1 -1
- data/lib/aruba/api.rb +8 -15
- data/lib/aruba/api/bundler.rb +16 -0
- data/lib/aruba/api/commands.rb +272 -0
- data/lib/aruba/api/core.rb +82 -43
- data/lib/aruba/api/environment.rb +24 -7
- data/lib/aruba/api/filesystem.rb +66 -64
- data/lib/aruba/api/text.rb +17 -11
- data/lib/aruba/aruba_path.rb +25 -111
- data/lib/aruba/basic_configuration.rb +8 -25
- data/lib/aruba/basic_configuration/option.rb +2 -2
- data/lib/aruba/cli.rb +4 -1
- data/lib/aruba/colorizer.rb +10 -99
- data/lib/aruba/command.rb +4 -0
- data/lib/aruba/config/jruby.rb +15 -5
- data/lib/aruba/config_wrapper.rb +17 -2
- data/lib/aruba/configuration.rb +107 -0
- data/lib/aruba/console.rb +5 -7
- data/lib/aruba/console/help.rb +5 -2
- data/lib/aruba/contracts/absolute_path.rb +3 -3
- data/lib/aruba/contracts/is_power_of_two.rb +2 -2
- data/lib/aruba/contracts/relative_path.rb +3 -3
- data/lib/aruba/cucumber.rb +0 -3
- data/lib/aruba/cucumber/command.rb +227 -190
- data/lib/aruba/cucumber/environment.rb +1 -1
- data/lib/aruba/cucumber/file.rb +56 -50
- data/lib/aruba/cucumber/hooks.rb +10 -63
- data/lib/aruba/cucumber/testing_frameworks.rb +76 -50
- data/lib/aruba/event_bus.rb +4 -2
- data/lib/aruba/event_bus/name_resolver.rb +10 -10
- data/lib/aruba/events.rb +2 -1
- data/lib/aruba/hooks.rb +3 -5
- data/lib/aruba/in_config_wrapper.rb +10 -3
- data/lib/aruba/initializer.rb +40 -34
- data/lib/aruba/matchers/base/base_matcher.rb +2 -11
- data/lib/aruba/matchers/base/message_indenter.rb +19 -0
- data/lib/aruba/matchers/base/object_formatter.rb +2 -7
- data/lib/aruba/matchers/collection/include_an_object.rb +11 -13
- data/lib/aruba/matchers/command/be_successfully_executed.rb +8 -4
- data/lib/aruba/matchers/command/have_exit_status.rb +16 -4
- data/lib/aruba/matchers/command/have_finished_in_time.rb +5 -5
- data/lib/aruba/matchers/command/have_output.rb +12 -5
- data/lib/aruba/matchers/command/have_output_on_stderr.rb +4 -2
- data/lib/aruba/matchers/command/have_output_on_stdout.rb +4 -2
- data/lib/aruba/matchers/command/have_output_size.rb +2 -2
- data/lib/aruba/matchers/directory/be_an_existing_directory.rb +5 -7
- data/lib/aruba/matchers/directory/have_sub_directory.rb +10 -7
- data/lib/aruba/matchers/file/be_a_command_found_in_path.rb +2 -4
- data/lib/aruba/matchers/file/be_an_existing_executable.rb +4 -6
- data/lib/aruba/matchers/file/be_an_existing_file.rb +5 -7
- data/lib/aruba/matchers/file/have_file_content.rb +4 -4
- data/lib/aruba/matchers/file/have_file_size.rb +8 -8
- data/lib/aruba/matchers/file/have_same_file_content.rb +9 -12
- data/lib/aruba/matchers/path/a_path_matching_pattern.rb +2 -4
- data/lib/aruba/matchers/path/be_an_absolute_path.rb +3 -5
- data/lib/aruba/matchers/path/be_an_existing_path.rb +4 -6
- data/lib/aruba/matchers/path/have_permissions.rb +8 -8
- data/lib/aruba/matchers/string/include_output_string.rb +8 -10
- data/lib/aruba/matchers/string/match_output_string.rb +9 -11
- data/lib/aruba/matchers/string/output_string_eq.rb +7 -9
- data/lib/aruba/platform.rb +0 -8
- data/lib/aruba/platforms/announcer.rb +60 -85
- data/lib/aruba/platforms/aruba_file_creator.rb +4 -2
- data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +8 -3
- data/lib/aruba/platforms/aruba_logger.rb +22 -2
- data/lib/aruba/platforms/command_monitor.rb +15 -102
- data/lib/aruba/platforms/determine_disk_usage.rb +56 -19
- data/lib/aruba/platforms/filesystem_status.rb +9 -9
- data/lib/aruba/platforms/local_environment.rb +2 -2
- data/lib/aruba/platforms/simple_table.rb +3 -11
- data/lib/aruba/platforms/unix_command_string.rb +7 -4
- data/lib/aruba/platforms/unix_environment_variables.rb +19 -26
- data/lib/aruba/platforms/unix_platform.rb +18 -39
- data/lib/aruba/platforms/unix_which.rb +3 -2
- data/lib/aruba/platforms/windows_command_string.rb +20 -7
- data/lib/aruba/platforms/windows_environment_variables.rb +42 -30
- data/lib/aruba/platforms/windows_platform.rb +4 -0
- data/lib/aruba/platforms/windows_which.rb +9 -4
- data/lib/aruba/processes/basic_process.rb +21 -27
- data/lib/aruba/processes/debug_process.rb +16 -5
- data/lib/aruba/processes/in_process.rb +20 -9
- data/lib/aruba/processes/spawn_process.rb +64 -36
- data/lib/aruba/rspec.rb +28 -31
- data/lib/aruba/runtime.rb +16 -7
- data/lib/aruba/setup.rb +32 -17
- data/lib/aruba/tasks/docker_helpers.rb +4 -2
- data/lib/aruba/version.rb +1 -1
- metadata +194 -64
- data/History.md +0 -612
- data/bin/bootstrap +0 -34
- data/bin/build +0 -3
- data/bin/release +0 -3
- data/fixtures/spawn_process/stderr.sh +0 -3
- data/lib/aruba/api/command.rb +0 -309
- data/lib/aruba/api/deprecated.rb +0 -895
- data/lib/aruba/api/rvm.rb +0 -44
- data/lib/aruba/config.rb +0 -101
- data/lib/aruba/cucumber/rvm.rb +0 -3
- data/lib/aruba/in_process.rb +0 -14
- data/lib/aruba/jruby.rb +0 -4
- data/lib/aruba/matchers/path/match_path_pattern.rb +0 -41
- data/lib/aruba/matchers/rspec_matcher_include_regexp.rb +0 -25
- data/lib/aruba/platforms/disk_usage_calculator.rb +0 -20
- data/lib/aruba/spawn_process.rb +0 -11
|
@@ -3,7 +3,7 @@ require 'rspec/expectations/version'
|
|
|
3
3
|
# @!method be_an_existing_path
|
|
4
4
|
# This matchers checks if <path> exists in filesystem
|
|
5
5
|
#
|
|
6
|
-
# @return [
|
|
6
|
+
# @return [Boolean] The result
|
|
7
7
|
#
|
|
8
8
|
# false:
|
|
9
9
|
# * if path does not exist
|
|
@@ -24,14 +24,12 @@ RSpec::Matchers.define :be_an_existing_path do |_|
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
failure_message do |actual|
|
|
27
|
-
format(
|
|
27
|
+
format('expected that path "%s" exists', actual)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
failure_message_when_negated do |actual|
|
|
31
|
-
format(
|
|
31
|
+
format('expected that path "%s" does not exist', actual)
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
RSpec::Matchers.alias_matcher :an_existing_path, :be_an_existing_path
|
|
37
|
-
end
|
|
35
|
+
RSpec::Matchers.alias_matcher :an_existing_path, :be_an_existing_path
|
|
@@ -6,7 +6,7 @@ require 'rspec/expectations/version'
|
|
|
6
6
|
# @param [Fixnum, String] permissions
|
|
7
7
|
# The permissions as octal number, e.g. `0700`, or String, e.g. `'0700'`
|
|
8
8
|
#
|
|
9
|
-
# @return [
|
|
9
|
+
# @return [Boolean] The result
|
|
10
10
|
#
|
|
11
11
|
# false:
|
|
12
12
|
# * if file has permissions
|
|
@@ -50,15 +50,15 @@ RSpec::Matchers.define :have_permissions do |expected|
|
|
|
50
50
|
values_match? @expected, @actual
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
-
failure_message do |
|
|
54
|
-
format(
|
|
53
|
+
failure_message do |_actual|
|
|
54
|
+
format('expected that path "%s" has permissions "%s", but has "%s".',
|
|
55
|
+
@old_actual, @expected, @actual)
|
|
55
56
|
end
|
|
56
57
|
|
|
57
|
-
failure_message_when_negated do |
|
|
58
|
-
format(
|
|
58
|
+
failure_message_when_negated do |_actual|
|
|
59
|
+
format('expected that path "%s" does not have permissions "%s", but has "%s".',
|
|
60
|
+
@old_actual, @expected, @actual)
|
|
59
61
|
end
|
|
60
62
|
end
|
|
61
63
|
|
|
62
|
-
|
|
63
|
-
RSpec::Matchers.alias_matcher :a_path_having_permissions, :have_permissions
|
|
64
|
-
end
|
|
64
|
+
RSpec::Matchers.alias_matcher :a_path_having_permissions, :have_permissions
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
# @!method include_output_string(string)
|
|
2
2
|
# This matchers checks if the output string of a command includes string.
|
|
3
3
|
#
|
|
4
|
-
# @param [
|
|
5
|
-
# The value of the
|
|
4
|
+
# @param [String] string
|
|
5
|
+
# The value of the output string
|
|
6
6
|
#
|
|
7
|
-
# @return [
|
|
7
|
+
# @return [Boolean] The result
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# False:
|
|
10
10
|
# * if the output string does not include string
|
|
11
|
-
#
|
|
11
|
+
# True:
|
|
12
12
|
# * if the output string includes string
|
|
13
13
|
#
|
|
14
14
|
# @example Use matcher
|
|
15
|
-
#
|
|
16
15
|
# RSpec.describe do
|
|
17
16
|
# it { expect(last_command_started).to have_output an_output_string_including string) }
|
|
18
17
|
# it { expect(last_command_started).to have_output include_output_string string) }
|
|
19
18
|
# end
|
|
20
19
|
RSpec::Matchers.define :include_output_string do |expected|
|
|
21
20
|
match do |actual|
|
|
21
|
+
actual.force_encoding('UTF-8')
|
|
22
22
|
@expected = Regexp.new(Regexp.escape(sanitize_text(expected.to_s)), Regexp::MULTILINE)
|
|
23
23
|
@actual = sanitize_text(actual)
|
|
24
24
|
|
|
@@ -30,7 +30,5 @@ RSpec::Matchers.define :include_output_string do |expected|
|
|
|
30
30
|
description { "string includes: #{description_of expected}" }
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
RSpec::Matchers.alias_matcher :file_content_including, :include_output_string
|
|
36
|
-
end
|
|
33
|
+
RSpec::Matchers.alias_matcher :an_output_string_including, :include_output_string
|
|
34
|
+
RSpec::Matchers.alias_matcher :file_content_including, :include_output_string
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
# @!method match_output_string(string)
|
|
2
2
|
# This matchers checks if the output string of a command matches regular expression.
|
|
3
3
|
#
|
|
4
|
-
# @param [
|
|
5
|
-
# The value of the
|
|
4
|
+
# @param [String] string
|
|
5
|
+
# The value of the output string
|
|
6
6
|
#
|
|
7
|
-
# @return [
|
|
7
|
+
# @return [Boolean] The result
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# False:
|
|
10
10
|
# * if the output string does not match regex
|
|
11
|
-
#
|
|
11
|
+
# True:
|
|
12
12
|
# * if the output string matches regex
|
|
13
13
|
#
|
|
14
14
|
# @example Use matcher
|
|
15
|
-
#
|
|
16
15
|
# RSpec.describe do
|
|
17
16
|
# it { expect(last_command_started).to have_output an_output_string_matching regex) }
|
|
18
17
|
# it { expect(last_command_started).to have_output match_output_string regex) }
|
|
19
18
|
# end
|
|
20
19
|
RSpec::Matchers.define :match_output_string do |expected|
|
|
21
20
|
match do |actual|
|
|
21
|
+
actual.force_encoding('UTF-8')
|
|
22
22
|
@expected = Regexp.new(unescape_text(expected), Regexp::MULTILINE)
|
|
23
23
|
@actual = sanitize_text(actual)
|
|
24
24
|
|
|
@@ -30,8 +30,6 @@ RSpec::Matchers.define :match_output_string do |expected|
|
|
|
30
30
|
description { "output string matches: #{description_of expected}" }
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
RSpec::Matchers.alias_matcher :file_content_matching, :match_output_string
|
|
37
|
-
end
|
|
33
|
+
RSpec::Matchers.alias_matcher :an_output_string_matching, :match_output_string
|
|
34
|
+
RSpec::Matchers.alias_matcher :a_file_name_matching, :match_output_string
|
|
35
|
+
RSpec::Matchers.alias_matcher :file_content_matching, :match_output_string
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
# @!method output_string_eq(string)
|
|
2
2
|
# This matchers checks if the output string of a command includes string.
|
|
3
3
|
#
|
|
4
|
-
# @param [
|
|
5
|
-
# The value of the
|
|
4
|
+
# @param [String] string
|
|
5
|
+
# The value of the output string
|
|
6
6
|
#
|
|
7
|
-
# @return [
|
|
7
|
+
# @return [Boolean]
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# False:
|
|
10
10
|
# * if the output string does not include string
|
|
11
|
-
#
|
|
11
|
+
# True:
|
|
12
12
|
# * if the output string includes string
|
|
13
13
|
#
|
|
14
14
|
# @example Use matcher
|
|
15
|
-
#
|
|
16
15
|
# RSpec.describe do
|
|
17
16
|
# it { expect(last_command_started).to have_output output_string_eq string) }
|
|
18
17
|
# it { expect(last_command_started).to have_output an_output_string_begin_eq string) }
|
|
19
18
|
# end
|
|
20
19
|
RSpec::Matchers.define :output_string_eq do |expected|
|
|
21
20
|
match do |actual|
|
|
21
|
+
actual.force_encoding('UTF-8')
|
|
22
22
|
@expected = sanitize_text(expected.to_s)
|
|
23
23
|
@actual = sanitize_text(actual.to_s)
|
|
24
24
|
|
|
@@ -30,6 +30,4 @@ RSpec::Matchers.define :output_string_eq do |expected|
|
|
|
30
30
|
description { "output string is eq: #{description_of expected}" }
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
RSpec::Matchers.alias_matcher :an_output_string_being_eq, :output_string_eq
|
|
35
|
-
end
|
|
33
|
+
RSpec::Matchers.alias_matcher :an_output_string_being_eq, :output_string_eq
|
data/lib/aruba/platform.rb
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
|
-
require 'thread'
|
|
2
1
|
require 'aruba/platforms/unix_platform'
|
|
3
2
|
require 'aruba/platforms/windows_platform'
|
|
4
3
|
|
|
5
4
|
# Aruba
|
|
6
5
|
module Aruba
|
|
7
6
|
PLATFORM_MUTEX = Mutex.new
|
|
8
|
-
end
|
|
9
7
|
|
|
10
|
-
# Aruba
|
|
11
|
-
module Aruba
|
|
12
|
-
# Platform
|
|
13
8
|
Platform = [Platforms::WindowsPlatform, Platforms::UnixPlatform].find(&:match?)
|
|
14
|
-
end
|
|
15
9
|
|
|
16
|
-
# Aruba
|
|
17
|
-
module Aruba
|
|
18
10
|
PLATFORM_MUTEX.synchronize do
|
|
19
11
|
@platform = Platform.new
|
|
20
12
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'shellwords'
|
|
2
2
|
require 'aruba/colorizer'
|
|
3
3
|
|
|
4
|
-
Aruba::
|
|
4
|
+
Aruba::Colorizer.coloring = false if !STDOUT.tty? && !ENV.key?('AUTOTEST')
|
|
5
5
|
|
|
6
6
|
# Aruba
|
|
7
7
|
module Aruba
|
|
@@ -21,31 +21,40 @@ module Aruba
|
|
|
21
21
|
#
|
|
22
22
|
# before do
|
|
23
23
|
# current_example = context.example
|
|
24
|
-
#
|
|
24
|
+
# if current_example.metadata[:announce_my_channel]
|
|
25
|
+
# aruba.announcer.activate :my_channel
|
|
26
|
+
# end
|
|
25
27
|
# end
|
|
26
28
|
#
|
|
27
29
|
# Aruba.announcer.announce(:my_channel, 'my message')
|
|
28
30
|
#
|
|
29
31
|
class Announcer
|
|
32
|
+
# Base Announcer class
|
|
33
|
+
class BaseAnnouncer
|
|
34
|
+
def mode?(m)
|
|
35
|
+
mode == m
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
30
39
|
# Announcer using Kernel.puts
|
|
31
|
-
class KernelPutsAnnouncer
|
|
40
|
+
class KernelPutsAnnouncer < BaseAnnouncer
|
|
32
41
|
def announce(message)
|
|
33
42
|
Kernel.puts message
|
|
34
43
|
end
|
|
35
44
|
|
|
36
|
-
def mode
|
|
37
|
-
:kernel_puts
|
|
45
|
+
def mode
|
|
46
|
+
:kernel_puts
|
|
38
47
|
end
|
|
39
48
|
end
|
|
40
49
|
|
|
41
50
|
# Announcer using Main#puts
|
|
42
|
-
class PutsAnnouncer
|
|
51
|
+
class PutsAnnouncer < BaseAnnouncer
|
|
43
52
|
def announce(message)
|
|
44
53
|
puts message
|
|
45
54
|
end
|
|
46
55
|
|
|
47
|
-
def mode
|
|
48
|
-
:puts
|
|
56
|
+
def mode
|
|
57
|
+
:puts
|
|
49
58
|
end
|
|
50
59
|
end
|
|
51
60
|
|
|
@@ -55,7 +64,7 @@ module Aruba
|
|
|
55
64
|
|
|
56
65
|
public
|
|
57
66
|
|
|
58
|
-
def initialize
|
|
67
|
+
def initialize
|
|
59
68
|
@announcers = []
|
|
60
69
|
@announcers << PutsAnnouncer.new
|
|
61
70
|
@announcers << KernelPutsAnnouncer.new
|
|
@@ -66,56 +75,41 @@ module Aruba
|
|
|
66
75
|
@channels = {}
|
|
67
76
|
@output_formats = {}
|
|
68
77
|
|
|
69
|
-
@options = args[1] || {}
|
|
70
|
-
|
|
71
78
|
after_init
|
|
72
79
|
end
|
|
73
80
|
|
|
74
81
|
private
|
|
75
82
|
|
|
76
|
-
# rubocop:disable Metrics/MethodLength
|
|
77
83
|
def after_init
|
|
78
84
|
output_format :changed_configuration, proc { |n, v| format('# %s = %s', n, v) }
|
|
79
|
-
output_format :changed_environment,
|
|
85
|
+
output_format :changed_environment,
|
|
86
|
+
proc { |n, v| format('$ export %s=%s', n, Shellwords.escape(v)) }
|
|
80
87
|
output_format :command, '$ %s'
|
|
81
88
|
output_format :directory, '$ cd %s'
|
|
82
|
-
output_format :environment,
|
|
83
|
-
|
|
84
|
-
output_format :
|
|
89
|
+
output_format :environment,
|
|
90
|
+
proc { |n, v| format('$ export %s=%s', n, Shellwords.escape(v)) }
|
|
91
|
+
output_format :full_environment,
|
|
92
|
+
proc { |h|
|
|
93
|
+
format("<<-ENVIRONMENT\n%s\nENVIRONMENT",
|
|
94
|
+
Aruba.platform.simple_table(h))
|
|
95
|
+
}
|
|
96
|
+
output_format :modified_environment,
|
|
97
|
+
proc { |n, v| format('$ export %s=%s', n, Shellwords.escape(v)) }
|
|
85
98
|
output_format :stderr, "<<-STDERR\n%s\nSTDERR"
|
|
86
99
|
output_format :stdout, "<<-STDOUT\n%s\nSTDOUT"
|
|
87
100
|
output_format :command_content, "<<-COMMAND\n%s\nCOMMAND"
|
|
88
|
-
output_format :stop_signal,
|
|
101
|
+
output_format :stop_signal,
|
|
102
|
+
proc { |p, s|
|
|
103
|
+
format('Command will be stopped with `kill -%s %s`', s, p)
|
|
104
|
+
}
|
|
89
105
|
output_format :timeout, '# %s-timeout: %s seconds'
|
|
90
106
|
output_format :wait_time, '# %s: %s seconds'
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if @options[:stdout]
|
|
97
|
-
warn('The use of "@announce_stdout-instance" variable and "options[:stdout] = true" for Announcer.new is deprecated. Please use "announcer.activate(:stdout)" instead.')
|
|
98
|
-
activate :stdout
|
|
99
|
-
end
|
|
100
|
-
if @options[:stderr]
|
|
101
|
-
warn('The use of "@announce_stderr-instance" variable and "options[:stderr] = true" for Announcer.new is deprecated. Please use "announcer.activate(:stderr)" instead.')
|
|
102
|
-
activate :stderr
|
|
103
|
-
end
|
|
104
|
-
if @options[:dir]
|
|
105
|
-
warn('The use of "@announce_dir-instance" variable and "options[:dir] = true" for Announcer.new is deprecated. Please use "announcer.activate(:directory)" instead.')
|
|
106
|
-
activate :directory
|
|
107
|
-
end
|
|
108
|
-
if @options[:cmd]
|
|
109
|
-
warn('The use of "@announce_cmd-instance" variable and "options[:cmd] = true" for Announcer.new is deprecated. Please use "announcer.activate(:command)" instead.')
|
|
110
|
-
activate :command
|
|
111
|
-
end
|
|
112
|
-
if @options[:env]
|
|
113
|
-
warn('The use of "@announce_env-instance" variable and "options[:env] = true" for Announcer.new is deprecated. Please use "announcer.activate(:modified_environment)" instead.')
|
|
114
|
-
activate :modified_enviroment
|
|
115
|
-
end
|
|
116
|
-
# rubocop:enable Metrics/LineLength
|
|
107
|
+
output_format :command_filesystem_status,
|
|
108
|
+
proc { |status|
|
|
109
|
+
format("<<-COMMAND FILESYSTEM STATUS\n%s\nCOMMAND FILESYSTEM STATUS",
|
|
110
|
+
Aruba.platform.simple_table(status.to_h, sort: false))
|
|
111
|
+
}
|
|
117
112
|
end
|
|
118
|
-
# rubocop:enable Metrics/MethodLength
|
|
119
113
|
|
|
120
114
|
def output_format(channel, string = '%s', &block)
|
|
121
115
|
output_formats[channel.to_sym] = if block_given?
|
|
@@ -139,11 +133,18 @@ module Aruba
|
|
|
139
133
|
# @param [Symbol] m
|
|
140
134
|
# The mode to set
|
|
141
135
|
def mode=(m)
|
|
142
|
-
@announcer = @announcers.find { |a|
|
|
136
|
+
@announcer = @announcers.find { |a| a.mode? m.to_sym }
|
|
143
137
|
|
|
144
138
|
self
|
|
145
139
|
end
|
|
146
140
|
|
|
141
|
+
# Fecth mode of announcer
|
|
142
|
+
#
|
|
143
|
+
# @return [Symbol] The current announcer mode
|
|
144
|
+
def mode
|
|
145
|
+
@announcer.mode
|
|
146
|
+
end
|
|
147
|
+
|
|
147
148
|
# Check if channel is activated
|
|
148
149
|
#
|
|
149
150
|
# @param [Symbol] channel
|
|
@@ -154,7 +155,7 @@ module Aruba
|
|
|
154
155
|
|
|
155
156
|
# Activate a channel
|
|
156
157
|
#
|
|
157
|
-
# @param [Symbol]
|
|
158
|
+
# @param [Symbol] chns
|
|
158
159
|
# The name of the channel to activate
|
|
159
160
|
def activate(*chns)
|
|
160
161
|
chns.flatten.each { |c| channels[c.to_sym] = true }
|
|
@@ -173,7 +174,7 @@ module Aruba
|
|
|
173
174
|
# @yield
|
|
174
175
|
# If block is given, that one is called and the return value is used as
|
|
175
176
|
# message to be announced.
|
|
176
|
-
def announce(channel, *args
|
|
177
|
+
def announce(channel, *args)
|
|
177
178
|
channel = channel.to_sym
|
|
178
179
|
|
|
179
180
|
the_output_format = if output_formats.key? channel
|
|
@@ -184,49 +185,23 @@ module Aruba
|
|
|
184
185
|
|
|
185
186
|
return unless activated?(channel)
|
|
186
187
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
188
|
+
begin
|
|
189
|
+
if block_given?
|
|
190
|
+
value = yield
|
|
191
|
+
args << value
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
message = the_output_format.call(*args)
|
|
195
|
+
message += "\n"
|
|
196
|
+
message = colorizer.cyan(message)
|
|
197
|
+
rescue NotImplementedError => e
|
|
198
|
+
message = "Error fetching announced value for #{channel}: #{e.message}"
|
|
199
|
+
end
|
|
194
200
|
|
|
195
201
|
announcer.announce(message)
|
|
196
202
|
|
|
197
203
|
nil
|
|
198
204
|
end
|
|
199
|
-
|
|
200
|
-
# @deprecated
|
|
201
|
-
def stdout(content)
|
|
202
|
-
warn('The announcer now has a new api to activate channels. Please use this one: announce(:stdout, message)')
|
|
203
|
-
announce :stdout, content
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
# @deprecated
|
|
207
|
-
def stderr(content)
|
|
208
|
-
warn('The announcer now has a new api to activate channels. Please use this one: announce(:stderr, message)')
|
|
209
|
-
announce :stderr, content
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
# @deprecated
|
|
213
|
-
def dir(dir)
|
|
214
|
-
warn('The announcer now has a new api to activate channels. Please use this one announce(:directory, message)')
|
|
215
|
-
announce :directory, dir
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
# @deprecated
|
|
219
|
-
def cmd(cmd)
|
|
220
|
-
warn('The announcer now has a new api to activate channels. Please use this one announce(:command, message)')
|
|
221
|
-
announce :command, cmd
|
|
222
|
-
end
|
|
223
|
-
|
|
224
|
-
# @deprecated
|
|
225
|
-
def env(name, value)
|
|
226
|
-
warn('The announcer now has a new api to activate channels. Please use this one: announce(:changed_environment, key, value)')
|
|
227
|
-
|
|
228
|
-
announce :changed_environment, name, value
|
|
229
|
-
end
|
|
230
205
|
end
|
|
231
206
|
end
|
|
232
207
|
end
|
|
@@ -15,10 +15,12 @@ module Aruba
|
|
|
15
15
|
# @param [Object] content
|
|
16
16
|
# The content of the file
|
|
17
17
|
#
|
|
18
|
-
# @param [
|
|
18
|
+
# @param [Boolean] check_presence (false)
|
|
19
19
|
# Check if file exist
|
|
20
20
|
def call(path, content, check_presence = false)
|
|
21
|
-
|
|
21
|
+
if check_presence && !Aruba.platform.file?(path)
|
|
22
|
+
raise "Expected #{path} to be present"
|
|
23
|
+
end
|
|
22
24
|
|
|
23
25
|
Aruba.platform.mkdir(File.dirname(path))
|
|
24
26
|
|