aruba 0.14.14 → 1.0.0.pre.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (246) hide show
  1. checksums.yaml +5 -5
  2. data/.cucumberproignore +3 -0
  3. data/.github/ISSUE_TEMPLATE.md +48 -0
  4. data/.github/PULL_REQUEST_TEMPLATE.md +39 -0
  5. data/.gitignore +1 -0
  6. data/.rspec +1 -0
  7. data/.rubocop.yml +1 -5
  8. data/.travis.yml +35 -27
  9. data/CONTRIBUTING.md +131 -29
  10. data/Dockerfile +67 -0
  11. data/Gemfile +33 -80
  12. data/History.md +602 -0
  13. data/README.md +24 -196
  14. data/Rakefile +87 -27
  15. data/appveyor.yml +0 -1
  16. data/aruba.gemspec +30 -40
  17. data/bin/bootstrap +34 -0
  18. data/bin/build +3 -0
  19. data/{script → bin}/console +0 -0
  20. data/bin/release +3 -0
  21. data/bin/test +9 -0
  22. data/cucumber.yml +1 -3
  23. data/docker-compose.yml +26 -0
  24. data/{bin → exec}/aruba +0 -0
  25. data/fixtures/cli-app/README.md +1 -1
  26. data/fixtures/cli-app/features/support/aruba.rb +1 -0
  27. data/fixtures/cli-app/features/support/env.rb +1 -1
  28. data/fixtures/cli-app/lib/cli/app.rb +1 -5
  29. data/fixtures/cli-app/spec/spec_helper.rb +1 -6
  30. data/fixtures/empty-app/lib/cli/app.rb +2 -0
  31. data/lib/aruba/api.rb +3 -3
  32. data/lib/aruba/api/{commands.rb → command.rb} +4 -30
  33. data/lib/aruba/api/core.rb +8 -25
  34. data/lib/aruba/api/deprecated.rb +150 -408
  35. data/lib/aruba/api/filesystem.rb +17 -2
  36. data/lib/aruba/api/rvm.rb +44 -0
  37. data/lib/aruba/aruba_path.rb +56 -32
  38. data/lib/aruba/basic_configuration.rb +3 -5
  39. data/lib/aruba/colorizer.rb +99 -10
  40. data/lib/aruba/command.rb +0 -2
  41. data/lib/aruba/config.rb +5 -5
  42. data/lib/aruba/config/jruby.rb +5 -15
  43. data/lib/aruba/console.rb +2 -0
  44. data/lib/aruba/console/help.rb +1 -7
  45. data/lib/aruba/cucumber.rb +0 -2
  46. data/lib/aruba/cucumber/command.rb +98 -72
  47. data/lib/aruba/cucumber/file.rb +15 -3
  48. data/lib/aruba/cucumber/hooks.rb +71 -10
  49. data/lib/aruba/event_bus/name_resolver.rb +2 -10
  50. data/lib/aruba/generators/script_file.rb +1 -1
  51. data/lib/aruba/in_process.rb +0 -2
  52. data/lib/aruba/initializer.rb +4 -14
  53. data/lib/aruba/matchers/base/object_formatter.rb +0 -5
  54. data/lib/aruba/matchers/file/have_same_file_content.rb +5 -5
  55. data/lib/aruba/matchers/string/output_string_eq.rb +1 -1
  56. data/lib/aruba/platforms/announcer.rb +11 -16
  57. data/lib/aruba/platforms/aruba_file_creator.rb +1 -5
  58. data/lib/aruba/platforms/aruba_logger.rb +1 -5
  59. data/lib/aruba/platforms/command_monitor.rb +10 -14
  60. data/lib/aruba/platforms/determine_disk_usage.rb +8 -3
  61. data/lib/aruba/platforms/filesystem_status.rb +1 -5
  62. data/lib/aruba/platforms/unix_command_string.rb +1 -8
  63. data/lib/aruba/platforms/unix_environment_variables.rb +6 -8
  64. data/lib/aruba/platforms/unix_platform.rb +9 -22
  65. data/lib/aruba/platforms/unix_which.rb +4 -0
  66. data/lib/aruba/platforms/windows_command_string.rb +6 -14
  67. data/lib/aruba/platforms/windows_environment_variables.rb +4 -16
  68. data/lib/aruba/platforms/windows_which.rb +4 -0
  69. data/lib/aruba/processes/basic_process.rb +22 -18
  70. data/lib/aruba/processes/spawn_process.rb +12 -35
  71. data/lib/aruba/rspec.rb +1 -0
  72. data/lib/aruba/runtime.rb +3 -4
  73. data/lib/aruba/setup.rb +9 -11
  74. data/lib/aruba/spawn_process.rb +1 -4
  75. data/lib/aruba/tasks/docker_helpers.rb +158 -0
  76. data/lib/aruba/version.rb +1 -1
  77. metadata +62 -230
  78. data/CHANGELOG.md +0 -991
  79. data/features/.nav +0 -72
  80. data/features/01_getting_started_with_aruba/cleanup_working_directory.feature +0 -57
  81. data/features/01_getting_started_with_aruba/run_commands.feature +0 -217
  82. data/features/01_getting_started_with_aruba/supported_testing_frameworks.feature +0 -88
  83. data/features/02_configure_aruba/activate_announcer_on_command_failure.feature +0 -38
  84. data/features/02_configure_aruba/basics.feature +0 -151
  85. data/features/02_configure_aruba/command_runtime_environment.feature +0 -129
  86. data/features/02_configure_aruba/console_history_file.feature +0 -38
  87. data/features/02_configure_aruba/exit_timeout.feature +0 -60
  88. data/features/02_configure_aruba/fixtures_directories.feature +0 -38
  89. data/features/02_configure_aruba/fixtures_path_prefix.feature +0 -23
  90. data/features/02_configure_aruba/home_directory.feature +0 -80
  91. data/features/02_configure_aruba/io_timeout.feature +0 -30
  92. data/features/02_configure_aruba/keep_ansi.feature +0 -30
  93. data/features/02_configure_aruba/log_level.feature +0 -38
  94. data/features/02_configure_aruba/physical_block_size.feature +0 -53
  95. data/features/02_configure_aruba/remove_ansi_escape_sequences.feature +0 -38
  96. data/features/02_configure_aruba/root_directory.feature +0 -30
  97. data/features/02_configure_aruba/startup_wait_time.feature +0 -48
  98. data/features/02_configure_aruba/working_directory.feature +0 -38
  99. data/features/03_testing_frameworks/cucumber/announce_information_for_troubleshooting.feature +0 -306
  100. data/features/03_testing_frameworks/cucumber/disable_bunder.feature +0 -18
  101. data/features/03_testing_frameworks/cucumber/steps/command/check_for_exit_statuses.feature +0 -136
  102. data/features/03_testing_frameworks/cucumber/steps/command/check_output_of_command.feature +0 -514
  103. data/features/03_testing_frameworks/cucumber/steps/command/check_stderr_of_command.feature +0 -68
  104. data/features/03_testing_frameworks/cucumber/steps/command/check_stdout_of_command.feature +0 -109
  105. data/features/03_testing_frameworks/cucumber/steps/command/debug_your_command_in_aruba.feature +0 -118
  106. data/features/03_testing_frameworks/cucumber/steps/command/run_a_command.feature +0 -66
  107. data/features/03_testing_frameworks/cucumber/steps/command/run_command_in_process.feature +0 -485
  108. data/features/03_testing_frameworks/cucumber/steps/command/run_command_interactively.feature +0 -90
  109. data/features/03_testing_frameworks/cucumber/steps/command/run_commands_which_require_a_shell.feature +0 -79
  110. data/features/03_testing_frameworks/cucumber/steps/command/send_signal_to_command.feature +0 -83
  111. data/features/03_testing_frameworks/cucumber/steps/command/stop_command.feature +0 -285
  112. data/features/03_testing_frameworks/cucumber/steps/environment/append_environment_variable.feature +0 -52
  113. data/features/03_testing_frameworks/cucumber/steps/environment/modify_home_variable_for_testing.feature +0 -62
  114. data/features/03_testing_frameworks/cucumber/steps/environment/prepend_environment_variable.feature +0 -52
  115. data/features/03_testing_frameworks/cucumber/steps/environment/set_environment_variable.feature +0 -49
  116. data/features/03_testing_frameworks/cucumber/steps/filesystem/append_to_file.feature +0 -45
  117. data/features/03_testing_frameworks/cucumber/steps/filesystem/cd_to_directory.feature +0 -33
  118. data/features/03_testing_frameworks/cucumber/steps/filesystem/check_existence_of_directory.feature +0 -57
  119. data/features/03_testing_frameworks/cucumber/steps/filesystem/check_existence_of_file.feature +0 -43
  120. data/features/03_testing_frameworks/cucumber/steps/filesystem/check_file_content.feature +0 -143
  121. data/features/03_testing_frameworks/cucumber/steps/filesystem/check_non_existence_of_directory.feature +0 -69
  122. data/features/03_testing_frameworks/cucumber/steps/filesystem/check_non_existence_of_file.feature +0 -80
  123. data/features/03_testing_frameworks/cucumber/steps/filesystem/check_permissions_of_file.feature +0 -39
  124. data/features/03_testing_frameworks/cucumber/steps/filesystem/compare_files.feature +0 -42
  125. data/features/03_testing_frameworks/cucumber/steps/filesystem/copy_file_or_directory.feature +0 -45
  126. data/features/03_testing_frameworks/cucumber/steps/filesystem/create_directory.feature +0 -57
  127. data/features/03_testing_frameworks/cucumber/steps/filesystem/create_file.feature +0 -76
  128. data/features/03_testing_frameworks/cucumber/steps/filesystem/move_file_or_directory.feature +0 -44
  129. data/features/03_testing_frameworks/cucumber/steps/filesystem/overwrite_file.feature +0 -72
  130. data/features/03_testing_frameworks/cucumber/steps/filesystem/remove_directory.feature +0 -38
  131. data/features/03_testing_frameworks/cucumber/steps/filesystem/remove_file.feature +0 -38
  132. data/features/03_testing_frameworks/cucumber/steps/filesystem/use_fixtures_for_setup_test.feature +0 -77
  133. data/features/03_testing_frameworks/rspec/hooks/define_after_hook_for_commands.feature +0 -43
  134. data/features/03_testing_frameworks/rspec/hooks/define_before_hook_for_commands.feature +0 -71
  135. data/features/03_testing_frameworks/rspec/setup_aruba_for_rspec.feature +0 -179
  136. data/features/04_aruba_api/command/find_a_started_command.feature +0 -83
  137. data/features/04_aruba_api/command/find_command_in_PATH.feature +0 -37
  138. data/features/04_aruba_api/command/read_stderr_of_command.feature +0 -46
  139. data/features/04_aruba_api/command/read_stdout_of_command.feature +0 -46
  140. data/features/04_aruba_api/command/run_command.feature +0 -423
  141. data/features/04_aruba_api/command/run_simple.feature +0 -254
  142. data/features/04_aruba_api/command/send_signal_to_command.feature +0 -53
  143. data/features/04_aruba_api/command/stop_all_commands.feature +0 -57
  144. data/features/04_aruba_api/command/stop_single_command.feature +0 -132
  145. data/features/04_aruba_api/command/terminate_all_commands.feature +0 -57
  146. data/features/04_aruba_api/command/use_last_command_started.feature +0 -50
  147. data/features/04_aruba_api/command/use_last_command_stopped.feature +0 -89
  148. data/features/04_aruba_api/core/expand_path.feature +0 -88
  149. data/features/04_aruba_api/environment/append_environment_variable.feature +0 -128
  150. data/features/04_aruba_api/environment/delete_environment_variable.feature +0 -63
  151. data/features/04_aruba_api/environment/prepend_environment_variable.feature +0 -128
  152. data/features/04_aruba_api/environment/set_environment_variable.feature +0 -376
  153. data/features/04_aruba_api/filesystem/cd_to_directory.feature +0 -184
  154. data/features/04_aruba_api/filesystem/check_existence_file_or_directory.feature +0 -62
  155. data/features/04_aruba_api/filesystem/check_if_path_is_absolute.feature +0 -48
  156. data/features/04_aruba_api/filesystem/check_if_path_is_directory.feature +0 -53
  157. data/features/04_aruba_api/filesystem/check_if_path_is_file.feature +0 -54
  158. data/features/04_aruba_api/filesystem/check_if_path_is_relative.feature +0 -48
  159. data/features/04_aruba_api/filesystem/create_directory.feature +0 -57
  160. data/features/04_aruba_api/filesystem/move_file_or_directory.feature +0 -119
  161. data/features/04_aruba_api/filesystem/report_disk_usage.feature +0 -152
  162. data/features/04_aruba_api/filesystem/use_fixtures.feature +0 -104
  163. data/features/04_aruba_api/text/extract_text.feature +0 -87
  164. data/features/04_aruba_api/text/replace_variables.feature +0 -45
  165. data/features/04_aruba_api/text/sanitize_text.feature +0 -228
  166. data/features/04_aruba_api/text/unescape_text.feature +0 -127
  167. data/features/05_use_rspec_matchers/command/check_timeouts.feature +0 -48
  168. data/features/05_use_rspec_matchers/directory/have_sub_directory.feature +0 -110
  169. data/features/05_use_rspec_matchers/file/be_a_command_found_in_path.feature +0 -115
  170. data/features/05_use_rspec_matchers/file/be_existing_executable.feature +0 -88
  171. data/features/05_use_rspec_matchers/file/be_existing_file.feature +0 -82
  172. data/features/05_use_rspec_matchers/file/have_file_content.feature +0 -123
  173. data/features/05_use_rspec_matchers/file/have_file_size.feature +0 -107
  174. data/features/05_use_rspec_matchers/path/be_an_absolute_path.feature +0 -74
  175. data/features/05_use_rspec_matchers/path/be_an_existing_path.feature +0 -97
  176. data/features/05_use_rspec_matchers/path/have_permissions.feature +0 -118
  177. data/features/06_use_aruba_cli/initialize_project_with_aruba.feature +0 -79
  178. data/features/06_use_aruba_cli/open_console.feature +0 -55
  179. data/features/08_other/improve_performance_if_using_jruby.feature +0 -37
  180. data/features/step_definitions/hooks.rb +0 -146
  181. data/features/support/aruba.rb +0 -7
  182. data/features/support/env.rb +0 -33
  183. data/features/support/simplecov_setup.rb +0 -11
  184. data/lib/aruba/api/bundler.rb +0 -16
  185. data/lib/aruba/cucumber/deprecated.rb +0 -93
  186. data/lib/aruba/matchers/deprecated.rb +0 -1
  187. data/lib/aruba/matchers/deprecated/file.rb +0 -17
  188. data/lib/aruba/reporting.rb +0 -126
  189. data/script/bootstrap +0 -24
  190. data/script/test +0 -3
  191. data/spec/aruba/api/bundler_spec.rb +0 -15
  192. data/spec/aruba/api/commands_spec.rb +0 -30
  193. data/spec/aruba/api/core_spec.rb +0 -184
  194. data/spec/aruba/api/deprecated_spec.rb +0 -421
  195. data/spec/aruba/api/filesystem_spec.rb +0 -746
  196. data/spec/aruba/api/runtime_spec.rb +0 -28
  197. data/spec/aruba/api_spec.rb +0 -73
  198. data/spec/aruba/aruba_path_spec.rb +0 -103
  199. data/spec/aruba/basic_configuration_spec.rb +0 -5
  200. data/spec/aruba/configuration_spec.rb +0 -5
  201. data/spec/aruba/hooks_spec.rb +0 -17
  202. data/spec/aruba/in_config_wrapper_spec.rb +0 -25
  203. data/spec/aruba/jruby_spec.rb +0 -73
  204. data/spec/aruba/matchers/command/have_output_size_spec.rb +0 -25
  205. data/spec/aruba/matchers/command_spec.rb +0 -174
  206. data/spec/aruba/matchers/deprecated_spec.rb +0 -120
  207. data/spec/aruba/matchers/directory_spec.rb +0 -57
  208. data/spec/aruba/matchers/file_spec.rb +0 -208
  209. data/spec/aruba/matchers/path_spec.rb +0 -58
  210. data/spec/aruba/platform/simple_table_spec.rb +0 -23
  211. data/spec/aruba/platform/windows_environment_variables_spec.rb +0 -500
  212. data/spec/aruba/platforms/unix_command_string_spec.rb +0 -17
  213. data/spec/aruba/platforms/windows_command_string_spec.rb +0 -22
  214. data/spec/aruba/processes/spawn_process_spec.rb +0 -112
  215. data/spec/aruba/rspec_spec.rb +0 -15
  216. data/spec/aruba/runtime_spec.rb +0 -29
  217. data/spec/event_bus/name_resolver_spec.rb +0 -68
  218. data/spec/event_bus_spec.rb +0 -158
  219. data/spec/spec_helper.rb +0 -22
  220. data/spec/support/configs/.keep +0 -0
  221. data/spec/support/configs/aruba.rb +0 -5
  222. data/spec/support/configs/pry.rb +0 -3
  223. data/spec/support/configs/rspec.rb +0 -15
  224. data/spec/support/helpers/.keep +0 -0
  225. data/spec/support/helpers/reporting.rb +0 -44
  226. data/spec/support/matchers/.keep +0 -0
  227. data/spec/support/matchers/option.rb +0 -35
  228. data/spec/support/shared_contexts/.keep +0 -0
  229. data/spec/support/shared_contexts/aruba.rb +0 -49
  230. data/spec/support/shared_examples/.keep +0 -0
  231. data/spec/support/shared_examples/configuration.rb +0 -116
  232. data/spec/support/shared_examples/directory.rb +0 -7
  233. data/spec/support/shared_examples/file.rb +0 -7
  234. data/templates/css/console.css +0 -24
  235. data/templates/css/filesystem.css +0 -42
  236. data/templates/css/pygments-autumn.css +0 -59
  237. data/templates/files.erb +0 -14
  238. data/templates/images/LICENSE +0 -22
  239. data/templates/images/folder.png +0 -0
  240. data/templates/images/page_white.png +0 -0
  241. data/templates/images/page_white_gherkin.png +0 -0
  242. data/templates/images/page_white_ruby.png +0 -0
  243. data/templates/index.erb +0 -20
  244. data/templates/js/filesystem.js +0 -5
  245. data/templates/js/jquery-1.11.3.min.js +0 -5
  246. data/templates/main.erb +0 -34
