pry 0.6.7pre4-i386-mingw32 → 0.6.8-i386-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,202 +1,202 @@
1
- # taken from irb
2
-
3
- require "readline"
4
-
5
- class Pry
6
-
7
- # Implements tab completion for Readline in Pry
8
- module InputCompleter
9
-
10
- if Readline.respond_to?("basic_word_break_characters=")
11
- Readline.basic_word_break_characters= " \t\n\"\\'`><=;|&{("
12
- end
13
-
14
- Readline.completion_append_character = nil
15
-
16
- ReservedWords = [
17
- "BEGIN", "END",
18
- "alias", "and",
19
- "begin", "break",
20
- "case", "class",
21
- "def", "defined", "do",
22
- "else", "elsif", "end", "ensure",
23
- "false", "for",
24
- "if", "in",
25
- "module",
26
- "next", "nil", "not",
27
- "or",
28
- "redo", "rescue", "retry", "return",
29
- "self", "super",
30
- "then", "true",
31
- "undef", "unless", "until",
32
- "when", "while",
33
- "yield",
34
- ]
35
-
36
- Operators = ["%", "&", "*", "**", "+", "-", "/",
37
- "<", "<<", "<=", "<=>", "==", "===", "=~", ">", ">=", ">>",
38
- "[]", "[]=", "^", "!", "!=", "!~"]
39
-
40
- # Return a new completion proc for use by Readline.
41
- # @param [Binding] target The current binding context.
42
- # @param [Array<String>] commands The array of Pry commands.
43
- def self.build_completion_proc(target, commands=[""])
44
- proc do |input|
45
- bind = target
46
-
47
- case input
48
- when /^(\/[^\/]*\/)\.([^.]*)$/
49
- # Regexp
50
- receiver = $1
51
- message = Regexp.quote($2)
52
-
53
- candidates = Regexp.instance_methods.collect{|m| m.to_s}
54
- select_message(receiver, message, candidates)
55
-
56
- when /^([^\]]*\])\.([^.]*)$/
57
- # Array
58
- receiver = $1
59
- message = Regexp.quote($2)
60
-
61
- candidates = Array.instance_methods.collect{|m| m.to_s}
62
- select_message(receiver, message, candidates)
63
-
64
- when /^([^\}]*\})\.([^.]*)$/
65
- # Proc or Hash
66
- receiver = $1
67
- message = Regexp.quote($2)
68
-
69
- candidates = Proc.instance_methods.collect{|m| m.to_s}
70
- candidates |= Hash.instance_methods.collect{|m| m.to_s}
71
- select_message(receiver, message, candidates)
72
-
73
- when /^(:[^:.]*)$/
74
- # Symbol
75
- if Symbol.respond_to?(:all_symbols)
76
- sym = $1
77
- candidates = Symbol.all_symbols.collect{|s| ":" + s.id2name}
78
- candidates.grep(/^#{sym}/)
79
- else
80
- []
81
- end
82
-
83
- when /^::([A-Z][^:\.\(]*)$/
84
- # Absolute Constant or class methods
85
- receiver = $1
86
- candidates = Object.constants.collect{|m| m.to_s}
87
- candidates.grep(/^#{receiver}/).collect{|e| "::" + e}
88
-
89
- when /^([A-Z].*)::([^:.]*)$/
90
- # Constant or class methods
91
- receiver = $1
92
- message = Regexp.quote($2)
93
- begin
94
- candidates = eval("#{receiver}.constants.collect{|m| m.to_s}", bind)
95
- candidates |= eval("#{receiver}.methods.collect{|m| m.to_s}", bind)
96
- rescue Exception
97
- candidates = []
98
- end
99
- candidates.grep(/^#{message}/).collect{|e| receiver + "::" + e}
100
-
101
- when /^(:[^:.]+)\.([^.]*)$/
102
- # Symbol
103
- receiver = $1
104
- message = Regexp.quote($2)
105
-
106
- candidates = Symbol.instance_methods.collect{|m| m.to_s}
107
- select_message(receiver, message, candidates)
108
-
109
- when /^(-?(0[dbo])?[0-9_]+(\.[0-9_]+)?([eE]-?[0-9]+)?)\.([^.]*)$/
110
- # Numeric
111
- receiver = $1
112
- message = Regexp.quote($5)
113
-
114
- begin
115
- candidates = eval(receiver, bind).methods.collect{|m| m.to_s}
116
- rescue Exception
117
- candidates = []
118
- end
119
- select_message(receiver, message, candidates)
120
-
121
- when /^(-?0x[0-9a-fA-F_]+)\.([^.]*)$/
122
- # Numeric(0xFFFF)
123
- receiver = $1
124
- message = Regexp.quote($2)
125
-
126
- begin
127
- candidates = eval(receiver, bind).methods.collect{|m| m.to_s}
128
- rescue Exception
129
- candidates = []
130
- end
131
- select_message(receiver, message, candidates)
132
-
133
- when /^(\$[^.]*)$/
134
- regmessage = Regexp.new(Regexp.quote($1))
135
- candidates = global_variables.collect{|m| m.to_s}.grep(regmessage)
136
-
137
- when /^([^."].*)\.([^.]*)$/
138
- # variable
139
- receiver = $1
140
- message = Regexp.quote($2)
141
-
142
- gv = eval("global_variables", bind).collect{|m| m.to_s}
143
- lv = eval("local_variables", bind).collect{|m| m.to_s}
144
- cv = eval("self.class.constants", bind).collect{|m| m.to_s}
145
-
146
- if (gv | lv | cv).include?(receiver) or /^[A-Z]/ =~ receiver && /\./ !~ receiver
147
- # foo.func and foo is local var. OR
148
- # Foo::Bar.func
149
- begin
150
- candidates = eval("#{receiver}.methods", bind).collect{|m| m.to_s}
151
- rescue Exception
152
- candidates = []
153
- end
154
- else
155
- # func1.func2
156
- candidates = []
157
- ObjectSpace.each_object(Module){|m|
158
- begin
159
- name = m.name
160
- rescue Exception
161
- name = ""
162
- end
163
- next if name != "IRB::Context" and
164
- /^(IRB|SLex|RubyLex|RubyToken)/ =~ name
165
- candidates.concat m.instance_methods(false).collect{|x| x.to_s}
166
- }
167
- candidates.sort!
168
- candidates.uniq!
169
- end
170
- select_message(receiver, message, candidates)
171
-
172
- when /^\.([^.]*)$/
173
- # unknown(maybe String)
174
-
175
- receiver = ""
176
- message = Regexp.quote($1)
177
-
178
- candidates = String.instance_methods(true).collect{|m| m.to_s}
179
- select_message(receiver, message, candidates)
180
-
181
- else
182
- candidates = eval("methods | private_methods | local_variables | self.class.constants", bind).collect{|m| m.to_s}
183
-
184
- (candidates|ReservedWords|commands).grep(/^#{Regexp.quote(input)}/)
185
- end
186
- end
187
- end
188
-
189
- def self.select_message(receiver, message, candidates)
190
- candidates.grep(/^#{message}/).collect do |e|
191
- case e
192
- when /^[a-zA-Z_]/
193
- receiver + "." + e
194
- when /^[0-9]/
195
- when *Operators
196
- #receiver + " " + e
197
- end
198
- end
199
- end
200
- end
201
- end
202
-
1
+ # taken from irb
2
+
3
+ require "readline"
4
+
5
+ class Pry
6
+
7
+ # Implements tab completion for Readline in Pry
8
+ module InputCompleter
9
+
10
+ if Readline.respond_to?("basic_word_break_characters=")
11
+ Readline.basic_word_break_characters= " \t\n\"\\'`><=;|&{("
12
+ end
13
+
14
+ Readline.completion_append_character = nil
15
+
16
+ ReservedWords = [
17
+ "BEGIN", "END",
18
+ "alias", "and",
19
+ "begin", "break",
20
+ "case", "class",
21
+ "def", "defined", "do",
22
+ "else", "elsif", "end", "ensure",
23
+ "false", "for",
24
+ "if", "in",
25
+ "module",
26
+ "next", "nil", "not",
27
+ "or",
28
+ "redo", "rescue", "retry", "return",
29
+ "self", "super",
30
+ "then", "true",
31
+ "undef", "unless", "until",
32
+ "when", "while",
33
+ "yield",
34
+ ]
35
+
36
+ Operators = ["%", "&", "*", "**", "+", "-", "/",
37
+ "<", "<<", "<=", "<=>", "==", "===", "=~", ">", ">=", ">>",
38
+ "[]", "[]=", "^", "!", "!=", "!~"]
39
+
40
+ # Return a new completion proc for use by Readline.
41
+ # @param [Binding] target The current binding context.
42
+ # @param [Array<String>] commands The array of Pry commands.
43
+ def self.build_completion_proc(target, commands=[""])
44
+ proc do |input|
45
+ bind = target
46
+
47
+ case input
48
+ when /^(\/[^\/]*\/)\.([^.]*)$/
49
+ # Regexp
50
+ receiver = $1
51
+ message = Regexp.quote($2)
52
+
53
+ candidates = Regexp.instance_methods.collect{|m| m.to_s}
54
+ select_message(receiver, message, candidates)
55
+
56
+ when /^([^\]]*\])\.([^.]*)$/
57
+ # Array
58
+ receiver = $1
59
+ message = Regexp.quote($2)
60
+
61
+ candidates = Array.instance_methods.collect{|m| m.to_s}
62
+ select_message(receiver, message, candidates)
63
+
64
+ when /^([^\}]*\})\.([^.]*)$/
65
+ # Proc or Hash
66
+ receiver = $1
67
+ message = Regexp.quote($2)
68
+
69
+ candidates = Proc.instance_methods.collect{|m| m.to_s}
70
+ candidates |= Hash.instance_methods.collect{|m| m.to_s}
71
+ select_message(receiver, message, candidates)
72
+
73
+ when /^(:[^:.]*)$/
74
+ # Symbol
75
+ if Symbol.respond_to?(:all_symbols)
76
+ sym = $1
77
+ candidates = Symbol.all_symbols.collect{|s| ":" + s.id2name}
78
+ candidates.grep(/^#{sym}/)
79
+ else
80
+ []
81
+ end
82
+
83
+ when /^::([A-Z][^:\.\(]*)$/
84
+ # Absolute Constant or class methods
85
+ receiver = $1
86
+ candidates = Object.constants.collect{|m| m.to_s}
87
+ candidates.grep(/^#{receiver}/).collect{|e| "::" + e}
88
+
89
+ when /^([A-Z].*)::([^:.]*)$/
90
+ # Constant or class methods
91
+ receiver = $1
92
+ message = Regexp.quote($2)
93
+ begin
94
+ candidates = eval("#{receiver}.constants.collect{|m| m.to_s}", bind)
95
+ candidates |= eval("#{receiver}.methods.collect{|m| m.to_s}", bind)
96
+ rescue Exception
97
+ candidates = []
98
+ end
99
+ candidates.grep(/^#{message}/).collect{|e| receiver + "::" + e}
100
+
101
+ when /^(:[^:.]+)\.([^.]*)$/
102
+ # Symbol
103
+ receiver = $1
104
+ message = Regexp.quote($2)
105
+
106
+ candidates = Symbol.instance_methods.collect{|m| m.to_s}
107
+ select_message(receiver, message, candidates)
108
+
109
+ when /^(-?(0[dbo])?[0-9_]+(\.[0-9_]+)?([eE]-?[0-9]+)?)\.([^.]*)$/
110
+ # Numeric
111
+ receiver = $1
112
+ message = Regexp.quote($5)
113
+
114
+ begin
115
+ candidates = eval(receiver, bind).methods.collect{|m| m.to_s}
116
+ rescue Exception
117
+ candidates = []
118
+ end
119
+ select_message(receiver, message, candidates)
120
+
121
+ when /^(-?0x[0-9a-fA-F_]+)\.([^.]*)$/
122
+ # Numeric(0xFFFF)
123
+ receiver = $1
124
+ message = Regexp.quote($2)
125
+
126
+ begin
127
+ candidates = eval(receiver, bind).methods.collect{|m| m.to_s}
128
+ rescue Exception
129
+ candidates = []
130
+ end
131
+ select_message(receiver, message, candidates)
132
+
133
+ when /^(\$[^.]*)$/
134
+ regmessage = Regexp.new(Regexp.quote($1))
135
+ candidates = global_variables.collect{|m| m.to_s}.grep(regmessage)
136
+
137
+ when /^([^."].*)\.([^.]*)$/
138
+ # variable
139
+ receiver = $1
140
+ message = Regexp.quote($2)
141
+
142
+ gv = eval("global_variables", bind).collect{|m| m.to_s}
143
+ lv = eval("local_variables", bind).collect{|m| m.to_s}
144
+ cv = eval("self.class.constants", bind).collect{|m| m.to_s}
145
+
146
+ if (gv | lv | cv).include?(receiver) or /^[A-Z]/ =~ receiver && /\./ !~ receiver
147
+ # foo.func and foo is local var. OR
148
+ # Foo::Bar.func
149
+ begin
150
+ candidates = eval("#{receiver}.methods", bind).collect{|m| m.to_s}
151
+ rescue Exception
152
+ candidates = []
153
+ end
154
+ else
155
+ # func1.func2
156
+ candidates = []
157
+ ObjectSpace.each_object(Module){|m|
158
+ begin
159
+ name = m.name
160
+ rescue Exception
161
+ name = ""
162
+ end
163
+ next if name != "IRB::Context" and
164
+ /^(IRB|SLex|RubyLex|RubyToken)/ =~ name
165
+ candidates.concat m.instance_methods(false).collect{|x| x.to_s}
166
+ }
167
+ candidates.sort!
168
+ candidates.uniq!
169
+ end
170
+ select_message(receiver, message, candidates)
171
+
172
+ when /^\.([^.]*)$/
173
+ # unknown(maybe String)
174
+
175
+ receiver = ""
176
+ message = Regexp.quote($1)
177
+
178
+ candidates = String.instance_methods(true).collect{|m| m.to_s}
179
+ select_message(receiver, message, candidates)
180
+
181
+ else
182
+ candidates = eval("methods | private_methods | local_variables | self.class.constants", bind).collect{|m| m.to_s}
183
+
184
+ (candidates|ReservedWords|commands).grep(/^#{Regexp.quote(input)}/)
185
+ end
186
+ end
187
+ end
188
+
189
+ def self.select_message(receiver, message, candidates)
190
+ candidates.grep(/^#{message}/).collect do |e|
191
+ case e
192
+ when /^[a-zA-Z_]/
193
+ receiver + "." + e
194
+ when /^[0-9]/
195
+ when *Operators
196
+ #receiver + " " + e
197
+ end
198
+ end
199
+ end
200
+ end
201
+ end
202
+
@@ -1,55 +1,55 @@
1
- class Pry
2
- module ObjectExtensions
3
-
4
- # Start a Pry REPL.
5
- # This method differs from `Pry.start` in that it does not
6
- # support an options hash. Also, when no parameter is provided, the Pry
7
- # session will start on the implied receiver rather than on
8
- # top-level (as in the case of `Pry.start`).
9
- # It has two forms of invocation. In the first form no parameter
10
- # should be provided and it will start a pry session on the
11
- # receiver. In the second form it should be invoked without an
12
- # explicit receiver and one parameter; this will start a Pry
13
- # session on the parameter.
14
- # @param [Object, Binding] target The receiver of the Pry session.
15
- # @example First form
16
- # "dummy".pry
17
- # @example Second form
18
- # pry "dummy"
19
- # @example Start a Pry session on current self (whatever that is)
20
- # pry
21
- def pry(target=self)
22
- Pry.start(target)
23
- end
24
-
25
- # Return a binding object for the receiver.
26
- def __binding__
27
- if is_a?(Module)
28
- return class_eval "binding"
29
- end
30
-
31
- unless respond_to? :__binding_impl__
32
- begin
33
- instance_eval %{
34
- def __binding_impl__
35
- binding
36
- end
37
- }
38
- rescue TypeError
39
- self.class.class_eval %{
40
- def __binding_impl__
41
- binding
42
- end
43
- }
44
- end
45
- end
46
-
47
- __binding_impl__
48
- end
49
- end
50
- end
51
-
52
- # bring the extensions into Object
53
- class Object
54
- include Pry::ObjectExtensions
55
- end
1
+ class Pry
2
+ module ObjectExtensions
3
+
4
+ # Start a Pry REPL.
5
+ # This method differs from `Pry.start` in that it does not
6
+ # support an options hash. Also, when no parameter is provided, the Pry
7
+ # session will start on the implied receiver rather than on
8
+ # top-level (as in the case of `Pry.start`).
9
+ # It has two forms of invocation. In the first form no parameter
10
+ # should be provided and it will start a pry session on the
11
+ # receiver. In the second form it should be invoked without an
12
+ # explicit receiver and one parameter; this will start a Pry
13
+ # session on the parameter.
14
+ # @param [Object, Binding] target The receiver of the Pry session.
15
+ # @example First form
16
+ # "dummy".pry
17
+ # @example Second form
18
+ # pry "dummy"
19
+ # @example Start a Pry session on current self (whatever that is)
20
+ # pry
21
+ def pry(target=self)
22
+ Pry.start(target)
23
+ end
24
+
25
+ # Return a binding object for the receiver.
26
+ def __binding__
27
+ if is_a?(Module)
28
+ return class_eval "binding"
29
+ end
30
+
31
+ unless respond_to? :__binding_impl__
32
+ begin
33
+ instance_eval %{
34
+ def __binding_impl__
35
+ binding
36
+ end
37
+ }
38
+ rescue TypeError
39
+ self.class.class_eval %{
40
+ def __binding_impl__
41
+ binding
42
+ end
43
+ }
44
+ end
45
+ end
46
+
47
+ __binding_impl__
48
+ end
49
+ end
50
+ end
51
+
52
+ # bring the extensions into Object
53
+ class Object
54
+ include Pry::ObjectExtensions
55
+ end