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.
Files changed (135) hide show
  1. checksums.yaml +5 -5
  2. data/.github/PULL_REQUEST_TEMPLATE.md +2 -1
  3. data/.rspec +0 -1
  4. data/.rubocop.yml +46 -182
  5. data/.rubocop_todo.yml +216 -0
  6. data/.simplecov +7 -5
  7. data/.travis.yml +56 -40
  8. data/.yardopts +3 -0
  9. data/CHANGELOG.md +1312 -0
  10. data/CONTRIBUTING.md +175 -83
  11. data/Gemfile +5 -69
  12. data/LICENSE +1 -1
  13. data/README.md +58 -21
  14. data/Rakefile +27 -54
  15. data/appveyor.yml +7 -10
  16. data/aruba.gemspec +38 -19
  17. data/bin/console +3 -12
  18. data/cucumber.yml +4 -22
  19. data/exe/aruba +1 -1
  20. data/fixtures/cli-app/README.md +1 -1
  21. data/fixtures/cli-app/Rakefile +1 -1
  22. data/fixtures/cli-app/bin/aruba-test-cli +1 -1
  23. data/fixtures/cli-app/cli-app.gemspec +4 -4
  24. data/fixtures/cli-app/lib/cli/app.rb +1 -1
  25. data/fixtures/cli-app/lib/cli/app/suppress_simple_cov_output.rb +3 -3
  26. data/fixtures/cli-app/lib/cli/app/version.rb +1 -1
  27. data/fixtures/cli-app/spec/spec_helper.rb +3 -2
  28. data/fixtures/empty-app/Rakefile +1 -1
  29. data/fixtures/empty-app/cli-app.gemspec +4 -4
  30. data/fixtures/empty-app/lib/cli/app.rb +0 -2
  31. data/fixtures/empty-app/lib/cli/app/version.rb +1 -1
  32. data/fixtures/getting-started-app/Gemfile +1 -1
  33. data/lib/aruba/api.rb +8 -15
  34. data/lib/aruba/api/bundler.rb +16 -0
  35. data/lib/aruba/api/commands.rb +272 -0
  36. data/lib/aruba/api/core.rb +82 -43
  37. data/lib/aruba/api/environment.rb +24 -7
  38. data/lib/aruba/api/filesystem.rb +66 -64
  39. data/lib/aruba/api/text.rb +17 -11
  40. data/lib/aruba/aruba_path.rb +25 -111
  41. data/lib/aruba/basic_configuration.rb +8 -25
  42. data/lib/aruba/basic_configuration/option.rb +2 -2
  43. data/lib/aruba/cli.rb +4 -1
  44. data/lib/aruba/colorizer.rb +10 -99
  45. data/lib/aruba/command.rb +4 -0
  46. data/lib/aruba/config/jruby.rb +15 -5
  47. data/lib/aruba/config_wrapper.rb +17 -2
  48. data/lib/aruba/configuration.rb +107 -0
  49. data/lib/aruba/console.rb +5 -7
  50. data/lib/aruba/console/help.rb +5 -2
  51. data/lib/aruba/contracts/absolute_path.rb +3 -3
  52. data/lib/aruba/contracts/is_power_of_two.rb +2 -2
  53. data/lib/aruba/contracts/relative_path.rb +3 -3
  54. data/lib/aruba/cucumber.rb +0 -3
  55. data/lib/aruba/cucumber/command.rb +227 -190
  56. data/lib/aruba/cucumber/environment.rb +1 -1
  57. data/lib/aruba/cucumber/file.rb +56 -50
  58. data/lib/aruba/cucumber/hooks.rb +10 -63
  59. data/lib/aruba/cucumber/testing_frameworks.rb +76 -50
  60. data/lib/aruba/event_bus.rb +4 -2
  61. data/lib/aruba/event_bus/name_resolver.rb +10 -10
  62. data/lib/aruba/events.rb +2 -1
  63. data/lib/aruba/hooks.rb +3 -5
  64. data/lib/aruba/in_config_wrapper.rb +10 -3
  65. data/lib/aruba/initializer.rb +40 -34
  66. data/lib/aruba/matchers/base/base_matcher.rb +2 -11
  67. data/lib/aruba/matchers/base/message_indenter.rb +19 -0
  68. data/lib/aruba/matchers/base/object_formatter.rb +2 -7
  69. data/lib/aruba/matchers/collection/include_an_object.rb +11 -13
  70. data/lib/aruba/matchers/command/be_successfully_executed.rb +8 -4
  71. data/lib/aruba/matchers/command/have_exit_status.rb +16 -4
  72. data/lib/aruba/matchers/command/have_finished_in_time.rb +5 -5
  73. data/lib/aruba/matchers/command/have_output.rb +12 -5
  74. data/lib/aruba/matchers/command/have_output_on_stderr.rb +4 -2
  75. data/lib/aruba/matchers/command/have_output_on_stdout.rb +4 -2
  76. data/lib/aruba/matchers/command/have_output_size.rb +2 -2
  77. data/lib/aruba/matchers/directory/be_an_existing_directory.rb +5 -7
  78. data/lib/aruba/matchers/directory/have_sub_directory.rb +10 -7
  79. data/lib/aruba/matchers/file/be_a_command_found_in_path.rb +2 -4
  80. data/lib/aruba/matchers/file/be_an_existing_executable.rb +4 -6
  81. data/lib/aruba/matchers/file/be_an_existing_file.rb +5 -7
  82. data/lib/aruba/matchers/file/have_file_content.rb +4 -4
  83. data/lib/aruba/matchers/file/have_file_size.rb +8 -8
  84. data/lib/aruba/matchers/file/have_same_file_content.rb +9 -12
  85. data/lib/aruba/matchers/path/a_path_matching_pattern.rb +2 -4
  86. data/lib/aruba/matchers/path/be_an_absolute_path.rb +3 -5
  87. data/lib/aruba/matchers/path/be_an_existing_path.rb +4 -6
  88. data/lib/aruba/matchers/path/have_permissions.rb +8 -8
  89. data/lib/aruba/matchers/string/include_output_string.rb +8 -10
  90. data/lib/aruba/matchers/string/match_output_string.rb +9 -11
  91. data/lib/aruba/matchers/string/output_string_eq.rb +7 -9
  92. data/lib/aruba/platform.rb +0 -8
  93. data/lib/aruba/platforms/announcer.rb +60 -85
  94. data/lib/aruba/platforms/aruba_file_creator.rb +4 -2
  95. data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +8 -3
  96. data/lib/aruba/platforms/aruba_logger.rb +22 -2
  97. data/lib/aruba/platforms/command_monitor.rb +15 -102
  98. data/lib/aruba/platforms/determine_disk_usage.rb +56 -19
  99. data/lib/aruba/platforms/filesystem_status.rb +9 -9
  100. data/lib/aruba/platforms/local_environment.rb +2 -2
  101. data/lib/aruba/platforms/simple_table.rb +3 -11
  102. data/lib/aruba/platforms/unix_command_string.rb +7 -4
  103. data/lib/aruba/platforms/unix_environment_variables.rb +19 -26
  104. data/lib/aruba/platforms/unix_platform.rb +18 -39
  105. data/lib/aruba/platforms/unix_which.rb +3 -2
  106. data/lib/aruba/platforms/windows_command_string.rb +20 -7
  107. data/lib/aruba/platforms/windows_environment_variables.rb +42 -30
  108. data/lib/aruba/platforms/windows_platform.rb +4 -0
  109. data/lib/aruba/platforms/windows_which.rb +9 -4
  110. data/lib/aruba/processes/basic_process.rb +21 -27
  111. data/lib/aruba/processes/debug_process.rb +16 -5
  112. data/lib/aruba/processes/in_process.rb +20 -9
  113. data/lib/aruba/processes/spawn_process.rb +64 -36
  114. data/lib/aruba/rspec.rb +28 -31
  115. data/lib/aruba/runtime.rb +16 -7
  116. data/lib/aruba/setup.rb +32 -17
  117. data/lib/aruba/tasks/docker_helpers.rb +4 -2
  118. data/lib/aruba/version.rb +1 -1
  119. metadata +194 -64
  120. data/History.md +0 -612
  121. data/bin/bootstrap +0 -34
  122. data/bin/build +0 -3
  123. data/bin/release +0 -3
  124. data/fixtures/spawn_process/stderr.sh +0 -3
  125. data/lib/aruba/api/command.rb +0 -309
  126. data/lib/aruba/api/deprecated.rb +0 -895
  127. data/lib/aruba/api/rvm.rb +0 -44
  128. data/lib/aruba/config.rb +0 -101
  129. data/lib/aruba/cucumber/rvm.rb +0 -3
  130. data/lib/aruba/in_process.rb +0 -14
  131. data/lib/aruba/jruby.rb +0 -4
  132. data/lib/aruba/matchers/path/match_path_pattern.rb +0 -41
  133. data/lib/aruba/matchers/rspec_matcher_include_regexp.rb +0 -25
  134. data/lib/aruba/platforms/disk_usage_calculator.rb +0 -20
  135. 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 [TrueClass, FalseClass] The result
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("expected that path \"%s\" exists", actual)
27
+ format('expected that path "%s" exists', actual)
28
28
  end