@@ -372,10 +372,25 @@ module Aruba
372
372
  #
373
373
  # @result [FileSize]
374
374
  # Bytes on disk
375
+
375
376
  def disk_usage(*paths)
376
377
  expect(paths.flatten).to Aruba::Matchers.all be_an_existing_path
378
+ expanded = paths.flatten.map { |p| ArubaPath.new(expand_path(p)) }
379
+
380
+ # TODO: change the API so that you could set something like
381
+ # aruba.config.fs_allocation_unit_size directly
382
+
383
+ typical_fs_unit = 4096 # very typical, except for giant or embedded filesystems
384
+ typical_dev_bsize = 512 # google dev_bsize for more info
385
+
386
+ block_multiplier = typical_fs_unit / typical_dev_bsize
387
+ fs_unit_size = aruba.config.physical_block_size * block_multiplier
377
388
 
378
- Aruba.platform.determine_disk_usage paths.flatten.map { |p| ArubaPath.new(expand_path(p)) }, aruba.config.physical_block_size
389
+ # TODO: the size argument here is unnecessary - ArubaPath should decide
390
+ # what the disk usage of a file is (even if Aruba.config needs to be
391
+ # read)
392
+ deprecated_block_count = fs_unit_size / block_multiplier
393
+ Aruba.platform.determine_disk_usage(expanded, deprecated_block_count)
379
394
  end
