gem-open 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "gem-open"
6
- s.version = "0.1.4"
6
+ s.version = "0.1.5"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Nando Vieira"]
9
9
  s.email = ["fnando.vieira@gmail.com"]
@@ -33,11 +33,19 @@ class Gem::Commands::OpenCommand < Gem::Command
33
33
  end
34
34
  end
35
35
 
36
+ def dirs
37
+ if Gem::Specification.respond_to?(:dirs)
38
+ Gem::Specification.dirs
39
+ else
40
+ Gem::SourceIndex.installed_spec_directories
41
+ end
42
+ end
43
+
36
44
  def search(gemname)
37
45
  regex = /^(.*?)-*([\d.]+[\w]*)?$/
38
46
  _, required_name, required_version = *gemname.match(regex)
39
47
 
40
- gemspecs = Dir["{#{Gem::SourceIndex.installed_spec_directories.join(",")}}/*.gemspec"].select do |gemspec|
48
+ gemspecs = Dir["{#{dirs.join(",")}}/*.gemspec"].select do |gemspec|
41
49
  basename = File.basename(gemspec).gsub(/\.gemspec$/, "")
42
50
 
43
51
  if required_version
@@ -12,6 +12,20 @@ class GemOpenTest < Test::Unit::TestCase
12
12
  @gemdir = File.expand_path(File.dirname(__FILE__) + "/gems")
13
13
  end
14
14
 
15
+ def test_use_gem_specification_dirs
16
+ Gem::Specification.expects(:respond_to?).with(:dirs).returns(true)
17
+ Gem::Specification.expects(:dirs).returns(["/some/dir"])
18
+
19
+ assert_equal ["/some/dir"], @plugin.dirs
20
+ end
21
+
22
+ def test_use_gem_source_index_dirs
23
+ Gem::Specification.expects(:respond_to?).with(:dirs).returns(false)
24
+ Gem::SourceIndex.expects(:installed_spec_directories).returns(["/some/dir"])
25
+
26
+ assert_equal ["/some/dir"], @plugin.dirs
27
+ end
28
+
15
29
  def test_require_gem_name_to_be_set
16
30
  @plugin.expects(:options).returns(:args => [])
17
31
  @plugin.expects(:say).with("Usage: #{@plugin.usage}")
@@ -37,7 +51,7 @@ class GemOpenTest < Test::Unit::TestCase
37
51
 
38
52
  gemname = "activesupport"
39
53
 
40
- Gem::SourceIndex.expects(:installed_spec_directories).returns([File.dirname(__FILE__) + "/resources"])
54
+ @plugin.expects(:dirs).returns([File.dirname(__FILE__) + "/resources"])
41
55
 
42
56
  @plugin.expects(:options).returns(:args => [gemname])
43
57
  @plugin.expects(:system).with("mate #{@gemdir}/activesupport-3.0.0.beta3")
@@ -51,7 +65,7 @@ class GemOpenTest < Test::Unit::TestCase
51
65
 
52
66
  gemname = "activesupport"
53
67
 
54
- Gem::SourceIndex.expects(:installed_spec_directories).returns([File.dirname(__FILE__) + "/resources"])
68
+ @plugin.expects(:dirs).returns([File.dirname(__FILE__) + "/resources"])
55
69
 
56
70
  @plugin.expects(:options).returns(:args => [gemname])
57
71
  @plugin.expects(:system).with("vim #{@gemdir}/activesupport-3.0.0.beta3")
@@ -62,7 +76,7 @@ class GemOpenTest < Test::Unit::TestCase
62
76
  def test_gem_without_version
63
77
  gemname = "activesupport"
64
78
 
65
- Gem::SourceIndex.expects(:installed_spec_directories).returns([File.dirname(__FILE__) + "/resources"])
79
+ @plugin.expects(:dirs).returns([File.dirname(__FILE__) + "/resources"])
66
80
 
67
81
  @plugin.expects(:options).returns(:args => [gemname])
68
82
  @plugin.expects(:system).with("mate #{@gemdir}/activesupport-3.0.0.beta3")
@@ -73,7 +87,7 @@ class GemOpenTest < Test::Unit::TestCase
73
87
  def test_gem_with_version
74
88
  gemname = "activesupport-2.3.5"
75
89
 
76
- Gem::SourceIndex.expects(:installed_spec_directories).returns([File.dirname(__FILE__) + "/resources"])
90
+ @plugin.expects(:dirs).returns([File.dirname(__FILE__) + "/resources"])
77
91
 
78
92
  @plugin.expects(:options).returns(:args => [gemname])
79
93
  @plugin.expects(:system).with("mate #{@gemdir}/activesupport-2.3.5")
@@ -84,7 +98,7 @@ class GemOpenTest < Test::Unit::TestCase
84
98
  def test_gem_with_compound_name
85
99
  gemname = "sinatra-sugar"
86
100
 
87
- Gem::SourceIndex.expects(:installed_spec_directories).returns([File.dirname(__FILE__) + "/resources"])
101
+ @plugin.expects(:dirs).returns([File.dirname(__FILE__) + "/resources"])
88
102
 
89
103
  @plugin.expects(:options).returns(:args => [gemname])
90
104
  @plugin.expects(:system).with("mate #{@gemdir}/sinatra-sugar-0.4.1")
@@ -95,7 +109,7 @@ class GemOpenTest < Test::Unit::TestCase
95
109
  def test_gem_with_compound_name_and_version
96
110
  gemname = "sinatra-sugar-0.4.1"
97
111
 
98
- Gem::SourceIndex.expects(:installed_spec_directories).returns([File.dirname(__FILE__) + "/resources"])
112
+ @plugin.expects(:dirs).returns([File.dirname(__FILE__) + "/resources"])
99
113
 
100
114
  @plugin.expects(:options).returns(:args => [gemname])
101
115
  @plugin.expects(:system).with("mate #{@gemdir}/sinatra-sugar-0.4.1")
@@ -108,7 +122,7 @@ class GemOpenTest < Test::Unit::TestCase
108
122
  ENV["EDITOR"] = nil
109
123
  gemname = "activesupport"
110
124
 
111
- Gem::SourceIndex.expects(:installed_spec_directories).returns([File.dirname(__FILE__) + "/resources"])
125
+ @plugin.expects(:dirs).returns([File.dirname(__FILE__) + "/resources"])
112
126
 
113
127
  @plugin.expects(:options).returns(:args => [gemname])
114
128
  @plugin.expects(:say).with("You must set your editor in your .bash_profile or equivalent:")
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: gem-open
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.4
5
+ version: 0.1.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Nando Vieira
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
58
  requirements: []
59
59
 
60
60
  rubyforge_project:
61
- rubygems_version: 1.7.2
61
+ rubygems_version: 1.8.0
62
62
  signing_key:
63
63
  specification_version: 3
64
64
  summary: Open gems on your favorite editor by running a specific gem command like `gem open nokogiri`.