pry-syntax-hacks 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.MIT +19 -0
- data/README.markdown +38 -0
- data/lib/pry-syntax-hacks.rb +11 -0
- metadata +82 -0
data/LICENSE.MIT
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2011 Conrad Irwin <conrad.irwin@gmail.com>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Introduction
|
2
|
+
Pry Syntax Hacks adds a few short-hands to help when exploring ruby objects.
|
3
|
+
|
4
|
+
The word "hack" is in the name of the gem deliberately — using this will almost certainly bite you
|
5
|
+
in unexpected ways.
|
6
|
+
|
7
|
+
# Features
|
8
|
+
|
9
|
+
Accessing instance variables:
|
10
|
+
|
11
|
+
pry (main)> User.new.@secret_password
|
12
|
+
=> "lollercoaster"
|
13
|
+
|
14
|
+
Calling private methods:
|
15
|
+
|
16
|
+
pry (main)> User.new.!hash_password("foo")
|
17
|
+
=> "a4721n"
|
18
|
+
|
19
|
+
Accessing method objects:
|
20
|
+
|
21
|
+
pry (main)> ["foo@bar.com"].map &User.:find_by_email
|
22
|
+
|
23
|
+
# Issues
|
24
|
+
|
25
|
+
This will break regular expressions most often:
|
26
|
+
|
27
|
+
pry (main)> Users.all.map(&:email).grep /...@foo.com/
|
28
|
+
|
29
|
+
will still get rewritten to:
|
30
|
+
|
31
|
+
pry (main)> Users.all.map(&:email).grep /..instance_variable_get('@foo').com/
|
32
|
+
|
33
|
+
which is probably not what you want.
|
34
|
+
|
35
|
+
# Meta-foo
|
36
|
+
|
37
|
+
Licensed under the MIT license. Contributions welcome.
|
38
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class Pry
|
2
|
+
alias_method :old_retrieve_line, :retrieve_line
|
3
|
+
|
4
|
+
def retrieve_line(*args)
|
5
|
+
val = old_retrieve_line(*args)
|
6
|
+
|
7
|
+
val.gsub(/\.(@[a-z0-9_]+)/, '.instance_variable_get("\1")').
|
8
|
+
gsub(/\.:([a-z0-9_]+[?!]?)/, '.method(:\1)').
|
9
|
+
gsub(/\.!([a-z0-9_]+[?!]?)([ \(])(?=(.*))/) { ".send#{$2}:#{$1}#{$3 == ""?"":","}".tap &method(:puts) }
|
10
|
+
end
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pry-syntax-hacks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Conrad Irwin
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-10-01 00:00:00 -07:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: pry
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description: Allows you to do object.@instance_var, or object.!private_method(:args), or foo.map &object.:method_name
|
36
|
+
email: conrad.irwin@gmail.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files: []
|
42
|
+
|
43
|
+
files:
|
44
|
+
- lib/pry-syntax-hacks.rb
|
45
|
+
- README.markdown
|
46
|
+
- LICENSE.MIT
|
47
|
+
has_rdoc: true
|
48
|
+
homepage: http://github.com/ConradIrwin/pry-syntax-hacks
|
49
|
+
licenses: []
|
50
|
+
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
requirements: []
|
75
|
+
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 1.6.2
|
78
|
+
signing_key:
|
79
|
+
specification_version: 3
|
80
|
+
summary: Allows various short-cuts that make exploring Ruby objects nicer
|
81
|
+
test_files: []
|
82
|
+
|