adamsanderson-open_gem 1.3.2 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :minor: 3
3
- :patch: 2
2
+ :minor: 4
3
+ :patch: 0
4
4
  :major: 1
@@ -14,16 +14,29 @@ module OpenGem
14
14
  end
15
15
  end
16
16
 
17
+ def add_exact_match_option
18
+ add_option('-x', '--exact',
19
+ 'Only list exact matches') do |value, options|
20
+ options[:exact] = true
21
+ end
22
+ end
23
+
17
24
  def get_spec(name)
18
- dep = Gem::Dependency.new name, options[:version]
25
+ dep = Gem::Dependency.new(name, options[:version])
19
26
  specs = Gem.source_index.search(dep)
20
27
  if block_given?
21
28
  specs = specs.select{|spec| yield spec}
22
29
  end
23
30
 
24
31
  if specs.length == 0
25
- say "'#{name}' is not available"
26
- return nil
32
+ # If we have not tried to do a pattern match yet, fall back on it.
33
+ if(!options[:exact] && !name.is_a?(Regexp))
34
+ pattern = /#{Regexp.escape name}/
35
+ get_spec(pattern)
36
+ else
37
+ say "#{name.inspect} is not available"
38
+ return nil
39
+ end
27
40
 
28
41
  elsif specs.length == 1 || options[:latest]
29
42
  return specs.last
@@ -12,6 +12,7 @@ class Gem::Commands::OpenCommand < Gem::Command
12
12
  add_command_option
13
13
  add_latest_version_option
14
14
  add_version_option
15
+ add_exact_match_option
15
16
  end
16
17
 
17
18
  def arguments # :nodoc:
@@ -12,6 +12,7 @@ class Gem::Commands::ReadCommand < Gem::Command
12
12
  add_command_option "Application to read rdoc with"
13
13
  add_latest_version_option
14
14
  add_version_option
15
+ add_exact_match_option
15
16
  end
16
17
 
17
18
  def arguments # :nodoc:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adamsanderson-open_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Sanderson
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-03 00:00:00 -07:00
12
+ date: 2009-08-03 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -42,6 +42,7 @@ files:
42
42
  - test/open_command_test.rb
43
43
  has_rdoc: false
44
44
  homepage: http://github.com/adamsanderson/open_gem
45
+ licenses:
45
46
  post_install_message:
46
47
  rdoc_options:
47
48
  - --charset=UTF-8
@@ -62,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
63
  requirements: []
63
64
 
64
65
  rubyforge_project:
65
- rubygems_version: 1.2.0
66
+ rubygems_version: 1.3.5
66
67
  signing_key:
67
68
  specification_version: 3
68
69
  summary: Gem Command to easily open a ruby gem with the editor of your choice.