gem-empty 1.1.1 → 1.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 349a468f9781f3f46f9c6f00443a19f910af56a0
4
- data.tar.gz: 8d643f44c77a4c93f7d98aa333f580126a77b32b
2
+ SHA256:
3
+ metadata.gz: ff17e62544185dfafc24dc791ef9fc4d420441823d425d718de5ec061c809aa6
4
+ data.tar.gz: 75ad4c116d0b2778dd8b473ccf4738a0abca8aab0261398a406d105ad10e0b3a
5
5
  SHA512:
6
- metadata.gz: 86cb35d631293e0b1ae0bab92ed98811f2e88947512e64a4212f66358c770093860f6919303fdb0f71fb008261461c33643b76fbd55e91b2e68f5bdc8f87aad2
7
- data.tar.gz: 83a4ee04e44e69b7bed6a4842b8f2e991b7f3b72ee79bae0122e5ccfc51c37a2e55185fb69f64545162bea9d48d4ef7312b08bb313ef01441ad7d601ad10f713
6
+ metadata.gz: 156ad9c9c043775d06874acf28541e19caf5e4ecf9fd7ca49a752e0f80627b5b93ca6f1833e3c586d2e9768dcb9f795974aecf3501cf82a0eae0d8d5bda567ed
7
+ data.tar.gz: 2d01c1a11a816915465103ff3f2fe2deccdd83e0fcb10072e2c72d1728ce773422748ece053c78f841510d630d9bc44a3e105654e28ae18f9bfe47f8e8fab825
@@ -0,0 +1,67 @@
1
+ name: tests
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+ name: ${{ matrix.ruby }}-${{ matrix.os }}
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ ruby:
16
+ # Due to https://github.com/actions/runner/issues/849, 'x.0' versions have to use quotes
17
+ - '2.0'
18
+ - 2.1
19
+ - 2.2
20
+ - 2.3
21
+ - 2.4
22
+ - 2.5
23
+ - 2.6
24
+ - 2.7
25
+ - '3.0'
26
+ - 3.1
27
+ - 3.2
28
+ - jruby
29
+ - truffleruby
30
+ os:
31
+ - macos
32
+ - ubuntu
33
+ - windows
34
+ exclude:
35
+ - ruby: 2.2 # Fails on setup
36
+ os: ubuntu
37
+ - ruby: 2.7 # Fails only on macos
38
+ os: macos
39
+ - ruby: 3.0 # Fails only on macos
40
+ os: macos
41
+ - ruby: 3.1 # Fails only on macos
42
+ os: macos
43
+ - ruby: 3.2 # Fails only on macos
44
+ os: macos
45
+ - ruby: jruby
46
+ os: macos
47
+ - ruby: jruby
48
+ os: windows
49
+ - ruby: truffleruby
50
+ os: macos
51
+ - ruby: truffleruby
52
+ os: windows
53
+
54
+ runs-on: ${{ matrix.os }}-latest
55
+
56
+ steps:
57
+ - uses: actions/checkout@v3
58
+
59
+ - name: Setup ruby ${{ matrix.ruby }}
60
+ uses: ruby/setup-ruby@v1
61
+ with:
62
+ ruby-version: ${{ matrix.ruby }}
63
+ bundler-cache: true
64
+
65
+ - run: bundle install
66
+
67
+ - run: bundle exec rake test
data/Gemfile CHANGED
@@ -1,16 +1,9 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- #ruby=2.0.0
4
-
5
3
  gemspec
6
4
 
7
5
  group :development do
8
- # statistics only on MRI 2.0 - avoid problems on older rubies
9
- gem "redcarpet", :platforms => [:mri_20]
10
- gem "simplecov", :platforms => [:mri_20]
11
- gem "coveralls", :platforms => [:mri_20]
12
-
13
- # rubinius support
14
- gem "rubysl-mutex_m", :platforms => [:rbx]
15
- gem "rubysl-singleton", :platforms => [:rbx]
6
+ gem "simplecov", :platforms => :ruby
7
+ gem "coveralls", :platforms => :ruby
8
+ gem "os"
16
9
  end
