aruba 1.0.0.pre.alpha.2 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +5 -5
  2. data/.github/PULL_REQUEST_TEMPLATE.md +2 -1
  3. data/.rspec +0 -1
  4. data/.rubocop.yml +46 -182
  5. data/.rubocop_todo.yml +216 -0
  6. data/.simplecov +7 -5
  7. data/.travis.yml +56 -40
  8. data/.yardopts +3 -0
  9. data/CHANGELOG.md +1312 -0
  10. data/CONTRIBUTING.md +175 -83
  11. data/Gemfile +5 -69
  12. data/LICENSE +1 -1
  13. data/README.md +58 -21
  14. data/Rakefile +27 -54
  15. data/appveyor.yml +7 -10
  16. data/aruba.gemspec +38 -19
  17. data/bin/console +3 -12
  18. data/cucumber.yml +4 -22
  19. data/exe/aruba +1 -1
  20. data/fixtures/cli-app/README.md +1 -1
  21. data/fixtures/cli-app/Rakefile +1 -1
  22. data/fixtures/cli-app/bin/aruba-test-cli +1 -1
  23. data/fixtures/cli-app/cli-app.gemspec +4 -4
  24. data/fixtures/cli-app/lib/cli/app.rb +1 -1
  25. data/fixtures/cli-app/lib/cli/app/suppress_simple_cov_output.rb +3 -3
  26. data/fixtures/cli-app/lib/cli/app/version.rb +1 -1
  27. data/fixtures/cli-app/spec/spec_helper.rb +3 -2
  28. data/fixtures/empty-app/Rakefile +1 -1
  29. data/fixtures/empty-app/cli-app.gemspec +4 -4
  30. data/fixtures/empty-app/lib/cli/app.rb +0 -2
  31. data/fixtures/empty-app/lib/cli/app/version.rb +1 -1
  32. data/fixtures/getting-started-app/Gemfile +1 -1
  33. data/lib/aruba/api.rb +8 -15
  34. data/lib/aruba/api/bundler.rb +16 -0
  35. data/lib/aruba/api/commands.rb +272 -0
  36. data/lib/aruba/api/core.rb +82 -43
  37. data/lib/aruba/api/environment.rb +24 -7
  38. data/lib/aruba/api/filesystem.rb +66 -64
  39. data/lib/aruba/api/text.rb +17 -11
  40. data/lib/aruba/aruba_path.rb +25 -111
  41. data/lib/aruba/basic_configuration.rb +8 -25
  42. data/lib/aruba/basic_configuration/option.rb +2 -2
  43. data/lib/aruba/cli.rb +4 -1
  44. data/lib/aruba/colorizer.rb +10 -99
  45. data/lib/aruba/command.rb +4 -0
  46. data/lib/aruba/config/jruby.rb +15 -5
  47. data/lib/aruba/config_wrapper.rb +17 -2
  48. data/lib/aruba/configuration.rb +107 -0
  49. data/lib/aruba/console.rb +5 -7
  50. data/lib/aruba/console/help.rb +5 -2
  51. data/lib/aruba/contracts/absolute_path.rb +3 -3
  52. data/lib/aruba/contracts/is_power_of_two.rb +2 -2
  53. data/lib/aruba/contracts/relative_path.rb +3 -3
  54. data/lib/aruba/cucumber.rb +0 -3
  55. data/lib/aruba/cucumber/command.rb +227 -190
  56. data/lib/aruba/cucumber/environment.rb +1 -1
  57. data/lib/aruba/cucumber/file.rb +56 -50
  58. data/lib/aruba/cucumber/hooks.rb +10 -63
  59. data/lib/aruba/cucumber/testing_frameworks.rb +76 -50
  60. data/lib/aruba/event_bus.rb +4 -2
  61. data/lib/aruba/event_bus/name_resolver.rb +10 -10
  62. data/lib/aruba/events.rb +2 -1
  63. data/lib/aruba/hooks.rb +3 -5
  64. data/lib/aruba/in_config_wrapper.rb +10 -3
  65. data/lib/aruba/initializer.rb +40 -34
  66. data/lib/aruba/matchers/base/base_matcher.rb +2 -11
  67. data/lib/aruba/matchers/base/message_indenter.rb +19 -0
  68. data/lib/aruba/matchers/base/object_formatter.rb +2 -7
  69. data/lib/aruba/matchers/collection/include_an_object.rb +11 -13
  70. data/lib/aruba/matchers/command/be_successfully_executed.rb +8 -4
  71. data/lib/aruba/matchers/command/have_exit_status.rb +16 -4
  72. data/lib/aruba/matchers/command/have_finished_in_time.rb +5 -5
  73. data/lib/aruba/matchers/command/have_output.rb +12 -5
  74. data/lib/aruba/matchers/command/have_output_on_stderr.rb +4 -2
  75. data/lib/aruba/matchers/command/have_output_on_stdout.rb +4 -2
  76. data/lib/aruba/matchers/command/have_output_size.rb +2 -2
  77. data/lib/aruba/matchers/directory/be_an_existing_directory.rb +5 -7
  78. data/lib/aruba/matchers/directory/have_sub_directory.rb +10 -7
  79. data/lib/aruba/matchers/file/be_a_command_found_in_path.rb +2 -4
  80. data/lib/aruba/matchers/file/be_an_existing_executable.rb +4 -6
  81. data/lib/aruba/matchers/file/be_an_existing_file.rb +5 -7
  82. data/lib/aruba/matchers/file/have_file_content.rb +4 -4
  83. data/lib/aruba/matchers/file/have_file_size.rb +8 -8
  84. data/lib/aruba/matchers/file/have_same_file_content.rb +9 -12
  85. data/lib/aruba/matchers/path/a_path_matching_pattern.rb +2 -4
  86. data/lib/aruba/matchers/path/be_an_absolute_path.rb +3 -5
  87. data/lib/aruba/matchers/path/be_an_existing_path.rb +4 -6
  88. data/lib/aruba/matchers/path/have_permissions.rb +8 -8
  89. data/lib/aruba/matchers/string/include_output_string.rb +8 -10
  90. data/lib/aruba/matchers/string/match_output_string.rb +9 -11
  91. data/lib/aruba/matchers/string/output_string_eq.rb +7 -9
  92. data/lib/aruba/platform.rb +0 -8
  93. data/lib/aruba/platforms/announcer.rb +60 -85
  94. data/lib/aruba/platforms/aruba_file_creator.rb +4 -2
  95. data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +8 -3
  96. data/lib/aruba/platforms/aruba_logger.rb +22 -2
  97. data/lib/aruba/platforms/command_monitor.rb +15 -102
  98. data/lib/aruba/platforms/determine_disk_usage.rb +56 -19
  99. data/lib/aruba/platforms/filesystem_status.rb +9 -9
  100. data/lib/aruba/platforms/local_environment.rb +2 -2
  101. data/lib/aruba/platforms/simple_table.rb +3 -11
  102. data/lib/aruba/platforms/unix_command_string.rb +7 -4
  103. data/lib/aruba/platforms/unix_environment_variables.rb +19 -26
  104. data/lib/aruba/platforms/unix_platform.rb +18 -39
  105. data/lib/aruba/platforms/unix_which.rb +3 -2
  106. data/lib/aruba/platforms/windows_command_string.rb +20 -7
  107. data/lib/aruba/platforms/windows_environment_variables.rb +42 -30
  108. data/lib/aruba/platforms/windows_platform.rb +4 -0
  109. data/lib/aruba/platforms/windows_which.rb +9 -4
  110. data/lib/aruba/processes/basic_process.rb +21 -27
  111. data/lib/aruba/processes/debug_process.rb +16 -5
  112. data/lib/aruba/processes/in_process.rb +20 -9
  113. data/lib/aruba/processes/spawn_process.rb +64 -36
  114. data/lib/aruba/rspec.rb +28 -31
  115. data/lib/aruba/runtime.rb +16 -7
  116. data/lib/aruba/setup.rb +32 -17
  117. data/lib/aruba/tasks/docker_helpers.rb +4 -2
  118. data/lib/aruba/version.rb +1 -1
  119. metadata +194 -64
  120. data/History.md +0 -612
  121. data/bin/bootstrap +0 -34
  122. data/bin/build +0 -3
  123. data/bin/release +0 -3
  124. data/fixtures/spawn_process/stderr.sh +0 -3
  125. data/lib/aruba/api/command.rb +0 -309
  126. data/lib/aruba/api/deprecated.rb +0 -895
  127. data/lib/aruba/api/rvm.rb +0 -44
  128. data/lib/aruba/config.rb +0 -101
  129. data/lib/aruba/cucumber/rvm.rb +0 -3
  130. data/lib/aruba/in_process.rb +0 -14
  131. data/lib/aruba/jruby.rb +0 -4
  132. data/lib/aruba/matchers/path/match_path_pattern.rb +0 -41
  133. data/lib/aruba/matchers/rspec_matcher_include_regexp.rb +0 -25
  134. data/lib/aruba/platforms/disk_usage_calculator.rb +0 -20
  135. data/lib/aruba/spawn_process.rb +0 -11
