Class: Pry
- Inherits:
-
Object
- Object
- Pry
- Defined in:
- lib/pry-syntax-hacks.rb
Defined Under Namespace
Classes: Command
Class Method Summary collapse
Instance Method Summary collapse
- #binding_or_raise(n) ⇒ Object
- #old_retrieve_line ⇒ Object
- #retrieve_line(eval_string, *args) ⇒ Object
Class Method Details
.hack_line(eval_string) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/pry-syntax-hacks.rb', line 9 def self.hack_line(eval_string) eval_string.gsub!(/\.(@[a-z0-9_]+)/, '.instance_variable_get("\1")') eval_string.gsub!(/\.:([a-z0-9_]+[?!]?)/, '.method(:\1)') eval_string.gsub!(/\.!([a-z0-9_]+[?!]?)([ \(])(?=(.*))/) { ".send#{$2}:#{$1}#{$3 == ""?"":","}" } eval_string.gsub!(/(^|[\s\[{>(<=])((\.\.\/)+)([a-z0-9_@]+)/) { "#{$1}_pry_.binding_or_raise(#{-1 - $2.size / 3}).eval('#{$4}')" } eval_string end |
Instance Method Details
#binding_or_raise(n) ⇒ Object
17 18 19 |
# File 'lib/pry-syntax-hacks.rb', line 17 def binding_or_raise(n) binding_stack[n] or raise "no parent binding" end |
#old_retrieve_line ⇒ Object
2 |
# File 'lib/pry-syntax-hacks.rb', line 2 alias_method :old_retrieve_line, :retrieve_line |