380
395
 
381
396
  # Get size of file
@@ -383,7 +398,7 @@ module Aruba
383
398
  # @return [Numeric]
384
399
  # The size of the file
385
400
  def file_size(name)
386
- raise ArgumentError, "#{name} does not exist" unless exist? name
401
+ expect(name).to be_an_existing_file
387
402
 
388
403
  Aruba.platform.determine_file_size expand_path(name)
389
404
  end
@@ -0,0 +1,44 @@
1
+ require 'aruba/api/environment'
2
+ require 'aruba/api/command'
3
+
4
+ # Aruba
5
+ module Aruba
6
+ # Api
7
+ module Api
8
+ # RVM
9
+ #
10
+ # @deprecated
11
+ module Rvm
12
+ # Use a clean rvm gemset
13
+ #
14
+ # Please make sure that you've got [rvm](http://rvm.io/) installed.
15
+ #
16
+ # @param [String] gemset
17
+ # The name of the gemset to be used
18
+ def use_clean_gemset(gemset)
19
+ run_command_and_stop(%{rvm gemset create "#{gemset}"}, true)
20
+ if all_stdout =~ /'#{gemset}' gemset created \((.*)\)\./
21
+ gem_home = Regexp.last_match[1]
22
+ set_environment_variable('GEM_HOME', gem_home)
23
+ set_environment_variable('GEM_PATH', gem_home)
24
+ set_environment_variable('BUNDLE_PATH', gem_home)
25
+
26
+ paths = (ENV['PATH'] || "").split(File::PATH_SEPARATOR)
27
+ paths.unshift(File.join(gem_home, 'bin'))
28
+ set_environment_variable('PATH', paths.uniq.join(File::PATH_SEPARATOR))
29
+
30
+ run_command_and_stop("gem install bundler", true)
31
+ else
32
+ raise "I didn't understand rvm's output: #{all_stdout}"
33
+ end
34
+ end
35
+
36
+ # Unset variables used by bundler
37
+ def unset_bundler_env_vars
38
+ %w[RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE].each do |key|
39
+ set_environment_variable(key, nil)
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -54,24 +54,6 @@ module Aruba
54
54
  @delegate_sd_obj.pop
