gem-ban 1.5.2 → 1.5.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,17 +2,21 @@
2
2
 
3
3
  ## Installation
4
4
 
5
- gem install gem-ban
6
-
5
+ # `gem install gem-ban`
6
+
7
7
 
8
8
  ## Usage
9
9
 
10
- gem ban nokogiri
10
+ ### `gem ban add nokogiri`
11
+ Prevent nokogiri from installing, but I still :heart: you anyhow mr. tenderfoot.
12
+
13
+ ### `gem ban remove nokogiri`
14
+ See, I mean it.
11
15
 
12
- gem unban nokogiri
13
-
14
- gem listban
16
+ ### `gem ban list`
17
+ If you don't believe me, look for yourself.
15
18
 
19
+ I still want my mixtape back though.
16
20
 
17
21
  ## License
18
22
 
@@ -1,26 +1,19 @@
1
1
  require 'rubygems/exceptions'
2
2
 
3
3
  module Gem::Ban
4
- VERSION = Version = '1.5.2'
4
+ VERSION = Version = '1.5.3'
5
5
 
6
6
  def self.ban(gem)
7
7
  raise Gem::Exception, "The gem #{gem} is already banned." if banned?(gem)
8
8
 
9
- _contents[:banned] = if _contents[:banned].is_a?(String)
10
- [_contents[:banned], gem.to_s].join(' ')
11
- else
12
- gem.to_s
13
- end
14
- write
9
+ banned += gem
15
10
  end
16
11
 
17
12
  def self.unban(gem)
18
13
  raise Gem::Exception, "There are no currently banned gems." unless banned
19
14
  raise Gem::Exception, "The gem #{gem} is not currently banned." unless banned?(gem)
20
15
 
21
- _contents[:banned].slice!(gem).strip!
22
- _contents.delete(:banned) if _contents[:banned].empty?
23
- write
16
+ banned -= gem
24
17
  end
25
18
 
26
19
  def self.banned?(gem)
@@ -28,16 +21,17 @@ module Gem::Ban
28
21
  end
29
22
 
30
23
  def self.banned
31
- _contents[:banned].is_a?(String) ? _contents[:banned].split(' ') : []
24
+ read[:banned].split ' ' || []
32
25
  end
33
26
 
34
27
  private
35
- def self._contents
36
- if ! defined? @@contents
37
- read
38
- @@contents ||= {}
39
- end
40
- @@contents
28
+
29
+ def self.banned=(new_banned)
30
+ write(if new_banned.nil? || new_banned.empty?
31
+ read.(delete :banned)
32
+ else
33
+ read.(merge! :banned => (@banned=new_banned).join(' '))
34
+ end)
41
35
  end
42
36
 
43
37
  def self.filename
@@ -46,10 +40,14 @@ private
46
40
 
47
41
  def self.read
48
42
  require 'yaml'
49
- @@contents=YAML.load(File.read(filename))
43
+ YAML.load(File.read(filename))
50
44
  end
51
45
 
52
- def self.write
53
- File.open(filename, 'w') { |f| f.write @@contents.to_yaml }
46
+ # dont make changes to ~/.gemrc while this is loaded
47
+ # needs a filesystem monitor callback to call read
48
+ def self.write(contents)
49
+ require 'yaml'
50
+ File.open(filename, 'w') { |f| f.write contents.to_yaml }
51
+ contents
54
52
  end
55
53
  end
@@ -2,11 +2,16 @@ require 'rubygems/exceptions'
2
2
  require 'rubygems/installer'
3
3
  require 'rubygems/ban'
4
4
 
5
- # hack
5
+ # bouncy hacks
6
+ # bevhavior can be overridden using --force
6
7
  class Gem::Installer
7
- alias :old_ensure_dependency :ensure_dependency
8
8
 
9
- # can be overridden using --force
9
+ alias :old_installation_satisfies_dependency? :installation_satisfies_dependency?
10
+ def installation_satisfies_dependency?(dependency)
11
+ (@force || Gem::Ban.banned?(gem_name = dependency.name.split('gem')[1])) && old_installation_satisfies_dependency?(dependency)
12
+ end
13
+
14
+ alias :old_ensure_dependency :ensure_dependency
10
15
  def ensure_dependency(spec, dependency)
11
16
  unless @force
12
17
  gem_name = dependency.name.split('gem')[1]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem-ban
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.5.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-31 00:00:00.000000000 Z
12
+ date: 2012-04-06 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Different places have different requirements, this aims to help ease
15
15
  concerns
@@ -46,7 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
46
46
  version: '0'
47
47
  requirements: []
48
48
  rubyforge_project:
49
- rubygems_version: 1.8.17
49
+ rubygems_version: 1.8.21
50
50
  signing_key:
51
51
  specification_version: 3
52
52
  summary: gem-ban, prevent certain gems from installation