aruba 0.8.1 → 0.9.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/.travis.yml +3 -1
- data/Gemfile +13 -10
- data/History.md +25 -7
- data/README.md +6 -1
- data/Rakefile +16 -3
- data/aruba.gemspec +10 -2
- data/bin/aruba +7 -0
- data/cucumber.yml +11 -2
- data/features/api/command/extract_text.feature +97 -0
- data/features/api/command/unescape_text.feature +119 -0
- data/features/api/core/expand_path.feature +16 -0
- data/features/api/{cd.feature → filesystem/cd.feature} +2 -1
- data/features/api/filesystem/create_directory.feature +57 -0
- data/features/api/filesystem/disk_usage.feature +151 -0
- data/features/api/filesystem/does_exist.feature +62 -0
- data/features/api/filesystem/is_absolute.feature +48 -0
- data/features/api/filesystem/is_directory.feature +53 -0
- data/features/api/filesystem/is_file.feature +54 -0
- data/features/api/filesystem/is_relative.feature +48 -0
- data/features/cli/console.feature +52 -0
- data/features/configuration/console_history_file.feature +38 -0
- data/features/configuration/exit_timeout.feature +2 -1
- data/features/configuration/fixtures_path_prefix.feature +0 -1
- data/features/configuration/home_directory.feature +0 -1
- data/features/configuration/io_timeout.feature +0 -1
- data/features/configuration/keep_ansi.feature +1 -2
- data/features/configuration/log_level.feature +38 -0
- data/features/configuration/physical_block_size.feature +53 -0
- data/features/configuration/remove_ansi_escape_sequences.feature +38 -0
- data/features/configuration/root_directory.feature +0 -1
- data/features/configuration/working_directory.feature +2 -1
- data/features/fixtures/cli-app/README.md +5 -0
- data/features/fixtures/cli-app/lib/cli/app.rb +1 -1
- data/features/fixtures/cli-app/spec/spec_helper.rb +1 -2
- data/features/fixtures/cli-app/spec/support/aruba.rb +1 -0
- data/features/fixtures/empty-app/lib/cli/app.rb +1 -1
- data/features/fixtures/empty-app/spec/spec_helper.rb +1 -1
- data/features/step_definitions/aruba_dev_steps.rb +12 -1
- data/features/support/env.rb +1 -1
- data/lib/aruba/announcer.rb +1 -14
- data/lib/aruba/api.rb +6 -6
- data/lib/aruba/api/command.rb +74 -12
- data/lib/aruba/api/core.rb +18 -11
- data/lib/aruba/api/deprecated.rb +60 -72
- data/lib/aruba/api/filesystem.rb +41 -16
- data/lib/aruba/aruba_logger.rb +77 -0
- data/lib/aruba/aruba_path.rb +33 -0
- data/lib/aruba/basic_configuration.rb +2 -2
- data/lib/aruba/cli.rb +11 -0
- data/lib/aruba/config.rb +13 -3
- data/lib/aruba/config/jruby.rb +5 -2
- data/lib/aruba/console.rb +66 -0
- data/lib/aruba/console/help.rb +33 -0
- data/lib/aruba/contracts/is_power_of_two.rb +15 -0
- data/lib/aruba/cucumber.rb +27 -10
- data/lib/aruba/cucumber/hooks.rb +15 -8
- data/lib/aruba/disk_usage_calculator.rb +7 -0
- data/lib/aruba/file_size.rb +52 -0
- data/lib/aruba/in_process.rb +1 -1
- data/lib/aruba/jruby.rb +1 -1
- data/lib/aruba/matchers/command.rb +1 -1
- data/lib/aruba/matchers/directory.rb +1 -1
- data/lib/aruba/matchers/environment.rb +1 -1
- data/lib/aruba/matchers/file.rb +1 -1
- data/lib/aruba/matchers/path.rb +1 -1
- data/lib/aruba/matchers/path/match_path_pattern.rb +1 -1
- data/lib/aruba/matchers/rspec_matcher_include_regexp.rb +1 -1
- data/lib/aruba/platform.rb +14 -242
- data/lib/aruba/{creators → platforms}/aruba_file_creator.rb +3 -3
- data/lib/aruba/{creators → platforms}/aruba_fixed_size_file_creator.rb +2 -2
- data/lib/aruba/platforms/simple_table.rb +36 -0
- data/lib/aruba/platforms/unix_command_string.rb +24 -0
- data/lib/aruba/platforms/unix_environment_variables.rb +130 -0
- data/lib/aruba/platforms/unix_platform.rb +226 -0
- data/lib/aruba/platforms/unix_which.rb +83 -0
- data/lib/aruba/platforms/windows_command_string.rb +23 -0
- data/lib/aruba/platforms/windows_environment_variables.rb +83 -0
- data/lib/aruba/platforms/windows_platform.rb +39 -0
- data/lib/aruba/platforms/windows_which.rb +104 -0
- data/lib/aruba/process_monitor.rb +3 -3
- data/lib/aruba/processes/basic_process.rb +23 -3
- data/lib/aruba/processes/debug_process.rb +2 -2
- data/lib/aruba/processes/in_process.rb +1 -1
- data/lib/aruba/processes/spawn_process.rb +10 -4
- data/lib/aruba/reporting.rb +1 -1
- data/lib/aruba/rspec.rb +8 -6
- data/lib/aruba/runtime.rb +8 -5
- data/lib/aruba/version.rb +1 -1
- data/spec/aruba/api_spec.rb +25 -23
- data/spec/aruba/aruba_path_spec.rb +37 -0
- data/spec/aruba/jruby_spec.rb +1 -1
- data/spec/aruba/matchers/file_spec.rb +2 -2
- data/spec/aruba/matchers/path_spec.rb +3 -3
- data/spec/aruba/platform/simple_table_spec.rb +23 -0
- data/spec/aruba/platform/windows_environment_variables_spec.rb +500 -0
- data/spec/aruba/spawn_process_spec.rb +3 -1
- metadata +90 -12
- data/lib/aruba/contracts/is_a.rb +0 -21
- data/lib/aruba/environment.rb +0 -121
data/lib/aruba/api/filesystem.rb
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
require 'aruba/platform'
|
2
|
+
|
2
3
|
require 'aruba/extensions/string/strip'
|
3
|
-
require 'aruba/creators/aruba_file_creator'
|
4
|
-
require 'aruba/creators/aruba_fixed_size_file_creator'
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
require 'aruba/platforms/aruba_file_creator'
|
6
|
+
require 'aruba/platforms/aruba_fixed_size_file_creator'
|
7
|
+
require 'aruba/disk_usage_calculator'
|
8
|
+
require 'aruba/aruba_path'
|
9
|
+
|
10
|
+
Aruba.platform.require_matching_files('../matchers/file/*.rb', __FILE__)
|
11
|
+
Aruba.platform.require_matching_files('../matchers/directory/*.rb', __FILE__)
|
12
|
+
Aruba.platform.require_matching_files('../matchers/path/*.rb', __FILE__)
|
9
13
|
|
10
14
|
module Aruba
|
11
15
|
module Api
|
@@ -15,7 +19,7 @@ module Aruba
|
|
15
19
|
# @param [String] file_or_directory
|
16
20
|
# The file/directory which should exist
|
17
21
|
def exist?(file_or_directory)
|
18
|
-
Aruba
|
22
|
+
Aruba.platform.exist? expand_path(file_or_directory)
|
19
23
|
end
|
20
24
|
|
21
25
|
# Check if file exist and is file
|
@@ -23,7 +27,7 @@ module Aruba
|
|
23
27
|
# @param [String] file
|
24
28
|
# The file/directory which should exist
|
25
29
|
def file?(file)
|
26
|
-
Aruba
|
30
|
+
Aruba.platform.file? expand_path(file)
|
27
31
|
end
|
28
32
|
|
29
33
|
# Check if directory exist and is directory
|
@@ -31,7 +35,7 @@ module Aruba
|
|
31
35
|
# @param [String] file
|
32
36
|
# The file/directory which should exist
|
33
37
|
def directory?(file)
|
34
|
-
Aruba
|
38
|
+
Aruba.platform.directory? expand_path(file)
|
35
39
|
end
|
36
40
|
|
37
41
|
# Check if path is absolute
|
@@ -140,7 +144,7 @@ module Aruba
|
|
140
144
|
|
141
145
|
args.each { |p| create_directory(File.dirname(p)) }
|
142
146
|
|
143
|
-
Aruba
|
147
|
+
Aruba.platform.touch(args.map { |p| expand_path(p) }, options)
|
144
148
|
|
145
149
|
self
|
146
150
|
end
|
@@ -174,13 +178,13 @@ module Aruba
|
|
174
178
|
destination_path = expand_path(destination)
|
175
179
|
|
176
180
|
if source_paths.count > 1
|
177
|
-
Aruba
|
181
|
+
Aruba.platform.mkdir(destination_path)
|
178
182
|
else
|
179
|
-
Aruba
|
183
|
+
Aruba.platform.mkdir(File.dirname(destination_path))
|
180
184
|
source_paths = source_paths.first
|
181
185
|
end
|
182
186
|
|
183
|
-
Aruba
|
187
|
+
Aruba.platform.cp source_paths, destination_path
|
184
188
|
|
185
189
|
self
|
186
190
|
end
|
@@ -239,7 +243,7 @@ module Aruba
|
|
239
243
|
args.each { |p| raise "Expected #{p} to be present" unless exist?(p) }
|
240
244
|
paths = args.map { |p| expand_path(p) }
|
241
245
|
|
242
|
-
Aruba
|
246
|
+
Aruba.platform.chmod(mode, paths, options)
|
243
247
|
|
244
248
|
self
|
245
249
|
end
|
@@ -254,7 +258,7 @@ module Aruba
|
|
254
258
|
def append_to_file(file_name, file_content)
|
255
259
|
file_name = expand_path(file_name)
|
256
260
|
|
257
|
-
Aruba
|
261
|
+
Aruba.platform.mkdir(File.dirname(file_name))
|
258
262
|
File.open(file_name, 'a') { |f| f << file_content }
|
259
263
|
end
|
260
264
|
|
@@ -263,7 +267,7 @@ module Aruba
|
|
263
267
|
# @param [String] directory_name
|
264
268
|
# The name of the directory which should be created
|
265
269
|
def create_directory(directory_name)
|
266
|
-
Aruba
|
270
|
+
Aruba.platform.mkdir expand_path(directory_name)
|
267
271
|
|
268
272
|
self
|
269
273
|
end
|
@@ -283,7 +287,7 @@ module Aruba
|
|
283
287
|
|
284
288
|
args = args.map { |p| expand_path(p) }
|
285
289
|
|
286
|
-
Aruba
|
290
|
+
Aruba.platform.rm(args, options)
|
287
291
|
end
|
288
292
|
|
289
293
|
# Read content of file and yield the content to block
|
@@ -300,6 +304,27 @@ module Aruba
|
|
300
304
|
|
301
305
|
yield(content)
|
302
306
|
end
|
307
|
+
|
308
|
+
# Calculate disk usage for file(s) and/or directories
|
309
|
+
#
|
310
|
+
# It shows the disk usage for a single file/directory. If multiple paths
|
311
|
+
# are given, it sum their size up.
|
312
|
+
#
|
313
|
+
# @param [Array, Path] paths
|
314
|
+
# The paths
|
315
|
+
#
|
316
|
+
# @result [FileSize]
|
317
|
+
# Bytes on disk
|
318
|
+
def disk_usage(*paths)
|
319
|
+
size = paths.flatten.map do |p|
|
320
|
+
DiskUsageCalculator.new.calc(
|
321
|
+
ArubaPath.new(expand_path(p)).blocks,
|
322
|
+
aruba.config.physical_block_size
|
323
|
+
)
|
324
|
+
end.inject(0, &:+)
|
325
|
+
|
326
|
+
FileSize.new(size)
|
327
|
+
end
|
303
328
|
end
|
304
329
|
end
|
305
330
|
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
module Aruba
|
4
|
+
class ArubaLogger
|
5
|
+
attr_reader :mode
|
6
|
+
|
7
|
+
# Create logger
|
8
|
+
#
|
9
|
+
# @param [Logger] logger (::Logger.new( $stderr ))
|
10
|
+
# The logger with should be used to output data
|
11
|
+
def initialize(opts = {})
|
12
|
+
@mode = opts.fetch(:default_mode, :info)
|
13
|
+
end
|
14
|
+
|
15
|
+
[:fatal, :warn, :debug, :info, :error, :unknown].each do |m|
|
16
|
+
define_method m do |msg|
|
17
|
+
if RUBY_VERSION < '1.9'
|
18
|
+
logger.send m, msg
|
19
|
+
else
|
20
|
+
logger.public_send m, msg
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Create new logger on every invocation to make
|
26
|
+
# capturing $stderr possible
|
27
|
+
def logger
|
28
|
+
l = ::Logger.new($stderr)
|
29
|
+
|
30
|
+
case mode
|
31
|
+
when :debug
|
32
|
+
l.level = ::Logger::DEBUG
|
33
|
+
format_debug(l)
|
34
|
+
when :silent
|
35
|
+
l.level = 9_999
|
36
|
+
when :info
|
37
|
+
l.level = ::Logger::INFO
|
38
|
+
format_standard(l)
|
39
|
+
else
|
40
|
+
l.level = ::Logger::INFO
|
41
|
+
format_standard(l)
|
42
|
+
end
|
43
|
+
|
44
|
+
l
|
45
|
+
end
|
46
|
+
|
47
|
+
# Is mode?
|
48
|
+
#
|
49
|
+
# @param [String, Symbol] m
|
50
|
+
# Mode to compare with
|
51
|
+
def mode?(m)
|
52
|
+
mode == m.to_sym
|
53
|
+
end
|
54
|
+
|
55
|
+
# Change mode of logger: :debug, ... + Change the output format
|
56
|
+
#
|
57
|
+
# @param [Symbol] m
|
58
|
+
# the mode: :debug, ...
|
59
|
+
def mode=(m)
|
60
|
+
@mode = m.to_sym
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def format_debug(l)
|
66
|
+
l.formatter = proc { |severity, datetime, progname, msg|
|
67
|
+
format("%s %s %s: %s\n", datetime, severity, progname, msg)
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
def format_standard(l)
|
72
|
+
l.formatter = proc { |severity, datetime, _, msg|
|
73
|
+
format("%s %s: %s\n", datetime, severity, msg)
|
74
|
+
}
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/lib/aruba/aruba_path.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
require 'delegate'
|
3
3
|
|
4
|
+
require 'aruba/file_size'
|
5
|
+
|
4
6
|
module Aruba
|
5
7
|
class ArubaPath < Delegator
|
6
8
|
def initialize(path)
|
@@ -60,6 +62,27 @@ module Aruba
|
|
60
62
|
end
|
61
63
|
end
|
62
64
|
|
65
|
+
# How many parts has the file name
|
66
|
+
#
|
67
|
+
# @return [Integer]
|
68
|
+
# The count of file name parts
|
69
|
+
#
|
70
|
+
# @example
|
71
|
+
#
|
72
|
+
# path = ArubaPath.new('path/to/file.txt')
|
73
|
+
# path.depth # => 3
|
74
|
+
#
|
75
|
+
def depth
|
76
|
+
if RUBY_VERSION < '1.9'
|
77
|
+
items = []
|
78
|
+
__getobj__.each_filename { |f| items << f }
|
79
|
+
|
80
|
+
items.size
|
81
|
+
else
|
82
|
+
__getobj__.each_filename.to_a.size
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
63
86
|
# Path ends with string
|
64
87
|
#
|
65
88
|
# @param [String] string
|
@@ -86,5 +109,15 @@ module Aruba
|
|
86
109
|
to_s[index]
|
87
110
|
end
|
88
111
|
end
|
112
|
+
|
113
|
+
# Report count of blocks allocated on disk
|
114
|
+
#
|
115
|
+
# This reports the amount of blocks which are allocated by the path.
|
116
|
+
#
|
117
|
+
# @return [Integer]
|
118
|
+
# The count of blocks on disk
|
119
|
+
def blocks
|
120
|
+
File::Stat.new(to_s).blocks
|
121
|
+
end
|
89
122
|
end
|
90
123
|
end
|
@@ -94,7 +94,7 @@ module Aruba
|
|
94
94
|
# Get access to hooks
|
95
95
|
def hooks
|
96
96
|
# rubocop:disable Metrics/LineLength
|
97
|
-
Aruba
|
97
|
+
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.'
|
98
98
|
# rubocop:enable Metrics/LineLength
|
99
99
|
|
100
100
|
@hooks
|
@@ -102,7 +102,7 @@ module Aruba
|
|
102
102
|
|
103
103
|
# @deprecated
|
104
104
|
def before_cmd(&block)
|
105
|
-
Aruba
|
105
|
+
Aruba.platform.deprecated 'The use of the "#before_cmd"-hook is deprecated. Please define with "#before(:command) {}" instead'
|
106
106
|
|
107
107
|
before(:command, &block)
|
108
108
|
end
|
data/lib/aruba/cli.rb
ADDED
data/lib/aruba/config.rb
CHANGED
@@ -4,10 +4,12 @@ require 'aruba/version'
|
|
4
4
|
require 'aruba/basic_configuration'
|
5
5
|
require 'aruba/config_wrapper'
|
6
6
|
require 'aruba/hooks'
|
7
|
+
|
7
8
|
require 'aruba/contracts/relative_path'
|
8
9
|
require 'aruba/contracts/absolute_path'
|
9
10
|
require 'aruba/contracts/enum'
|
10
|
-
|
11
|
+
|
12
|
+
require 'aruba/contracts/is_power_of_two'
|
11
13
|
|
12
14
|
module Aruba
|
13
15
|
# Aruba Configuration
|
@@ -29,15 +31,16 @@ module Aruba
|
|
29
31
|
option_accessor :exit_timeout, :contract => { Num => Num }, :default => 15
|
30
32
|
option_accessor :io_wait_timeout, :contract => { Num => Num }, :default => 0.1
|
31
33
|
option_accessor :fixtures_directories, :contract => { Array => ArrayOf[String] }, :default => %w(features/fixtures spec/fixtures test/fixtures)
|
32
|
-
option_accessor :command_runtime_environment, :contract => { Hash => Hash }, :default => ENV.to_hash
|
34
|
+
option_accessor :command_runtime_environment, :contract => { Hash => Hash }, :default => ENV.to_hash.dup
|
33
35
|
# rubocop:disable Metrics/LineLength
|
34
36
|
option_accessor(:command_search_paths, :contract => { ArrayOf[String] => ArrayOf[String] }) { |config| [File.join(config.root_directory.value, 'bin')] }
|
35
37
|
# rubocop:enable Metrics/LineLength
|
36
38
|
option_accessor :keep_ansi, :contract => { Bool => Bool }, :default => false
|
39
|
+
option_accessor :remove_ansi_escape_sequences, :contract => { Bool => Bool }, :default => true
|
37
40
|
# rubocop:disable Metrics/LineLength
|
38
41
|
option_accessor :command_launcher, :contract => { Aruba::Contracts::Enum[:in_process, :spawn, :debug] => Aruba::Contracts::Enum[:in_process, :spawn, :debug] }, :default => :spawn
|
39
42
|
# rubocop:enable Metrics/LineLength
|
40
|
-
option_accessor :main_class, :contract => {
|
43
|
+
option_accessor :main_class, :contract => { Class => Maybe[Class] }, :default => nil
|
41
44
|
# rubocop:disable Metrics/LineLength
|
42
45
|
|
43
46
|
# rubocop:disable Metrics/LineLength
|
@@ -49,6 +52,13 @@ module Aruba
|
|
49
52
|
option_accessor :home_directory, :contract => { Or[Aruba::Contracts::AbsolutePath, Aruba::Contracts::RelativePath] => Or[Aruba::Contracts::AbsolutePath, Aruba::Contracts::RelativePath] }, :default => ENV['HOME']
|
50
53
|
end
|
51
54
|
# rubocop:enable Metrics/LineLength
|
55
|
+
|
56
|
+
# rubocop:disable Metrics/LineLength
|
57
|
+
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
|
58
|
+
# rubocop:enable Metrics/LineLength
|
59
|
+
|
60
|
+
option_accessor :physical_block_size, :contract => { Aruba::Contracts::IsPowerOfTwo => Aruba::Contracts::IsPowerOfTwo }, :default => 512
|
61
|
+
option_accessor :console_history_file, :contract => { String => String }, :default => '~/.aruba_history'
|
52
62
|
end
|
53
63
|
end
|
54
64
|
|
data/lib/aruba/config/jruby.rb
CHANGED
@@ -6,9 +6,12 @@ Aruba.configure do |config|
|
|
6
6
|
next unless RUBY_PLATFORM == 'java'
|
7
7
|
|
8
8
|
# disable JIT since these processes are so short lived
|
9
|
-
ENV['JRUBY_OPTS'] = "-X-C #{ENV['JRUBY_OPTS']}"
|
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'
|
10
13
|
|
11
14
|
# force jRuby to use client JVM for faster startup times
|
12
|
-
ENV['JAVA_OPTS'] = "-d32 #{ENV['JAVA_OPTS']}" if RbConfig::CONFIG['host_os'] =~ /solaris|sunos/i
|
15
|
+
ENV['JAVA_OPTS'] = "-d32 #{ENV['JAVA_OPTS']}" if RbConfig::CONFIG['host_os'] =~ /solaris|sunos/i && !ENV['JAVA_OPTS'].include?('-d32')
|
13
16
|
end
|
14
17
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'irb'
|
2
|
+
|
3
|
+
require 'aruba/api'
|
4
|
+
require 'aruba/console/help'
|
5
|
+
|
6
|
+
module Aruba
|
7
|
+
class Console
|
8
|
+
# rubocop:disable Metrics/MethodLength
|
9
|
+
def start
|
10
|
+
# Start IRB with current context:
|
11
|
+
# http://stackoverflow.com/questions/4189818/how-to-run-irb-start-in-context-of-current-class
|
12
|
+
ARGV.clear
|
13
|
+
IRB.setup nil
|
14
|
+
|
15
|
+
IRB.conf[:PROMPT] = {}
|
16
|
+
IRB.conf[:IRB_NAME] = 'aruba'
|
17
|
+
IRB.conf[:PROMPT][:ARUBA] = {
|
18
|
+
:PROMPT_I => '%N:%03n:%i> ',
|
19
|
+
:PROMPT_N => '%N:%03n:%i> ',
|
20
|
+
:PROMPT_S => '%N:%03n:%i%l ',
|
21
|
+
:PROMPT_C => '%N:%03n:%i* ',
|
22
|
+
:RETURN => "# => %s\n"
|
23
|
+
}
|
24
|
+
IRB.conf[:PROMPT_MODE] = :ARUBA
|
25
|
+
|
26
|
+
IRB.conf[:RC] = false
|
27
|
+
|
28
|
+
require 'irb/completion'
|
29
|
+
require 'irb/ext/save-history'
|
30
|
+
IRB.conf[:READLINE] = true
|
31
|
+
IRB.conf[:SAVE_HISTORY] = 1000
|
32
|
+
IRB.conf[:HISTORY_FILE] = Aruba.config.console_history_file
|
33
|
+
|
34
|
+
# rubocop:disable Lint/NestedMethodDefinition
|
35
|
+
context = Class.new do
|
36
|
+
include Aruba::Api
|
37
|
+
include Aruba::Console::Help
|
38
|
+
|
39
|
+
def initialize
|
40
|
+
setup_aruba
|
41
|
+
end
|
42
|
+
|
43
|
+
def inspect
|
44
|
+
'nil'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
# rubocop:enable Lint/NestedMethodDefinition
|
48
|
+
|
49
|
+
irb = IRB::Irb.new(IRB::WorkSpace.new(context.new))
|
50
|
+
IRB.conf[:MAIN_CONTEXT] = irb.context
|
51
|
+
|
52
|
+
trap("SIGINT") do
|
53
|
+
IRB.irb.signal_handle
|
54
|
+
end
|
55
|
+
|
56
|
+
begin
|
57
|
+
catch(:IRB_EXIT) do
|
58
|
+
irb.eval_input
|
59
|
+
end
|
60
|
+
ensure
|
61
|
+
IRB.irb_at_exit
|
62
|
+
end
|
63
|
+
end
|
64
|
+
# rubocop:enable Metrics/MethodLength
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'aruba/api'
|
2
|
+
|
3
|
+
module Aruba
|
4
|
+
class Console
|
5
|
+
# Helpers for Aruba::Console
|
6
|
+
module Help
|
7
|
+
# Output help information
|
8
|
+
def aruba_help
|
9
|
+
puts 'Aruba Version: ' + Aruba::VERSION
|
10
|
+
puts 'Issue Tracker: ' + 'https://github.com/cucumber/aruba/issues'
|
11
|
+
puts "Documentation:\n" + %w(http://www.rubydoc.info/gems/aruba).map { |d| format('* %s', d) }.join("\n")
|
12
|
+
puts
|
13
|
+
|
14
|
+
nil
|
15
|
+
end
|
16
|
+
|
17
|
+
# List available methods in aruba
|
18
|
+
def aruba_methods
|
19
|
+
ms = if RUBY_VERSION < '1.9'
|
20
|
+
# rubocop:disable Style/EachWithObject
|
21
|
+
(Aruba::Api.instance_methods - Module.instance_methods).inject([]) { |a, e| a << format("* %s", e); a }.sort
|
22
|
+
# rubocop:enable Style/EachWithObject
|
23
|
+
else
|
24
|
+
(Aruba::Api.instance_methods - Module.instance_methods).each_with_object([]) { |e, a| a << format("* %s", e) }.sort
|
25
|
+
end
|
26
|
+
|
27
|
+
puts "Available Methods:\n" + ms.join("\n")
|
28
|
+
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|