55
55
  end
56
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
57
  # How many parts has the file name
76
58
  #
77
59
  # @return [Integer]
@@ -83,14 +65,7 @@ module Aruba
83
65
  # path.depth # => 3
84
66
  #
85
67
  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
68
+ __getobj__.each_filename.to_a.size
94
69
  end
95
70
 
96
71
  # Path ends with string
@@ -113,11 +88,7 @@ module Aruba
113
88
  #
114
89
  # @param [Integer, Range] index
115
90
  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
91
+ to_s[index]
121
92
  end
122
93
 
123
94
  # Report count of blocks allocated on disk
@@ -126,8 +97,61 @@ module Aruba
126
97
  #
127
98
  # @return [Integer]
128
99
  # The count of blocks on disk
100
+ #
101
+ # @deprecated
129
102
  def blocks
130
- File::Stat.new(to_s).blocks
103
+ min_bytes_used = minimum_disk_space_used
104
+ min_bytes_used / Aruba.config.physical_block_size
105
+ end
106
+
107
+ # TODO: Aruba.config.physical_block_size could be allowed to be nil
108
+ # (So the unit size can be autodetected)
109
+
110
+ # Report minimum disk space used
111
+ #
112
+ # This estimates the minimum bytes allocated by the path.
113
+ #
114
+ # E.g. a 1-byte text file on a typical EXT-3 filesystem takes up 4096 bytes
115
+ # (could be more if it was truncated or less for sparse files).
116
+ #
117
+ # Both `File::Stat` and the `stat()` system call will report 8 `blocks`
118
+ # (each "usually" represents 512 bytes). So 8 * 512 is exactly 4096 bytes.
119
+ #
120
+ # (The "magic" 512 bye implied makes the value of "blocks" so confusing).
121
+ #
122
+ # Currently Aruba allows you to set what's called the `physical_block_size`,
123
+ # which is a bit misleading - it's the "512" value. So if you somehow have a
124
+ # "filesystem unit size" of 8192 (instead of a typical 4KB), set the
125
+ # `physical_block_size` to 1024 (yes, divide by 8: 8192/8 = 1024).
126
+ #
127
+ # Ideally, Aruba should provide e.g. `Aruba.config.fs_allocation_unit`
128
+ # (with 4096 as the default), so you wouldn't have to "divide by 8".
129
+ #
130
+ # (typical_fs_unit / typical_dev_bsize = 4096 / 512 = 8)
131
+ #
132
+ #
133
+ # @return [Integer]
134
+ # Total bytes allocate
135
+ #
136
+ # TODO: this is recommended over the above "blocks"
137
+ def minimum_disk_space_used
138
+ # TODO: replace Aruba.config.physical_block_size
139
+ # with something like Aruba.config.fs_allocation_unit
140
+ dev_bsize = Aruba.config.physical_block_size
141
+
142
+ stat = File::Stat.new(to_s)
143
+
144
+ blocks = stat.blocks
145
+ return (blocks * dev_bsize) if blocks
146
+
147
+ typical_fs_unit = 4096
148
+ typical_dev_bsize = 512 # google dev_bsize for more info
149
+
150
+ block_multiplier = typical_fs_unit / typical_dev_bsize
151
+ fs_unit_size = dev_bsize * block_multiplier
152
+ fs_units = (stat.size + fs_unit_size - 1) / fs_unit_size
153
+ fs_units = 1 if fs_units.zero?
154
+ fs_units * fs_unit_size
131
155
  end
