push_safety 0.0.1
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.
- data/README.rdoc +78 -0
- data/lib/push_safety/version.rb +3 -0
- data/lib/push_safety.rb +2 -0
- data/lib/rubygems_plugin.rb +62 -0
- metadata +101 -0
data/README.rdoc
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
= push_safety
|
2
|
+
|
3
|
+
* http://github.com/jdleesmiller/push_safety
|
4
|
+
|
5
|
+
== SYNOPSIS
|
6
|
+
|
7
|
+
The <tt>gem push</tt> command makes it incredibly easy to publish your gems...
|
8
|
+
maybe a little too easy. PushSafety is a RubyGems plugin that refuses to push a
|
9
|
+
gem unless it is on a whitelist. Add your open source gems to your whitelist,
|
10
|
+
and keep your private gems safe from accidental pushes.
|
11
|
+
|
12
|
+
=== Usage
|
13
|
+
|
14
|
+
1. Create a whitelist file. The default location is <tt>~/.gem_push_safety</tt>.
|
15
|
+
Separate gem names with whitespace (e.g. one gem name per line). For example,
|
16
|
+
if you work on open source gems +foo+ and +bar+, your file should read
|
17
|
+
foo
|
18
|
+
bar
|
19
|
+
2. Use <tt>gem push</tt> as normal. If you try to push a gem that is not in
|
20
|
+
your whitelist, it gives an error.
|
21
|
+
|
22
|
+
You can use a different file for the whitelist; see <tt>gem help push</tt> once
|
23
|
+
you have installed PushSafety.
|
24
|
+
|
25
|
+
== REQUIREMENTS
|
26
|
+
|
27
|
+
You must have ruby and rubygems installed.
|
28
|
+
|
29
|
+
PushSafety has been tested on:
|
30
|
+
* x86-linux (Ubuntu 10.10) with Ruby 1.8.7p299 and rubygems 1.3.7
|
31
|
+
* x86-linux (rvm) with Ruby 1.9.2p0 (2010-08-18 revision 29036) and rubygems
|
32
|
+
1.3.7
|
33
|
+
|
34
|
+
PushSafety has not yet been tested on Windows.
|
35
|
+
|
36
|
+
== INSTALLATION
|
37
|
+
|
38
|
+
sudo gem install push_safety
|
39
|
+
|
40
|
+
== DEVELOPMENT
|
41
|
+
|
42
|
+
To get the source and development depencies:
|
43
|
+
git clone git://github.com/jdleesmiller/push_safety.git
|
44
|
+
cd push_safety
|
45
|
+
gem build push_safety.gemspec
|
46
|
+
sudo gem install push_safety-X.X.X.gem --development
|
47
|
+
where X.X.X is the current version.
|
48
|
+
|
49
|
+
== HISTORY
|
50
|
+
|
51
|
+
<em>0.0.1</em>
|
52
|
+
* first release
|
53
|
+
|
54
|
+
== LICENSE
|
55
|
+
|
56
|
+
(The MIT License)
|
57
|
+
|
58
|
+
Copyright (c) 2010 John Lees-Miller
|
59
|
+
|
60
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
61
|
+
a copy of this software and associated documentation files (the
|
62
|
+
'Software'), to deal in the Software without restriction, including
|
63
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
64
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
65
|
+
permit persons to whom the Software is furnished to do so, subject to
|
66
|
+
the following conditions:
|
67
|
+
|
68
|
+
The above copyright notice and this permission notice shall be
|
69
|
+
included in all copies or substantial portions of the Software.
|
70
|
+
|
71
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
72
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
73
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
74
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
75
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
76
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
77
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
78
|
+
|
data/lib/push_safety.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'rubygems/command_manager'
|
2
|
+
require 'rubygems/commands/push_command'
|
3
|
+
require 'rubygems/format'
|
4
|
+
|
5
|
+
#
|
6
|
+
# Patch the PushCommand to first check the whitelist.
|
7
|
+
#
|
8
|
+
# You can technically only push one gem at once, but if you pass several gems,
|
9
|
+
# we check that they are all on the whitelist.
|
10
|
+
#
|
11
|
+
class Gem::Commands::PushCommand
|
12
|
+
# If this gets loaded twice, it will do strange things.
|
13
|
+
if respond_to?(:unsafe_execute)
|
14
|
+
raise "PushSafety has been loaded twice; something is wrong."
|
15
|
+
end
|
16
|
+
|
17
|
+
alias unsafe_description description
|
18
|
+
alias unsafe_initialize initialize
|
19
|
+
alias unsafe_execute execute
|
20
|
+
|
21
|
+
def initialize
|
22
|
+
unsafe_initialize
|
23
|
+
|
24
|
+
default_file = File.join(Gem.user_home, '.gem_push_safety')
|
25
|
+
defaults.merge!(:push_safety_file => default_file)
|
26
|
+
|
27
|
+
add_option :PushSafety, '--push-safety-file STRING',
|
28
|
+
"whitelist file (default #{default_file})" do |value, options|
|
29
|
+
options[:push_safety_file] = value
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def description
|
34
|
+
"#{unsafe_description} (with PushSafety plugin)"
|
35
|
+
end
|
36
|
+
|
37
|
+
def execute
|
38
|
+
white_list_file = options[:push_safety_file]
|
39
|
+
unless File.exists?(white_list_file)
|
40
|
+
raise "The whitelist file '#{white_list_file}' does not exist;"\
|
41
|
+
" PushSafety will not allow you to push any gems."
|
42
|
+
end
|
43
|
+
|
44
|
+
white_list = File.read(white_list_file).split(/\s+/)
|
45
|
+
if white_list.empty? || white_list.all?{|f| f.empty?}
|
46
|
+
raise "The whitelist file '#{white_list_file}' is empty;"\
|
47
|
+
" PushSafety will not allow you to push any gems."
|
48
|
+
end
|
49
|
+
|
50
|
+
grey_list = get_all_gem_names.map {|gem_file|
|
51
|
+
Gem::Format.from_file_by_path(gem_file).spec.name}
|
52
|
+
black_list = grey_list - white_list
|
53
|
+
|
54
|
+
unless black_list.empty?
|
55
|
+
raise "The following gems are not on your PushSafety whitelist:"\
|
56
|
+
"\n#{black_list.join("\n")}\nYour whitelist file is #{white_list_file}."
|
57
|
+
end
|
58
|
+
|
59
|
+
unsafe_execute
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: push_safety
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- John Lees-Miller
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-12-06 00:00:00 +00:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: gemma
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 23
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 0
|
33
|
+
- 0
|
34
|
+
version: 1.0.0
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
hash: 15
|
38
|
+
segments:
|
39
|
+
- 1
|
40
|
+
- 0
|
41
|
+
version: "1.0"
|
42
|
+
type: :development
|
43
|
+
version_requirements: *id001
|
44
|
+
description: |
|
45
|
+
The gem push command makes it incredibly easy to publish your gems... maybe a
|
46
|
+
little too easy. PushSafety is a RubyGems plugin that refuses to push a gem
|
47
|
+
unless it is on a whitelist. Add your open source gems to your whitelist, and
|
48
|
+
keep your private gems safe from accidental pushes.
|
49
|
+
|
50
|
+
email:
|
51
|
+
- jdleesmiller@gmail.com
|
52
|
+
executables: []
|
53
|
+
|
54
|
+
extensions: []
|
55
|
+
|
56
|
+
extra_rdoc_files:
|
57
|
+
- README.rdoc
|
58
|
+
files:
|
59
|
+
- lib/push_safety/version.rb
|
60
|
+
- lib/push_safety.rb
|
61
|
+
- lib/rubygems_plugin.rb
|
62
|
+
- README.rdoc
|
63
|
+
has_rdoc: true
|
64
|
+
homepage: https://github.com/jdleesmiller/push_safety
|
65
|
+
licenses: []
|
66
|
+
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options:
|
69
|
+
- --main
|
70
|
+
- README.rdoc
|
71
|
+
- --title
|
72
|
+
- push_safety-0.0.1 Documentation
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
hash: 3
|
81
|
+
segments:
|
82
|
+
- 0
|
83
|
+
version: "0"
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
hash: 3
|
90
|
+
segments:
|
91
|
+
- 0
|
92
|
+
version: "0"
|
93
|
+
requirements: []
|
94
|
+
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 1.3.7
|
97
|
+
signing_key:
|
98
|
+
specification_version: 3
|
99
|
+
summary: Avoid accidentally pushing a private gem to rubygems.org (reduce paranoia).
|
100
|
+
test_files: []
|
101
|
+
|