@@ -32,8 +32,8 @@ module Aruba
32
32
  contract = opts[:contract]
33
33
  default = opts[:default]
34
34
 
35
- fail ArgumentError, 'Either use block or default value' if block_given? && default
36
- fail ArgumentError, 'contract-options is required' if contract.nil?
35
+ raise ArgumentError, 'Either use block or default value' if block_given? && default
36
+ raise ArgumentError, 'contract-options is required' if contract.nil?
37
37
 
38
38
  Contract contract
39
39
  add_option(name, block_given? ? yield(InConfigWrapper.new(known_options)) : default)
@@ -61,9 +61,8 @@ module Aruba
61
61
  contract = opts[:contract]
62
62
  default = opts[:default]
63
63
 
64
- fail ArgumentError, 'Either use block or default value' if block_given? && default
65
- # fail ArgumentError, 'Either use block or default value' if !block_given? && default.nil? && default.to_s.empty?
66
- fail ArgumentError, 'contract-options is required' if contract.nil?
64
+ raise ArgumentError, 'Either use block or default value' if block_given? && default
65
+ raise ArgumentError, 'contract-options is required' if contract.nil?
67
66
 
68
67
  # Add writer
69
68
  add_option(name, block_given? ? yield(InConfigWrapper.new(known_options)) : default)