132
156
  end
133
157
  end
@@ -57,6 +57,7 @@ module Aruba
57
57
  # @option [Object] default
58
58
  # The default value
59
59
  #
60
+ # rubocop:disable Metrics/CyclomaticComplexity
60
61
  def option_accessor(name, opts = {})
61
62
  contract = opts[:contract]
62
63
  default = opts[:default]
@@ -74,6 +75,7 @@ module Aruba
74
75
  # Add reader
75
76
  option_reader name, :contract => { None => contract.values.first }
76
77
  end
78
+ # rubocop:enable Metrics/CyclomaticComplexity
77
79
 
78
80
  private
79
81
 
@@ -215,11 +217,7 @@ module Aruba
215
217
 
216
218
  # Set if name is option
217
219
  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
220
+ public_send("#{name}=".to_sym, *args) if option? name
223
221
  end
224
222
 
225
223
  private
@@ -1,19 +1,108 @@
1
- # Aruba
2
1
  module Aruba
3
- # Simple colorizer class. Only supports the color cyan
4
- class Colorizer
5
- class << self
6
- attr_accessor :coloring
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
7
71
 
8
- alias coloring? coloring
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/
75
+
76
+ def self.included(klass)
77
+ if klass == String
78
+ ATTRIBUTES.delete(:clear)
79
+ ATTRIBUTE_NAMES.delete(:clear)
80
+ end
9
81
  end