29
29
 
30
30
  failure_message_when_negated do |actual|
31
- format("expected that path \"%s\" does not exist", actual)
31
+ format('expected that path "%s" does not exist', actual)
32
32
  end
33
33
  end
34
34
 
35
- if RSpec::Expectations::Version::STRING >= '3.0'
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 [TrueClass, FalseClass] The result
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 |actual|
54
- format("expected that path \"%s\" has permissions \"%s\", but has \"%s\".", @old_actual, @expected, @actual)
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 |actual|
58
- format("expected that path \"%s\" does not have permissions \"%s\", but has \"%s\".", @old_actual, @expected, @actual)
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
- if RSpec::Expectations::Version::STRING >= '3.0'
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 [Integer] status
5
- # The value of the exit status
4
+ # @param [String] string
5
+ # The value of the output string
6
6
  #
7
- # @return [TrueClass, FalseClass] The result
7
+ # @return [Boolean] The result
8
8
  #
9
- # false:
9
+ # False:
10
10
  # * if the output string does not include string
11
- # true:
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
- if RSpec::Expectations::Version::STRING >= '3.0'
34
- RSpec::Matchers.alias_matcher :an_output_string_including, :include_output_string
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 [Integer] status
5
- # The value of the exit status
4
+ # @param [String] string
5
+ # The value of the output string
6
6
  #