@@ -72,7 +71,7 @@ module Aruba
72
71
  define_method("#{name}=") { |v| find_option(name).value = v }
73
72
 
74
73
  # Add reader
75
- option_reader name, :contract => { None => contract.values.first }
74
+ option_reader name, contract: { None => contract.values.first }
76
75
  end
77
76
 
78
77
  private
@@ -80,7 +79,7 @@ module Aruba
80
79
  def add_option(name, value = nil)
81
80
  return if known_options.key?(name)
82
81
 
83
- known_options[name] = Option.new(:name => name, :value => value)
82
+ known_options[name] = Option.new(name: name, value: value)
84
83
 
85
84
  self
86
85
  end
@@ -114,29 +113,13 @@ module Aruba
114
113
 
115
114
  # Make deep dup copy of configuration
116
115
  def make_copy
117
- obj = self.dup
116
+ obj = dup
118
117
  obj.local_options = Marshal.load(Marshal.dump(local_options))
119
118
  obj.hooks = @hooks
120
119
 
121
120
  obj
122
121
  end
123
122
 
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
123
  # Define or run before-hook
141
124
  #
142
125
  # @param [Symbol, String] name
@@ -226,7 +209,7 @@ module Aruba
226
209
  end
227
210
 
228
211
  def find_option(name)
229
- fail NotImplementedError, %(Unknown option "#{name}") unless option? name
212
+ raise NotImplementedError, %(Unknown option "#{name}") unless option? name
230
213
 
231
214
  local_options[name]
232
215
  end
@@ -15,8 +15,8 @@ module Aruba
15
15
  name = opts[:name]
16
16
  value = opts[:value]
17
17
 
18
- fail ArgumentError, '"name" is required' unless opts.key? :name
19
- fail ArgumentError, '"value" is required' unless opts.key? :value
18
+ raise ArgumentError, '"name" is required' unless opts.key? :name
19
+ raise ArgumentError, '"value" is required' unless opts.key? :value
20
20
 