10
82
 
11
- def cyan(string)
12
- if self.class.coloring?
13
- "\e[36m#{string}\e[0m"
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, '')
14
92
  else
15
- string
93
+ ''
16
94
  end
17
95
  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
18
107
  end
19
108
  end
@@ -56,8 +56,6 @@ module Aruba
56
56
 
57
57
  # Terminate command
58
58
  def terminate(*)
59
- return if __getobj__.stopped?
60
-
61
59
  __getobj__.terminate
62
60
  event_bus.notify Events::CommandStopped.new(self)
63
61
 
@@ -25,11 +25,7 @@ module Aruba
25
25
 
26
26
  option_accessor :working_directory, :contract => { Aruba::Contracts::RelativePath => Aruba::Contracts::RelativePath }, :default => 'tmp/aruba'
27
27
 
28
- if RUBY_VERSION < '1.9'
29
- option_reader :fixtures_path_prefix, :contract => { None => String }, :default => '%'
30
- else
31
- option_reader :fixtures_path_prefix, :contract => { None => String }, :default => ?%
32
- end
28
+ option_reader :fixtures_path_prefix, :contract => { None => String }, :default => ?%
33
29
 
34
30
  option_accessor :exit_timeout, :contract => { Num => Num }, :default => 15
35
31
  option_accessor :stop_signal, :contract => { Maybe[String] => Maybe[String] }, :default => nil
