subl 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/LICENSE.txt +13 -0
- data/README.md +13 -20
- data/lib/subl/command.rb +16 -8
- data/lib/subl/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ecb50de04626795261924f898604fade14e3641
|
4
|
+
data.tar.gz: 511920c22c8ebc25657183256c4b34f9b9e810d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3600c272b3b43a61ac1e7d1bb84b5994e23b7f4feb37bee44d7d75ba93ea75d7b576d737942c99e1ecd046e0d666fa812df1c2dfbbd7e2b9c284b3dc9ea8d0fc
|
7
|
+
data.tar.gz: da93eacdb572456c4e142c53bab9f1a0b39a577b7675f572ab778aeb874fc60a97f0f7ef7a6299998955b89c7cac8080c33cb69d5220a4cb65e27f5ca58475a1
|
data/.gitignore
CHANGED
data/LICENSE.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
2
|
+
Version 2, December 2004
|
3
|
+
|
4
|
+
Copyright (C) 2014 Johannes Opper <johannes.opper@gmail.com>
|
5
|
+
|
6
|
+
Everyone is permitted to copy and distribute verbatim or modified
|
7
|
+
copies of this license document, and changing it is allowed as long
|
8
|
+
as the name is changed.
|
9
|
+
|
10
|
+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
11
|
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
12
|
+
|
13
|
+
0. You just DO WHAT THE FUCK YOU WANT TO.
|
data/README.md
CHANGED
@@ -1,28 +1,22 @@
|
|
1
1
|
# Subl
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
Provides `subl` command within `irb` or `pry`.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
|
-
Add
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'subl'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install subl
|
7
|
+
Add `require 'subl'` to your `~/.irbrc` or `~/.pryrc`.
|
22
8
|
|
23
9
|
## Usage
|
24
10
|
|
25
|
-
|
11
|
+
```ruby
|
12
|
+
subl '/path/to/file' # => open the given file path
|
13
|
+
subl 'foo.rb', 23 # => open foo.rb on line 23
|
14
|
+
subl :rake # => open gem
|
15
|
+
subl Foo.method(:bar) # => open source_location of the given method
|
16
|
+
subl Foo # => open class/module definition
|
17
|
+
MyClass.subl :bar # => open method definition
|
18
|
+
MyClass.subl /baz/ # => open first matching method definition
|
19
|
+
```
|
26
20
|
|
27
21
|
## Development
|
28
22
|
|
@@ -30,7 +24,6 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
30
24
|
|
31
25
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
26
|
|
33
|
-
##
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/subl.
|
27
|
+
## Contributions
|
36
28
|
|
29
|
+
Thanks @janosch-x for the additions!
|
data/lib/subl/command.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module Subl
|
2
2
|
class Command
|
3
|
-
attr_accessor :candidate, :line, :
|
3
|
+
attr_accessor :candidate, :line, :original_binding
|
4
4
|
|
5
5
|
def initialize(candidate:, line: nil, binding: nil)
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
self.candidate = candidate
|
7
|
+
self.line = line
|
8
|
+
self.original_binding = binding
|
9
9
|
end
|
10
10
|
|
11
11
|
def call
|
@@ -21,13 +21,21 @@ module Subl
|
|
21
21
|
def path
|
22
22
|
case candidate
|
23
23
|
when String then candidate
|
24
|
-
when Symbol then
|
24
|
+
when Symbol then resolve_symbol(candidate)
|
25
25
|
when Class, Module then resolve_class(candidate)
|
26
26
|
when Method then resolve_method(candidate)
|
27
27
|
when Regexp then resolve_regexp(candidate)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
def resolve_symbol(name)
|
32
|
+
if original_binding.class.in?([Object, NilClass])
|
33
|
+
resolve_gem(name)
|
34
|
+
else
|
35
|
+
resolve_regexp(/^#{name}$/)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
31
39
|
def resolve_method(m)
|
32
40
|
loc = Array(m.source_location)
|
33
41
|
self.line ||= loc.last
|
@@ -50,9 +58,9 @@ module Subl
|
|
50
58
|
resolve_method(klass.instance_method(m))
|
51
59
|
end
|
52
60
|
|
53
|
-
def resolve_regexp(
|
54
|
-
m =
|
55
|
-
resolve_method(
|
61
|
+
def resolve_regexp(regexp)
|
62
|
+
m = original_binding&.receiver.methods.grep(regexp).first or return
|
63
|
+
resolve_method(original_binding.receiver.method(m))
|
56
64
|
end
|
57
65
|
|
58
66
|
def resolve_gem(name)
|
data/lib/subl/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: subl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johannes Opper
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- ".rspec"
|
64
64
|
- ".travis.yml"
|
65
65
|
- Gemfile
|
66
|
+
- LICENSE.txt
|
66
67
|
- README.md
|
67
68
|
- Rakefile
|
68
69
|
- bin/console
|
@@ -95,4 +96,3 @@ signing_key:
|
|
95
96
|
specification_version: 4
|
96
97
|
summary: Provides "subl" command within irb
|
97
98
|
test_files: []
|
98
|
-
has_rdoc:
|