gem-empty 0.9.0 → 1.0.0

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: e7980f4fa51e450012e7439abd3a67642ce7bb94
4
- data.tar.gz: 7a707094189fb61e136f2af8c958c6176fccf670
3
+ metadata.gz: 5bbd464c2b3d70cadf8d22c16ce97f71e46100ac
4
+ data.tar.gz: adf762ac6cf0e8f1464d279f310e5677b045a8ff
5
5
  SHA512:
6
- metadata.gz: 7fbcb2fbd35eba9ddff7d117e02582728218b4ec47cf442c859272422106f6b0e766eeb8c288e7cf37e1784bdba8ee2eaac7a33e1135dced8d4017c7c38541a9
7
- data.tar.gz: 72fba77132cf20d285943579880610e82666682d00c5868a75267a4ad37c5521697b9574bedf85d8190d51465fce2f5c0960331f0913bcafb1364f119058714a
6
+ metadata.gz: bd55f20814bb45071438411ebe2497ccfb3802b79f121aa24c470dd46cef8d42cf02ea0c43874cbd531e13ba89219dafa44bbdeb69a12b5a8855391ba1d1acff
7
+ data.tar.gz: f652c969af148314324ba57d28f6980c8b7ab3e01e84eb5a4d21d7efdbdf5bd38ded637a6cc3eee1951c724cf38f5f6151afb2f857b227531ac84ad3a21803c1
data/.travis.yml CHANGED
@@ -1,13 +1,13 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - jruby
4
+ - rbx
4
5
  - ruby-head
5
6
  - 1.8.7
6
7
  - 1.9.2
7
8
  - 1.9.3
8
9
  - 2.0.0
9
10
  - 2.1.0
10
- - rbx
11
11
  notifications:
12
12
  irc:
13
13
  channels:
@@ -17,6 +17,4 @@ notifications:
17
17
  - mpapis@gmail.com
18
18
  on_failure: change
19
19
  matrix:
20
- allow_failures:
21
- - rvm: rbx
22
20
  fast_finish: true
data/Changelog.md CHANGED
@@ -1,4 +1,6 @@
1
1
  # Changelog
2
2
 
3
- ## still in testing
3
+ ## 1.0.0
4
4
  date: 2013-12-20
5
+
6
+ - stable release
@@ -1,12 +1,11 @@
1
+ require 'gem-empty/specification'
1
2
  require 'rubygems/command_manager'
2
3
  require 'rubygems/uninstaller'
3
4
  require 'rubygems/version'
4
5
 
5
6
  class EmptyCommand < Gem::Command
6
7
  def initialize
7
- super 'empty', 'remove all gems from current GEM_HOME.'
8
- @failed = {}
9
- @worked = []
8
+ super 'empty', 'Remove all gems from current GEM_HOME.'
10
9
  end
11
10
 
12
11
  def arguments # :nodoc:
@@ -37,23 +36,16 @@ DOC
37
36
  Gem::GemNotInHomeException,
38
37
  Gem::FilePermissionError => e
39
38
 
40
- say "\t#{e.class}: #{e.message}"
39
+ alert_error "#{e.class}: #{e.message}"
41
40
  end
42
41
 
43
42
  private
44
43
 
45
44
  def gem_dir_specs
46
45
  @gem_dir_specs ||=
47
- installed_gems.select do |spec|
46
+ GemEmpty::Specification.installed_gems.select do |spec|
48
47
  File.exists?( File.join( Gem.dir, 'gems', spec.full_name ) )
49
48
  end
50
49
  end
51
50
 
52
- def installed_gems
53
- if Gem::VERSION > '1.8' then
54
- Gem::Specification.to_a
55
- else
56
- Gem.source_index.map{|name,spec| spec}
57
- end
58
- end
59
51
  end
@@ -1,14 +1,14 @@
1
1
  module GemEmpty
2
2
  module Specification
3
- def self.find
4
- @gem_empty_spec ||=
5
- if Gem::Specification.respond_to?(:find_by_name)
6
- Gem::Specification.find_by_name("gem-empty")
7
- else
8
- Gem.source_index.find_name("gem-empty").last
9
- end
10
- rescue Gem::LoadError
11
- nil
3
+ def self.installed_gems
4
+ if Gem::VERSION > '1.8' then
5
+ Gem::Specification.to_a
6
+ else
7
+ Gem.source_index.map{|name,spec| spec}
8
+ end
9
+ end
10
+ def self.find(name = "gem-empty")
11
+ @gem_empty_spec ||= installed_gems.find{|spec| spec.name == name}
12
12
  end
