aruba 0.14.9 → 1.0.0

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 (309) hide show
  1. checksums.yaml +4 -4
  2. data/.cucumberproignore +3 -0
  3. data/.github/ISSUE_TEMPLATE.md +48 -0
  4. data/.github/PULL_REQUEST_TEMPLATE.md +41 -0
  5. data/.gitignore +1 -0
  6. data/.rspec +1 -1
  7. data/.rubocop.yml +20 -179
  8. data/.rubocop_todo.yml +262 -0
  9. data/.simplecov +7 -5
  10. data/.travis.yml +54 -46
  11. data/.yardopts +3 -0
  12. data/CHANGELOG.md +613 -246
  13. data/CONTRIBUTING.md +247 -45
  14. data/Dockerfile +67 -0
  15. data/Gemfile +5 -96
  16. data/LICENSE +1 -1
  17. data/README.md +57 -180
  18. data/Rakefile +63 -32
  19. data/appveyor.yml +8 -11
  20. data/aruba.gemspec +47 -41
  21. data/bin/console +7 -0
  22. data/bin/test +9 -0
  23. data/cucumber.yml +4 -24
  24. data/doc/dependency_decisions.yml +42 -2
  25. data/docker-compose.yml +26 -0
  26. data/{bin → exe}/aruba +1 -1
  27. data/fixtures/cli-app/Rakefile +1 -1
  28. data/fixtures/cli-app/bin/aruba-test-cli +6 -0
  29. data/fixtures/cli-app/cli-app.gemspec +1 -2
  30. data/fixtures/cli-app/features/support/aruba.rb +1 -0
  31. data/fixtures/cli-app/features/support/env.rb +1 -1
  32. data/fixtures/cli-app/lib/cli/app/suppress_simple_cov_output.rb +3 -3
  33. data/fixtures/cli-app/lib/cli/app/version.rb +1 -1
  34. data/fixtures/cli-app/lib/cli/app.rb +1 -5
  35. data/fixtures/cli-app/spec/spec_helper.rb +4 -6
  36. data/fixtures/empty-app/Rakefile +1 -1
  37. data/fixtures/empty-app/cli-app.gemspec +1 -2
  38. data/fixtures/empty-app/lib/cli/app/version.rb +1 -1
  39. data/fixtures/empty-app/lib/cli/app.rb +0 -6
  40. data/fixtures/getting-started-app/Gemfile +1 -1
  41. data/lib/aruba/api/commands.rb +109 -143
  42. data/lib/aruba/api/core.rb +57 -43
  43. data/lib/aruba/api/environment.rb +16 -7
  44. data/lib/aruba/api/filesystem.rb +42 -29
  45. data/lib/aruba/api/text.rb +3 -9
  46. data/lib/aruba/api.rb +6 -11
  47. data/lib/aruba/aruba_path.rb +27 -89
  48. data/lib/aruba/basic_configuration.rb +4 -24
  49. data/lib/aruba/cli.rb +1 -1
  50. data/lib/aruba/colorizer.rb +10 -99
  51. data/lib/aruba/command.rb +2 -0
  52. data/lib/aruba/config/jruby.rb +15 -5
  53. data/lib/aruba/config_wrapper.rb +1 -1
  54. data/lib/aruba/configuration.rb +92 -0
  55. data/lib/aruba/console/help.rb +1 -7
  56. data/lib/aruba/console.rb +5 -5
  57. data/lib/aruba/contracts/absolute_path.rb +2 -2
  58. data/lib/aruba/contracts/relative_path.rb +2 -2
  59. data/lib/aruba/cucumber/command.rb +171 -160
  60. data/lib/aruba/cucumber/environment.rb +1 -1
  61. data/lib/aruba/cucumber/file.rb +21 -35
  62. data/lib/aruba/cucumber/hooks.rb +17 -56
  63. data/lib/aruba/cucumber/testing_frameworks.rb +74 -50
  64. data/lib/aruba/cucumber.rb +0 -5
  65. data/lib/aruba/event_bus/name_resolver.rb +5 -16
  66. data/lib/aruba/hooks.rb +1 -1
  67. data/lib/aruba/in_config_wrapper.rb +5 -1
  68. data/lib/aruba/initializer.rb +36 -42
  69. data/lib/aruba/matchers/base/base_matcher.rb +2 -2
  70. data/lib/aruba/matchers/base/message_indenter.rb +19 -0
  71. data/lib/aruba/matchers/base/object_formatter.rb +2 -9
  72. data/lib/aruba/matchers/collection/include_an_object.rb +7 -9
  73. data/lib/aruba/matchers/command/be_successfully_executed.rb +6 -4
  74. data/lib/aruba/matchers/command/have_exit_status.rb +14 -4
  75. data/lib/aruba/matchers/command/have_finished_in_time.rb +3 -5
  76. data/lib/aruba/matchers/command/have_output.rb +10 -5
  77. data/lib/aruba/matchers/command/have_output_on_stderr.rb +2 -2
  78. data/lib/aruba/matchers/command/have_output_on_stdout.rb +2 -2
  79. data/lib/aruba/matchers/command/have_output_size.rb +2 -2
  80. data/lib/aruba/matchers/directory/be_an_existing_directory.rb +5 -7
  81. data/lib/aruba/matchers/directory/have_sub_directory.rb +4 -6
  82. data/lib/aruba/matchers/file/be_a_command_found_in_path.rb +2 -4
  83. data/lib/aruba/matchers/file/be_an_existing_executable.rb +4 -6
  84. data/lib/aruba/matchers/file/be_an_existing_file.rb +5 -7
  85. data/lib/aruba/matchers/file/have_file_content.rb +4 -4
  86. data/lib/aruba/matchers/file/have_file_size.rb +6 -8
  87. data/lib/aruba/matchers/file/have_same_file_content.rb +5 -8
  88. data/lib/aruba/matchers/path/a_path_matching_pattern.rb +2 -4
  89. data/lib/aruba/matchers/path/be_an_absolute_path.rb +3 -5
  90. data/lib/aruba/matchers/path/be_an_existing_path.rb +4 -6
  91. data/lib/aruba/matchers/path/have_permissions.rb +6 -8
  92. data/lib/aruba/matchers/string/include_output_string.rb +8 -10
  93. data/lib/aruba/matchers/string/match_output_string.rb +9 -11
  94. data/lib/aruba/matchers/string/output_string_eq.rb +7 -9
  95. data/lib/aruba/platform.rb +0 -8
  96. data/lib/aruba/platforms/announcer.rb +42 -79
  97. data/lib/aruba/platforms/aruba_file_creator.rb +2 -6
  98. data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +2 -2
  99. data/lib/aruba/platforms/aruba_logger.rb +23 -7
  100. data/lib/aruba/platforms/command_monitor.rb +12 -107
  101. data/lib/aruba/platforms/determine_disk_usage.rb +56 -14
  102. data/lib/aruba/platforms/filesystem_status.rb +10 -14
  103. data/lib/aruba/platforms/local_environment.rb +2 -2
  104. data/lib/aruba/platforms/simple_table.rb +3 -11
  105. data/lib/aruba/platforms/unix_command_string.rb +7 -11
  106. data/lib/aruba/platforms/unix_environment_variables.rb +18 -27
  107. data/lib/aruba/platforms/unix_platform.rb +20 -51
  108. data/lib/aruba/platforms/unix_which.rb +2 -1
  109. data/lib/aruba/platforms/windows_command_string.rb +15 -10
  110. data/lib/aruba/platforms/windows_environment_variables.rb +43 -44
  111. data/lib/aruba/platforms/windows_platform.rb +4 -0
  112. data/lib/aruba/platforms/windows_which.rb +4 -3
  113. data/lib/aruba/processes/basic_process.rb +28 -30
  114. data/lib/aruba/processes/debug_process.rb +12 -3
  115. data/lib/aruba/processes/in_process.rb +17 -8
  116. data/lib/aruba/processes/spawn_process.rb +57 -46
  117. data/lib/aruba/rspec.rb +14 -36
  118. data/lib/aruba/runtime.rb +3 -6
  119. data/lib/aruba/setup.rb +6 -6
  120. data/lib/aruba/tasks/docker_helpers.rb +154 -0
  121. data/lib/aruba/version.rb +1 -1
  122. metadata +191 -244
  123. data/features/.nav +0 -72
  124. data/features/api/command/find_command.feature +0 -83
  125. data/features/api/command/last_command_started.feature +0 -50
  126. data/features/api/command/last_command_stopped.feature +0 -89
  127. data/features/api/command/run.feature +0 -414
  128. data/features/api/command/run_simple.feature +0 -242
  129. data/features/api/command/send_signal.feature +0 -53
  130. data/features/api/command/stderr.feature +0 -46
  131. data/features/api/command/stdout.feature +0 -46
  132. data/features/api/command/stop.feature +0 -131
  133. data/features/api/command/stop_all_commands.feature +0 -53
  134. data/features/api/command/terminate_all_commands.feature +0 -53
  135. data/features/api/command/which.feature +0 -37
  136. data/features/api/core/expand_path.feature +0 -88
  137. data/features/api/environment/append_environment_variable.feature +0 -128
  138. data/features/api/environment/delete_environment_variable.feature +0 -63
  139. data/features/api/environment/prepend_environment_variable.feature +0 -128
  140. data/features/api/environment/set_environment_variable.feature +0 -376
  141. data/features/api/filesystem/cd.feature +0 -184
  142. data/features/api/filesystem/create_directory.feature +0 -57
  143. data/features/api/filesystem/disk_usage.feature +0 -152
  144. data/features/api/filesystem/does_exist.feature +0 -62
  145. data/features/api/filesystem/fixtures.feature +0 -104
  146. data/features/api/filesystem/is_absolute.feature +0 -48
  147. data/features/api/filesystem/is_directory.feature +0 -53
  148. data/features/api/filesystem/is_file.feature +0 -54
  149. data/features/api/filesystem/is_relative.feature +0 -48
  150. data/features/api/filesystem/move.feature +0 -119
  151. data/features/api/text/extract_text.feature +0 -87
  152. data/features/api/text/replace_variables.feature +0 -45
  153. data/features/api/text/sanitize_text.feature +0 -228
  154. data/features/api/text/unescape_text.feature +0 -127
  155. data/features/cli/console.feature +0 -52
  156. data/features/cli/init.feature +0 -79
  157. data/features/configuration/activate_announcer_on_command_failure.feature +0 -38
  158. data/features/configuration/command_runtime_environment.feature +0 -129
  159. data/features/configuration/console_history_file.feature +0 -38
  160. data/features/configuration/exit_timeout.feature +0 -52
  161. data/features/configuration/fixtures_directories.feature +0 -38
  162. data/features/configuration/fixtures_path_prefix.feature +0 -23
  163. data/features/configuration/home_directory.feature +0 -80
  164. data/features/configuration/io_timeout.feature +0 -30
  165. data/features/configuration/keep_ansi.feature +0 -30
  166. data/features/configuration/log_level.feature +0 -38
  167. data/features/configuration/physical_block_size.feature +0 -53
  168. data/features/configuration/remove_ansi_escape_sequences.feature +0 -38
  169. data/features/configuration/root_directory.feature +0 -30
  170. data/features/configuration/startup_wait_time.feature +0 -48
  171. data/features/configuration/usage.feature +0 -159
  172. data/features/configuration/working_directory.feature +0 -33
  173. data/features/development/build.feature +0 -15
  174. data/features/getting_started/cleanup.feature +0 -58
  175. data/features/getting_started/run_commands.feature +0 -187
  176. data/features/getting_started/supported_testing_frameworks.feature +0 -104
  177. data/features/getting_started/writing_good_feature_tests.feature +0 -38
  178. data/features/hooks/after/command.feature +0 -46
  179. data/features/hooks/before/command.feature +0 -75
  180. data/features/matchers/collection/include_an_object.feature +0 -72
  181. data/features/matchers/directory/have_sub_directory.feature +0 -110
  182. data/features/matchers/file/be_a_command_found_in_path.feature +0 -115
  183. data/features/matchers/file/be_existing_executable.feature +0 -88
  184. data/features/matchers/file/be_existing_file.feature +0 -82
  185. data/features/matchers/file/have_file_content.feature +0 -123
  186. data/features/matchers/file/have_file_size.feature +0 -107
  187. data/features/matchers/path/be_an_absolute_path.feature +0 -74
  188. data/features/matchers/path/be_an_existing_path.feature +0 -97
  189. data/features/matchers/path/have_permissions.feature +0 -118
  190. data/features/matchers/timeouts.feature +0 -48
  191. data/features/platforms/jruby.feature +0 -14
  192. data/features/rspec/integration.feature +0 -179
  193. data/features/step_definitions/aruba_dev_steps.rb +0 -56
  194. data/features/step_definitions/hooks.rb +0 -156
  195. data/features/steps/command/debug.feature +0 -92
  196. data/features/steps/command/exit_statuses.feature +0 -136
  197. data/features/steps/command/in_process.feature +0 -485
  198. data/features/steps/command/interactive.feature +0 -90
  199. data/features/steps/command/output.feature +0 -567
  200. data/features/steps/command/run.feature +0 -66
  201. data/features/steps/command/send_signal.feature +0 -104
  202. data/features/steps/command/shell.feature +0 -155
  203. data/features/steps/command/stderr.feature +0 -68
  204. data/features/steps/command/stdout.feature +0 -109
  205. data/features/steps/command/stop.feature +0 -313
  206. data/features/steps/core/announce.feature +0 -283
  207. data/features/steps/environment/append_environment_variable.feature +0 -52
  208. data/features/steps/environment/disable_bunder.feature +0 -18
  209. data/features/steps/environment/home_variable.feature +0 -62
  210. data/features/steps/environment/prepend_environment_variable.feature +0 -52
  211. data/features/steps/environment/set_environment_variable.feature +0 -49
  212. data/features/steps/filesystem/append_to_file.feature +0 -45
  213. data/features/steps/filesystem/cd_to_directory.feature +0 -33
  214. data/features/steps/filesystem/check_file_content.feature +0 -61
  215. data/features/steps/filesystem/check_permissions_of_file.feature +0 -39
  216. data/features/steps/filesystem/compare_files.feature +0 -42
  217. data/features/steps/filesystem/copy.feature +0 -45
  218. data/features/steps/filesystem/create_directory.feature +0 -57
  219. data/features/steps/filesystem/create_file.feature +0 -76
  220. data/features/steps/filesystem/existence_of_directory.feature +0 -57
  221. data/features/steps/filesystem/existence_of_file.feature +0 -43
  222. data/features/steps/filesystem/file_content.feature +0 -86
  223. data/features/steps/filesystem/fixtures.feature +0 -64
  224. data/features/steps/filesystem/move.feature +0 -45
  225. data/features/steps/filesystem/non_existence_of_directory.feature +0 -69
  226. data/features/steps/filesystem/non_existence_of_file.feature +0 -80
  227. data/features/steps/filesystem/overwrite_file.feature +0 -72
  228. data/features/steps/filesystem/remove_directory.feature +0 -38
  229. data/features/steps/filesystem/remove_file.feature +0 -38
  230. data/features/steps/filesystem/use_fixture.feature +0 -77
  231. data/features/steps/overview.feature +0 -25
  232. data/features/support/aruba.rb +0 -7
  233. data/features/support/env.rb +0 -33
  234. data/features/support/jruby.rb +0 -5
  235. data/features/support/simplecov_setup.rb +0 -8
  236. data/fixtures/cli-app/bin/cli +0 -6
  237. data/fixtures/spawn_process/stderr.sh +0 -3
  238. data/lib/aruba/api/deprecated.rb +0 -1234
  239. data/lib/aruba/config.rb +0 -107
  240. data/lib/aruba/cucumber/core.rb +0 -5
  241. data/lib/aruba/cucumber/rvm.rb +0 -3
  242. data/lib/aruba/in_process.rb +0 -14
  243. data/lib/aruba/jruby.rb +0 -4
  244. data/lib/aruba/matchers/deprecated/file.rb +0 -17
  245. data/lib/aruba/matchers/deprecated.rb +0 -1
  246. data/lib/aruba/matchers/path/match_path_pattern.rb +0 -41
  247. data/lib/aruba/matchers/rspec_matcher_include_regexp.rb +0 -25
  248. data/lib/aruba/platforms/disk_usage_calculator.rb +0 -20
  249. data/lib/aruba/reporting.rb +0 -126
  250. data/lib/aruba/spawn_process.rb +0 -11
  251. data/script/bootstrap +0 -28
  252. data/script/console +0 -16
  253. data/script/test +0 -3
  254. data/spec/aruba/api/bundler_spec.rb +0 -15
  255. data/spec/aruba/api/deprecated_spec.rb +0 -308
  256. data/spec/aruba/api/environment/restore_env_spec.rb +0 -86
  257. data/spec/aruba/api/environment/set_env_spec.rb +0 -46
  258. data/spec/aruba/api/filesystem/file_size_spec.rb +0 -28
  259. data/spec/aruba/api/runtime_spec.rb +0 -28
  260. data/spec/aruba/api_spec.rb +0 -981
  261. data/spec/aruba/aruba_path_spec.rb +0 -103
  262. data/spec/aruba/basic_configuration_spec.rb +0 -5
  263. data/spec/aruba/configuration_spec.rb +0 -5
  264. data/spec/aruba/hooks_spec.rb +0 -17
  265. data/spec/aruba/in_config_wrapper_spec.rb +0 -25
  266. data/spec/aruba/jruby_spec.rb +0 -55
  267. data/spec/aruba/matchers/command/have_output_size_spec.rb +0 -25
  268. data/spec/aruba/matchers/command_spec.rb +0 -174
  269. data/spec/aruba/matchers/deprecated_spec.rb +0 -120
  270. data/spec/aruba/matchers/directory_spec.rb +0 -57
  271. data/spec/aruba/matchers/file_spec.rb +0 -208
  272. data/spec/aruba/matchers/path_spec.rb +0 -58
  273. data/spec/aruba/platform/simple_table_spec.rb +0 -23
  274. data/spec/aruba/platform/windows_environment_variables_spec.rb +0 -500
  275. data/spec/aruba/platforms/unix_command_string_spec.rb +0 -17
  276. data/spec/aruba/platforms/windows_command_string_spec.rb +0 -22
  277. data/spec/aruba/rspec_spec.rb +0 -15
  278. data/spec/aruba/runtime_spec.rb +0 -29
  279. data/spec/aruba/spawn_process_spec.rb +0 -96
  280. data/spec/event_bus/name_resolver_spec.rb +0 -68
  281. data/spec/event_bus_spec.rb +0 -158
  282. data/spec/spec_helper.rb +0 -20
  283. data/spec/support/configs/.keep +0 -0
  284. data/spec/support/configs/aruba.rb +0 -5
  285. data/spec/support/configs/pry.rb +0 -3
  286. data/spec/support/configs/rspec.rb +0 -15
  287. data/spec/support/helpers/.keep +0 -0
  288. data/spec/support/helpers/reporting.rb +0 -44
  289. data/spec/support/matchers/.keep +0 -0
  290. data/spec/support/matchers/option.rb +0 -35
  291. data/spec/support/shared_contexts/.keep +0 -0
  292. data/spec/support/shared_contexts/aruba.rb +0 -49
  293. data/spec/support/shared_examples/.keep +0 -0
  294. data/spec/support/shared_examples/configuration.rb +0 -116
  295. data/spec/support/shared_examples/directory.rb +0 -7
  296. data/spec/support/shared_examples/file.rb +0 -7
  297. data/templates/css/console.css +0 -24
  298. data/templates/css/filesystem.css +0 -42
  299. data/templates/css/pygments-autumn.css +0 -59
  300. data/templates/files.erb +0 -14
  301. data/templates/images/LICENSE +0 -22
  302. data/templates/images/folder.png +0 -0
  303. data/templates/images/page_white.png +0 -0
  304. data/templates/images/page_white_gherkin.png +0 -0
  305. data/templates/images/page_white_ruby.png +0 -0
  306. data/templates/index.erb +0 -20
  307. data/templates/js/filesystem.js +0 -5
  308. data/templates/js/jquery-1.11.3.min.js +0 -5
  309. data/templates/main.erb +0 -34