@@ -46,6 +42,7 @@ module Aruba
46
42
  option_accessor :command_launcher, :contract => { Aruba::Contracts::Enum[:in_process, :spawn, :debug] => Aruba::Contracts::Enum[:in_process, :spawn, :debug] }, :default => :spawn
47
43
  # rubocop:enable Metrics/LineLength
48
44
  option_accessor :main_class, :contract => { Class => Maybe[Class] }, :default => nil
45
+ # rubocop:disable Metrics/LineLength
49
46
 
50
47
  # rubocop:disable Metrics/LineLength
51
48
  if Aruba::VERSION >= '1.0.0'
@@ -61,6 +58,9 @@ module Aruba
61
58
  option_accessor :log_level, :contract => { Aruba::Contracts::Enum[:fatal, :warn, :debug, :info, :error, :unknown, :silent] => Aruba::Contracts::Enum[:fatal, :warn, :debug, :info, :error, :unknown, :silent] }, :default => :info
62
59
  # rubocop:enable Metrics/LineLength
63
60
 
61
+ # TODO: deprecate this value and replace with "filesystem allocation unit"
62
+ # equal to 4096 by default. "filesystem allocation unit" would represent
63
+ # the actual MINIMUM space taken in bytes by a 1-byte file
64
64
  option_accessor :physical_block_size, :contract => { Aruba::Contracts::IsPowerOfTwo => Aruba::Contracts::IsPowerOfTwo }, :default => 512
