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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3ac42bf803354d6947b1d3d4160df7b955d57cbb
4
- data.tar.gz: a2c1eeb10cf3803f70f2719ef1ff5698a165f95b
3
+ metadata.gz: 653879f7a3b60e0305f666c60f2b127a59bbff1f
4
+ data.tar.gz: 9b120ecad0dd094cf1172800c71ee3cdf9587580
5
5
  SHA512:
6
- metadata.gz: d1f736bd982ab854a33c29c0ceb95dacf8098fab6914a24d9c931b482b47c928a6dd2e3ec9b55a4ff9cb8e012702636a6b1deee3805abe34135088135809e39e
7
- data.tar.gz: 684339d7e20f289cd01e6729e5951eb1d120940e323a6f7c017e5ccf0b7213b250d0e0f9a7183f6d644eca523b4cde80c5079ce712d90ba37c5c794a3cb26680
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
- class << self
7
- def start!(argv)
8
- Kernel.exec(*grep_command, argv[0], *Bundler.load.specs.map(&:full_gem_path))
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
@@ -1,5 +1,5 @@
1
1
  module Bundler
2
2
  module Grep
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler-grep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - takkanm