aruba-win-fix 0.14.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (324) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.gitignore +37 -0
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +188 -0
  6. data/.simplecov +34 -0
  7. data/.travis.yml +47 -0
  8. data/.yardopts +8 -0
  9. data/CONTRIBUTING.md +71 -0
  10. data/Gemfile +83 -0
  11. data/History.md +579 -0
  12. data/LICENSE +20 -0
  13. data/README.md +226 -0
  14. data/Rakefile +49 -0
  15. data/TODO.md +13 -0
  16. data/appveyor.yml +32 -0
  17. data/aruba.gemspec +48 -0
  18. data/bin/aruba +7 -0
  19. data/config/.gitignore +1 -0
  20. data/cucumber.yml +26 -0
  21. data/features/.nav +72 -0
  22. data/features/api/command/find_command.feature +83 -0
  23. data/features/api/command/last_command_started.feature +50 -0
  24. data/features/api/command/last_command_stopped.feature +89 -0
  25. data/features/api/command/run.feature +414 -0
  26. data/features/api/command/run_simple.feature +242 -0
  27. data/features/api/command/send_signal.feature +53 -0
  28. data/features/api/command/stderr.feature +46 -0
  29. data/features/api/command/stdout.feature +46 -0
  30. data/features/api/command/stop.feature +131 -0
  31. data/features/api/command/stop_all_commands.feature +53 -0
  32. data/features/api/command/terminate_all_commands.feature +53 -0
  33. data/features/api/command/which.feature +37 -0
  34. data/features/api/core/expand_path.feature +88 -0
  35. data/features/api/environment/append_environment_variable.feature +128 -0
  36. data/features/api/environment/delete_environment_variable.feature +63 -0
  37. data/features/api/environment/prepend_environment_variable.feature +128 -0
  38. data/features/api/environment/set_environment_variable.feature +376 -0
  39. data/features/api/filesystem/cd.feature +184 -0
  40. data/features/api/filesystem/create_directory.feature +57 -0
  41. data/features/api/filesystem/disk_usage.feature +152 -0
  42. data/features/api/filesystem/does_exist.feature +62 -0
  43. data/features/api/filesystem/fixtures.feature +104 -0
  44. data/features/api/filesystem/is_absolute.feature +48 -0
  45. data/features/api/filesystem/is_directory.feature +53 -0
  46. data/features/api/filesystem/is_file.feature +54 -0
  47. data/features/api/filesystem/is_relative.feature +48 -0
  48. data/features/api/filesystem/move.feature +119 -0
  49. data/features/api/text/extract_text.feature +87 -0
  50. data/features/api/text/replace_variables.feature +45 -0
  51. data/features/api/text/sanitize_text.feature +228 -0
  52. data/features/api/text/unescape_text.feature +127 -0
  53. data/features/cli/console.feature +52 -0
  54. data/features/cli/init.feature +79 -0
  55. data/features/configuration/activate_announcer_on_command_failure.feature +38 -0
  56. data/features/configuration/command_runtime_environment.feature +129 -0
  57. data/features/configuration/console_history_file.feature +38 -0
  58. data/features/configuration/exit_timeout.feature +52 -0
  59. data/features/configuration/fixtures_directories.feature +38 -0
  60. data/features/configuration/fixtures_path_prefix.feature +23 -0
  61. data/features/configuration/home_directory.feature +80 -0
  62. data/features/configuration/io_timeout.feature +30 -0
  63. data/features/configuration/keep_ansi.feature +30 -0
  64. data/features/configuration/log_level.feature +38 -0
  65. data/features/configuration/physical_block_size.feature +53 -0
  66. data/features/configuration/remove_ansi_escape_sequences.feature +38 -0
  67. data/features/configuration/root_directory.feature +30 -0
  68. data/features/configuration/startup_wait_time.feature +48 -0
  69. data/features/configuration/usage.feature +159 -0
  70. data/features/configuration/working_directory.feature +33 -0
  71. data/features/development/build.feature +15 -0
  72. data/features/development/test.feature +24 -0
  73. data/features/getting_started/cleanup.feature +67 -0
  74. data/features/getting_started/install.feature +8 -0
  75. data/features/getting_started/run_commands.feature +177 -0
  76. data/features/getting_started/supported_testing_frameworks.feature +104 -0
  77. data/features/getting_started/writing_good_feature_tests.feature +38 -0
  78. data/features/hooks/after/command.feature +44 -0
  79. data/features/hooks/before/command.feature +71 -0
  80. data/features/matchers/collection/include_an_object.feature +72 -0
  81. data/features/matchers/directory/have_sub_directory.feature +110 -0
  82. data/features/matchers/file/be_a_command_found_in_path.feature +115 -0
  83. data/features/matchers/file/be_existing_executable.feature +88 -0
  84. data/features/matchers/file/be_existing_file.feature +82 -0
  85. data/features/matchers/file/have_file_content.feature +123 -0
  86. data/features/matchers/file/have_file_size.feature +107 -0
  87. data/features/matchers/path/be_an_absolute_path.feature +74 -0
  88. data/features/matchers/path/be_an_existing_path.feature +97 -0
  89. data/features/matchers/path/have_permissions.feature +118 -0
  90. data/features/matchers/timeouts.feature +48 -0
  91. data/features/platforms/jruby.feature +14 -0
  92. data/features/rspec/integration.feature +179 -0
  93. data/features/step_definitions/aruba_dev_steps.rb +56 -0
  94. data/features/step_definitions/hooks.rb +96 -0
  95. data/features/steps/command/debug.feature +92 -0
  96. data/features/steps/command/exit_statuses.feature +136 -0
  97. data/features/steps/command/in_process.feature +485 -0
  98. data/features/steps/command/interactive.feature +90 -0
  99. data/features/steps/command/output.feature +588 -0
  100. data/features/steps/command/run.feature +66 -0
  101. data/features/steps/command/send_signal.feature +104 -0
  102. data/features/steps/command/shell.feature +155 -0
  103. data/features/steps/command/stderr.feature +68 -0
  104. data/features/steps/command/stdout.feature +109 -0
  105. data/features/steps/command/stop.feature +313 -0
  106. data/features/steps/core/announce.feature +283 -0
  107. data/features/steps/environment/append_environment_variable.feature +52 -0
  108. data/features/steps/environment/home_variable.feature +62 -0
  109. data/features/steps/environment/prepend_environment_variable.feature +52 -0
  110. data/features/steps/environment/set_environment_variable.feature +49 -0
  111. data/features/steps/filesystem/append_to_file.feature +45 -0
  112. data/features/steps/filesystem/cd_to_directory.feature +33 -0
  113. data/features/steps/filesystem/check_file_content.feature +61 -0
  114. data/features/steps/filesystem/check_permissions_of_file.feature +39 -0
  115. data/features/steps/filesystem/compare_files.feature +42 -0
  116. data/features/steps/filesystem/copy.feature +45 -0
  117. data/features/steps/filesystem/create_directory.feature +57 -0
  118. data/features/steps/filesystem/create_file.feature +76 -0
  119. data/features/steps/filesystem/existence_of_directory.feature +57 -0
  120. data/features/steps/filesystem/existence_of_file.feature +43 -0
  121. data/features/steps/filesystem/file_content.feature +86 -0
  122. data/features/steps/filesystem/fixtures.feature +64 -0
  123. data/features/steps/filesystem/move.feature +45 -0
  124. data/features/steps/filesystem/non_existence_of_directory.feature +69 -0
  125. data/features/steps/filesystem/non_existence_of_file.feature +80 -0
  126. data/features/steps/filesystem/overwrite_file.feature +72 -0
  127. data/features/steps/filesystem/remove_directory.feature +38 -0
  128. data/features/steps/filesystem/remove_file.feature +38 -0
  129. data/features/steps/filesystem/use_fixture.feature +77 -0
  130. data/features/steps/overview.feature +60 -0
  131. data/features/support/aruba.rb +7 -0
  132. data/features/support/env.rb +33 -0
  133. data/features/support/jruby.rb +5 -0
  134. data/features/support/simplecov_setup.rb +8 -0
  135. data/fixtures/cli-app/.gitignore +9 -0
  136. data/fixtures/cli-app/.rspec +2 -0
  137. data/fixtures/cli-app/README.md +39 -0
  138. data/fixtures/cli-app/Rakefile +1 -0
  139. data/fixtures/cli-app/bin/cli +6 -0
  140. data/fixtures/cli-app/cli-app.gemspec +26 -0
  141. data/fixtures/cli-app/features/support/env.rb +1 -0
  142. data/fixtures/cli-app/lib/cli/app.rb +13 -0
  143. data/fixtures/cli-app/lib/cli/app/suppress_simple_cov_output.rb +15 -0
  144. data/fixtures/cli-app/lib/cli/app/version.rb +5 -0
  145. data/fixtures/cli-app/script/console +14 -0
  146. data/fixtures/cli-app/spec/spec_helper.rb +9 -0
  147. data/fixtures/cli-app/spec/support/aruba.rb +1 -0
  148. data/fixtures/copy/file.txt +1 -0
  149. data/fixtures/empty-app/.gitignore +9 -0
  150. data/fixtures/empty-app/.rspec +2 -0
  151. data/fixtures/empty-app/README.md +24 -0
  152. data/fixtures/empty-app/Rakefile +1 -0
  153. data/fixtures/empty-app/cli-app.gemspec +26 -0
  154. data/fixtures/empty-app/lib/cli/app.rb +13 -0
  155. data/fixtures/empty-app/lib/cli/app/version.rb +5 -0
  156. data/fixtures/getting-started-app/.gitignore +4 -0
  157. data/fixtures/getting-started-app/Gemfile +4 -0
  158. data/fixtures/getting-started-app/README.md +3 -0
  159. data/fixtures/getting-started-app/features/support/env.rb +1 -0
  160. data/fixtures/spawn_process/stderr.sh +3 -0
  161. data/lib/aruba.rb +1 -0
  162. data/lib/aruba/api.rb +34 -0
  163. data/lib/aruba/api/command.rb +307 -0
  164. data/lib/aruba/api/core.rb +191 -0
  165. data/lib/aruba/api/deprecated.rb +897 -0
  166. data/lib/aruba/api/environment.rb +89 -0
  167. data/lib/aruba/api/filesystem.rb +392 -0
  168. data/lib/aruba/api/rvm.rb +44 -0
  169. data/lib/aruba/api/text.rb +56 -0
  170. data/lib/aruba/aruba_path.rb +133 -0
  171. data/lib/aruba/basic_configuration.rb +240 -0
  172. data/lib/aruba/basic_configuration/option.rb +32 -0
  173. data/lib/aruba/cli.rb +26 -0
  174. data/lib/aruba/colorizer.rb +108 -0
  175. data/lib/aruba/command.rb +74 -0
  176. data/lib/aruba/config.rb +108 -0
  177. data/lib/aruba/config/jruby.rb +17 -0
  178. data/lib/aruba/config_wrapper.rb +58 -0
  179. data/lib/aruba/console.rb +70 -0
  180. data/lib/aruba/console/help.rb +35 -0
  181. data/lib/aruba/contracts/absolute_path.rb +20 -0
  182. data/lib/aruba/contracts/enum.rb +26 -0
  183. data/lib/aruba/contracts/is_power_of_two.rb +22 -0
  184. data/lib/aruba/contracts/relative_path.rb +20 -0
  185. data/lib/aruba/cucumber.rb +13 -0
  186. data/lib/aruba/cucumber/command.rb +422 -0
  187. data/lib/aruba/cucumber/core.rb +5 -0
  188. data/lib/aruba/cucumber/environment.rb +42 -0
  189. data/lib/aruba/cucumber/file.rb +201 -0
  190. data/lib/aruba/cucumber/hooks.rb +160 -0
  191. data/lib/aruba/cucumber/rvm.rb +3 -0
  192. data/lib/aruba/cucumber/testing_frameworks.rb +95 -0
  193. data/lib/aruba/errors.rb +37 -0
  194. data/lib/aruba/event_bus.rb +59 -0
  195. data/lib/aruba/event_bus/name_resolver.rb +168 -0
  196. data/lib/aruba/events.rb +39 -0
  197. data/lib/aruba/extensions/string/strip.rb +25 -0
  198. data/lib/aruba/file_size.rb +63 -0
  199. data/lib/aruba/generators/script_file.rb +46 -0
  200. data/lib/aruba/hooks.rb +56 -0
  201. data/lib/aruba/in_config_wrapper.rb +24 -0
  202. data/lib/aruba/in_process.rb +14 -0
  203. data/lib/aruba/initializer.rb +222 -0
  204. data/lib/aruba/jruby.rb +4 -0
  205. data/lib/aruba/matchers/base/base_matcher.rb +96 -0
  206. data/lib/aruba/matchers/base/object_formatter.rb +114 -0
  207. data/lib/aruba/matchers/collection.rb +1 -0
  208. data/lib/aruba/matchers/collection/all.rb +11 -0
  209. data/lib/aruba/matchers/collection/include_an_object.rb +122 -0
  210. data/lib/aruba/matchers/command.rb +1 -0
  211. data/lib/aruba/matchers/command/be_successfully_executed.rb +34 -0
  212. data/lib/aruba/matchers/command/have_exit_status.rb +38 -0
  213. data/lib/aruba/matchers/command/have_finished_in_time.rb +37 -0
  214. data/lib/aruba/matchers/command/have_output.rb +36 -0
  215. data/lib/aruba/matchers/command/have_output_on_stderr.rb +32 -0
  216. data/lib/aruba/matchers/command/have_output_on_stdout.rb +32 -0
  217. data/lib/aruba/matchers/command/have_output_size.rb +28 -0
  218. data/lib/aruba/matchers/directory.rb +1 -0
  219. data/lib/aruba/matchers/directory/be_an_existing_directory.rb +38 -0
  220. data/lib/aruba/matchers/directory/have_sub_directory.rb +53 -0
  221. data/lib/aruba/matchers/environment.rb +1 -0
  222. data/lib/aruba/matchers/file.rb +1 -0
  223. data/lib/aruba/matchers/file/be_a_command_found_in_path.rb +36 -0
  224. data/lib/aruba/matchers/file/be_an_existing_executable.rb +37 -0
  225. data/lib/aruba/matchers/file/be_an_existing_file.rb +38 -0
  226. data/lib/aruba/matchers/file/have_file_content.rb +62 -0
  227. data/lib/aruba/matchers/file/have_file_size.rb +47 -0
  228. data/lib/aruba/matchers/file/have_same_file_content.rb +48 -0
  229. data/lib/aruba/matchers/path.rb +1 -0
  230. data/lib/aruba/matchers/path/a_path_matching_pattern.rb +25 -0
  231. data/lib/aruba/matchers/path/be_an_absolute_path.rb +36 -0
  232. data/lib/aruba/matchers/path/be_an_existing_path.rb +37 -0
  233. data/lib/aruba/matchers/path/have_permissions.rb +64 -0
  234. data/lib/aruba/matchers/path/match_path_pattern.rb +41 -0
  235. data/lib/aruba/matchers/rspec_matcher_include_regexp.rb +25 -0
  236. data/lib/aruba/matchers/string.rb +1 -0
  237. data/lib/aruba/matchers/string/include_output_string.rb +36 -0
  238. data/lib/aruba/matchers/string/match_output_string.rb +37 -0
  239. data/lib/aruba/matchers/string/output_string_eq.rb +35 -0
  240. data/lib/aruba/platform.rb +25 -0
  241. data/lib/aruba/platforms/announcer.rb +232 -0
  242. data/lib/aruba/platforms/aruba_file_creator.rb +35 -0
  243. data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +35 -0
  244. data/lib/aruba/platforms/aruba_logger.rb +81 -0
  245. data/lib/aruba/platforms/command_monitor.rb +229 -0
  246. data/lib/aruba/platforms/determine_disk_usage.rb +28 -0
  247. data/lib/aruba/platforms/determine_file_size.rb +22 -0
  248. data/lib/aruba/platforms/disk_usage_calculator.rb +20 -0
  249. data/lib/aruba/platforms/filesystem_status.rb +68 -0
  250. data/lib/aruba/platforms/local_environment.rb +29 -0
  251. data/lib/aruba/platforms/simple_table.rb +54 -0
  252. data/lib/aruba/platforms/unix_command_string.rb +27 -0
  253. data/lib/aruba/platforms/unix_environment_variables.rb +220 -0
  254. data/lib/aruba/platforms/unix_platform.rb +276 -0
  255. data/lib/aruba/platforms/unix_which.rb +85 -0
  256. data/lib/aruba/platforms/windows_command_string.rb +31 -0
  257. data/lib/aruba/platforms/windows_environment_variables.rb +89 -0
  258. data/lib/aruba/platforms/windows_platform.rb +42 -0
  259. data/lib/aruba/platforms/windows_which.rb +106 -0
  260. data/lib/aruba/processes/basic_process.rb +143 -0
  261. data/lib/aruba/processes/debug_process.rb +69 -0
  262. data/lib/aruba/processes/in_process.rb +125 -0
  263. data/lib/aruba/processes/spawn_process.rb +278 -0
  264. data/lib/aruba/reporting.rb +126 -0
  265. data/lib/aruba/rspec.rb +107 -0
  266. data/lib/aruba/runtime.rb +96 -0
  267. data/lib/aruba/setup.rb +90 -0
  268. data/lib/aruba/spawn_process.rb +11 -0
  269. data/lib/aruba/version.rb +3 -0
  270. data/script/bootstrap +28 -0
  271. data/script/console +16 -0
  272. data/script/test +3 -0
  273. data/spec/aruba/api/environment/restore_env_spec.rb +65 -0
  274. data/spec/aruba/api/environment/set_env_spec.rb +42 -0
  275. data/spec/aruba/api/filesystem/file_size_spec.rb +28 -0
  276. data/spec/aruba/api/runtime_spec.rb +28 -0
  277. data/spec/aruba/api_spec.rb +1209 -0
  278. data/spec/aruba/aruba_path_spec.rb +103 -0
  279. data/spec/aruba/basic_configuration_spec.rb +5 -0
  280. data/spec/aruba/configuration_spec.rb +5 -0
  281. data/spec/aruba/hooks_spec.rb +17 -0
  282. data/spec/aruba/in_config_wrapper_spec.rb +25 -0
  283. data/spec/aruba/jruby_spec.rb +55 -0
  284. data/spec/aruba/matchers/command/have_output_size_spec.rb +25 -0
  285. data/spec/aruba/matchers/command_spec.rb +174 -0
  286. data/spec/aruba/matchers/directory_spec.rb +57 -0
  287. data/spec/aruba/matchers/file_spec.rb +127 -0
  288. data/spec/aruba/matchers/path_spec.rb +88 -0
  289. data/spec/aruba/platform/simple_table_spec.rb +23 -0
  290. data/spec/aruba/platform/windows_environment_variables_spec.rb +500 -0
  291. data/spec/aruba/rspec_spec.rb +15 -0
  292. data/spec/aruba/runtime_spec.rb +29 -0
  293. data/spec/aruba/spawn_process_spec.rb +60 -0
  294. data/spec/event_bus/name_resolver_spec.rb +68 -0
  295. data/spec/event_bus_spec.rb +160 -0
  296. data/spec/spec_helper.rb +23 -0
  297. data/spec/support/configs/.keep +0 -0
  298. data/spec/support/configs/aruba.rb +5 -0
  299. data/spec/support/configs/pry.rb +3 -0
  300. data/spec/support/configs/rspec.rb +15 -0
  301. data/spec/support/helpers/.keep +0 -0
  302. data/spec/support/helpers/reporting.rb +44 -0
  303. data/spec/support/matchers/.keep +0 -0
  304. data/spec/support/matchers/option.rb +35 -0
  305. data/spec/support/shared_contexts/.keep +0 -0
  306. data/spec/support/shared_contexts/aruba.rb +48 -0
  307. data/spec/support/shared_examples/.keep +0 -0
  308. data/spec/support/shared_examples/configuration.rb +116 -0
  309. data/spec/support/shared_examples/directory.rb +7 -0
  310. data/spec/support/shared_examples/file.rb +7 -0
  311. data/templates/css/console.css +24 -0
  312. data/templates/css/filesystem.css +42 -0
  313. data/templates/css/pygments-autumn.css +59 -0
  314. data/templates/files.erb +14 -0
  315. data/templates/images/LICENSE +22 -0
  316. data/templates/images/folder.png +0 -0
  317. data/templates/images/page_white.png +0 -0
  318. data/templates/images/page_white_gherkin.png +0 -0
  319. data/templates/images/page_white_ruby.png +0 -0
  320. data/templates/index.erb +20 -0
  321. data/templates/js/filesystem.js +5 -0
  322. data/templates/js/jquery-1.11.3.min.js +5 -0
  323. data/templates/main.erb +34 -0
  324. metadata +629 -0
