htauth 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/CONTRIBUTING.md +46 -0
- data/HISTORY.md +36 -0
- data/Manifest.txt +45 -0
- data/{README → README.md} +21 -22
- data/Rakefile +17 -0
- data/bin/htpasswd-ruby +5 -5
- data/lib/htauth/algorithm.rb +1 -8
- data/lib/htauth/crypt.rb +1 -1
- data/lib/htauth/digest.rb +5 -2
- data/lib/htauth/digest_entry.rb +5 -4
- data/lib/htauth/digest_file.rb +1 -1
- data/lib/htauth/errors.rb +10 -0
- data/lib/htauth/file.rb +1 -1
- data/lib/htauth/md5.rb +2 -0
- data/lib/htauth/passwd.rb +10 -4
- data/lib/htauth/passwd_entry.rb +2 -1
- data/lib/htauth/passwd_file.rb +64 -63
- data/lib/htauth/plaintext.rb +12 -11
- data/lib/htauth/version.rb +8 -9
- data/lib/htauth.rb +14 -4
- data/spec/crypt_spec.rb +10 -12
- data/spec/digest_entry_spec.rb +20 -21
- data/spec/digest_file_spec.rb +11 -12
- data/spec/digest_spec.rb +23 -23
- data/spec/md5_spec.rb +2 -2
- data/spec/passwd_entry_spec.rb +47 -48
- data/spec/passwd_file_spec.rb +12 -13
- data/spec/passwd_spec.rb +37 -38
- data/spec/plaintext_spec.rb +4 -7
- data/spec/sha1_spec.rb +3 -5
- data/spec/spec_helper.rb +8 -4
- data/spec/test.add.digest +3 -0
- data/spec/test.add.passwd +3 -0
- data/spec/test.delete.digest +1 -0
- data/spec/test.delete.passwd +1 -0
- data/spec/test.original.digest +2 -0
- data/spec/test.original.passwd +2 -0
- data/spec/test.update.digest +2 -0
- data/spec/test.update.passwd +2 -0
- data/tasks/default.rake +276 -0
- data/tasks/this.rb +214 -0
- metadata +131 -75
- data/HISTORY +0 -26
- data/gemspec.rb +0 -43
- data/tasks/announce.rake +0 -38
- data/tasks/config.rb +0 -98
- data/tasks/distribution.rake +0 -46
- data/tasks/documentation.rake +0 -31
- data/tasks/rspec.rake +0 -29
- data/tasks/rubyforge.rake +0 -59
- data/tasks/utils.rb +0 -80
data/spec/passwd_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'htauth/passwd'
|
3
3
|
require 'tempfile'
|
4
4
|
|
@@ -41,8 +41,8 @@ describe HTAuth::Passwd do
|
|
41
41
|
begin
|
42
42
|
@htauth.run([ "-h" ])
|
43
43
|
rescue SystemExit => se
|
44
|
-
se.status.
|
45
|
-
@stdout.string.
|
44
|
+
se.status.must_equal 1
|
45
|
+
@stdout.string.must_match( /passwordfile username/m )
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -50,8 +50,8 @@ describe HTAuth::Passwd do
|
|
50
50
|
begin
|
51
51
|
@htauth.run([ "--version" ])
|
52
52
|
rescue SystemExit => se
|
53
|
-
se.status.
|
54
|
-
@stdout.string.
|
53
|
+
se.status.must_equal 1
|
54
|
+
@stdout.string.must_match( /version #{HTAuth::VERSION}/)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -62,11 +62,11 @@ describe HTAuth::Passwd do
|
|
62
62
|
@stdin.rewind
|
63
63
|
@htauth.run([ "-m", "-c", @new_file, "alice" ])
|
64
64
|
rescue SystemExit => se
|
65
|
-
se.status.
|
65
|
+
se.status.must_equal 0
|
66
66
|
l = IO.readlines(@new_file)
|
67
67
|
fields = l.first.split(':')
|
68
|
-
fields.first.
|
69
|
-
fields.last.
|
68
|
+
fields.first.must_equal "alice"
|
69
|
+
fields.last.must_match( /^\$apr1\$/ )
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -78,27 +78,26 @@ describe HTAuth::Passwd do
|
|
78
78
|
@stdin.rewind
|
79
79
|
@htauth.run([ "-c", @tf.path, "bob"])
|
80
80
|
rescue SystemExit => se
|
81
|
-
se.status.
|
81
|
+
se.status.must_equal 0
|
82
82
|
after_lines = IO.readlines(@tf.path)
|
83
|
-
after_lines.size.
|
84
|
-
before_lines.size.
|
83
|
+
after_lines.size.must_equal 1
|
84
|
+
before_lines.size.must_equal 2
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
88
|
it "adds an entry to an existing file and force SHA" do
|
89
|
-
before_lines = IO.readlines(@tf.path)
|
90
89
|
begin
|
91
90
|
@stdin.puts "c secret"
|
92
91
|
@stdin.puts "c secret"
|
93
92
|
@stdin.rewind
|
94
93
|
@htauth.run([ "-s", @tf.path, "charlie" ])
|
95
94
|
rescue SystemExit => se
|
96
|
-
se.status.
|
95
|
+
se.status.must_equal 0
|
97
96
|
after_lines = IO.readlines(@tf.path)
|
98
|
-
after_lines.
|
97
|
+
after_lines.size.must_equal 3
|
99
98
|
al = after_lines.last.split(':')
|
100
|
-
al.first.
|
101
|
-
al.last.
|
99
|
+
al.first.must_equal "charlie"
|
100
|
+
al.last.must_match( /\{SHA\}/ )
|
102
101
|
end
|
103
102
|
end
|
104
103
|
|
@@ -109,8 +108,8 @@ describe HTAuth::Passwd do
|
|
109
108
|
@stdin.rewind
|
110
109
|
@htauth.run(["-c", "-p", @tf.path, "bradley"])
|
111
110
|
rescue SystemExit => se
|
112
|
-
se.status.
|
113
|
-
IO.read(@tf.path).strip.
|
111
|
+
se.status.must_equal 0
|
112
|
+
IO.read(@tf.path).strip.must_equal "bradley:a bad password"
|
114
113
|
end
|
115
114
|
end
|
116
115
|
|
@@ -118,8 +117,8 @@ describe HTAuth::Passwd do
|
|
118
117
|
begin
|
119
118
|
@htauth.run(["-c", "-p", "-b", @tf.path, "bradley", "a bad password"])
|
120
119
|
rescue SystemExit => se
|
121
|
-
se.status.
|
122
|
-
IO.read(@tf.path).strip.
|
120
|
+
se.status.must_equal 0
|
121
|
+
IO.read(@tf.path).strip.must_equal "bradley:a bad password"
|
123
122
|
end
|
124
123
|
end
|
125
124
|
|
@@ -131,16 +130,16 @@ describe HTAuth::Passwd do
|
|
131
130
|
@stdin.rewind
|
132
131
|
@htauth.run([ "-d", @tf.path, "alice" ])
|
133
132
|
rescue SystemExit => se
|
134
|
-
@stderr.string.
|
135
|
-
se.status.
|
133
|
+
@stderr.string.must_equal ""
|
134
|
+
se.status.must_equal 0
|
136
135
|
after_lines = IO.readlines(@tf.path)
|
137
|
-
after_lines.size.
|
136
|
+
after_lines.size.must_equal before_lines.size
|
138
137
|
|
139
138
|
a_b = before_lines.first.split(":")
|
140
139
|
a_a = after_lines.first.split(":")
|
141
140
|
|
142
|
-
a_b.first.
|
143
|
-
a_b.last.
|
141
|
+
a_b.first.must_equal a_a.first
|
142
|
+
a_b.last.wont_equal a_a.last
|
144
143
|
end
|
145
144
|
end
|
146
145
|
|
@@ -148,9 +147,9 @@ describe HTAuth::Passwd do
|
|
148
147
|
begin
|
149
148
|
@htauth.run([ "-D", @tf.path, "bob" ])
|
150
149
|
rescue SystemExit => se
|
151
|
-
@stderr.string.
|
152
|
-
se.status.
|
153
|
-
IO.read(@tf.path).
|
150
|
+
@stderr.string.must_equal ""
|
151
|
+
se.status.must_equal 0
|
152
|
+
IO.read(@tf.path).must_equal IO.read(PASSWD_DELETE_TEST_FILE)
|
154
153
|
end
|
155
154
|
end
|
156
155
|
|
@@ -158,8 +157,8 @@ describe HTAuth::Passwd do
|
|
158
157
|
begin
|
159
158
|
@htauth.run(["-n", "-p", "-b", "bradley", "a bad password"])
|
160
159
|
rescue SystemExit => se
|
161
|
-
se.status.
|
162
|
-
@stdout.string.strip.
|
160
|
+
se.status.must_equal 0
|
161
|
+
@stdout.string.strip.must_equal "bradley:a bad password"
|
163
162
|
end
|
164
163
|
end
|
165
164
|
|
@@ -170,8 +169,8 @@ describe HTAuth::Passwd do
|
|
170
169
|
@stdin.rewind
|
171
170
|
@htauth.run([ "-c", "/etc/you-cannot-create-me", "alice"])
|
172
171
|
rescue SystemExit => se
|
173
|
-
@stderr.string.
|
174
|
-
se.status.
|
172
|
+
@stderr.string.must_match( %r{Password file failure \(/etc/you-cannot-create-me\)}m )
|
173
|
+
se.status.must_equal 1
|
175
174
|
end
|
176
175
|
end
|
177
176
|
|
@@ -182,8 +181,8 @@ describe HTAuth::Passwd do
|
|
182
181
|
@stdin.rewind
|
183
182
|
@htauth.run([ @tf.path, "alice"])
|
184
183
|
rescue SystemExit => se
|
185
|
-
@stderr.string.
|
186
|
-
se.status.
|
184
|
+
@stderr.string.must_match( /They don't match, sorry./m )
|
185
|
+
se.status.must_equal 1
|
187
186
|
end
|
188
187
|
end
|
189
188
|
|
@@ -191,8 +190,8 @@ describe HTAuth::Passwd do
|
|
191
190
|
begin
|
192
191
|
@htauth.run(["--blah"])
|
193
192
|
rescue SystemExit => se
|
194
|
-
@stderr.string.
|
195
|
-
se.status.
|
193
|
+
@stderr.string.must_match( /ERROR:/m )
|
194
|
+
se.status.must_equal 1
|
196
195
|
end
|
197
196
|
end
|
198
197
|
|
@@ -200,8 +199,8 @@ describe HTAuth::Passwd do
|
|
200
199
|
begin
|
201
200
|
@htauth.run(["-c", "-n"])
|
202
201
|
rescue SystemExit => se
|
203
|
-
@stderr.string.
|
204
|
-
se.status.
|
202
|
+
@stderr.string.must_match( /ERROR:/m )
|
203
|
+
se.status.must_equal 1
|
205
204
|
end
|
206
205
|
end
|
207
206
|
end
|
data/spec/plaintext_spec.rb
CHANGED
@@ -1,18 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require File.join(File.dirname(__FILE__),"spec_helper.rb")
|
4
|
-
|
5
|
-
require 'htauth/sha1'
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'htauth/plaintext'
|
6
3
|
|
7
4
|
describe HTAuth::Plaintext do
|
8
5
|
it "has a prefix" do
|
9
|
-
HTAuth::Plaintext.new.prefix.
|
6
|
+
HTAuth::Plaintext.new.prefix.must_equal ""
|
10
7
|
end
|
11
8
|
|
12
9
|
it "encrypts the same way that apache does" do
|
13
10
|
apache_result = "a secret"
|
14
11
|
pt = HTAuth::Plaintext.new
|
15
|
-
pt.encode("a secret").
|
12
|
+
pt.encode("a secret").must_equal apache_result
|
16
13
|
end
|
17
14
|
end
|
18
15
|
|
data/spec/sha1_spec.rb
CHANGED
@@ -1,17 +1,15 @@
|
|
1
|
-
|
2
|
-
require File.join(File.dirname(__FILE__),"spec_helper.rb")
|
3
|
-
|
1
|
+
require 'spec_helper'
|
4
2
|
require 'htauth/sha1'
|
5
3
|
|
6
4
|
describe HTAuth::Sha1 do
|
7
5
|
it "has a prefix" do
|
8
|
-
HTAuth::Sha1.new.prefix.
|
6
|
+
HTAuth::Sha1.new.prefix.must_equal "{SHA}"
|
9
7
|
end
|
10
8
|
|
11
9
|
it "encrypts the same way that apache does" do
|
12
10
|
apache_result = "{SHA}ZrnlrvmM7ZCOV3FAvM7la89NKbk="
|
13
11
|
sha1 = HTAuth::Sha1.new
|
14
|
-
sha1.encode("a secret").
|
12
|
+
sha1.encode("a secret").must_equal apache_result
|
15
13
|
end
|
16
14
|
end
|
17
15
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
-
|
2
|
-
require '
|
1
|
+
if RUBY_VERSION >= '1.9.2' then
|
2
|
+
require 'simplecov'
|
3
|
+
puts "Using coverage!"
|
4
|
+
SimpleCov.start if ENV['COVERAGE']
|
5
|
+
end
|
3
6
|
|
4
|
-
|
5
|
-
require '
|
7
|
+
gem 'minitest'
|
8
|
+
require 'minitest/autorun'
|
9
|
+
require 'minitest/pride'
|
6
10
|
|
7
11
|
PASSWD_ORIGINAL_TEST_FILE = File.join(File.dirname(__FILE__), "test.original.passwd")
|
8
12
|
PASSWD_ADD_TEST_FILE = File.join(File.dirname(__FILE__), "test.add.passwd")
|
@@ -0,0 +1 @@
|
|
1
|
+
bob:htauth:fcbeab6821d2ab3b00934c958db0fd1e
|
@@ -0,0 +1 @@
|
|
1
|
+
alice:$apr1$DghnA...$CsPcgerfsI/Ryy0AOAJtb0
|
data/tasks/default.rake
ADDED
@@ -0,0 +1,276 @@
|
|
1
|
+
# vim: syntax=ruby
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'digest'
|
4
|
+
#------------------------------------------------------------------------------
|
5
|
+
# If you want to Develop on this project just run 'rake develop' and you'll
|
6
|
+
# have all you need to get going. If you want to use bundler for development,
|
7
|
+
# then run 'rake develop:using_bundler'
|
8
|
+
#------------------------------------------------------------------------------
|
9
|
+
namespace :develop do
|
10
|
+
|
11
|
+
# Install all the development and runtime dependencies of this gem using the
|
12
|
+
# gemspec.
|
13
|
+
task :default do
|
14
|
+
require 'rubygems/dependency_installer'
|
15
|
+
installer = ::Gem::DependencyInstaller.new
|
16
|
+
|
17
|
+
This.set_coverage_gem
|
18
|
+
|
19
|
+
puts "Installing gem depedencies needed for development"
|
20
|
+
This.platform_gemspec.dependencies.each do |dep|
|
21
|
+
if dep.matching_specs.empty? then
|
22
|
+
puts "Installing : #{dep}"
|
23
|
+
installer.install dep
|
24
|
+
else
|
25
|
+
puts "Skipping : #{dep} -> already installed #{dep.matching_specs.first.full_name}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
puts "\n\nNow run 'rake test'"
|
29
|
+
end
|
30
|
+
|
31
|
+
# Create a Gemfile that just references the gemspec
|
32
|
+
file 'Gemfile' => :gemspec do
|
33
|
+
File.open( "Gemfile", "w+" ) do |f|
|
34
|
+
f.puts "# DO NOT EDIT - This file is automatically generated"
|
35
|
+
f.puts "# Make changes to Manifest.txt and/or Rakefile and regenerate"
|
36
|
+
f.puts 'source "https://rubygems.org/"'
|
37
|
+
f.puts 'gemspec'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "Create a bundler Gemfile"
|
42
|
+
task :using_bundler => 'Gemfile' do
|
43
|
+
puts "Now you can 'bundle'"
|
44
|
+
end
|
45
|
+
|
46
|
+
# Gemfiles are build artifacts
|
47
|
+
CLOBBER << FileList['Gemfile*']
|
48
|
+
end
|
49
|
+
desc "Boostrap development"
|
50
|
+
task :develop => "develop:default"
|
51
|
+
|
52
|
+
#------------------------------------------------------------------------------
|
53
|
+
# Minitest - standard TestTask
|
54
|
+
#------------------------------------------------------------------------------
|
55
|
+
begin
|
56
|
+
require 'rake/testtask'
|
57
|
+
Rake::TestTask.new( :test ) do |t|
|
58
|
+
t.ruby_opts = %w[ -w -rubygems ]
|
59
|
+
t.libs = %w[ lib spec test ]
|
60
|
+
t.pattern = "{test,spec}/**/{test_*,*_spec}.rb"
|
61
|
+
end
|
62
|
+
|
63
|
+
task :test_requirements
|
64
|
+
task :test => :test_requirements
|
65
|
+
task :default => :test
|
66
|
+
rescue LoadError
|
67
|
+
This.task_warning( 'test' )
|
68
|
+
end
|
69
|
+
|
70
|
+
#------------------------------------------------------------------------------
|
71
|
+
# RDoc - standard rdoc rake task, although we must make sure to use a more
|
72
|
+
# recent version of rdoc since it is the one that has 'tomdoc' markup
|
73
|
+
#------------------------------------------------------------------------------
|
74
|
+
begin
|
75
|
+
gem 'rdoc' # otherwise we get the wrong task from stdlib
|
76
|
+
require 'rdoc/task'
|
77
|
+
RDoc::Task.new do |t|
|
78
|
+
t.markup = 'tomdoc'
|
79
|
+
t.rdoc_dir = 'doc'
|
80
|
+
t.main = 'README.md'
|
81
|
+
t.title = "#{This.name} #{This.version}"
|
82
|
+
t.rdoc_files.include( FileList['*.{rdoc,md,txt}'], FileList['ext/**/*.c'],
|
83
|
+
FileList['lib/**/*.rb'] )
|
84
|
+
end
|
85
|
+
rescue StandardError, LoadError
|
86
|
+
This.task_warning( 'rdoc' )
|
87
|
+
end
|
88
|
+
|
89
|
+
#------------------------------------------------------------------------------
|
90
|
+
# Coverage - optional code coverage, rcov for 1.8 and simplecov for 1.9, so
|
91
|
+
# for the moment only rcov is listed.
|
92
|
+
#------------------------------------------------------------------------------
|
93
|
+
if RUBY_VERSION < "1.9.0"
|
94
|
+
begin
|
95
|
+
require 'rcov/rcovtask'
|
96
|
+
Rcov::RcovTask.new( 'coverage' ) do |t|
|
97
|
+
t.libs << 'spec'
|
98
|
+
t.pattern = 'spec/**/*_spec.rb'
|
99
|
+
t.verbose = true
|
100
|
+
t.rcov_opts << "-x ^/" # remove all the global files
|
101
|
+
t.rcov_opts << "--sort coverage" # so we see the worst files at the top
|
102
|
+
end
|
103
|
+
rescue LoadError
|
104
|
+
This.task_warning( 'rcov' )
|
105
|
+
end
|
106
|
+
else
|
107
|
+
begin
|
108
|
+
require 'simplecov'
|
109
|
+
desc 'Run tests with code coverage'
|
110
|
+
task :coverage do
|
111
|
+
ENV['COVERAGE'] = 'true'
|
112
|
+
Rake::Task[:test].execute
|
113
|
+
end
|
114
|
+
CLOBBER << FileList["coverage"]
|
115
|
+
rescue LoadError
|
116
|
+
This.task_warning( 'simplecov' )
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
#------------------------------------------------------------------------------
|
121
|
+
# Manifest - We want an explicit list of thos files that are to be packaged in
|
122
|
+
# the gem. Most of this is from Hoe.
|
123
|
+
#------------------------------------------------------------------------------
|
124
|
+
namespace 'manifest' do
|
125
|
+
desc "Check the manifest"
|
126
|
+
task :check => :clean do
|
127
|
+
files = FileList["**/*", ".*"].exclude( This.exclude_from_manifest ).to_a.sort
|
128
|
+
files = files.select{ |f| File.file?( f ) }
|
129
|
+
|
130
|
+
tmp = "Manifest.tmp"
|
131
|
+
File.open( tmp, 'w' ) do |f|
|
132
|
+
f.puts files.join("\n")
|
133
|
+
end
|
134
|
+
|
135
|
+
begin
|
136
|
+
sh "diff -du Manifest.txt #{tmp}"
|
137
|
+
ensure
|
138
|
+
rm tmp
|
139
|
+
end
|
140
|
+
puts "Manifest looks good"
|
141
|
+
end
|
142
|
+
|
143
|
+
desc "Generate the manifest"
|
144
|
+
task :generate => :clean do
|
145
|
+
files = %x[ git ls-files ].split("\n").sort
|
146
|
+
files.reject! { |f| f =~ This.exclude_from_manifest }
|
147
|
+
File.open( "Manifest.txt", "w" ) do |f|
|
148
|
+
f.puts files.join("\n")
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
#------------------------------------------------------------------------------
|
154
|
+
# Fixme - look for fixmes and report them
|
155
|
+
#------------------------------------------------------------------------------
|
156
|
+
namespace :fixme do
|
157
|
+
task :default => 'manifest:check' do
|
158
|
+
This.manifest.each do |file|
|
159
|
+
next if file == __FILE__
|
160
|
+
next unless file =~ %r/(txt|rb|md|rdoc|css|html|xml|css)\Z/
|
161
|
+
puts "FIXME: Rename #{file}" if file =~ /fixme/i
|
162
|
+
IO.readlines( file ).each_with_index do |line, idx|
|
163
|
+
prefix = "FIXME: #{file}:#{idx+1}".ljust(42)
|
164
|
+
puts "#{prefix} => #{line.strip}" if line =~ /fixme/i
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def fixme_project_root
|
170
|
+
This.project_path( '../fixme' )
|
171
|
+
end
|
172
|
+
|
173
|
+
def fixme_project_path( subtree )
|
174
|
+
fixme_project_root.join( subtree )
|
175
|
+
end
|
176
|
+
|
177
|
+
def local_fixme_files
|
178
|
+
This.manifest.select { |p| p =~ %r|^tasks/| }
|
179
|
+
end
|
180
|
+
|
181
|
+
def outdated_fixme_files
|
182
|
+
local_fixme_files.reject do |local|
|
183
|
+
upstream = fixme_project_path( local )
|
184
|
+
Digest::SHA256.file( local ) == Digest::SHA256.file( upstream )
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def fixme_up_to_date?
|
189
|
+
outdated_fixme_files.empty?
|
190
|
+
end
|
191
|
+
|
192
|
+
desc "See if the fixme tools are outdated"
|
193
|
+
task :outdated => :release_check do
|
194
|
+
if fixme_up_to_date? then
|
195
|
+
puts "Fixme files are up to date."
|
196
|
+
else
|
197
|
+
outdated_fixme_files.each do |f|
|
198
|
+
puts "#{f} is outdated"
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
desc "Update outdated fixme files"
|
204
|
+
task :update => :release_check do
|
205
|
+
if fixme_up_to_date? then
|
206
|
+
puts "Fixme files are already up to date."
|
207
|
+
else
|
208
|
+
puts "Updating fixme files:"
|
209
|
+
outdated_fixme_files.each do |local|
|
210
|
+
upstream = fixme_project_path( local )
|
211
|
+
puts " * #{local}"
|
212
|
+
FileUtils.cp( upstream, local )
|
213
|
+
end
|
214
|
+
puts "Use your git commands as appropriate."
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
desc "Look for fixmes and report them"
|
219
|
+
task :fixme => "fixme:default"
|
220
|
+
|
221
|
+
#------------------------------------------------------------------------------
|
222
|
+
# Gem Specification
|
223
|
+
#------------------------------------------------------------------------------
|
224
|
+
# Really this is only here to support those who use bundler
|
225
|
+
desc "Build the #{This.name}.gemspec file"
|
226
|
+
task :gemspec do
|
227
|
+
File.open( This.gemspec_file, "wb+" ) do |f|
|
228
|
+
f.puts "# DO NOT EDIT - This file is automatically generated"
|
229
|
+
f.puts "# Make changes to Manifest.txt and/or Rakefile and regenerate"
|
230
|
+
f.write This.platform_gemspec.to_ruby
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
# the gemspec is also a dev artifact and should not be kept around.
|
235
|
+
CLOBBER << This.gemspec_file.to_s
|
236
|
+
|
237
|
+
# .rbc files from ruby 2.0
|
238
|
+
CLOBBER << FileList["**/*.rbc"]
|
239
|
+
|
240
|
+
# The standard gem packaging task, everyone has it.
|
241
|
+
require 'rubygems/package_task'
|
242
|
+
::Gem::PackageTask.new( This.platform_gemspec ) do
|
243
|
+
# nothing
|
244
|
+
end
|
245
|
+
|
246
|
+
#------------------------------------------------------------------------------
|
247
|
+
# Release - the steps we go through to do a final release, this is pulled from
|
248
|
+
# a compbination of mojombo's rakegem, hoe and hoe-git
|
249
|
+
#
|
250
|
+
# 1) make sure we are on the master branch
|
251
|
+
# 2) make sure there are no uncommitted items
|
252
|
+
# 3) check the manifest and make sure all looks good
|
253
|
+
# 4) build the gem
|
254
|
+
# 5) do an empty commit to have the commit message of the version
|
255
|
+
# 6) tag that commit as the version
|
256
|
+
# 7) push master
|
257
|
+
# 8) push the tag
|
258
|
+
# 7) pus the gem
|
259
|
+
#------------------------------------------------------------------------------
|
260
|
+
task :release_check do
|
261
|
+
unless `git branch` =~ /^\* master$/
|
262
|
+
abort "You must be on the master branch to release!"
|
263
|
+
end
|
264
|
+
unless `git status` =~ /^nothing to commit/m
|
265
|
+
abort "Nope, sorry, you have unfinished business"
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
desc "Create tag v#{This.version}, build and push #{This.platform_gemspec.full_name} to rubygems.org"
|
270
|
+
task :release => [ :release_check, 'manifest:check', :gem ] do
|
271
|
+
sh "git commit --allow-empty -a -m 'Release #{This.version}'"
|
272
|
+
sh "git tag -a -m 'v#{This.version}' v#{This.version}"
|
273
|
+
sh "git push origin master"
|
274
|
+
sh "git push origin v#{This.version}"
|
275
|
+
sh "gem push pkg/#{This.platform_gemspec.full_name}.gem"
|
276
|
+
end
|