21
21
  @name = name
22
22
  @value = value
@@ -18,7 +18,10 @@ 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,
22
+ default: 'cucumber',
23
+ enum: %w(cucumber rspec minitest),
24
+ desc: 'Choose which test framework to use'
22
25
  def init
23
26
  Aruba::Initializer.new.call(options[:test_framework])
24
27
  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
@@ -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
 
@@ -56,6 +58,8 @@ module Aruba
56
58
 
57
59
  # Terminate command
58
60
  def terminate(*)
61
+ return if __getobj__.stopped?
62
+
59
63
  __getobj__.terminate
60
64
  event_bus.notify Events::CommandStopped.new(self)
61
65
 
@@ -2,16 +2,26 @@ 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
5
+ config.before :command do |command|
6
6
  next unless RUBY_PLATFORM == 'java'
7
7
 
8
+ env = command.environment
9
+
10
+ jruby_opts = env['JRUBY_OPTS'] || ''
11
+
8
12
  # 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'
13
+ jruby_opts = "-X-C #{jruby_opts}" unless jruby_opts.include? '-X-C'
10
14
 
11
15
  # Faster startup for jruby
12
- ENV['JRUBY_OPTS'] = "--dev #{ENV['JRUBY_OPTS']}" unless (ENV['JRUBY_OPTS'] || '').include? '--dev'
16
+ jruby_opts = "--dev #{jruby_opts}" unless jruby_opts.include? '--dev'
17
+
18
+ env['JRUBY_OPTS'] = jruby_opts
19
+
20
+ if /solaris|sunos/i.match?(RbConfig::CONFIG['host_os'])
21
+ java_opts = env['JAVA_OPTS'] || ''
13
22
 
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')
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
16
26
  end
17
27
  end
@@ -30,9 +30,11 @@ module Aruba
30
30
  # If one method ends with "=", e.g. ":option1=", then notify the event
31
31
  # queue, that the user changes the value of "option1"
32
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? '='
33
+ notify(name, args) if name.to_s.end_with?('=')
34
34
 
35
- config.send(name, *args, &block)
35
+ return config.send(name, *args, &block) if config.respond_to? name
36
+
37
+ super
36
38
  end
37
39
 
38
40
  # Pass on respond_to?-calls
@@ -54,5 +56,18 @@ module Aruba
54
56
  def respond_to?(m)
55
57
  config.respond_to? m
56
58
  end
59
+
60
+ private
61
+
62
+ def notify(name, args)
63
+ event_bus.notify(
64
+ Events::ChangedConfiguration.new(
65
+ changed: {
66
+ name: name.to_s.gsub(/=$/, ''),
67
+ value: args.first
68
+ }
69
+ )
70
+ )
71
+ end
57
72
  end
58
73
  end
