gem-ag 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +35 -2
- data/gem-ag.gemspec +1 -1
- data/lib/rubygems/commands/ag_command.rb +17 -12
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38428e73520fd6ff13da40a4a9b0d7ce0ce13a6a
|
4
|
+
data.tar.gz: af3ac09a1671393b5875d7f38adcb22d3c3a2fd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2318e5fa8d88c7151125f55ca39e0a83a5b3f1c94a3a0e186c9abd273d15bc141c6dfa565509f6650be0422c90ac876d3a9188cbb19768fe5d3c6066efaa169
|
7
|
+
data.tar.gz: 4cf570c29bb50112ae148d73703835f8767898d87ffb76a0bbe60aa37a80ed5d0b8e7163371d3a4fb579fa11a63b9aaad55f8b17c5d702306231d9cd466f2cca
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Gem::Ag
|
2
2
|
|
3
|
-
|
3
|
+
RubyGems plugin to search with [The Silver Searcher](https://github.com/ggreer/the_silver_searcher)
|
4
|
+
|
4
5
|
|
5
6
|
## Installation
|
6
7
|
|
@@ -20,7 +21,39 @@ Or install it yourself as:
|
|
20
21
|
|
21
22
|
## Usage
|
22
23
|
|
23
|
-
|
24
|
+
The `gem ag` command attempts to support all the same command line options as `ag` out of the box. The big difference is you cannot specify paths to search. Instead you can pass in a list of gem names.
|
25
|
+
|
26
|
+
```
|
27
|
+
Usage: gem ag PATTERN [GEMNAME ...] [options]
|
28
|
+
```
|
29
|
+
|
30
|
+
### Examples
|
31
|
+
|
32
|
+
Search for "Hello World" in Rails and Active Record gems.
|
33
|
+
|
34
|
+
```
|
35
|
+
gem ag "Hello World" rails active-record
|
36
|
+
```
|
37
|
+
|
38
|
+
Search for "def" in the rake gem, and print ag stats.
|
39
|
+
|
40
|
+
```
|
41
|
+
gem ag --stats "def" rake
|
42
|
+
````
|
43
|
+
|
44
|
+
Search in all installed gems:
|
45
|
+
|
46
|
+
```
|
47
|
+
gem ag "Hello World"
|
48
|
+
```
|
49
|
+
|
50
|
+
By using `bundle exec` you can search only in the gems in yoru bundle.
|
51
|
+
|
52
|
+
Search in all bundled gems:
|
53
|
+
|
54
|
+
```
|
55
|
+
bundle exec gem ag "Hello World"
|
56
|
+
```
|
24
57
|
|
25
58
|
## Contributing
|
26
59
|
|
data/gem-ag.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "gem-ag"
|
7
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.3"
|
8
8
|
spec.authors = ["Christopher Sexton"]
|
9
9
|
spec.email = ["github@codeography.com"]
|
10
10
|
spec.summary = %q{Search installed gems with ag}
|
@@ -18,8 +18,9 @@ class Gem::Commands::AgCommand < Gem::Command
|
|
18
18
|
|
19
19
|
def execute
|
20
20
|
search_term, gems_to_search = options[:args]
|
21
|
-
|
22
|
-
|
21
|
+
gems_to_search = Array(gems_to_search).compact
|
22
|
+
paths = search_paths(gems_to_search)
|
23
|
+
flags = ag_flags
|
23
24
|
|
24
25
|
execute_ag flags, search_term, paths
|
25
26
|
end
|
@@ -30,15 +31,15 @@ class Gem::Commands::AgCommand < Gem::Command
|
|
30
31
|
@ag_flags ||= Array.new
|
31
32
|
end
|
32
33
|
|
33
|
-
def search_paths(
|
34
|
-
specs = if gems_to_search
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
specs.map
|
34
|
+
def search_paths(gems_to_search)
|
35
|
+
specs = if gems_to_search.empty?
|
36
|
+
Gem::Specification.find_all
|
37
|
+
else
|
38
|
+
Array(gems_to_search).map do |name|
|
39
|
+
Gem::Specification.find_all_by_name name
|
40
|
+
end.flatten
|
41
|
+
end
|
42
|
+
specs.map(&:full_require_paths).flatten
|
42
43
|
end
|
43
44
|
|
44
45
|
def add_ag_opts(list)
|
@@ -50,8 +51,12 @@ class Gem::Commands::AgCommand < Gem::Command
|
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
54
|
+
def quote(list)
|
55
|
+
list.map{|item| "\"#{item}\""}.join ' '
|
56
|
+
end
|
57
|
+
|
53
58
|
def execute_ag(flags, search_term, paths)
|
54
|
-
exec "ag #{flags} #{search_term} #{paths}"
|
59
|
+
exec "ag #{flags.join ' '} #{search_term} #{quote paths}"
|
55
60
|
end
|
56
61
|
|
57
62
|
# Holy hell this is a big list of things. Taken from the ag man page. If
|