@@ -13,6 +13,8 @@ module Aruba
13
13
  #
14
14
  # @param [String] value
15
15
  # The value of the environment variable. Needs to be a string.
16
+ #
17
+ # @return [self]
16
18
  def set_environment_variable(name, value)
17
19
  name = name.to_s
18
20
  value = value.to_s
@@ -21,7 +23,8 @@ module Aruba
21
23
  aruba.environment[name] = value
22
24
  new_environment = aruba.environment.to_h
23
25
 
24
- aruba.event_bus.notify Events::AddedEnvironmentVariable.new(:old => old_environment, :new => new_environment, :changed => { :name => name, :value => value })
26
+ environment_change = { old: old_environment, new: new_environment, changed: { name: name, value: value } }
27
+ aruba.event_bus.notify Events::AddedEnvironmentVariable.new(environment_change)
25
28
 
26
29
  self
27
30
  end
@@ -33,6 +36,8 @@ module Aruba
33
36
  #
34
37
  # @param [String] value
35
38
  # The value of the environment variable. Needs to be a string.
39
+ #
40
+ # @return [self]
36
41
  def append_environment_variable(name, value)
37
42
  name = name.to_s
38
43
  value = value.to_s
@@ -41,7 +46,8 @@ module Aruba
41
46
  aruba.environment.append name, value