@@ -0,0 +1,107 @@
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
+ option_reader :root_directory, contract: { None => String }, default: Dir.getwd
21
+
22
+ option_accessor :working_directory,
23
+ contract: { Aruba::Contracts::RelativePath =>
24
+ Aruba::Contracts::RelativePath },
25
+ default: 'tmp/aruba'
26
+
27
+ option_reader :fixtures_path_prefix, contract: { None => String }, default: '%'
28
+
29
+ option_accessor :exit_timeout, contract: { Num => Num }, default: 15
30
+ option_accessor :stop_signal, contract: { Maybe[String] => Maybe[String] }, default: nil
31
+ option_accessor :io_wait_timeout, contract: { Num => Num }, default: 0.1
32
+ option_accessor :startup_wait_time, contract: { Num => Num }, default: 0
33
+ option_accessor :fixtures_directories,
34
+ contract: { Array => ArrayOf[String] },
35
+ default: %w(features/fixtures spec/fixtures test/fixtures fixtures)
36
+
37
+ option_accessor :command_runtime_environment, contract: { Hash => Hash }, default: {}
38
+ option_accessor :command_search_paths,
39
+ contract: { ArrayOf[String] => ArrayOf[String] } do |config|
40
+ [File.join(config.root_directory.value, 'bin'),
41
+ File.join(config.root_directory.value, 'exe')]
42
+ end
43
+ option_accessor :remove_ansi_escape_sequences, contract: { Bool => Bool }, default: true
44
+ option_accessor :command_launcher,
45
+ contract: {
46
+ Aruba::Contracts::Enum[:in_process, :spawn, :debug] =>
47
+ Aruba::Contracts::Enum[:in_process, :spawn, :debug]
48
+ },
49
+ default: :spawn
50
+ option_accessor :main_class, contract: { Class => Maybe[Class] }, default: nil
51
+
52
+ option_accessor :home_directory,
53
+ contract: {
54
+ Or[Aruba::Contracts::AbsolutePath, Aruba::Contracts::RelativePath] =>
55
+ Or[Aruba::Contracts::AbsolutePath, Aruba::Contracts::RelativePath]
56
+ } do |config|
57
+ File.join(config.root_directory.value, config.working_directory.value)
58
+ end
59
+
60
+ option_accessor :log_level,
61
+ contract: {
62
+ Aruba::Contracts::Enum[:fatal, :warn, :debug, :info,
63
+ :error, :unknown, :silent] =>
64
+ Aruba::Contracts::Enum[:fatal, :warn, :debug, :info,
65
+ :error, :unknown, :silent]
66
+ },
67
+ default: :info
68
+
69
+ # TODO: deprecate this value and replace with "filesystem allocation unit"
70
+ # equal to 4096 by default. "filesystem allocation unit" would represent
71
+ # the actual MINIMUM space taken in bytes by a 1-byte file
72
+ option_accessor :physical_block_size,
73
+ contract: { Aruba::Contracts::IsPowerOfTwo =>
74
+ Aruba::Contracts::IsPowerOfTwo },
75
+ default: 512
76
+ option_accessor :console_history_file, contract: { String => String },
77
+ default: '~/.aruba_history'
78
+
79
+ option_accessor :activate_announcer_on_command_failure,
80
+ contract: { ArrayOf[Symbol] => ArrayOf[Symbol] },
81
+ default: []
82
+ option_accessor :allow_absolute_paths, contract: { Bool => Bool }, default: false
83
+ end
84
+ end
85
+
86
+ # Aruba
87
+ module Aruba
88
+ @config = Configuration.new
89
+
90
+ class << self
91
+ attr_reader :config
92
+
93
+ # Configure aruba
94
+ #
95
+ # @example How to configure aruba
96
+ #
97
+ # Aruba.configure do |config|
98
+ # config.<option> = <value>
99
+ # end
100
+ #
101
+ def configure(&block)
102
+ @config.configure(&block)
103
+
104
+ self
105
+ end
106
+ end
107
+ end
@@ -9,7 +9,6 @@ module Aruba
9
9
  class Console
10
10
  # Start the aruba console
11
11
  #
12
- # rubocop:disable Metrics/MethodLength
13
12
  def start
14
13
  # Start IRB with current context:
15
14
  # http://stackoverflow.com/questions/4189818/how-to-run-irb-start-in-context-of-current-class
@@ -20,10 +19,10 @@ module Aruba
20
19
 
21
20
  IRB.conf[:PROMPT] = {}
22
21
  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"
22
+ PROMPT_I: '%N:%03n:%i> ',
23
+ PROMPT_S: '%N:%03n:%i%l ',
24
+ PROMPT_C: '%N:%03n:%i* ',
25
+ RETURN: "# => %s\n"
27
26
  }
28
27
  IRB.conf[:PROMPT_MODE] = :ARUBA
29
28
 
@@ -51,7 +50,7 @@ module Aruba
51
50
  irb = IRB::Irb.new(IRB::WorkSpace.new(context.new))
52
51
  IRB.conf[:MAIN_CONTEXT] = irb.context
53
52
 
54
- trap("SIGINT") do
53
+ trap('SIGINT') do
55
54
  irb.signal_handle
56
55
  end
57
56
 
@@ -63,6 +62,5 @@ module Aruba
63
62
  IRB.irb_at_exit
64
63
  end
65
64
  end
66
- # rubocop:enable Metrics/MethodLength
67
65
  end
68
66
  end