7
- # @return [TrueClass, FalseClass] The result
7
+ # @return [Boolean] The result
8
8
  #
9
- # false:
9
+ # False:
10
10
  # * if the output string does not match regex
11
- # true:
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
- if RSpec::Expectations::Version::STRING >= '3.0'
34
- RSpec::Matchers.alias_matcher :an_output_string_matching, :match_output_string
35
- RSpec::Matchers.alias_matcher :a_file_name_matching, :match_output_string
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 [Integer] status
5
- # The value of the exit status
4
+ # @param [String] string
5
+ # The value of the output string
6
6
  #
7
- # @return [TrueClass, FalseClass] The result
7
+ # @return [Boolean]
8
8
  #
9
- # false:
9
+ # False:
10
10
  # * if the output string does not include string
11
- # true:
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
- if RSpec::Expectations::Version::STRING >= '3.0'
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
@@ -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::AnsiColor.coloring = false if !STDOUT.tty? && !ENV.key?("AUTOTEST")
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
- # aruba.announcer.activate :my_channel if current_example.metadata[:announce_my_channel]
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?(m)
37
- :kernel_puts == m
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?(m)
48
- :puts == m
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(*args)
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, proc { |n, v| format('$ export %s=%s', n, Shellwords.escape(v)) }
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, proc { |n, v| format('$ export %s=%s', n, Shellwords.escape(v)) }
83
- output_format :full_environment, proc { |h| format("<<-ENVIRONMENT\n%s\nENVIRONMENT", Aruba.platform.simple_table(h)) }
84
- output_format :modified_environment, proc { |n, v| format('$ export %s=%s', n, Shellwords.escape(v)) }
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, proc { |p, s| format('Command will be stopped with `kill -%s %s`', s, p) }
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
- # rubocop:disable Metrics/LineLength
92
- output_format :command_filesystem_status, proc { |status| format("<<-COMMAND FILESYSTEM STATUS\n%s\nCOMMAND FILESYSTEM STATUS", Aruba.platform.simple_table(status.to_h, :sort => false)) }
93
- # rubocop:enable Metrics/LineLength
94
-
95
- # rubocop:disable Metrics/LineLength
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| f.mode? m.to_sym }
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] channel
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, &block)
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
- message = if block_given?
188
- the_output_format.call(yield)
189
- else
190
- the_output_format.call(*args)
191
- end
192
- message += "\n"
193
- message = colorizer.cyan(message)
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 [TrueClass, FalseClass] check_presence (false)
18
+ # @param [Boolean] check_presence (false)
19
19
  # Check if file exist
20
20
  def call(path, content, check_presence = false)
21
- fail "Expected #{path} to be present" if check_presence && !Aruba.platform.file?(path)
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