42
47
  new_environment = aruba.environment.to_h
43
48
 
44
- aruba.event_bus.notify Events::ChangedEnvironmentVariable.new(:old => old_environment, :new => new_environment, :changed => { :name => name, :value => value })
49
+ environment_change = { old: old_environment, new: new_environment, changed: { name: name, value: value } }
50
+ aruba.event_bus.notify Events::ChangedEnvironmentVariable.new(environment_change)
45
51
 
46
52
  self
47
53
  end
@@ -53,6 +59,8 @@ module Aruba
53
59
  #
54
60
  # @param [String] value
55
61
  # The value of the environment variable. Needs to be a string.
62
+ #
63
+ # @return [self]
56
64
  def prepend_environment_variable(name, value)
57
65
  name = name.to_s
58
66
  value = value.to_s
@@ -61,18 +69,18 @@ module Aruba
61
69
  aruba.environment.prepend name, value
62
70
  new_environment = aruba.environment.to_h
63
71
 
64
- aruba.event_bus.notify Events::ChangedEnvironmentVariable.new(:old => old_environment, :new => new_environment, :changed => { :name => name, :value => value })
72
+ environment_change = { old: old_environment, new: new_environment, changed: { name: name, value: value } }
73
+ aruba.event_bus.notify Events::ChangedEnvironmentVariable.new(environment_change)
65
74
 