65
65
  option_accessor :console_history_file, :contract => { String => String }, :default => '~/.aruba_history'
66
66
 
@@ -2,26 +2,16 @@ require 'rbconfig'
2
2
 
3
3
  # ideas taken from: http://blog.headius.com/2010/03/jruby-startup-time-tips.html
4
4
  Aruba.configure do |config|
5
- config.before :command do |command|
5
+ config.before :command do
6
6
  next unless RUBY_PLATFORM == 'java'
7
7
 
8
- env = command.environment
9
-
10
- jruby_opts = env['JRUBY_OPTS'] || ''
11
-
12
8
  # disable JIT since these processes are so short lived
13
- jruby_opts = "-X-C #{jruby_opts}" unless jruby_opts.include? '-X-C'
9
+ ENV['JRUBY_OPTS'] = "-X-C #{ENV['JRUBY_OPTS']}" unless (ENV['JRUBY_OPTS'] || '') .include? '-X-C'
14
10
 
15
11
  # Faster startup for jruby
16
- jruby_opts = "--dev #{jruby_opts}" unless jruby_opts.include? '--dev'
17
-
18
- env['JRUBY_OPTS'] = jruby_opts
19
-
20
- if RbConfig::CONFIG['host_os'] =~ /solaris|sunos/i
21
- java_opts = env['JAVA_OPTS'] || ''
12
+ ENV['JRUBY_OPTS'] = "--dev #{ENV['JRUBY_OPTS']}" unless (ENV['JRUBY_OPTS'] || '').include? '--dev'
22
13
 
23
- # force jRuby to use client JVM for faster startup times
24
- env['JAVA_OPTS'] = "-d32 #{java_opts}" unless java_opts.include?('-d32')
25
- end
14
+ # force jRuby to use client JVM for faster startup times
15
+ ENV['JAVA_OPTS'] = "-d32 #{ENV['JAVA_OPTS']}" if RbConfig::CONFIG['host_os'] =~ /solaris|sunos/i && !(ENV['JAVA_OPTS'] || '').include?('-d32')
26
16
  end
27
17
  end
@@ -35,6 +35,7 @@ module Aruba
35
35
  IRB.conf[:SAVE_HISTORY] = 1000
36
36
  IRB.conf[:HISTORY_FILE] = Aruba.config.console_history_file
37
37
 
38
+ # rubocop:disable Lint/NestedMethodDefinition
38
39
  context = Class.new do
39
40
  include Aruba::Api
40
41
  include Aruba::Console::Help
@@ -47,6 +48,7 @@ module Aruba
47
48
  'nil'
48
49
  end
49
50
  end
51
+ # rubocop:enable Lint/NestedMethodDefinition
50
52
 
51
53
  irb = IRB::Irb.new(IRB::WorkSpace.new(context.new))
52
54
  IRB.conf[:MAIN_CONTEXT] = irb.context
@@ -18,13 +18,7 @@ module Aruba
18
18
 
19
19
  # List available methods in aruba
20
20
  def aruba_methods
21
- ms = if RUBY_VERSION < '1.9'
22
- # rubocop:disable Style/EachWithObject
23
- (Aruba::Api.instance_methods - Module.instance_methods).inject([]) { |a, e| a << format("* %s", e); a }.sort
24
- # rubocop:enable Style/EachWithObject
25
- else
26
- (Aruba::Api.instance_methods - Module.instance_methods).each_with_object([]) { |e, a| a << format("* %s", e) }.sort
27
- end
21
+ ms = (Aruba::Api.instance_methods - Module.instance_methods).each_with_object([]) { |e, a| a << format("* %s", e) }.sort
28
22
 
29
23
  puts "Available Methods:\n" + ms.join("\n")
30
24