13
13
  def self.version
14
14
  find ? find.version.to_s : nil
@@ -1,3 +1,3 @@
1
1
  module GemEmpty
2
- VERSION = "0.9.0"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -1,6 +1,8 @@
1
1
  require 'test_helper'
2
2
  require 'gem-empty/command'
3
3
  require 'rubygems/installer'
4
+ require 'rubygems/user_interaction'
5
+ require 'rubygems/mock_gem_ui'
4
6
 
5
7
  class Gem::Specification
6
8
  def self.remove_spec spec
@@ -9,19 +11,32 @@ class Gem::Specification
9
11
  end
10
12
 
11
13
  describe EmptyCommand do
14
+ include Gem::DefaultUserInteraction
15
+
12
16
  subject do
13
17
  EmptyCommand.new
14
18
  end
15
19
 
20
+ it "has some strings" do
21
+ subject.arguments.class.must_equal(String)
22
+ subject.usage.class.must_equal(String)
23
+ subject.defaults_str.class.must_equal(String)
24
+ subject.description.class.must_equal(String)
25
+ subject.program_name.class.must_equal(String)
26
+ end
27
+
16
28
  describe "wrappers" do
17
29
  before do
18
30
  file = Tempfile.new('command-wrappers')
19
31
  @test_path = file.path
20
32
  file.close
21
33
  file.unlink
22
- found_rake = Gem::Specification.find_by_name('rake')
23
- installer = Gem::Installer.new(found_rake.cache_file, :version => found_rake.version, :install_dir => @test_path)
24
- installer.install
34
+ @ui = Gem::MockGemUi.new
35
+ @found_rake = Gem::Specification.find_by_name('rake')
36
+ installer = Gem::Installer.new(@found_rake.cache_file, :version => @found_rake.version, :install_dir => @test_path)
37
+ use_ui @ui do
38
+ installer.install
39
+ end
25
40
  subject.instance_variable_set(:@gem_dir_specs, [installer.spec])
26
41
  end
27
42
 
@@ -29,11 +44,31 @@ describe EmptyCommand do
29
44
  FileUtils.rm_rf(@test_path)
30
45
  end
31
46
 
32
- it "regenerates wrappers" do
33
- File.exist?(File.join(@test_path, "gems", "rake-10.1.0")).must_equal(true)
34
- subject.execute(:install_dir => @test_path)
35
- File.exist?(File.join(@test_path, "gems", "rake-10.1.0")).must_equal(false)
47
+ it "removes gems" do
48
+ File.exist?(File.join(@test_path, "gems", @found_rake.full_name)).must_equal(true)
49
+ use_ui @ui do
50
+ subject.execute(:install_dir => @test_path)
51
+ end
52
+ File.exist?(File.join(@test_path, "gems", @found_rake.full_name)).must_equal(false)
53
+ @ui.output.must_match(
54
+ /Removing rake\nSuccessfully uninstalled rake-/
55
+ )
56
+ @ui.error.must_equal("")
36
57
  end
58
+
59
+ it "fails gems" do
60
+ File.chmod(0500, File.join(@test_path, "bin") )
61
+ use_ui @ui do
62
+ subject.execute(:install_dir => @test_path)
63
+ end
64
+ File.exist?(File.join(@test_path, "gems", @found_rake.full_name)).must_equal(true)
65
+ File.chmod(0755, File.join(@test_path, "bin") )
66
+ @ui.output.must_equal("")
67
+ @ui.error.must_match(
68
+ /ERROR: Gem::FilePermissionError: You don't have write permissions for the .* directory/
69
+ )
70
+ end
71
+
37
72
  end
38
73
 
39
74
  it "finds gem executables" do
@@ -4,12 +4,20 @@ require 'gem-empty/version'
4
4
 
5
5
  describe GemEmpty::Specification do
6
6
 
7
+ before do
8
+ GemEmpty::Specification.instance_variable_set(:@gem_empty_spec, nil)
9
+ end
10
+
7
11
  it "finds specification" do
8
- GemEmpty::Specification.find.name.must_equal("gem-empty")
12
+ GemEmpty::Specification.find("gem-empty").name.must_equal("gem-empty")
9
13
  end
10
14
 
11
15
  it "gets specification version" do
12
16
  GemEmpty::Specification.version.must_equal(GemEmpty::VERSION)
13
17
  end
14
18
 
19
+ it "does not find imaginary gems" do
20
+ GemEmpty::Specification.find("imaginary-gem").must_equal(nil)
21
+ end
22
+
15
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem-empty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Papis