@@ -0,0 +1,32 @@
1
+ # Aruba
2
+ module Aruba
3
+ # Basic Configuration
4
+ #
5
+ class BasicConfiguration
6
+ # A configuration option
7
+ #
8
+ # @private
9
+ class Option
10
+ attr_accessor :name, :value
11
+ attr_reader :default_value
12
+
13
+ # Create option
14
+ def initialize(opts = {})
15
+ name = opts[:name]
16
+ value = opts[:value]
17
+
18
+ fail ArgumentError, '"name" is required' unless opts.key? :name
19
+ fail ArgumentError, '"value" is required' unless opts.key? :value
20
+
21
+ @name = name
22
+ @value = value
23
+ @default_value = value
24
+ end
25
+
26
+ # Compare option
27
+ def ==(other)
28
+ name == other.name && value == other.value
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,26 @@
1
+ require 'thor'
2
+ require 'aruba/console'
3
+ require 'aruba/initializer'
4
+
5
+ # Aruba
6
+ module Aruba
7
+ # Command line Interface
8
+ #
9
+ # @private
10
+ class Cli < Thor
11
+ def self.exit_on_failure?
12
+ true
13
+ end
14
+
15
+ desc 'console', "Start aruba's console"
16
+ def console
17
+ Aruba::Console.new.start
18
+ end
19
+
20
+ desc 'init', 'Initialize aruba'
21
+ option :test_framework, :default => 'cucumber', :enum => %w(cucumber rspec minitest), :desc => 'Choose which test framework to use'
22
+ def init
23
+ Aruba::Initializer.new.call(options[:test_framework])
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,108 @@
1
+ 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/
75
+
76
+ def self.included(klass)
77
+ if klass == String
78
+ ATTRIBUTES.delete(:clear)
79
+ ATTRIBUTE_NAMES.delete(:clear)
80
+ end
81
+ end
82
+
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, '')
92
+ else
93
+ ''
94
+ end
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
107
+ end
108
+ end
@@ -0,0 +1,74 @@
1
+ require 'delegate'
2
+ require 'aruba/processes/spawn_process'
3
+ require 'aruba/processes/in_process'
4
+ require 'aruba/processes/debug_process'
5
+
6
+ # Aruba
7
+ module Aruba
8
+ # Command
9
+ #
10
+ # This class is not meant for direct use - Command.new, though it's API is
11
+ # public. As it is just a wrapper class, have a look at `BasicProcess` and
12
+ # the like for the public API.
13
+ #
14
+ # @see BasicProcess
15
+ # @see SpawnProcess
16
+ #
17
+ # @private
18
+ class Command < SimpleDelegator
19
+ private
20
+
21
+ attr_reader :event_bus
22
+
23
+ public
24
+
25
+ def initialize(command, opts = {})
26
+ launchers = []
27
+ launchers << Processes::DebugProcess
28
+ launchers << Processes::InProcess
29
+ launchers << Processes::SpawnProcess
30
+
31
+ launcher = launchers.find { |l| l.match? opts[:mode] }
32
+
33
+ super launcher.new(
34
+ command,
35
+ opts.fetch(:exit_timeout),
36
+ opts.fetch(:io_wait_timeout),
37
+ opts.fetch(:working_directory),
38
+ opts.fetch(:environment),
39
+ opts.fetch(:main_class),
40
+ opts.fetch(:stop_signal),
41
+ opts.fetch(:startup_wait_time)
42
+ )
43
+
44
+ @event_bus = opts.fetch(:event_bus)
45
+ rescue KeyError => e
46
+ raise ArgumentError, e.message
47
+ end
48
+
49
+ # Stop command
50
+ def stop(*)
51
+ __getobj__.stop
52
+ event_bus.notify Events::CommandStopped.new(self)
53
+
54
+ self
55
+ end
56
+
57
+ # Terminate command
58
+ def terminate(*)
59
+ __getobj__.terminate
60
+ event_bus.notify Events::CommandStopped.new(self)
61
+
62
+ self
63
+ end
64
+
65
+ # Start command
66
+ def start
67
+ __getobj__.start
68
+ event_bus.notify Events::CommandStarted.new(self)
69
+
70
+ self
71
+ end
72
+ alias run! start
73
+ end
74
+ end
@@ -0,0 +1,108 @@
1
+ require 'contracts'
2
+
3
+ require 'aruba/version'
4
+ require 'aruba/basic_configuration'
5
+ require 'aruba/in_config_wrapper'
6
+ require 'aruba/hooks'
7
+
8
+ require 'aruba/contracts/relative_path'
9
+ require 'aruba/contracts/absolute_path'
10
+ require 'aruba/contracts/enum'
11
+
12
+ require 'aruba/contracts/is_power_of_two'
13
+
14
+ # Aruba
15
+ module Aruba
16
+ # Aruba Configuration
17
+ #
18
+ # This defines the configuration options of aruba
19
+ class Configuration < BasicConfiguration
20
+ if Aruba::VERSION >= '1.0.0'
21
+ option_reader :root_directory, :contract => { None => String }, :default => Dir.getwd
22
+ else
23
+ option_accessor :root_directory, :contract => { String => String }, :default => Dir.getwd
24
+ end
25
+
26
+ option_accessor :working_directory, :contract => { Aruba::Contracts::RelativePath => Aruba::Contracts::RelativePath }, :default => 'tmp/aruba'
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
33
+
34
+ option_accessor :exit_timeout, :contract => { Num => Num }, :default => 15
35
+ option_accessor :stop_signal, :contract => { Maybe[String] => Maybe[String] }, :default => nil
36
+ option_accessor :io_wait_timeout, :contract => { Num => Num }, :default => 0.1
37
+ option_accessor :startup_wait_time, :contract => { Num => Num }, :default => 0
38
+ option_accessor :fixtures_directories, :contract => { Array => ArrayOf[String] }, :default => %w(features/fixtures spec/fixtures test/fixtures fixtures)
39
+ option_accessor :command_runtime_environment, :contract => { Hash => Hash }, :default => ENV.to_hash
40
+ # rubocop:disable Metrics/LineLength
41
+ option_accessor(:command_search_paths, :contract => { ArrayOf[String] => ArrayOf[String] }) { |config| [File.join(config.root_directory.value, 'bin'), File.join(config.root_directory.value, 'exe')] }
42
+ # rubocop:enable Metrics/LineLength
43
+ option_accessor :keep_ansi, :contract => { Bool => Bool }, :default => false
44
+ option_accessor :remove_ansi_escape_sequences, :contract => { Bool => Bool }, :default => true
45
+ # rubocop:disable Metrics/LineLength
46
+ option_accessor :command_launcher, :contract => { Aruba::Contracts::Enum[:in_process, :spawn, :debug] => Aruba::Contracts::Enum[:in_process, :spawn, :debug] }, :default => :spawn
47
+ # rubocop:enable Metrics/LineLength
48
+ option_accessor :main_class, :contract => { Class => Maybe[Class] }, :default => nil
49
+ # rubocop:disable Metrics/LineLength
50
+
51
+ # rubocop:disable Metrics/LineLength
52
+ if Aruba::VERSION >= '1.0.0'
53
+ option_accessor :home_directory, :contract => { Or[Aruba::Contracts::AbsolutePath, Aruba::Contracts::RelativePath] => Or[Aruba::Contracts::AbsolutePath, Aruba::Contracts::RelativePath] } do |config|
54
+ File.join(config.root_directory.value, config.working_directory.value)
55
+ end
56
+ else
57
+ option_accessor :home_directory, :contract => { Or[Aruba::Contracts::AbsolutePath, Aruba::Contracts::RelativePath] => Or[Aruba::Contracts::AbsolutePath, Aruba::Contracts::RelativePath] }, :default => ENV['HOME']
58
+ end
59
+ # rubocop:enable Metrics/LineLength
60
+
61
+ # rubocop:disable Metrics/LineLength
62
+ 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
63
+ # rubocop:enable Metrics/LineLength
64
+
65
+ option_accessor :physical_block_size, :contract => { Aruba::Contracts::IsPowerOfTwo => Aruba::Contracts::IsPowerOfTwo }, :default => 512
66
+ option_accessor :console_history_file, :contract => { String => String }, :default => '~/.aruba_history'
67
+
68
+ option_accessor :activate_announcer_on_command_failure, :contract => { ArrayOf[Symbol] => ArrayOf[Symbol] }, :default => []
69
+ end
70
+ end
71
+
72
+ # Aruba
73
+ module Aruba
74
+ @config = Configuration.new
75
+
76
+ class << self
77
+ attr_reader :config
78
+
79
+ # Configure aruba
80
+ #
81
+ # @example How to configure aruba
82
+ #
83
+ # Aruba.configure do |config|
84
+ # config.<option> = <value>
85
+ # end
86
+ #
87
+ def configure(&block)
88
+ @config.configure(&block)
89
+
90
+ self
91
+ end
92
+ end
93
+ end
94
+
95
+ # Aruba
96
+ module Aruba
97
+ # Old Config
98
+ #
99
+ # @private
100
+ # @deprecated
101
+ class Config < Configuration
102
+ def initialize(*args)
103
+ warn('The use of "Aruba::Config" is deprecated. Use "Aruba::Configuration" instead.')
104
+
105
+ super
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,17 @@
1
+ require 'rbconfig'
2
+
3
+ # ideas taken from: http://blog.headius.com/2010/03/jruby-startup-time-tips.html
4
+ Aruba.configure do |config|
5
+ config.before :command do
6
+ next unless RUBY_PLATFORM == 'java'
7
+
8
+ # disable JIT since these processes are so short lived
9
+ ENV['JRUBY_OPTS'] = "-X-C #{ENV['JRUBY_OPTS']}" unless (ENV['JRUBY_OPTS'] || '') .include? '-X-C'
10
+
11
+ # Faster startup for jruby
12
+ ENV['JRUBY_OPTS'] = "--dev #{ENV['JRUBY_OPTS']}" unless (ENV['JRUBY_OPTS'] || '').include? '--dev'
13
+
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')
16
+ end
17
+ end
@@ -0,0 +1,58 @@
1
+ module Aruba
2
+ # This wraps the current runtime configuration of aruba.
3
+ # If an option is changed, it notifies the event queue.
4
+ #
5
+ # This class is not meant for direct use - ConfigWrapper.new - by normal
6
+ # users.
7
+ #
8
+ # @private
9
+ class ConfigWrapper
10
+ private
11
+
12
+ attr_reader :config, :event_bus
13
+
14
+ public
15
+
16
+ # Create proxy
17
+ #
18
+ # @param [Config] config
19
+ # An aruba config object.
20
+ #
21
+ # @param [#notify] event_bus
22
+ # The event queue which should be notified.
23
+ def initialize(config, event_bus)
24
+ @config = config
25
+ @event_bus = event_bus
26
+ end
27
+
28
+ # Proxy all methods
29
+ #
30
+ # If one method ends with "=", e.g. ":option1=", then notify the event
31
+ # queue, that the user changes the value of "option1"
32
+ def method_missing(name, *args, &block)
33
+ event_bus.notify Events::ChangedConfiguration.new(:changed => { :name => name.to_s.gsub(/=$/, ''), :value => args.first }) if name.to_s.end_with? '='
34
+
35
+ config.send(name, *args, &block)
36
+ end
37
+
38
+ # Pass on respond_to?-calls
39
+ def respond_to_missing?(name, _include_private)
40
+ config.respond_to? name
41
+ end
42
+
43
+ # Compare two configs
44
+ #
45
+ # The comparism is done based on their values. No hooks are compared.
46
+ #
47
+ # Somehow `#respond_to_missing?`, `method_missing?` and `respond_to?` don't
48
+ # help here.
49
+ def ==(other)
50
+ config == other
51
+ end
52
+
53
+ # Pass on respond_to?-calls
54
+ def respond_to?(m)
55
+ config.respond_to? m
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,70 @@
1
+ require 'irb'
2
+
3
+ require 'aruba/api'
4
+ require 'aruba/console/help'
5
+
6
+ # Aruba
7
+ module Aruba
8
+ # Consule
9
+ class Console
10
+ # Start the aruba console
11
+ #
12
+ # rubocop:disable Metrics/MethodLength
13
+ def start
14
+ # Start IRB with current context:
15
+ # http://stackoverflow.com/questions/4189818/how-to-run-irb-start-in-context-of-current-class
16
+ ARGV.clear
17
+ IRB.setup nil
18
+
19
+ IRB.conf[:IRB_NAME] = 'aruba'
20
+
21
+ IRB.conf[:PROMPT] = {}
22
+ IRB.conf[:PROMPT][:ARUBA] = {
23
+ :PROMPT_I => '%N:%03n:%i> ',
24
+ :PROMPT_S => '%N:%03n:%i%l ',
25
+ :PROMPT_C => '%N:%03n:%i* ',
26
+ :RETURN => "# => %s\n"
27
+ }
28
+ IRB.conf[:PROMPT_MODE] = :ARUBA
29
+
30
+ IRB.conf[:RC] = false
31
+
32
+ require 'irb/completion'
33
+ require 'irb/ext/save-history'
34
+ IRB.conf[:READLINE] = true
35
+ IRB.conf[:SAVE_HISTORY] = 1000
36
+ IRB.conf[:HISTORY_FILE] = Aruba.config.console_history_file
37
+
38
+ # rubocop:disable Lint/NestedMethodDefinition
39
+ context = Class.new do
40
+ include Aruba::Api
41
+ include Aruba::Console::Help
42
+
43
+ def initialize
44
+ setup_aruba
45
+ end
46
+
47
+ def inspect
48
+ 'nil'
49
+ end
50
+ end
51
+ # rubocop:enable Lint/NestedMethodDefinition
52
+
53
+ irb = IRB::Irb.new(IRB::WorkSpace.new(context.new))
54
+ IRB.conf[:MAIN_CONTEXT] = irb.context
55
+
56
+ trap("SIGINT") do
57
+ irb.signal_handle
58
+ end
59
+
60
+ begin
61
+ catch(:IRB_EXIT) do
62
+ irb.eval_input
63
+ end
64
+ ensure
65
+ IRB.irb_at_exit
66
+ end
67
+ end
68
+ # rubocop:enable Metrics/MethodLength
69
+ end
70
+ end