bundler-grep 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/bundler/grep.rb +33 -3
- data/lib/bundler/grep/version.rb +1 -1
- 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: 653879f7a3b60e0305f666c60f2b127a59bbff1f
|
4
|
+
data.tar.gz: 9b120ecad0dd094cf1172800c71ee3cdf9587580
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c503b4b99b75e851687fad0f1713dc3dc3b65c1f9931d4baeacf40c16302bc62519bb60e6b7edcdc39fcfb7e09c7bdfd289a4d225cd4f457ddc3e333f1d5a80
|
7
|
+
data.tar.gz: e5ddf5d51c1ed1e19e74d2be1d809e34f1251d7ed033c1b544a62687005a31e2139fd354b629bd1291456e98604aeaa53f05aa9d7663392f0b5cec6054ea67a6
|
data/README.md
CHANGED
@@ -31,6 +31,12 @@ If you want to use any grep command, you can set `BUNDLER_GREP_CMD`.
|
|
31
31
|
$ BUNDLER_GREP_CMD='hw' bundle grep KEYWORD
|
32
32
|
```
|
33
33
|
|
34
|
+
If you want to grep specific gems, you can use `--gems` option.
|
35
|
+
|
36
|
+
```sh
|
37
|
+
$ bundle grep --gems gem_name1,gem_name2 KEYWORD
|
38
|
+
```
|
39
|
+
|
34
40
|
## Development
|
35
41
|
|
36
42
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/bundler/grep.rb
CHANGED
@@ -1,15 +1,35 @@
|
|
1
1
|
require "bundler/grep/version"
|
2
2
|
require 'bundler'
|
3
|
+
require 'optparse'
|
3
4
|
|
4
5
|
module Bundler
|
5
6
|
module Grep
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
def self.start!(argv)
|
8
|
+
Bundler::Grep::Command.new(argv).start!
|
9
|
+
end
|
10
|
+
|
11
|
+
class Command
|
12
|
+
def initialize(argv)
|
13
|
+
parse_argument!(argv)
|
14
|
+
end
|
15
|
+
|
16
|
+
def start!
|
17
|
+
Kernel.exec(*grep_command, @argv[0], *selected_gem_paths)
|
9
18
|
end
|
10
19
|
|
11
20
|
private
|
12
21
|
|
22
|
+
def parse_argument!(argv)
|
23
|
+
opt = OptionParser.new
|
24
|
+
opt.on('-g name1[,name2..]', '--gems name1[,name2..]', 'select target gems') do |gems|
|
25
|
+
@gems = gems.split(',')
|
26
|
+
end
|
27
|
+
opt.version = Bundler::Grep::VERSION
|
28
|
+
|
29
|
+
opt.parse!(argv)
|
30
|
+
@argv = argv
|
31
|
+
end
|
32
|
+
|
13
33
|
def grep_command
|
14
34
|
if ENV['BUNDLER_GREP_CMD']
|
15
35
|
ENV['BUNDLER_GREP_CMD'].split(/ /).reject {|w| w == '' }
|
@@ -17,6 +37,16 @@ module Bundler
|
|
17
37
|
%w(grep -R)
|
18
38
|
end
|
19
39
|
end
|
40
|
+
|
41
|
+
def selected_gem_paths
|
42
|
+
if @gems
|
43
|
+
Bundler.load.specs.find_all {|spec|
|
44
|
+
@gems.include?(spec.name)
|
45
|
+
}.map(&:full_gem_path)
|
46
|
+
else
|
47
|
+
Bundler.load.specs.map(&:full_gem_path)
|
48
|
+
end
|
49
|
+
end
|
20
50
|
end
|
21
51
|
end
|
22
52
|
end
|
data/lib/bundler/grep/version.rb
CHANGED