data/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # Gem empty
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/gem-empty.png)](http://rubygems.org/gems/gem-empty)
3
+ [![Version](https://img.shields.io/gem/v/gem-empty)](https://rubygems.org/gems/gem-empty)
4
+ [![Downloads Total](https://img.shields.io/gem/dt/gem-empty)](https://rubygems.org/gems/gem-empty)
5
+ [![Tests](https://github.com/rvm/gem-empty/workflows/tests/badge.svg)](https://github.com/rvm/gem-empty/actions?query=branch%3Amaster)
4
6
  [![Code Climate](https://codeclimate.com/github/rvm/gem-empty.png)](https://codeclimate.com/github/rvm/gem-empty)
5
- [![Coverage Status](https://coveralls.io/repos/rvm/gem-empty/badge.png?branch=master)](https://coveralls.io/r/rvm/gem-empty?branch=master)
6
- [![Build Status](https://travis-ci.org/rvm/gem-empty.png?branch=master)](https://travis-ci.org/rvm/gem-empty)
7
- [![Dependency Status](https://gemnasium.com/rvm/gem-empty.png)](https://gemnasium.com/rvm/gem-empty)
8
- [![Documentation](http://b.repl.ca/v1/yard-docs-blue.png)](http://rubydoc.info/gems/gem-empty/frames)
7
+ [![Coverage](https://coveralls.io/repos/rvm/gem-empty/badge.png?branch=master)](https://coveralls.io/r/rvm/gem-empty?branch=master)
8
+ [![Financial Contributors on Open Collective](https://opencollective.com/rvm/all/badge.svg?label=backers)](https://opencollective.com/rvm)
9
9
 
10
10
  Gem command to remove all gems from current `GEM_HOME`
11
11
 
data/gem-empty.gemspec CHANGED
@@ -6,8 +6,8 @@ require File.expand_path("../lib/gem-empty/version.rb", __FILE__)
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "gem-empty"
8
8
  s.version = GemEmpty::VERSION
9
- s.authors = ["Michal Papis", "Andy Fleener"]
10
- s.email = ["mpapis@gmail.com", "anfleene@gmail.com"]
9
+ s.authors = ["Michal Papis", "Andy Fleener", "Piotr Kuczynski"]
10
+ s.email = ["mpapis@gmail.com", "anfleene@gmail.com", "piotr.kuczynski@gmail.com"]
11
11
  s.homepage = "https://github.com/rvm/gem-empty"
12
12
  s.summary = "Gem command to remove all gems from current GEM_HOME."
13
13
  s.license = "Apache 2.0"
@@ -15,5 +15,4 @@ Gem::Specification.new do |s|
15
15
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
16
  s.add_development_dependency("rake")
17
17
  s.add_development_dependency("minitest")
18
- # s.add_development_dependency("smf-gem")
19
18
  end
@@ -4,12 +4,19 @@ require 'rubygems/uninstaller'
4
4
  require 'rubygems/version'
5
5
  require 'fileutils'
6
6
 
7
+ # rubygems plugin to empty GEM_HOME
7
8
  class EmptyCommand < Gem::Command
8
9
  attr_reader :options
9
10
 
11
+ GEM_REMOVAL_ERRORS = [
12
+ Gem::DependencyRemovalException,
13
+ Gem::InstallError,
14
+ Gem::GemNotInHomeException,
15
+ Gem::FilePermissionError,
16
+ ]
17
+
10
18
  def initialize
11
- super 'empty', 'Remove all gems from current GEM_HOME.'
12
- @default_options = { :install_dir => Gem.dir, :force => true, :executables => true }
19
+ super 'empty', description
13
20
  end
14
21
 
15
22
  def arguments # :nodoc:
@@ -25,34 +32,51 @@ class EmptyCommand < Gem::Command
25
32
  end
26
33
 
27
34
  def description # :nodoc:
28
- <<-DOC
29
- Remove all gems from current 'GEM_HOME'.
30
- DOC
35
+ "Remove all gems from current 'GEM_HOME'."
31
36
  end
32
37
 
33
38
  def execute(opts = {})
34
- @options = @default_options.merge(opts)
35
- uninstaller = Gem::Uninstaller.new(nil, options)
36
- uninstaller.remove_all(gem_dir_specs)
39
+ remove_gems(opts)
40
+ rescue *GEM_REMOVAL_ERRORS => exception
41
+ alert_error "#{exception.class}: #{exception.message}"
42
+ end
37
43
 
38
- # Remove any Git gems installed via bundler
39
- FileUtils.rm_rf( File.join( options[:install_dir] ,'bundler','gems' ) )
44
+ private
40
45
 
41
- rescue Gem::DependencyRemovalException,
42
- Gem::InstallError,
43
- Gem::GemNotInHomeException,
44
- Gem::FilePermissionError => e
46
+ # A method so it's evaluated as late as possible
47
+ # giving chance to change Gem.dir
48
+ def self.default_options
49
+ {
50
+ :install_dir => Gem.dir,
51
+ :force => true,
52
+ :executables => true,
53
+ }
54
+ end
45
55
 
46
- alert_error "#{e.class}: #{e.message}"
56
+ def remove_gems(opts)
57
+ @options = self.class.default_options.merge(opts)
58
+ remove_rubygems_gems
59
+ remove_bundler_gems
47
60
  end
48
61
 
49
- private
62
+ def remove_rubygems_gems
63
+ uninstaller = Gem::Uninstaller.new(nil, options)
64
+ uninstaller.remove_all(gem_dir_specs)
65
+ end
66
+
67
+ def remove_bundler_gems
68
+ FileUtils.rm_rf(File.join(gem_install_dir, 'bundler', 'gems'))
69
+ end
50
70
 
51
71
  def gem_dir_specs
52
72
  @gem_dir_specs ||=
53
- GemEmpty::Specification.installed_gems.select do |spec|
54
- File.exists?( File.join( options[:install_dir], 'gems', spec.full_name ) )
55
- end
73
+ GemEmpty::Specification.installed_gems.select do |spec|
74
+ File.exist?(File.join(gem_install_dir, 'gems', spec.full_name))
75
+ end
76
+ end
77
+
78
+ def gem_install_dir
79
+ options[:install_dir]
56
80
  end
57
81
 
58
82
  end
@@ -1,17 +1,19 @@
1
1
  module GemEmpty
2
+ # monkey patch rubygems specification to easily find gem version
2
3
  module Specification
3
4
  def self.installed_gems
4
- if Gem::VERSION > '1.8' then
5
+ if Gem::VERSION > '1.8'
5
6
  Gem::Specification.to_a
6
7
  else
7
8
  Gem.source_index.map{|name,spec| spec}
8
9
  end
9
10
  end
10
- def self.find(name = "gem-empty")
11
- @gem_empty_spec ||= installed_gems.find{|spec| spec.name == name}
11
+ def self.find_gem_spec(name)
12
+ installed_gems.find{|spec| spec.name == name}
12
13
  end
13
- def self.version
14
- find ? find.version.to_s : nil
14
+ def self.gem_loaded?(name, version)
15
+ spec = find_gem_spec(name)
16
+ spec && spec.version.to_s == version
15
17
  end
16
18
  end
17
19
  end
@@ -1,3 +1,3 @@
1
1
  module GemEmpty
2
- VERSION = "1.1.1"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -5,10 +5,9 @@ called_path, called_version = __FILE__.match(/^(.*\/gem-empty-([^\/]+)\/lib).*$/
5
5
 
6
6
  # continue only if loaded and called versions all the same, and not shared gems disabled in bundler
7
7
  if
8
- ( $:.include?(called_path) || GemEmpty::Specification.version == called_version ) and
8
+ ( $:.include?(called_path) || GemEmpty::Specification.gem_loaded?("gem-empty", called_version) ) and
9
9
  ( !defined?(Bundler) || ( defined?(Bundler) && Bundler::SharedHelpers.in_bundle? && !Bundler.settings[:disable_shared_gems]) )
10
-
10
+ then
11
11
  require 'gem-empty/command'
12
12
  Gem::CommandManager.instance.register_command :empty
13
-
14
13
  end
@@ -4,9 +4,11 @@ require 'rubygems/installer'
4
4
  require 'rubygems/user_interaction'
5
5
  require 'rubygems/mock_gem_ui'
6
6
 
7
- class Gem::Specification
8
- def self.remove_spec spec
9
- true # fake the removal from _all
7
+ if RUBY_VERSION < "2.3"
8
+ class Gem::Specification
9
+ def self.remove_spec spec
10
+ true # fake the removal from _all
11
+ end
10
12
  end
11
13
  end
12
14
 
@@ -18,11 +20,11 @@ describe EmptyCommand do
18
20
  end
19
21
 
20
22
  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)
23
+ _(subject.arguments.class).must_equal(String)
24
+ _(subject.usage.class).must_equal(String)
25
+ _(subject.defaults_str.class).must_equal(String)
26
+ _(subject.description.class).must_equal(String)
27
+ _(subject.program_name.class).must_equal(String)
26
28
  end
27
29
 
28
30
  describe "gem-empty" do
@@ -33,7 +35,8 @@ describe EmptyCommand do
33
35
  file.unlink
34
36
  @ui = Gem::MockGemUi.new
35
37
  @found_minitest = Gem::Specification.find_by_name('minitest')
36
- installer = Gem::Installer.new(@found_minitest.cache_file, :version => @found_minitest.version, :install_dir => @test_path)
38
+ package = RUBY_VERSION >= "2.3" ? Gem::Package.new(@found_minitest.cache_file) : @found_minitest.cache_file
39
+ installer = Gem::Installer.new(package, :version => @found_minitest.version, :install_dir => @test_path)
37
40
  bundler_git_gems_path = File.join(@test_path,'bundler','gems')
38
41
  FileUtils.mkdir_p(bundler_git_gems_path)
39
42
  @git_gem_file = File.join(bundler_git_gems_path, 'git-test')
@@ -49,24 +52,24 @@ describe EmptyCommand do
49
52
  end
50
53
 
51
54
  it "removes gems" do
52
- File.exist?(File.join(@test_path, "gems", @found_minitest.full_name)).must_equal(true)
55
+ _(File.exist?(File.join(@test_path, "gems", @found_minitest.full_name))).must_equal(true)
53
56
  use_ui @ui do
54
57
  subject.execute(:install_dir => @test_path)
55
58
  end
56
- File.exist?(File.join(@test_path, "gems", @found_minitest.full_name)).must_equal(false)
57
- @ui.output.must_match(
59
+ _(File.exist?(File.join(@test_path, "gems", @found_minitest.full_name))).must_equal(false)
60
+ _(@ui.output).must_match(
58
61
  /Successfully uninstalled minitest-/
59
62
  )
60
- @ui.error.must_equal("")
63
+ _(@ui.error).must_equal("")
61
64
  end
62
65
 
63
66
  it "removes git gems installed via bundler" do
64
- File.exist?(@git_gem_file).must_equal(true)
67
+ _(File.exist?(@git_gem_file)).must_equal(true)
65
68
  use_ui @ui do
66
69
  subject.execute(:install_dir => @test_path)
67
70
  end
68
- File.exist?(@git_gem_file).must_equal(false)
69
- @ui.error.must_equal("")
71
+ _(File.exist?(@git_gem_file)).must_equal(false)
72
+ _(@ui.error).must_equal("")
70
73
  end
71
74
 
72
75
  it "fails gems" do
@@ -74,10 +77,10 @@ describe EmptyCommand do
74
77
  use_ui @ui do
75
78
  subject.execute(:install_dir => @test_path)
76
79
  end
77
- File.exist?(File.join(@test_path, "gems", @found_minitest.full_name)).must_equal(true)
80
+ _(File.exist?(File.join(@test_path, "gems", @found_minitest.full_name))).must_equal(true)
78
81
  File.chmod(0755, File.join(@test_path) )
79
- @ui.output.must_equal("")
80
- @ui.error.must_match(
82
+ _(@ui.output).must_equal("")
83
+ _(@ui.error).must_match(
81
84
  /ERROR: Gem::FilePermissionError: You don't have write permissions for the .* directory/
82
85
  )
83
86
  end
@@ -86,8 +89,8 @@ describe EmptyCommand do
86
89
 
87
90
  it "finds gem executables" do
88
91
  subject.stub :options, {:install_dir => Gem.dir } do
89
- subject.send(:gem_dir_specs).map{|spec| spec.name}.must_include('minitest')
92
+ _(subject.send(:gem_dir_specs).map{|spec| spec.name}).must_include('minitest')
90
93
  end
91
94
  end
92
95
 
93
- end
96
+ end
@@ -9,15 +9,18 @@ describe GemEmpty::Specification do
9
9
  end
10
10
 
11
11
  it "finds specification" do
12
- GemEmpty::Specification.find("gem-empty").name.must_equal("gem-empty")
12
+ _(GemEmpty::Specification.find_gem_spec("gem-empty").name).must_equal("gem-empty")
13
13
  end
14
14
 
15
- it "gets specification version" do
16
- GemEmpty::Specification.version.must_equal(GemEmpty::VERSION)
15
+ it "does not find imaginary gems" do
16
+ _(GemEmpty::Specification.find_gem_spec("imaginary-gem")).must_be_nil
17
17
  end
18
18
 
19
- it "does not find imaginary gems" do
20
- GemEmpty::Specification.find("imaginary-gem").must_equal(nil)
19
+ it "confirms specification version" do
20
+ _(GemEmpty::Specification.gem_loaded?("gem-empty", GemEmpty::VERSION)).must_equal true
21
21
  end
22
22
 
23
- end
23
+ it "does not confirms specification version" do
24
+ _(GemEmpty::Specification.gem_loaded?("gem-empty", "0.0.0")).wont_equal true
25
+ end
26
+ end
data/test/test_helper.rb CHANGED
@@ -1,6 +1,7 @@
1
- if
2
- RUBY_VERSION == "2.0.0" # check Gemfile
3
- then
1
+ require "os"
2
+
3
+ # Coverage only on newer ruby to avoid problems with older versions
4
+ if RUBY_VERSION == "3.0.0" && !OS.windows? && !OS.mac?
4
5
  require "coveralls"
5
6
  require "simplecov"
6
7
 
metadata CHANGED
@@ -1,55 +1,56 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem-empty
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Papis
8
8
  - Andy Fleener
9
+ - Piotr Kuczynski
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2015-04-23 00:00:00.000000000 Z
13
+ date: 2023-05-26 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: rake
16
17
  requirement: !ruby/object:Gem::Requirement
17
18
  requirements:
18
- - - '>='
19
+ - - ">="
19
20
  - !ruby/object:Gem::Version
20
21
  version: '0'
21
22
  type: :development
22
23
  prerelease: false
23
24
  version_requirements: !ruby/object:Gem::Requirement
24
25
  requirements:
25
- - - '>='
26
+ - - ">="
26
27
  - !ruby/object:Gem::Version
27
28
  version: '0'
28
29
  - !ruby/object:Gem::Dependency
29
30
  name: minitest
30
31
  requirement: !ruby/object:Gem::Requirement
31
32
  requirements:
32
- - - '>='
33
+ - - ">="
33
34
  - !ruby/object:Gem::Version
34
35
  version: '0'
35
36
  type: :development
36
37
  prerelease: false
37
38
  version_requirements: !ruby/object:Gem::Requirement
38
39
  requirements:
39
- - - '>='
40
+ - - ">="
40
41
  - !ruby/object:Gem::Version
41
42
  version: '0'
42
43
  description:
43
44
  email:
44
45
  - mpapis@gmail.com
45
46
  - anfleene@gmail.com
47
+ - piotr.kuczynski@gmail.com
46
48
  executables: []
47
49
  extensions: []
48
50
  extra_rdoc_files: []
49
51
  files:
50
- - .gitignore
51
- - .travis.yml
52
- - Changelog.md
52
+ - ".github/workflows/tests.yaml"
53
+ - ".gitignore"
53
54
  - Gemfile
54
55
  - LICENSE
55
56
  - README.md
@@ -72,17 +73,16 @@ require_paths:
72
73
  - lib
73
74
  required_ruby_version: !ruby/object:Gem::Requirement
74
75
  requirements:
75
- - - '>='
76
+ - - ">="
76
77
  - !ruby/object:Gem::Version
77
78
  version: '0'
78
79
  required_rubygems_version: !ruby/object:Gem::Requirement
79
80
  requirements:
80
- - - '>='
81
+ - - ">="
81
82
  - !ruby/object:Gem::Version
82
83
  version: '0'
83
84
  requirements: []
84
- rubyforge_project:
85
- rubygems_version: 2.4.3
85
+ rubygems_version: 3.0.3.1
86
86
  signing_key:
87
87
  specification_version: 4
88
88
  summary: Gem command to remove all gems from current GEM_HOME.
data/.travis.yml DELETED
@@ -1,21 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 1.8.7
4
- - 1.9.2
5
- - 1.9.3
6
- - 2.0.0
7
- - 2.1
8
- - 2.2
9
- - ruby-head
10
- - jruby
11
- - rbx
12
- notifications:
13
- irc:
14
- channels:
15
- - "irc.freenode.org#rvm-test"
16
- email:
17
- recipients:
18
- - mpapis@gmail.com
19
- on_failure: change
20
- matrix:
21
- fast_finish: true
data/Changelog.md DELETED
@@ -1,6 +0,0 @@
1
- # Changelog
2
-
3
- ## 1.0.0
4
- date: 2013-12-20
5
-
6
- - stable release