66
75
  self
67
76
  end
68
77
 
69
78
  # Remove existing environment variable
70
79
  #
71
- # @param [String] key
80
+ # @param [String] name
72
81
  # The name of the environment variable as string, e.g. 'HOME'
73
82
  #
74
- # @param [String] value
75
- # The value of the environment variable. Needs to be a string.
83
+ # @return [self]
76
84
  def delete_environment_variable(name)
77
85
  name = name.to_s
78
86
 
@@ -80,7 +88,8 @@ module Aruba
80
88
  aruba.environment.delete name
81
89
  new_environment = aruba.environment.to_h
82
90
 
83
- aruba.event_bus.notify Events::DeletedEnvironmentVariable.new(:old => old_environment, :new => new_environment, :changed => { :name => name, :value => '' })
91
+ environment_change = { old: old_environment, new: new_environment, changed: { name: name, value: '' } }
92
+ aruba.event_bus.notify Events::ChangedEnvironmentVariable.new(environment_change)
84
93
 
85
94
  self
86
95
  end
@@ -1,9 +1,8 @@
1
- require 'aruba/platform'
1
+ require 'pathname'
2
2
 
3
+ require 'aruba/platform'
3
4
  require 'aruba/extensions/string/strip'
4
5
 
5
- require 'aruba/aruba_path'
6
-
7
6
  Aruba.platform.require_matching_files('../matchers/file/*.rb', __FILE__)
