gem-empty 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e7980f4fa51e450012e7439abd3a67642ce7bb94
4
+ data.tar.gz: 7a707094189fb61e136f2af8c958c6176fccf670
5
+ SHA512:
6
+ metadata.gz: 7fbcb2fbd35eba9ddff7d117e02582728218b4ec47cf442c859272422106f6b0e766eeb8c288e7cf37e1784bdba8ee2eaac7a33e1135dced8d4017c7c38541a9
7
+ data.tar.gz: 72fba77132cf20d285943579880610e82666682d00c5868a75267a4ad37c5521697b9574bedf85d8190d51465fce2f5c0960331f0913bcafb1364f119058714a
@@ -0,0 +1,3 @@
1
+ Gemfile.lock
2
+ coverage/
3
+ *.gem
@@ -0,0 +1,22 @@
1
+ language: ruby
2
+ rvm:
3
+ - jruby
4
+ - ruby-head
5
+ - 1.8.7
6
+ - 1.9.2
7
+ - 1.9.3
8
+ - 2.0.0
9
+ - 2.1.0
10
+ - rbx
11
+ notifications:
12
+ irc:
13
+ channels:
14
+ - "irc.freenode.org#rvm-test"
15
+ email:
16
+ recipients:
17
+ - mpapis@gmail.com
18
+ on_failure: change
19
+ matrix:
20
+ allow_failures:
21
+ - rvm: rbx
22
+ fast_finish: true
@@ -0,0 +1,4 @@
1
+ # Changelog
2
+
3
+ ## still in testing
4
+ date: 2013-12-20
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "https://rubygems.org"
2
+
3
+ #ruby=2.0.0
4
+
5
+ gemspec
6
+
7
+ 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]
16
+ end
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2013-2014 Michal Papis
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,16 @@
1
+ # Gem wrappers
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/gem-empty.png)](http://rubygems.org/gems/gem-empty)
4
+ [![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)
9
+
10
+ Gem command to remove all gems from current `GEM_HOME`
11
+
12
+ ## Usage
13
+
14
+ ```bash
15
+ gem empty
16
+ ```
@@ -0,0 +1,9 @@
1
+ require "rake/testtask"
2
+
3
+ task :default => [:test]
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.verbose = true
7
+ t.libs.push("demo", "test")
8
+ t.pattern = "test/**/*_test.rb"
9
+ end
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- encoding: utf-8 -*-
3
+
4
+ require File.expand_path("../lib/gem-empty/version.rb", __FILE__)
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "gem-empty"
8
+ s.version = GemEmpty::VERSION
9
+ s.authors = ["Michal Papis"]
10
+ s.email = ["mpapis@gmail.com"]
11
+ s.homepage = "https://github.com/rvm/gem-wrappers"
12
+ s.summary = "Gem command to remove all gems from current GEM_HOME."
13
+ s.license = "Apache 2.0"
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.add_development_dependency("rake")
17
+ s.add_development_dependency("minitest")
18
+ # s.add_development_dependency("smf-gem")
19
+ end
@@ -0,0 +1,59 @@
1
+ require 'rubygems/command_manager'
2
+ require 'rubygems/uninstaller'
3
+ require 'rubygems/version'
4
+
5
+ class EmptyCommand < Gem::Command
6
+ def initialize
7
+ super 'empty', 'remove all gems from current GEM_HOME.'
8
+ @failed = {}
9
+ @worked = []
10
+ end
11
+
12
+ def arguments # :nodoc:
13
+ "empty remove all gems from current GEM_HOME."
14
+ end
15
+
16
+ def usage # :nodoc:
17
+ "#{program_name}"
18
+ end
19
+
20
+ def defaults_str # :nodoc:
21
+ ""
22
+ end
23
+
24
+ def description # :nodoc:
25
+ <<-DOC
26
+ Remove all gems from current 'GEM_HOME'.
27
+ DOC
28
+ end
29
+
30
+ def execute(options = {})
31
+ options = {:force => true, :executables => true }.merge(options)
32
+ uninstaller = Gem::Uninstaller.new(nil, options)
33
+ uninstaller.remove_all(gem_dir_specs)
34
+
35
+ rescue Gem::DependencyRemovalException,
36
+ Gem::InstallError,
37
+ Gem::GemNotInHomeException,
38
+ Gem::FilePermissionError => e
39
+
40
+ say "\t#{e.class}: #{e.message}"
41
+ end
42
+
43
+ private
44
+
45
+ def gem_dir_specs
46
+ @gem_dir_specs ||=
47
+ installed_gems.select do |spec|
48
+ File.exists?( File.join( Gem.dir, 'gems', spec.full_name ) )
49
+ end
50
+ end
51
+
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
+ end
@@ -0,0 +1,17 @@
1
+ module GemEmpty
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
12
+ end
13
+ def self.version
14
+ find ? find.version.to_s : nil
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module GemEmpty
2
+ VERSION = "0.9.0"
3
+ end
@@ -0,0 +1,14 @@
1
+ # Simulate require_relative - it's required as the plugin can be called in wrong version or from bundler.
2
+ require File.expand_path('../gem-empty/specification.rb', __FILE__)
3
+
4
+ called_path, called_version = __FILE__.match(/^(.*\/gem-empty-([^\/]+)\/lib).*$/)[1..2]
5
+
6
+ # continue only if loaded and called versions all the same, and not shared gems disabled in bundler
7
+ if
8
+ ( $:.include?(called_path) || GemEmpty::Specification.version == called_version ) and
9
+ ( !defined?(Bundler) || ( defined?(Bundler) && Bundler::SharedHelpers.in_bundle? && !Bundler.settings[:disable_shared_gems]) )
10
+
11
+ require 'gem-empty/command'
12
+ Gem::CommandManager.instance.register_command :empty
13
+
14
+ end
@@ -0,0 +1,43 @@
1
+ require 'test_helper'
2
+ require 'gem-empty/command'
3
+ require 'rubygems/installer'
4
+
5
+ class Gem::Specification
6
+ def self.remove_spec spec
7
+ true # fake the removal from _all
8
+ end
9
+ end
10
+
11
+ describe EmptyCommand do
12
+ subject do
13
+ EmptyCommand.new
14
+ end
15
+
16
+ describe "wrappers" do
17
+ before do
18
+ file = Tempfile.new('command-wrappers')
19
+ @test_path = file.path
20
+ file.close
21
+ 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
25
+ subject.instance_variable_set(:@gem_dir_specs, [installer.spec])
26
+ end
27
+
28
+ after do
29
+ FileUtils.rm_rf(@test_path)
30
+ end
31
+
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)
36
+ end
37
+ end
38
+
39
+ it "finds gem executables" do
40
+ subject.send(:gem_dir_specs).map{|spec| spec.name}.must_include('minitest')
41
+ end
42
+
43
+ end
@@ -0,0 +1,15 @@
1
+ require 'test_helper'
2
+ require 'gem-empty/specification'
3
+ require 'gem-empty/version'
4
+
5
+ describe GemEmpty::Specification do
6
+
7
+ it "finds specification" do
8
+ GemEmpty::Specification.find.name.must_equal("gem-empty")
9
+ end
10
+
11
+ it "gets specification version" do
12
+ GemEmpty::Specification.version.must_equal(GemEmpty::VERSION)
13
+ end
14
+
15
+ end
@@ -0,0 +1,21 @@
1
+ if
2
+ RUBY_VERSION == "2.0.0" # check Gemfile
3
+ then
4
+ require "coveralls"
5
+ require "simplecov"
6
+
7
+ SimpleCov.start do
8
+ formatter SimpleCov::Formatter::MultiFormatter[
9
+ SimpleCov::Formatter::HTMLFormatter,
10
+ Coveralls::SimpleCov::Formatter,
11
+ ]
12
+ command_name "Unit Tests"
13
+ add_filter "/test/"
14
+ add_filter "/demo/"
15
+ end
16
+
17
+ Coveralls.noisy = true unless ENV['CI']
18
+ end
19
+
20
+ require 'minitest/autorun'
21
+ require 'minitest/unit'
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gem-empty
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - Michal Papis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description:
42
+ email:
43
+ - mpapis@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - .travis.yml
50
+ - Changelog.md
51
+ - Gemfile
52
+ - LICENSE
53
+ - README.md
54
+ - Rakefile
55
+ - gem-empty.gemspec
56
+ - lib/gem-empty/command.rb
57
+ - lib/gem-empty/specification.rb
58
+ - lib/gem-empty/version.rb
59
+ - lib/rubygems_plugin.rb
60
+ - test/gem-wrappers/command_test.rb
61
+ - test/gem-wrappers/specification_and_version_test.rb
62
+ - test/test_helper.rb
63
+ homepage: https://github.com/rvm/gem-wrappers
64
+ licenses:
65
+ - Apache 2.0
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.0.14
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: Gem command to remove all gems from current GEM_HOME.
87
+ test_files:
88
+ - test/gem-wrappers/command_test.rb
89
+ - test/gem-wrappers/specification_and_version_test.rb
90
+ - test/test_helper.rb