gem_locate 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Kabari Hendrick
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.textile ADDED
@@ -0,0 +1,57 @@
1
+ h1. Gem Locate
2
+
3
+ Searches gems by name, summary, and description in case you want to find a gem by what it is doing rather than it's name. Currently this only searches your *local* gems.
4
+
5
+ _I think someone made something like this before...but I couldn't find it_
6
+
7
+ h2. Install
8
+
9
+ @[sudo] gem install gem_locate@
10
+
11
+ h2. Usage
12
+
13
+ pre.. $ gem help locate
14
+ Usage: gem locate [STRING] [options]
15
+ Options:
16
+ -i, --[no-]installed Check for installed gem
17
+ -v, --version VERSION Specify version of gem to locate
18
+ -n, --name-matches REGEXP Name of gem(s) to query on matches the
19
+ provided REGEXP
20
+ -d, --[no-]details Display detailed information of gem(s)
21
+ --[no-]versions Display only gem names
22
+ -a, --all Display all gem versions
23
+ --prerelease Display prerelease versions
24
+
25
+ Local/Remote Options:
26
+ -l, --local Restrict operations to the LOCAL domain
27
+ -B, --bulk-threshold COUNT Threshold for switching to bulk
28
+ synchronization (default 1000)
29
+
30
+ Common Options:
31
+ -h, --help Get help on this command
32
+ -V, --[no-]verbose Set the verbose level of output
33
+ -q, --quiet Silence commands
34
+ --config-file FILE Use this config file instead of default
35
+ --backtrace Show stack backtrace on errors
36
+ --debug Turn on Ruby debugging
37
+
38
+ Arguments:
39
+ STRING fragment of gem name,summary, or description to search for
40
+
41
+ Summary:
42
+ Find all gems whose name, summary, or description match STRING
43
+
44
+ Defaults:
45
+ --local
46
+
47
+ h1. Note on Patches/Pull Requests
48
+
49
+ * Fork the project.
50
+ * Make your feature addition or bug fix.
51
+ * Commit, do not mess with rakefile, version, or history.
52
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
53
+ * Send me a pull request :)
54
+
55
+ h1. Copyright
56
+
57
+ Copyright (c) 2010 Kabari Hendrick. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,51 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "gem_locate"
8
+ gem.summary = %Q{Same as 'gem search' but search description and summary also}
9
+ gem.description = %Q{Searches gems by name, summary, and description in case you want to find a gem by what it is doing rather than it's name.}
10
+ gem.email = "kabari@gmail.com"
11
+ gem.homepage = "http://github.com/kabari/gem_locate"
12
+ gem.authors = ["Kabari Hendrick"]
13
+ gem.files = FileList["lib/rubygems_plugin.rb",
14
+ "lib/commands/locate.rb",
15
+ "lib/gem_extension/source_index.rb",
16
+ "README.rdoc",
17
+ "LICENSE",
18
+ "VERSION",
19
+ "Rakefile"]
20
+ gem.test_files = []
21
+ gem.executables = []
22
+ gem.required_rubygems_version = Gem::Requirement.new(">= 1.3.5") if gem.respond_to? :required_rubygems_version=
23
+ gem.post_install_message = <<MESSAGE
24
+
25
+ ========================================================================
26
+
27
+ Thanks for installing Gem Locate! You can now run:
28
+
29
+ gem locate STRING Same as 'gem search' but search description and summary also
30
+
31
+ ========================================================================
32
+
33
+ MESSAGE
34
+
35
+ gem.add_development_dependency "yard", ">= 0"
36
+ end
37
+ Jeweler::GemcutterTasks.new
38
+ rescue LoadError
39
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
40
+ end
41
+
42
+ task :default => :check_dependencies
43
+
44
+ begin
45
+ require 'yard'
46
+ YARD::Rake::YardocTask.new
47
+ rescue LoadError
48
+ task :yardoc do
49
+ abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
50
+ end
51
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.5.0
@@ -0,0 +1,66 @@
1
+ class Gem::Commands::LocateCommand < Gem::Commands::QueryCommand
2
+ def initialize
3
+ super 'locate', 'Find all gems whose name, summary, or description match STRING'
4
+
5
+ %w(-r -b --source -p -u).each{|com| remove_option com }
6
+ end
7
+
8
+ def arguments # :nodoc:
9
+ "STRING fragment of gem name,summary, or description to search for"
10
+ end
11
+
12
+ def defaults_str # :nodoc:
13
+ "--local"
14
+ end
15
+
16
+ def usage # :nodoc:
17
+ "#{program_name} [STRING]"
18
+ end
19
+
20
+ def execute
21
+ string = get_one_optional_argument
22
+ options[:name] = /#{string}/i
23
+ exit_code = 0
24
+
25
+ name = options[:name]
26
+ prerelease = options[:prerelease]
27
+
28
+ if options[:installed] then
29
+ if name.source.empty? then
30
+ alert_error "You must specify a gem name"
31
+ exit_code |= 4
32
+ elsif installed? name, options[:version] then
33
+ say "true"
34
+ else
35
+ say "false"
36
+ exit_code |= 1
37
+ end
38
+
39
+ raise Gem::SystemExitException, exit_code
40
+ end
41
+
42
+ dep = Gem::Dependency.new name, Gem::Requirement.default
43
+
44
+ if prerelease and not both? then
45
+ alert_warning "prereleases are always shown locally"
46
+ end
47
+
48
+ if ui.outs.tty? or both? then
49
+ say
50
+ say "*** LOCAL GEMS ***"
51
+ say
52
+ end
53
+
54
+ specs = Gem.source_index.locate dep
55
+
56
+ spec_tuples = specs.map do |spec|
57
+ [[spec.name, spec.version, spec.original_platform, spec], :local]
58
+ end
59
+
60
+ output_query_results spec_tuples
61
+
62
+ # TODO support remote gem search
63
+ end
64
+
65
+ end
66
+
@@ -0,0 +1,49 @@
1
+ class Gem::SourceIndex
2
+
3
+ # This is basically the same as Gem::SourceIndex.search
4
+ def locate(gem_pattern, platform_only = false)
5
+ version_requirement = nil
6
+ only_platform = false
7
+
8
+ # TODO - Remove support and warning for legacy arguments after 2008/11
9
+ unless Gem::Dependency === gem_pattern
10
+ warn "#{Gem.location_of_caller.join ':'}:Warning: Gem::SourceIndex#search support for #{gem_pattern.class} patterns is deprecated, use #find_name"
11
+ end
12
+
13
+ case gem_pattern
14
+ when Regexp then
15
+ version_requirement = platform_only || Gem::Requirement.default
16
+ when Gem::Dependency then
17
+ only_platform = platform_only
18
+ version_requirement = gem_pattern.version_requirements
19
+ gem_pattern = if Regexp === gem_pattern.name then
20
+ gem_pattern.name
21
+ elsif gem_pattern.name.empty? then
22
+ //
23
+ else
24
+ /^#{Regexp.escape gem_pattern.name}$/
25
+ end
26
+ else
27
+ version_requirement = platform_only || Gem::Requirement.default
28
+ gem_pattern = /#{gem_pattern}/i
29
+ end
30
+
31
+ unless Gem::Requirement === version_requirement then
32
+ version_requirement = Gem::Requirement.create version_requirement
33
+ end
34
+
35
+ specs = all_gems.values.select do |spec|
36
+ if version_requirement.satisfied_by? spec.version
37
+ [spec.name, spec.description, spec.summary].detect{|q| (q =~ gem_pattern) if q }
38
+ end
39
+ end
40
+
41
+ if only_platform then
42
+ specs = specs.select do |spec|
43
+ Gem::Platform.match spec.platform
44
+ end
45
+ end
46
+
47
+ specs.sort_by { |s| s.sort_obj }
48
+ end
49
+ end
@@ -0,0 +1,10 @@
1
+ $:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
2
+
3
+ require 'rubygems/command_manager'
4
+ require 'rubygems/command'
5
+ require 'rubygems/commands/query_command'
6
+
7
+ require "commands/locate"
8
+ require "gem_extension/source_index"
9
+ # register gem command
10
+ Gem::CommandManager.instance.register_command :locate
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gem_locate
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ platform: ruby
6
+ authors:
7
+ - Kabari Hendrick
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-02-11 00:00:00 -06:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: yard
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description: Searches gems by name, summary, and description in case you want to find a gem by what it is doing rather than it's name.
26
+ email: kabari@gmail.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - LICENSE
33
+ - README.textile
34
+ files:
35
+ - LICENSE
36
+ - Rakefile
37
+ - VERSION
38
+ - lib/commands/locate.rb
39
+ - lib/gem_extension/source_index.rb
40
+ - lib/rubygems_plugin.rb
41
+ - README.textile
42
+ has_rdoc: true
43
+ homepage: http://github.com/kabari/gem_locate
44
+ licenses: []
45
+
46
+ post_install_message: |+
47
+
48
+ ========================================================================
49
+
50
+ Thanks for installing Gem Locate! You can now run:
51
+
52
+ gem locate STRING Same as 'gem search' but search description and summary also
53
+
54
+ ========================================================================
55
+
56
+ rdoc_options:
57
+ - --charset=UTF-8
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: "0"
65
+ version:
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 1.3.5
71
+ version:
72
+ requirements: []
73
+
74
+ rubyforge_project:
75
+ rubygems_version: 1.3.5
76
+ signing_key:
77
+ specification_version: 3
78
+ summary: Same as 'gem search' but search description and summary also
79
+ test_files: []
80
+