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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f25848a87f8d1be0ae1c2a4deb7e662da4d5be3
4
- data.tar.gz: 49d0c2a156c946588b42cd1a423df930b3665de4
3
+ metadata.gz: 38428e73520fd6ff13da40a4a9b0d7ce0ce13a6a
4
+ data.tar.gz: af3ac09a1671393b5875d7f38adcb22d3c3a2fd9
5
5
  SHA512:
6
- metadata.gz: f96b4df02ca73f76bb4355b3f6db1737adb909511f59ca8b41b6d6b3cbf6ecb981be7dc90580cc11a80391cb31b1f77d80ee2eccc13b50a96ce8968ec2a6ab29
7
- data.tar.gz: 5db847b40f2ab0a941fdbfb6d342a26d0457130e68dc6b1cd8a5e420c421a9ddd6b47ce853f9bf034f920877e4df5add897f5f3f4c81034b1eb39bbd732d34fb
6
+ metadata.gz: d2318e5fa8d88c7151125f55ca39e0a83a5b3f1c94a3a0e186c9abd273d15bc141c6dfa565509f6650be0422c90ac876d3a9188cbb19768fe5d3c6066efaa169
7
+ data.tar.gz: 4cf570c29bb50112ae148d73703835f8767898d87ffb76a0bbe60aa37a80ed5d0b8e7163371d3a4fb579fa11a63b9aaad55f8b17c5d702306231d9cd466f2cca
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Gem::Ag
2
2
 
3
- TODO: Write a gem description
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
- TODO: Write usage instructions here
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
 
@@ -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.1"
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
- paths = search_paths(gems_to_search).join ' '
22
- flags = ag_flags.join ' '
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(*gems_to_search)
34
- specs = if gems_to_search
35
- Gem::Specification.find_all
36
- else
37
- Array(gems_to_search).map do |name|
38
- Gem::Specification.find_all_by_name name
39
- end.flatten
40
- end
41
- specs.map{|s| "\"#{s.full_gem_path}\""}
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem-ag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Sexton