gem-ag 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4f25848a87f8d1be0ae1c2a4deb7e662da4d5be3
4
+ data.tar.gz: 49d0c2a156c946588b42cd1a423df930b3665de4
5
+ SHA512:
6
+ metadata.gz: f96b4df02ca73f76bb4355b3f6db1737adb909511f59ca8b41b6d6b3cbf6ecb981be7dc90580cc11a80391cb31b1f77d80ee2eccc13b50a96ce8968ec2a6ab29
7
+ data.tar.gz: 5db847b40f2ab0a941fdbfb6d342a26d0457130e68dc6b1cd8a5e420c421a9ddd6b47ce853f9bf034f920877e4df5add897f5f3f4c81034b1eb39bbd732d34fb
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gem-ag.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Christopher Sexton
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ # Gem::Ag
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'gem-ag'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install gem-ag
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/gem-ag/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "gem-ag"
7
+ spec.version = "0.0.1"
8
+ spec.authors = ["Christopher Sexton"]
9
+ spec.email = ["github@codeography.com"]
10
+ spec.summary = %q{Search installed gems with ag}
11
+ spec.homepage = "https://github.com/csexton/gem-ag"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files -z`.split("\x0")
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_development_dependency "bundler", "~> 1.7"
20
+ spec.add_development_dependency "rake", "~> 10.0"
21
+ spec.add_development_dependency "pry"
22
+ end
@@ -0,0 +1,115 @@
1
+ require 'rubygems/command'
2
+ require 'pry'
3
+
4
+ class Gem::Commands::AgCommand < Gem::Command
5
+ def initialize
6
+ super 'ag', "Search for PATTERN in installed gem source using 'ag'"
7
+
8
+ add_ag_opts possible_ag_opts
9
+ end
10
+
11
+ def arguments
12
+ "PATTERN Search Pattern"
13
+ end
14
+
15
+ def usage
16
+ "#{program_name} PATTERN [GEMNAME ...]"
17
+ end
18
+
19
+ def execute
20
+ search_term, gems_to_search = options[:args]
21
+ paths = search_paths(gems_to_search).join ' '
22
+ flags = ag_flags.join ' '
23
+
24
+ execute_ag flags, search_term, paths
25
+ end
26
+
27
+ private
28
+
29
+ def ag_flags
30
+ @ag_flags ||= Array.new
31
+ end
32
+
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}\""}
42
+ end
43
+
44
+ def add_ag_opts(list)
45
+ list.each do |current_opt|
46
+ add_option(*current_opt) do |value, options|
47
+ ag_flags << current_opt.first.split(' ').first
48
+ ag_flags << value unless value === true
49
+ end
50
+ end
51
+ end
52
+
53
+ def execute_ag(flags, search_term, paths)
54
+ exec "ag #{flags} #{search_term} #{paths}"
55
+ end
56
+
57
+ # Holy hell this is a big list of things. Taken from the ag man page. If
58
+ # there is a better way to pass options through the rubygems plugin system I
59
+ # would love to refactor this to just pass the options along to the ag
60
+ # command.
61
+ def possible_ag_opts
62
+ [
63
+ ["--ackmate", "Output results in a format parseable by AckMate https://github.com/protocool/AckMate."],
64
+ ["-a", "--all-types", "Search all files. This doesn't include hidden files, and doesn't respect any ignore files."],
65
+ ["-A", "--after [LINES]", "Print lines after match. Defaults to 2."],
66
+ ["-B", "--before [LINES]", "Print lines before match. Defaults to 2."],
67
+ ["--break", "Print a newline between matches in different files. Enabled by default."],
68
+ ["--nobreak", "Don't print a newline between matches in different files. Enabled by default."],
69
+ ["--color", "Print color codes in results. Enabled by default."],
70
+ ["--nocolor", "Don't print color codes in results. Enabled by default."],
71
+ ["--color-line-number", "Color codes for line numbers. Defaults to 1;33."],
72
+ ["--color-match", "Color codes for result match numbers. Defaults to 30;43."],
73
+ ["--color-path", "Color codes for path names. Defaults to 1;32."],
74
+ ["--column", "Print column numbers in results."],
75
+ ["-C", "--context [LINES]", "Print lines before and after matches. Defaults to 2."],
76
+ ["-D", "--debug", "Output ridiculous amounts of debugging info. Probably not use-ful."],
77
+ ["--depth NUM", "Search up to NUM directories deep. Default is 25."],
78
+ ["-f", "--follow", "Follow symlinks."],
79
+ ["--group", "The default, --group,lumps multiple matches in the same file together,and presents them under a single occurrence of the filename. --nogroup refrains from this, and instead places the filename at the start of each match line."],
80
+ ["--nogroup", "Don't lumps multiple matches in the same file together."],
81
+ ["-g PATTERN", "Print filenames matching PATTERN."],
82
+ ["-G", "--file-search-regex PATTERN", "Only search files whose names match PATTERN."],
83
+ ["-H", "--heading", "Print filenames above matching contents."],
84
+ ["-H", "--noheading", "Don't print filenames above matching contents."],
85
+ ["--hidden", "Search hidden files. This option obeys ignore files."],
86
+ ["--ignore PATTERN", "Ignore files/directories whose names match this pattern. Literal file and directory names are also allowed."],
87
+ ["--ignore-dir NAME", "Alias for --ignore for compatibility with ack."],
88
+ ["-i", "--ignore-case", "Match case-insensitively."],
89
+ ["-l", "--files-with-matches", "Only print the names of files containing matches,not the match-ing lines. An empty query will print all files that would be searched."],
90
+ ["-L", "--files-without-matches", "Only print the names of files that don't contain matches."],
91
+ ["--list-file-types", "See file types."],
92
+ ["-m", "--max-count NUM", "Skip the rest of a file after NUM matches. Default is 10,000."],
93
+ ["--no-numbers", "Don't show line numbers."],
94
+ ["-p", "--path-to-agignore STRING", "Provide a path to a specific .agignore file."],
95
+ ["--pager COMMAND", "Use a pager such as less. Use --nopager to override. This option is also ignored if output is piped to another program."],
96
+ ["--print-long-lines", "Print matches on very long lines (> 2k characters by default)."],
97
+ ["--passthrough", "When searching a stream, print all lines even if they don't match."],
98
+ ["-Q", "--literal", "Do not parse PATTERN as a regular expression. Try to match it literally."],
99
+ ["-s", "--case-sensitive", "Match case-sensitively."],
100
+ ["-S", "--smart-case", "Match case-sensitively if there are any uppercase letters in PATTERN, case-insensitively otherwise. Enabled by default."],
101
+ ["--search-binary", "Search binary files for matches."],
102
+ ["--silent", "Suppress all log messages, including errors."],
103
+ ["--stats", "Print stats (files scanned, time taken, etc)."],
104
+ ["-t", "--all-text", "Search all text files. This doesn't include hidden files."],
105
+ ["-u", "--unrestricted", "Search all files. This ignores .agignore, .gitignore, etc. It searches binary and hidden files as well."],
106
+ ["-U", "--skip-vcs-ignores", "Ignore VCS ignore files (.gitignore, .hgignore, svn:ignore), but still use .agignore."],
107
+ ["-v", "--invert-match", "Match every line not containing the specified pattern."],
108
+ ["--vimgrep", "Output results like vim's :vimgrep /pattern/g would (it reports every match on the line)."],
109
+ ["-w", "--word-regexp", "Only match whole words."],
110
+ ["-z", "--search-zip", "Search contents of compressed files."],
111
+ ["-0", "--null", "Separate the filenames with \\0, rather than \\n: this allows xargs -0 <command> to correctly process filenames containing spaces or newlines."],
112
+ ]
113
+ end
114
+ end
115
+
@@ -0,0 +1,4 @@
1
+ require 'rubygems/command_manager'
2
+ require 'rubygems/commands/ag_command'
3
+
4
+ Gem::CommandManager.instance.register_command :ag
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gem-ag
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Christopher Sexton
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - github@codeography.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - gem-ag.gemspec
68
+ - lib/rubygems/commands/ag_command.rb
69
+ - lib/rubygems_plugin.rb
70
+ homepage: https://github.com/csexton/gem-ag
71
+ licenses:
72
+ - MIT
73
+ metadata: {}
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 2.2.2
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: Search installed gems with ag
94
+ test_files: []