8
7
  Aruba.platform.require_matching_files('../matchers/directory/*.rb', __FILE__)
9
8
  Aruba.platform.require_matching_files('../matchers/path/*.rb', __FILE__)
@@ -40,8 +39,10 @@ module Aruba
40
39
 
41
40
  # Check if file exist and is executable
42
41
  #
43
- # @param [String] file
44
- # The file which should exist
42
+ # @param [String] path
43
+ # The path which should exist and be executable
44
+ #
45
+ # @return [Boolean]
45
46
  def executable?(path)
46
47
  path = expand_path(path)
47
48
 
@@ -50,18 +51,16 @@ module Aruba
50
51
 
51
52
  # Check if path is absolute
52
53
  #
53
- # @return [TrueClass, FalseClass]
54
- # Result of check
54
+ # @return [Boolean]
55
55
  def absolute?(path)
56
- ArubaPath.new(path).absolute?
56
+ Aruba.platform.absolute_path?(path)
57
57
  end
58
58
 
59
59
  # Check if path is relative
60
60
  #
61
- # @return [TrueClass, FalseClass]
62
- # Result of check
61
+ # @return [Boolean]
63
62
  def relative?(path)
64
- ArubaPath.new(path).relative?
63
+ Aruba.platform.relative_path?(path)
65
64
  end
66
65
 
67
66
  # Return all existing paths (directories, files) in current dir
@@ -69,7 +68,7 @@ module Aruba
69
68
  # @return [Array]
70
69
  # List of files and directories
71
70
  def all_paths
72
- list('.').map { |p| expand_path(p) }
71
+ list('.').map { |path| expand_path(path) }
73
72
  end
74
73
 
75
74
  # Return all existing files in current directory
@@ -107,9 +106,9 @@ module Aruba
107
106
  fail ArgumentError, %(Only directories are supported. Path "#{name}" is not a directory.) unless directory? name
108
107
 
109
108
  existing_files = Dir.glob(expand_path(File.join(name, '**', '*')))
110
- current_working_directory = ArubaPath.new(expand_path('.'))
109
+ current_working_directory = Pathname.new(expand_path('.'))
111
110
 
112
- existing_files.map { |d| ArubaPath.new(d).relative_path_from(current_working_directory).to_s }
111
+ existing_files.map { |d| Pathname.new(d).relative_path_from(current_working_directory).to_s }
113
112
  end
114
113
 
115
114
  # Return content of file
@@ -128,10 +127,10 @@ module Aruba
128
127
  # The method does not check if file already exists. If the file name is a
129
128
  # path the method will create all neccessary directories.
130
129
  #
131
- # @param [String] file_name
130
+ # @param [String] name
132
131
  # The name of the file
133
132
  #
134
- # @param [String] file_content
133
+ # @param [String] content
135
134
  # The content which should be written to the file
136
135
  def write_file(name, content)
137
136
  Aruba.platform.create_file(expand_path(name), content, false)
@@ -181,8 +180,13 @@ module Aruba
181
180
  raise ArgumentError, %(The following source "#{s}" does not exist.) unless exist? s
182
181
  end
183
182
 
184
- raise ArgumentError, "Using a fixture as destination (#{destination}) is not supported" if destination.start_with? aruba.config.fixtures_path_prefix
185
- raise ArgumentError, "Multiples sources can only be copied to a directory" if source.count > 1 && exist?(destination) && !directory?(destination)
183
+ if destination.start_with? aruba.config.fixtures_path_prefix
184
+ raise ArgumentError, "Using a fixture as destination (#{destination}) is not supported"
185
+ end
186
+
187
+ if source.count > 1 && exist?(destination) && !directory?(destination)
188
+ raise ArgumentError, 'Multiples sources can only be copied to a directory'
189
+ end
186
190
 
187
191
  source_paths = source.map { |f| expand_path(f) }
188
192
  destination_path = expand_path(destination)
@@ -222,13 +226,17 @@ module Aruba
222
226
  raise ArgumentError, "Using a fixture as source (#{source}) is not supported" if s.start_with? aruba.config.fixtures_path_prefix
223
227
  end
224
228
 
225
- raise ArgumentError, "Using a fixture as destination (#{destination}) is not supported" if destination.start_with? aruba.config.fixtures_path_prefix
229
+ if destination.start_with? aruba.config.fixtures_path_prefix
230
+ raise ArgumentError, "Using a fixture as destination (#{destination}) is not supported"
231
+ end
226
232
 
