calabash 2.0.0.pre10 → 2.0.0.pre11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -17
- data/bin/calabash +3 -4
- data/lib/calabash.rb +53 -10
- data/lib/calabash/android.rb +89 -28
- data/lib/calabash/android/adb.rb +32 -20
- data/lib/calabash/android/application.rb +1 -1
- data/lib/calabash/android/build/builder.rb +1 -1
- data/lib/calabash/android/build/java_keystore.rb +1 -1
- data/lib/calabash/android/build/resigner.rb +1 -1
- data/lib/calabash/android/device.rb +22 -66
- data/lib/calabash/android/device/helper_application.rb +95 -0
- data/lib/calabash/android/environment.rb +14 -1
- data/lib/calabash/android/gestures.rb +6 -22
- data/lib/calabash/android/interactions.rb +14 -17
- data/lib/calabash/android/lib/.irbrc +9 -1
- data/lib/calabash/android/lib/AndroidManifest.xml +23 -2
- data/lib/calabash/android/lib/HelperApplication.apk +0 -0
- data/lib/calabash/android/lib/HelperApplicationTestServer.apk +0 -0
- data/lib/calabash/android/lib/TestServer.apk +0 -0
- data/lib/calabash/android/life_cycle.rb +3 -3
- data/lib/calabash/android/orientation.rb +8 -8
- data/lib/calabash/android/physical_buttons.rb +19 -16
- data/lib/calabash/android/server.rb +1 -1
- data/lib/calabash/android/text.rb +12 -12
- data/lib/calabash/android/web.rb +12 -0
- data/lib/calabash/application.rb +3 -0
- data/lib/calabash/cli/generate.rb +8 -18
- data/lib/calabash/cli/helpers.rb +4 -9
- data/lib/calabash/cli/run.rb +1 -1
- data/lib/calabash/console_helpers.rb +179 -11
- data/lib/calabash/device.rb +4 -19
- data/lib/calabash/gestures.rb +292 -198
- data/lib/calabash/interactions.rb +3 -40
- data/lib/calabash/internal.rb +48 -0
- data/lib/calabash/ios.rb +76 -16
- data/lib/calabash/ios/automator.rb +9 -0
- data/lib/calabash/ios/automator/automator.rb +217 -0
- data/lib/calabash/ios/automator/coordinates.rb +37 -0
- data/lib/calabash/ios/automator/device_agent.rb +379 -0
- data/lib/calabash/ios/conditions.rb +1 -1
- data/lib/calabash/ios/console_helpers.rb +2 -2
- data/lib/calabash/ios/date_picker.rb +10 -8
- data/lib/calabash/ios/device.rb +0 -1
- data/lib/calabash/ios/device/device_implementation.rb +9 -21
- data/lib/calabash/ios/device/gestures_mixin.rb +53 -55
- data/lib/calabash/ios/device/keyboard_mixin.rb +21 -0
- data/lib/calabash/ios/device/rotation_mixin.rb +3 -65
- data/lib/calabash/ios/gestures.rb +24 -90
- data/lib/calabash/ios/interactions.rb +1 -6
- data/lib/calabash/ios/lib/.irbrc +9 -2
- data/lib/calabash/ios/orientation.rb +8 -8
- data/lib/calabash/ios/runtime.rb +14 -14
- data/lib/calabash/ios/scroll.rb +25 -17
- data/lib/calabash/ios/slider.rb +11 -18
- data/lib/calabash/ios/text.rb +20 -74
- data/lib/calabash/ios/uia.rb +1 -1
- data/lib/calabash/ios/web.rb +10 -0
- data/lib/calabash/lib/skeleton/{Gemfile → Gemfile.skeleton} +0 -0
- data/lib/calabash/lib/skeleton/config/{cucumber.yml → cucumber.yml.skeleton} +0 -0
- data/lib/calabash/lib/skeleton/features/{sample.feature → sample.feature.skeleton} +0 -0
- data/lib/calabash/lib/skeleton/features/step_definitions/{calabash_steps.rb → sample_steps.rb.skeleton} +8 -8
- data/lib/calabash/lib/skeleton/features/support/{dry_run.rb → dry_run.rb.skeleton} +2 -5
- data/lib/calabash/lib/skeleton/features/support/{env.rb → env.rb.skeleton} +2 -8
- data/lib/calabash/lib/skeleton/features/support/hooks.rb.skeleton +34 -0
- data/lib/calabash/life_cycle.rb +16 -8
- data/lib/calabash/location.rb +14 -15
- data/lib/calabash/orientation.rb +8 -8
- data/lib/calabash/page.rb +1 -4
- data/lib/calabash/retry.rb +33 -0
- data/lib/calabash/screenshot.rb +3 -3
- data/lib/calabash/stubs.rb +21 -0
- data/lib/calabash/text.rb +31 -19
- data/lib/calabash/utility.rb +41 -8
- data/lib/calabash/version.rb +1 -1
- data/lib/calabash/wait.rb +177 -192
- data/lib/calabash/web.rb +44 -0
- metadata +39 -32
- data/lib/calabash/ios/device/text_mixin.rb +0 -21
- data/lib/calabash/lib/skeleton/features/support/hooks.rb +0 -83
Binary file
|
Binary file
|
Binary file
|
@@ -21,19 +21,19 @@ module Calabash
|
|
21
21
|
raise 'No application given, and Application.default is not set'
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
Calabash::Internal.with_default_device(required_os: :android) {|device| device.resume_app(path_or_application)}
|
25
25
|
|
26
26
|
true
|
27
27
|
end
|
28
28
|
|
29
29
|
# @!visibility private
|
30
|
-
|
30
|
+
define_method(:_send_current_app_to_background) do |for_seconds|
|
31
31
|
package = focused_package
|
32
32
|
activity = focused_activity
|
33
33
|
|
34
34
|
go_home
|
35
35
|
sleep(for_seconds)
|
36
|
-
|
36
|
+
Calabash::Internal.with_default_device(required_os: :android) {|device| device.resume_activity(package, activity)}
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -3,28 +3,28 @@ module Calabash
|
|
3
3
|
# @!visibility private
|
4
4
|
module Orientation
|
5
5
|
# @!visibility private
|
6
|
-
|
7
|
-
|
6
|
+
define_method(:_set_orientation_landscape) do
|
7
|
+
Calabash::Internal.with_default_device(required_os: :android) {|device| device.perform_action('set_activity_orientation', 'landscape')}
|
8
8
|
end
|
9
9
|
|
10
10
|
# @!visibility private
|
11
|
-
|
12
|
-
|
11
|
+
define_method(:_set_orientation_portrait) do
|
12
|
+
Calabash::Internal.with_default_device(required_os: :android) {|device| device.perform_action('set_activity_orientation', 'portrait')}
|
13
13
|
end
|
14
14
|
|
15
15
|
# @!visibility private
|
16
|
-
|
16
|
+
define_method(:_portrait?) do
|
17
17
|
_orientation == 'portrait'
|
18
18
|
end
|
19
19
|
|
20
20
|
# @!visibility private
|
21
|
-
|
21
|
+
define_method(:_landscape?) do
|
22
22
|
_orientation == 'landscape'
|
23
23
|
end
|
24
24
|
|
25
25
|
# @!visibility private
|
26
|
-
|
27
|
-
|
26
|
+
define_method(:_orientation) do
|
27
|
+
Calabash::Internal.with_default_device(required_os: :android) {|device| device.perform_action('get_activity_orientation')['message']}
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -8,44 +8,47 @@ module Calabash
|
|
8
8
|
module PhysicalButtons
|
9
9
|
|
10
10
|
# @!visibility private
|
11
|
-
def
|
12
|
-
|
11
|
+
def press_physical_button(key)
|
12
|
+
Calabash::Internal.with_default_device(required_os: :android) do |device|
|
13
|
+
device.perform_action('press_physical_key', key)
|
14
|
+
end
|
15
|
+
|
13
16
|
true
|
14
17
|
end
|
15
18
|
|
16
19
|
# @!visibility private
|
17
|
-
def
|
18
|
-
|
20
|
+
def press_physical_back_button
|
21
|
+
press_physical_button('KEYCODE_BACK')
|
19
22
|
end
|
20
23
|
|
21
24
|
# @!visibility private
|
22
|
-
def
|
23
|
-
|
25
|
+
def press_physical_menu_button
|
26
|
+
press_physical_button('KEYCODE_MENU')
|
24
27
|
end
|
25
28
|
|
26
29
|
# @!visibility private
|
27
|
-
def
|
28
|
-
|
30
|
+
def press_physical_down_button
|
31
|
+
press_physical_button('KEYCODE_DPAD_DOWN')
|
29
32
|
end
|
30
33
|
|
31
34
|
# @!visibility private
|
32
|
-
def
|
33
|
-
|
35
|
+
def press_physical_up_button
|
36
|
+
press_physical_button('KEYCODE_DPAD_UP')
|
34
37
|
end
|
35
38
|
|
36
39
|
# @!visibility private
|
37
|
-
def
|
38
|
-
|
40
|
+
def press_physical_left_button
|
41
|
+
press_physical_button('KEYCODE_DPAD_LEFT')
|
39
42
|
end
|
40
43
|
|
41
44
|
# @!visibility private
|
42
|
-
def
|
43
|
-
|
45
|
+
def press_physical_right_button
|
46
|
+
press_physical_button('KEYCODE_DPAD_RIGHT')
|
44
47
|
end
|
45
48
|
|
46
49
|
# @!visibility private
|
47
|
-
def
|
48
|
-
|
50
|
+
def press_physical_enter_button
|
51
|
+
press_physical_button('KEYCODE_ENTER')
|
49
52
|
end
|
50
53
|
end
|
51
54
|
end
|
@@ -6,46 +6,46 @@ module Calabash
|
|
6
6
|
# pressing the back button if the keyboard is showing. If the keyboard is
|
7
7
|
# already hidden/dismissed, nothing is done.
|
8
8
|
def dismiss_keyboard
|
9
|
-
|
9
|
+
Calabash::Internal.with_default_device(required_os: :android) {|device| device.perform_action('hide_soft_keyboard')}
|
10
10
|
sleep 0.5
|
11
11
|
end
|
12
12
|
|
13
13
|
# @!visibility private
|
14
|
-
|
15
|
-
|
14
|
+
define_method(:_clear_text) do
|
15
|
+
Calabash::Internal.with_default_device(required_os: :android) {|device| device.perform_action('clear_text')}
|
16
16
|
end
|
17
17
|
|
18
18
|
# @!visibility private
|
19
|
-
|
19
|
+
define_method(:_clear_text_in) do |view|
|
20
20
|
tap(view)
|
21
21
|
sleep 0.5
|
22
22
|
clear_text
|
23
23
|
end
|
24
24
|
|
25
25
|
# @!visibility private
|
26
|
-
|
27
|
-
|
26
|
+
define_method(:_enter_text) do |text|
|
27
|
+
Calabash::Internal.with_default_device(required_os: :android) {|device| device.enter_text(text)}
|
28
28
|
end
|
29
29
|
|
30
30
|
# @!visibility private
|
31
|
-
|
31
|
+
define_method(:_enter_text_in) do |view, text|
|
32
32
|
tap(view)
|
33
33
|
sleep 0.5
|
34
34
|
enter_text(text)
|
35
35
|
end
|
36
36
|
|
37
37
|
# @!visibility private
|
38
|
-
|
38
|
+
define_method(:_tap_keyboard_action_key) do |action_key|
|
39
39
|
if action_key.nil?
|
40
|
-
|
40
|
+
Calabash::Internal.with_default_device(required_os: :android) {|device| device.perform_action('press_user_action_button')}
|
41
41
|
else
|
42
|
-
|
42
|
+
Calabash::Internal.with_default_device(required_os: :android) {|device| device.perform_action('press_user_action_button', action_key.to_s)}
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
# @!visibility private
|
47
|
-
|
48
|
-
|
47
|
+
define_method(:_keyboard_visible?) do
|
48
|
+
Calabash::Internal.with_default_device(required_os: :android) {|device| device.keyboard_visible?}
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Calabash
|
2
|
+
module Android
|
3
|
+
module Web
|
4
|
+
# @!visibility private
|
5
|
+
define_method(:_evaluate_javascript_in) do |query, javascript|
|
6
|
+
Calabash::Internal.with_default_device(required_os: :android) do |device|
|
7
|
+
device.evaluate_javascript_in(query, javascript)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/calabash/application.rb
CHANGED
@@ -17,24 +17,14 @@ module Calabash
|
|
17
17
|
exit 1
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
reset_method = :clear
|
20
|
+
cucumber_config = File.read(file(File.join('config', 'cucumber.yml.skeleton')))
|
22
21
|
|
23
|
-
|
22
|
+
env = File.read(file(File.join('features', 'support', 'env.rb.skeleton')))
|
23
|
+
dry_run = File.read(file(File.join('features', 'support', 'dry_run.rb.skeleton')))
|
24
|
+
sample_feature = File.read(file(File.join('features', 'sample.feature.skeleton')))
|
25
|
+
calabash_steps = File.read(file(File.join('features', 'step_definitions', 'sample_steps.rb.skeleton')))
|
24
26
|
|
25
|
-
|
26
|
-
dry_run = File.read(file(File.join('features', 'support', 'dry_run.rb')))
|
27
|
-
sample_feature = File.read(file(File.join('features', 'sample.feature')))
|
28
|
-
calabash_steps = File.read(file(File.join('features', 'step_definitions', 'calabash_steps.rb')))
|
29
|
-
|
30
|
-
hooks = File.read(file(File.join('features', 'support', 'hooks.rb')))
|
31
|
-
hooks.sub!("#!DEFAULT_RESET_BETWEEN#!", ":#{reset_between}")
|
32
|
-
|
33
|
-
if reset_method.nil?
|
34
|
-
hooks.sub!("#!DEFAULT_RESET_METHOD#!", 'nil')
|
35
|
-
else
|
36
|
-
hooks.sub!("#!DEFAULT_RESET_METHOD#!", ":#{reset_method}")
|
37
|
-
end
|
27
|
+
hooks = File.read(file(File.join('features', 'support', 'hooks.rb.skeleton')))
|
38
28
|
|
39
29
|
FileUtils.mkdir('config')
|
40
30
|
|
@@ -45,12 +35,12 @@ module Calabash
|
|
45
35
|
FileUtils.mkdir('features/support')
|
46
36
|
|
47
37
|
File.open(File.join('features', 'sample.feature'), 'w') {|file| file.write(sample_feature) }
|
48
|
-
File.open(File.join('features', 'step_definitions', '
|
38
|
+
File.open(File.join('features', 'step_definitions', 'sample_steps.rb'), 'w') {|file| file.write(calabash_steps) }
|
49
39
|
File.open(File.join('features', 'support', 'hooks.rb'), 'w') {|file| file.write(hooks) }
|
50
40
|
File.open(File.join('features', 'support', 'env.rb'), 'w') {|file| file.write(env) }
|
51
41
|
File.open(File.join('features', 'support', 'dry_run.rb'), 'w') {|file| file.write(dry_run) }
|
52
42
|
|
53
|
-
gemfile = File.readlines(file(File.join('Gemfile')))
|
43
|
+
gemfile = File.readlines(file(File.join('Gemfile.skeleton')))
|
54
44
|
|
55
45
|
unless File.exist?('Gemfile')
|
56
46
|
File.open('Gemfile', 'w') do |file|
|
data/lib/calabash/cli/helpers.rb
CHANGED
@@ -6,8 +6,7 @@ module Calabash
|
|
6
6
|
# @!visibility private
|
7
7
|
HELP = {
|
8
8
|
help: 'help',
|
9
|
-
generate
|
10
|
-
run: 'run [application] [cucumber options]',
|
9
|
+
:'generate-cucumber' => 'generate-cucumber',
|
11
10
|
console: 'console [application]',
|
12
11
|
version: 'version',
|
13
12
|
setup_keystore: 'setup-keystore',
|
@@ -35,7 +34,7 @@ EOF
|
|
35
34
|
else
|
36
35
|
output.write <<EOF
|
37
36
|
Usage:
|
38
|
-
calabash [options] #{HELP[key]}
|
37
|
+
#{Calabash::Utility.bundle_exec_prepend}calabash [options] #{HELP[key]}
|
39
38
|
EOF
|
40
39
|
end
|
41
40
|
end
|
@@ -43,18 +42,14 @@ EOF
|
|
43
42
|
# @!visibility private
|
44
43
|
def print_usage(output=STDOUT)
|
45
44
|
output.write <<EOF
|
46
|
-
Usage: calabash [options] <command-name> [command specific options]
|
45
|
+
Usage: #{Calabash::Utility.bundle_exec_prepend}calabash [options] <command-name> [command specific options]
|
47
46
|
<command-name> can be one of
|
48
47
|
#{HELP[:help]} [command]
|
49
48
|
print help information.
|
50
49
|
|
51
|
-
#{HELP[:generate]}
|
50
|
+
#{HELP[:'generate-cucumber']}
|
52
51
|
generate a Cucumber project folder structure.
|
53
52
|
|
54
|
-
#{HELP[:run]}
|
55
|
-
runs Cucumber in the current folder with the environment needed.
|
56
|
-
the cucumber options will be passed unchanged to cucumber
|
57
|
-
|
58
53
|
#{HELP[:console]}
|
59
54
|
starts an interactive console to interact with your app via Calabash
|
60
55
|
|
data/lib/calabash/cli/run.rb
CHANGED
@@ -5,21 +5,99 @@ module Calabash
|
|
5
5
|
# Methods you can use in the Calabash console to help you
|
6
6
|
# interact with your app.
|
7
7
|
module ConsoleHelpers
|
8
|
+
# Reloads all required files that have git changes
|
9
|
+
def reload_git_files
|
10
|
+
files_to_reload =
|
11
|
+
(`cd ../../../ && git status`.lines.grep(/modified/).map{|l| l.split(" ").last.gsub('../', '')} +
|
12
|
+
`cd ../../../ && git ls-files --others --exclude-standard`.lines).map(&:chomp)
|
13
|
+
|
14
|
+
$LOADED_FEATURES.each do |file|
|
15
|
+
files_to_reload.each do |reload_name|
|
16
|
+
if file.end_with?(reload_name)
|
17
|
+
puts "LOADING #{file}"
|
18
|
+
load file
|
19
|
+
break
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
true
|
25
|
+
end
|
26
|
+
|
27
|
+
# Outputs all calabash methods
|
28
|
+
def cal_methods
|
29
|
+
c = Class.new(BasicObject) do
|
30
|
+
include Calabash
|
31
|
+
end
|
32
|
+
|
33
|
+
ConsoleHelpers.puts_unbound_methods(c, 'cal.')
|
34
|
+
true
|
35
|
+
end
|
36
|
+
|
37
|
+
# Outputs a calabash method
|
38
|
+
def cal_method(method)
|
39
|
+
c = Class.new(BasicObject) do
|
40
|
+
include Calabash
|
41
|
+
end
|
42
|
+
|
43
|
+
ConsoleHelpers.puts_unbound_method(c, method.to_sym, 'cal.')
|
44
|
+
true
|
45
|
+
end
|
46
|
+
|
47
|
+
# Outputs all calabash iOS methods
|
48
|
+
def cal_ios_methods
|
49
|
+
c = Class.new(BasicObject) do
|
50
|
+
include Calabash::IOSInternal
|
51
|
+
end
|
52
|
+
|
53
|
+
ConsoleHelpers.puts_unbound_methods(c, 'cal_ios.')
|
54
|
+
true
|
55
|
+
end
|
56
|
+
|
57
|
+
# Outputs a calabash Android method
|
58
|
+
def cal_ios_method(method)
|
59
|
+
c = Class.new(BasicObject) do
|
60
|
+
include Calabash::IOSInternal
|
61
|
+
end
|
62
|
+
|
63
|
+
ConsoleHelpers.puts_unbound_method(c, method.to_sym, 'cal_ios.')
|
64
|
+
true
|
65
|
+
end
|
66
|
+
|
67
|
+
# Outputs all calabash Android methods
|
68
|
+
def cal_android_methods
|
69
|
+
c = Class.new(BasicObject) do
|
70
|
+
include Calabash::AndroidInternal
|
71
|
+
end
|
72
|
+
|
73
|
+
ConsoleHelpers.puts_unbound_methods(c, 'cal_android.')
|
74
|
+
true
|
75
|
+
end
|
76
|
+
|
77
|
+
# Outputs a calabash Android method
|
78
|
+
def cal_android_method(method)
|
79
|
+
c = Class.new(BasicObject) do
|
80
|
+
include Calabash::AndroidInternal
|
81
|
+
end
|
82
|
+
|
83
|
+
ConsoleHelpers.puts_unbound_method(c, method.to_sym, 'cal_android.')
|
84
|
+
true
|
85
|
+
end
|
8
86
|
|
9
87
|
# Outputs all visible elements as a tree.
|
10
88
|
def tree
|
11
|
-
ConsoleHelpers.dump(
|
89
|
+
ConsoleHelpers.dump(Calabash::Internal.with_default_device {|device| device.dump})
|
12
90
|
true
|
13
91
|
end
|
14
92
|
|
15
93
|
# List the visible element classes.
|
16
94
|
def classes
|
17
|
-
query("*").map{|e| e['class']}.uniq
|
95
|
+
cal.query("*").map{|e| e['class']}.uniq
|
18
96
|
end
|
19
97
|
|
20
98
|
# List the visible element ids.
|
21
99
|
def ids
|
22
|
-
query("*").map{|e| e['id']}.compact
|
100
|
+
cal.query("*").map{|e| e['id']}.compact
|
23
101
|
end
|
24
102
|
|
25
103
|
# Copy all the commands entered in the current console session into the OS
|
@@ -92,14 +170,31 @@ module Calabash
|
|
92
170
|
# @!visibility private
|
93
171
|
def puts_console_details
|
94
172
|
puts ''
|
95
|
-
puts
|
96
|
-
puts Color.cyan('>
|
97
|
-
puts Color.cyan('>
|
98
|
-
puts Color.cyan(">
|
99
|
-
puts Color.cyan('>
|
100
|
-
puts Color.cyan('>
|
101
|
-
puts Color.cyan('>
|
102
|
-
puts Color.cyan('>
|
173
|
+
puts '# => Useful Console Methods <= #'
|
174
|
+
puts Color.cyan('> ids => List all the visible ids.')
|
175
|
+
puts Color.cyan('> classes => List all the visible classes.')
|
176
|
+
puts Color.cyan("> tree => The app's visible view hierarchy.")
|
177
|
+
puts Color.cyan('> copy => Copy console commands to the Clipboard.')
|
178
|
+
puts Color.cyan('> clear => Clear the console.')
|
179
|
+
puts Color.cyan('> verbose => Turn debug logging on.')
|
180
|
+
puts Color.cyan('> quiet => Turn debug logging off.')
|
181
|
+
puts Color.cyan('> cal_methods => Print all cross-platform Calabash methods.')
|
182
|
+
puts Color.cyan('> cal_method(method) => Print all information about a Calabash method')
|
183
|
+
|
184
|
+
if defined?(Calabash::AndroidInternal)
|
185
|
+
puts ''
|
186
|
+
puts 'Android specific'
|
187
|
+
puts Color.cyan('> cal_android_methods => Print all Android-specific Calabash methods.')
|
188
|
+
puts Color.cyan('> cal_android_method(method) => Print all information about an Android-specific Calabash method.')
|
189
|
+
end
|
190
|
+
|
191
|
+
if defined?(Calabash::IOSInternal)
|
192
|
+
puts ''
|
193
|
+
puts 'iOS specific'
|
194
|
+
puts Color.cyan('> cal_ios_methods => Print all iOS-specific Calabash methods.')
|
195
|
+
puts Color.cyan('> cal_ios_method(method) => Print all information about an ios-specific Calabash method.')
|
196
|
+
end
|
197
|
+
|
103
198
|
puts ''
|
104
199
|
end
|
105
200
|
|
@@ -191,5 +286,78 @@ module Calabash
|
|
191
286
|
def self.visible?(data)
|
192
287
|
raise AbstractMethodError
|
193
288
|
end
|
289
|
+
|
290
|
+
# @!visibility private
|
291
|
+
def self.puts_unbound_methods(clazz, prefix)
|
292
|
+
(clazz.instance_methods - BasicObject.instance_methods).each do |method_sym|
|
293
|
+
signature,description = method_signature(clazz.instance_method(method_sym))
|
294
|
+
|
295
|
+
puts_method(signature, description, prefix)
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
# @!visibility private
|
300
|
+
def self.puts_unbound_method(clazz, method, prefix)
|
301
|
+
signature,description = method_signature(clazz.instance_method(method), true)
|
302
|
+
|
303
|
+
puts_method(signature, description, prefix)
|
304
|
+
end
|
305
|
+
|
306
|
+
# @!visibility private
|
307
|
+
def self.puts_method(signature, description, prefix)
|
308
|
+
if signature != nil
|
309
|
+
puts Color.yellow(description)
|
310
|
+
puts Color.blue("#{prefix}#{signature}")
|
311
|
+
puts ''
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
# @!visibility private
|
316
|
+
def self.method_signature(method, full_description = false)
|
317
|
+
file_name, line = method.source_location
|
318
|
+
|
319
|
+
file = File.open(file_name, 'r')
|
320
|
+
|
321
|
+
description = nil
|
322
|
+
read_next_lines = false
|
323
|
+
|
324
|
+
(line-1).times do
|
325
|
+
line = file.gets.strip
|
326
|
+
|
327
|
+
if line.start_with?('#')
|
328
|
+
if line.length == 1 || line.start_with?("# @")
|
329
|
+
read_next_lines = false
|
330
|
+
end
|
331
|
+
|
332
|
+
if description.nil?
|
333
|
+
description = line[2..-1]
|
334
|
+
read_next_lines = true
|
335
|
+
elsif read_next_lines || full_description
|
336
|
+
description = "#{description}\n#{line[2..-1]}"
|
337
|
+
end
|
338
|
+
else
|
339
|
+
description = nil
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
signature = file.gets.strip[4..-1]
|
344
|
+
|
345
|
+
method_name = if signature.index('(')
|
346
|
+
signature[0,signature.index('(')]
|
347
|
+
else
|
348
|
+
signature
|
349
|
+
end
|
350
|
+
|
351
|
+
# Remove alias'ed methods
|
352
|
+
if method_name != method.name.to_s
|
353
|
+
signature = nil
|
354
|
+
end
|
355
|
+
|
356
|
+
if description && description.start_with?("@!visibility private")
|
357
|
+
signature = nil
|
358
|
+
end
|
359
|
+
|
360
|
+
[signature,description]
|
361
|
+
end
|
194
362
|
end
|
195
363
|
end
|