227
233
  source.each do |s|
228
234
  raise ArgumentError, %(The following source "#{s}" does not exist.) unless exist? s
229
235
  end
230
236
 
231
- raise ArgumentError, "Multiple sources can only be copied to a directory" if source.count > 1 && exist?(destination) && !directory?(destination)
237
+ if source.count > 1 && exist?(destination) && !directory?(destination)
238
+ raise ArgumentError, 'Multiple sources can only be copied to a directory'
239
+ end
232
240
 
233
241
  source_paths = source.map { |f| expand_path(f) }
234
242
  destination_path = expand_path(destination)
@@ -252,10 +260,10 @@ module Aruba
252
260
  # The method does not check if file already exists. If the file name is a
253
261
  # path the method will create all neccessary directories.
254
262
  #
255
- # @param [String] file_name
263
+ # @param [String] name
256
264
  # The name of the file
257
265
  #
258
- # @param [Integer] file_size
266
+ # @param [Integer] size
259
267
  # The size of the file
260
268
  def write_fixed_size_file(name, size)
261
269
  Aruba.platform.create_fixed_size_file(expand_path(name), size, false)
@@ -297,8 +305,8 @@ module Aruba
297
305
  mode
298
306
  end
299
307
 
300
- args.each { |p| raise "Expected #{p} to be present" unless exist?(p) }
301
- paths = args.map { |p| expand_path(p) }
308
+ args.each { |path| raise "Expected #{path} to be present" unless exist?(path) }
309
+ paths = args.map { |path| expand_path(path) }
302
310
 
303
311
  Aruba.platform.chmod(mode, paths, options)
304
312
 
@@ -342,7 +350,7 @@ module Aruba
342
350
  {}
343
351
  end
344
352
 
345
- args = args.map { |p| expand_path(p) }
353
+ args = args.map { |path| expand_path(path) }
346
354
 
347
355
  Aruba.platform.rm(args, options)
348
356
  end
@@ -354,7 +362,7 @@ module Aruba
354
362
  #
355
363
  # @yield
356
364
  # Pass the content of the given file to this block
357
- def with_file_content(file, &block)
365
+ def with_file_content(file)
358
366
  expect(file).to be_an_existing_path
359
367
 
360
368
  content = read(file).join("\n")
@@ -370,16 +378,21 @@ module Aruba
370
378
  # @param [Array, Path] paths
371
379
  # The paths
372
380
  #
373
- # @result [FileSize]
381
+ # @return [FileSize]
374
382
  # Bytes on disk
375
383
  def disk_usage(*paths)
376
- expect(paths.flatten).to Aruba::Matchers.all be_an_existing_path
384
+ paths = paths.flatten
385
+ expect(paths).to Aruba::Matchers.all be_an_existing_path
386
+ expanded = paths.map { |path| expand_path(path) }
377
387
 
378
- Aruba.platform.determine_disk_usage paths.flatten.map { |p| ArubaPath.new(expand_path(p)) }, aruba.config.physical_block_size
388
+ Aruba.platform.determine_disk_usage(expanded)
379
389
  end
380
390
 
381
391
  # Get size of file
382
392
  #
393
+ # @param [String] name
394
+ # File name
395
+ #
383
396
  # @return [Numeric]
384
397
  # The size of the file
385
398
  def file_size(name)
@@ -22,11 +22,7 @@ module Aruba
22
22
  # @param [#to_s] text
23
23
  # Input
24
24
  def extract_text(text)
25
- if Aruba::VERSION < '1'
26
- text.gsub(/(?:\e|\033)\[\d+(?>(;\d+)*)m/, '')
27
- else
28
- text.gsub(/(?:\e|\033)\[\d+(?>(;\d+)*)m/, '').gsub(/\\\[|\\\]/, '').gsub(/\007|\016|\017/, '')
29
- end
25
+ text.gsub(/(?:\e|\033)\[\d+(?>(;\d+)*)m/, '').gsub(/\\\[|\\\]/, '').gsub(/\007|\016|\017/, '')
30
26
  end
31
27
 
32
28
  # Unescape special characters and remove ANSI characters
@@ -35,14 +31,12 @@ module Aruba
35
31
  # The text to sanitize
36
32
  def sanitize_text(text)
37
33
  text = unescape_text(text)
38
- text = extract_text(text) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
34
+ text = extract_text(text) if aruba.config.remove_ansi_escape_sequences
39
35
 
40
36
  text.chomp
41
37
  end
42
38
 
43
- # @experimental
44
- #
45
- # Replace variables in command string
39
+ # Replace variables in command string (experimental)
46
40
  #
47
41
  # @param [#to_s] text
48
42
  # The text to parse
data/lib/aruba/api.rb CHANGED
@@ -8,10 +8,6 @@ require 'aruba/platform'
8
8
  require 'aruba/api/core'
9
9
  require 'aruba/api/commands'
10
10
 
11
- if Aruba::VERSION <= '1.0.0'
12
- require 'aruba/api/deprecated'
13
- end
14
-
15
11
  require 'aruba/api/environment'
16
12
  require 'aruba/api/filesystem'
17
13
  require 'aruba/api/text'
@@ -23,12 +19,11 @@ Aruba.platform.require_matching_files('../matchers/**/*.rb', __FILE__)
23
19
  module Aruba
24
20
  # Api
25
21
  module Api
26
- include Aruba::Api::Core
27
- include Aruba::Api::Commands
28
- include Aruba::Api::Environment
29
- include Aruba::Api::Filesystem
30
- include Aruba::Api::Bundler
31
- include Aruba::Api::Deprecated
32
- include Aruba::Api::Text
22
+ include Core
23
+ include Commands
24
+ include Environment
25
+ include Filesystem
26
+ include Text
27
+ include Bundler
33
28
  end
34
29
  end
@@ -1,30 +1,21 @@
1
1
  require 'pathname'
2
- require 'delegate'
3
-
4
- require 'aruba/file_size'
5
2
 
6
3
  # Aruba
7
4
  module Aruba
8
5
  # Pathname for aruba files and directories
9
6
  #
10
7
  # @private
11
- class ArubaPath < Delegator
8
+ class ArubaPath
12
9
  def initialize(path)
13
- obj = [path.to_s].flatten
14
-
15
- super obj
16
-
17
- @delegate_sd_obj = obj
10
+ @obj = [path.to_s].flatten
18
11
  end
19
12
 
20
- # Get path
21
- def __getobj__
22
- ::Pathname.new(::File.join(*@delegate_sd_obj))
13
+ def to_str
14
+ to_pathname.to_s
23
15
  end
24
16
 
25
- # Set path
26
- def __setobj__(obj)
27
- @delegate_sd_obj = [obj.to_s].flatten
17
+ def to_s
18
+ to_str
28
19
  end
29
20
 
30
21
  # Add directory/file to path
@@ -39,95 +30,42 @@ module Aruba
39
30
  # puts path
40
31
  # # => path/to/dir.d/subdir.d
41
32
  def push(p)
42
- @delegate_sd_obj << p
33
+ @obj << p
43
34
  end
44
35
  alias << push
45
36
 
46
- # Remove last component of path
37
+ # Remove last pushed component of path
47
38
  #
48
39
  # @example
49
- # path = ArubaPath.new 'path/to/dir.d'
40
+ # path = ArubaPath.new 'path/to'
41
+ # path.push 'dir'
50
42
  # path.pop
51
- # puts path
52
- # # => path/to
43
+ # puts path # => path/to
53
44
  def pop
54
- @delegate_sd_obj.pop
55
- end
56
-
57
- if RUBY_VERSION < '1.9'
58
- def to_s
59
- __getobj__.to_s
60
- end
61
-
62
- def relative?
63
- !(%r{\A/} === to_s)
64
- end
65
-
66
- def absolute?
67
- (%r{\A/} === to_s)
68
- end
69
-
70
- def to_ary
71
- to_a
72
- end
73
- end
74
-
75
- # How many parts has the file name
76
- #
77
- # @return [Integer]
78
- # The count of file name parts
79
- #
80
- # @example
81
- #
82
- # path = ArubaPath.new('path/to/file.txt')
83
- # path.depth # => 3
84
- #
85
- def depth
86
- if RUBY_VERSION < '1.9'
87
- items = []
88
- __getobj__.each_filename { |f| items << f }
89
-
90
- items.size
91
- else
92
- __getobj__.each_filename.to_a.size
93
- end
94
- end
95
-
96
- # Path ends with string
97
- #
98
- # @param [String] string
99
- # The string to check
100
- def end_with?(string)
101
- to_s.end_with? string
102
- end
103
-
104
- # Path starts with string
105
- #
106
- # @param [String] string
107
- # The string to check
108
- def start_with?(string)
109
- to_s.start_with? string
45
+ @obj.pop
110
46
  end
111
47
 
112
48
  # Return string at index
113
49
  #
114
50
  # @param [Integer, Range] index
115
51
  def [](index)
116
- if RUBY_VERSION < '1.9'
117
- to_s.chars.to_a[index].to_a.join('')
118
- else
119
- to_s[index]
120
- end
52
+ to_s[index]
121
53
  end
122
54
 
123
- # Report count of blocks allocated on disk
124
- #
125
- # This reports the amount of blocks which are allocated by the path.
126
- #
127
- # @return [Integer]
128
- # The count of blocks on disk
129
- def blocks
130
- File::Stat.new(to_s).blocks
55
+ private
56
+
57
+ # Get path
58
+ def to_pathname
59
+ current_path = @obj.inject do |path, element|
60
+ if element.start_with? '~'
61
+ element
62
+ elsif Aruba.platform.absolute_path? element
63
+ element
64
+ else
65
+ File.join(path, element)
66
+ end
67
+ end
68
+ ::Pathname.new(current_path)
131
69
  end
132
70
  end
133
71
  end
@@ -72,7 +72,7 @@ module Aruba
72
72
  define_method("#{name}=") { |v| find_option(name).value = v }
73
73
 
74
74
  # Add reader
75
- option_reader name, :contract => { None => contract.values.first }
75
+ option_reader name, contract: { None => contract.values.first }
76
76
  end
77
77
 
78
78
  private
@@ -80,7 +80,7 @@ module Aruba
80
80
  def add_option(name, value = nil)
81
81
  return if known_options.key?(name)
82
82
 
83
- known_options[name] = Option.new(:name => name, :value => value)
83
+ known_options[name] = Option.new(name: name, value: value)
84
84
 
85
85
  self
86
86
  end
@@ -114,29 +114,13 @@ module Aruba
114
114
 
115
115
  # Make deep dup copy of configuration
116
116
  def make_copy
117
- obj = self.dup
117
+ obj = dup
118
118
  obj.local_options = Marshal.load(Marshal.dump(local_options))
119
119
  obj.hooks = @hooks
120
120
 
121
121
  obj
122
122
  end
123
123
 
124
- # Get access to hooks
125
- def hooks
126
- # rubocop:disable Metrics/LineLength
127
- Aruba.platform.deprecated 'The use of the "#aruba.config.hooks" is deprecated. Please use "#aruba.config.before(:name) {}" to define and "#aruba.config.before(:name, *args)" to run a hook. This method will become private in the next major version.'
128
- # rubocop:enable Metrics/LineLength
129
-
130
- @hooks
131
- end
132
-
133
- # @deprecated
134
- def before_cmd(&block)
135
- Aruba.platform.deprecated 'The use of the "#before_cmd"-hook is deprecated. Please define with "#before(:command) {}" instead'
136
-
137
- before(:command, &block)
138
- end
139
-
140
124
  # Define or run before-hook
141
125
  #
142
126
  # @param [Symbol, String] name
@@ -215,11 +199,7 @@ module Aruba
215
199
 
216
200
  # Set if name is option
217
201
  def set_if_option(name, *args)
218
- if RUBY_VERSION < '1.9'
219
- send("#{name}=".to_sym, *args) if option? name
220
- else
221
- public_send("#{name}=".to_sym, *args) if option? name
222
- end
202
+ public_send("#{name}=".to_sym, *args) if option? name
223
203
  end
224
204
 
225
205
  private
data/lib/aruba/cli.rb CHANGED
@@ -18,7 +18,7 @@ module Aruba
18
18
  end
19
19
 
20
20
  desc 'init', 'Initialize aruba'
21
- option :test_framework, :default => 'cucumber', :enum => %w(cucumber rspec minitest), :desc => 'Choose which test framework to use'
21
+ option :test_framework, default: 'cucumber', enum: %w(cucumber rspec minitest), desc: 'Choose which test framework to use'
22
22
  def init
23
23
  Aruba::Initializer.new.call(options[:test_framework])
24
24
  end
@@ -1,108 +1,19 @@
1
+ # Aruba
1
2
  module Aruba
2
- # The ANSIColor module can be used for namespacing and mixed into your own
3
- # classes.
4
- module AnsiColor
5
- # :stopdoc:
6
- ATTRIBUTES = [
7
- [ :clear , 0 ],
8
- [ :reset , 0 ], # synonym for :clear
9
- [ :bold , 1 ],
10
- [ :dark , 2 ],
11
- [ :italic , 3 ], # not widely implemented
12
- [ :underline , 4 ],
13
- [ :underscore , 4 ], # synonym for :underline
14
- [ :blink , 5 ],
15
- [ :rapid_blink , 6 ], # not widely implemented
16
- [ :negative , 7 ], # no reverse because of String#reverse
17
- [ :concealed , 8 ],
18
- [ :strikethrough, 9 ], # not widely implemented
19
- [ :black , 30 ],
20
- [ :red , 31 ],
21
- [ :green , 32 ],
22
- [ :yellow , 33 ],
23
- [ :blue , 34 ],
24
- [ :magenta , 35 ],
25
- [ :cyan , 36 ],
26
- [ :white , 37 ],
27
- [ :on_black , 40 ],
28
- [ :on_red , 41 ],
29
- [ :on_green , 42 ],
30
- [ :on_yellow , 43 ],
31
- [ :on_blue , 44 ],
32
- [ :on_magenta , 45 ],
33
- [ :on_cyan , 46 ],
34
- [ :on_white , 47 ]
35
- ].freeze
36
-
37
- ATTRIBUTE_NAMES = ATTRIBUTES.transpose.first
38
- # :startdoc:
39
-
40
- # Returns true, if the coloring function of this module
41
- # is switched on, false otherwise.
42
- def self.coloring?
43
- @coloring
44
- end
45
-
46
- # Turns the coloring on or off globally, so you can easily do
47
- # this for example:
48
- # Cucumber::Term::ANSIColor::coloring = STDOUT.isatty
49
- def self.coloring=(val)
50
- @coloring = val
51
- end
52
- self.coloring = true
53
-
54
- ATTRIBUTES.each do |c, v|
55
- define_method(c) do |string|
56
- result = ''
57
- result << "\e[#{v}m" if Aruba::AnsiColor.coloring?
58
- if block_given?
59
- result << yield
60
- elsif string
61
- result << string
62
- elsif respond_to?(:to_str)
63
- result << to_str
64
- else
65
- return result #only switch on
66
- end
67
- result << "\e[0m" if Aruba::AnsiColor.coloring?
68
- result
69
- end
70
- end
71
-
72
- # Regular expression that is used to scan for ANSI-sequences while
73
- # uncoloring strings.
74
- COLORED_REGEXP = /\e\[(?:[34][0-7]|[0-9])?m/
3
+ # Simple colorizer class. Only supports the color cyan
4
+ class Colorizer
5
+ class << self
6
+ attr_accessor :coloring
75
7
 
76
- def self.included(klass)
77
- if klass == String
78
- ATTRIBUTES.delete(:clear)
79
- ATTRIBUTE_NAMES.delete(:clear)
80
- end
8
+ alias coloring? coloring
81
9
  end
82
10
 
83
- # Returns an uncolored version of the string, that is all
84
- # ANSI-sequences are stripped from the string.
85
- def uncolored(string = nil) # :yields:
86
- if block_given?
87
- yield.gsub(COLORED_REGEXP, '')
88
- elsif string
89
- string.gsub(COLORED_REGEXP, '')
90
- elsif respond_to?(:to_str)
91
- to_str.gsub(COLORED_REGEXP, '')
11
+ def cyan(string)
12
+ if self.class.coloring?
13
+ "\e[36m#{string}\e[0m"
92
14
  else
93
- ''
15
+ string
94
16
  end
95
17
  end
96
-
97
- # Returns an array of all Aruba::Platforms::AnsiColor attributes as symbols.
98
- def attributes
99
- ATTRIBUTE_NAMES
100
- end
101
- end
102
- end
103
-
104
- module Aruba
105
- class Colorizer
106
- include Aruba::AnsiColor
107
18
  end
108
19
  end
data/lib/aruba/command.rb CHANGED
@@ -48,6 +48,8 @@ module Aruba
48
48
 
49
49
  # Stop command
50
50
  def stop(*)
51
+ return if __getobj__.stopped?
52
+
51
53
  __getobj__.stop
52
54
  event_bus.notify Events::CommandStopped.new(self)
53
55