kjess 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CONTRIBUTING.md +45 -0
- data/HISTORY.rdoc +5 -0
- data/LICENSE +16 -0
- data/Manifest.txt +53 -0
- data/README.rdoc +44 -0
- data/Rakefile +337 -0
- data/example/client_test.rb +73 -0
- data/lib/kjess.rb +11 -0
- data/lib/kjess/client.rb +289 -0
- data/lib/kjess/connection.rb +119 -0
- data/lib/kjess/error.rb +5 -0
- data/lib/kjess/protocol.rb +76 -0
- data/lib/kjess/request.rb +31 -0
- data/lib/kjess/request/delete.rb +11 -0
- data/lib/kjess/request/dump_stats.rb +7 -0
- data/lib/kjess/request/flush.rb +11 -0
- data/lib/kjess/request/flush_all.rb +7 -0
- data/lib/kjess/request/get.rb +21 -0
- data/lib/kjess/request/quit.rb +7 -0
- data/lib/kjess/request/reload.rb +7 -0
- data/lib/kjess/request/set.rb +19 -0
- data/lib/kjess/request/shutdown.rb +7 -0
- data/lib/kjess/request/stats.rb +7 -0
- data/lib/kjess/request/status.rb +8 -0
- data/lib/kjess/request/version.rb +8 -0
- data/lib/kjess/response.rb +76 -0
- data/lib/kjess/response/client_error.rb +19 -0
- data/lib/kjess/response/deleted.rb +5 -0
- data/lib/kjess/response/dumped_stats.rb +48 -0
- data/lib/kjess/response/end.rb +5 -0
- data/lib/kjess/response/eof.rb +5 -0
- data/lib/kjess/response/error.rb +13 -0
- data/lib/kjess/response/flushed_all_queues.rb +6 -0
- data/lib/kjess/response/not_found.rb +5 -0
- data/lib/kjess/response/not_stored.rb +5 -0
- data/lib/kjess/response/reloaded_config.rb +6 -0
- data/lib/kjess/response/server_error.rb +18 -0
- data/lib/kjess/response/stats.rb +60 -0
- data/lib/kjess/response/stored.rb +5 -0
- data/lib/kjess/response/unknown.rb +3 -0
- data/lib/kjess/response/value.rb +26 -0
- data/lib/kjess/response/version.rb +10 -0
- data/lib/kjess/stats_cache.rb +31 -0
- data/spec/client_spec.rb +265 -0
- data/spec/kestrel_server.rb +137 -0
- data/spec/request/set_spec.rb +13 -0
- data/spec/request/version_spec.rb +17 -0
- data/spec/request_spec.rb +30 -0
- data/spec/response/client_error_spec.rb +17 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/utils.rb +18 -0
- data/spec/version_spec.rb +9 -0
- data/tasks/kestrel.rake +70 -0
- metadata +193 -0
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Hi there!
|
2
|
+
|
3
|
+
I see you are interested in contributing. That is wonderful. I love
|
4
|
+
contributions.
|
5
|
+
|
6
|
+
I guarantee that there are bugs in this software. And I guarantee that there is
|
7
|
+
a feature you want that is not in here yet. As such, any and all bugs reports
|
8
|
+
are gratefully accepted, bugfixes even more so. Helping out with bugs is the
|
9
|
+
easiest way to contribute.
|
10
|
+
|
11
|
+
|
12
|
+
## The Quick Version
|
13
|
+
|
14
|
+
* Have a [GitHub Account][].
|
15
|
+
* Search the [GitHub Issues][] and see if your issue already present. If so
|
16
|
+
add your comments, :thumbsup:, etc.
|
17
|
+
* Issue not there? Not a problem, open up a [new issue][].
|
18
|
+
* **Bug reports** please be as detailed as possible. Include:
|
19
|
+
* full ruby engine and version: `ruby -e 'puts RUBY_DESCRIPTION'`
|
20
|
+
* operating system and version
|
21
|
+
* version of kjess `ruby -e 'ruby -rubygems -e "require 'kjess'; puts KJess::VERSION'`
|
22
|
+
* as much detail about the bug as possible so I can replicated it. Feel free
|
23
|
+
to link in a [gist][]
|
24
|
+
* **New Feature**
|
25
|
+
* What the new feature should do.
|
26
|
+
* What benefit the new feature brings to the project.
|
27
|
+
* Fork the [repo][].
|
28
|
+
* Create a new branch for your issue: `git checkout -b issue/my-issue`
|
29
|
+
* Lovingly craft your contribution:
|
30
|
+
* `rake develop` to get started, or if you prefer bundler `rake develop:using_bunder && bundle`.
|
31
|
+
* `rake test` to run tests
|
32
|
+
* Make sure that `rake test` passes. Its important, I said it twice.
|
33
|
+
* Add yourself to the contributors section below.
|
34
|
+
* Submit your [pull request][].
|
35
|
+
|
36
|
+
# Contributors
|
37
|
+
|
38
|
+
* Jeremy Hinegardner
|
39
|
+
|
40
|
+
[GitHub Account]: https://github.com/signup/free "GitHub Signup"
|
41
|
+
[GitHub Issues]: https://github.com/copiousfreetime/kjess/issues "KJess Issues"
|
42
|
+
[new issue]: https://github.com/copiousfreetime/kjess/issues/new "New KJess Issue"
|
43
|
+
[gist]: https://gist.github.com/ "New Gist"
|
44
|
+
[repo]: https://github.com/copiousfreetime/kjess "KJess Repo"
|
45
|
+
[pull request]: https://help.github.com/articles/using-pull-requests "Using Pull Requests"
|
data/HISTORY.rdoc
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
ISC LICENSE - http://opensource.org/licenses/isc-license.txt
|
2
|
+
|
3
|
+
Copyright (c) 2012 Jeremy Hinegardner
|
4
|
+
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
16
|
+
|
data/Manifest.txt
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
CONTRIBUTING.md
|
2
|
+
HISTORY.rdoc
|
3
|
+
LICENSE
|
4
|
+
Manifest.txt
|
5
|
+
README.rdoc
|
6
|
+
Rakefile
|
7
|
+
example/client_test.rb
|
8
|
+
lib/kjess.rb
|
9
|
+
lib/kjess/client.rb
|
10
|
+
lib/kjess/connection.rb
|
11
|
+
lib/kjess/error.rb
|
12
|
+
lib/kjess/protocol.rb
|
13
|
+
lib/kjess/request.rb
|
14
|
+
lib/kjess/request/delete.rb
|
15
|
+
lib/kjess/request/dump_stats.rb
|
16
|
+
lib/kjess/request/flush.rb
|
17
|
+
lib/kjess/request/flush_all.rb
|
18
|
+
lib/kjess/request/get.rb
|
19
|
+
lib/kjess/request/quit.rb
|
20
|
+
lib/kjess/request/reload.rb
|
21
|
+
lib/kjess/request/set.rb
|
22
|
+
lib/kjess/request/shutdown.rb
|
23
|
+
lib/kjess/request/stats.rb
|
24
|
+
lib/kjess/request/status.rb
|
25
|
+
lib/kjess/request/version.rb
|
26
|
+
lib/kjess/response.rb
|
27
|
+
lib/kjess/response/client_error.rb
|
28
|
+
lib/kjess/response/deleted.rb
|
29
|
+
lib/kjess/response/dumped_stats.rb
|
30
|
+
lib/kjess/response/end.rb
|
31
|
+
lib/kjess/response/eof.rb
|
32
|
+
lib/kjess/response/error.rb
|
33
|
+
lib/kjess/response/flushed_all_queues.rb
|
34
|
+
lib/kjess/response/not_found.rb
|
35
|
+
lib/kjess/response/not_stored.rb
|
36
|
+
lib/kjess/response/reloaded_config.rb
|
37
|
+
lib/kjess/response/server_error.rb
|
38
|
+
lib/kjess/response/stats.rb
|
39
|
+
lib/kjess/response/stored.rb
|
40
|
+
lib/kjess/response/unknown.rb
|
41
|
+
lib/kjess/response/value.rb
|
42
|
+
lib/kjess/response/version.rb
|
43
|
+
lib/kjess/stats_cache.rb
|
44
|
+
spec/client_spec.rb
|
45
|
+
spec/kestrel_server.rb
|
46
|
+
spec/request/set_spec.rb
|
47
|
+
spec/request/version_spec.rb
|
48
|
+
spec/request_spec.rb
|
49
|
+
spec/response/client_error_spec.rb
|
50
|
+
spec/spec_helper.rb
|
51
|
+
spec/utils.rb
|
52
|
+
spec/version_spec.rb
|
53
|
+
tasks/kestrel.rake
|
data/README.rdoc
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
== KJess
|
2
|
+
|
3
|
+
* Homepage[https://github.com/copiousfreetime/kjess/]
|
4
|
+
* {Github Project}[https://github.com/copiousfreetime/kjess]
|
5
|
+
* email jeremy at hinegardner dot org
|
6
|
+
|
7
|
+
== DESCRIPTION
|
8
|
+
|
9
|
+
KJess is a pure ruby Kestrel client that supports Kestrel's Memcache style
|
10
|
+
protocol.
|
11
|
+
|
12
|
+
== FEATURES
|
13
|
+
|
14
|
+
A pure ruby native client to Kestrel.
|
15
|
+
|
16
|
+
== Examples
|
17
|
+
|
18
|
+
client = Kestrel::Client.new( 'k.example.com' )
|
19
|
+
client.set( 'my_queue', 'item' ) # put an 'item' on 'my_queue'
|
20
|
+
i = client.reserve( 'my_queue' ) # get an item off 'my_queue' with
|
21
|
+
# Reliable Read
|
22
|
+
|
23
|
+
# do something with the item pulled off the queue
|
24
|
+
|
25
|
+
client.close( 'my_queue' ) # confirm with Kestrel that the item
|
26
|
+
# retrieved was processed
|
27
|
+
|
28
|
+
== ISC LICENSE
|
29
|
+
|
30
|
+
http://opensource.org/licenses/isc-license.txt
|
31
|
+
|
32
|
+
Copyright (c) 2012 Jeremy Hinegardner
|
33
|
+
|
34
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
35
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
36
|
+
and this permission notice appear in all copies.
|
37
|
+
|
38
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
39
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
40
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
41
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
42
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
43
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
44
|
+
THIS SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,337 @@
|
|
1
|
+
# vim: syntax=ruby
|
2
|
+
|
3
|
+
This.name = "kjess"
|
4
|
+
This.author = "Jeremy Hinegardner"
|
5
|
+
This.email = "jeremy@copiousfreetime.org"
|
6
|
+
This.homepage = "http://github.com/copiousfreetime/#{ This.name }"
|
7
|
+
This.version = Util.version
|
8
|
+
|
9
|
+
#------------------------------------------------------------------------------
|
10
|
+
# If you want to Develop on this project just run 'rake develop' and you'll
|
11
|
+
# have all you need to get going. If you want to use bundler for development,
|
12
|
+
# then run 'rake develop:using_bundler'
|
13
|
+
#------------------------------------------------------------------------------
|
14
|
+
namespace :develop do
|
15
|
+
|
16
|
+
# Install all the development and runtime dependencies of this gem using the
|
17
|
+
# gemspec.
|
18
|
+
task :default do
|
19
|
+
require 'rubygems/dependency_installer'
|
20
|
+
installer = Gem::DependencyInstaller.new
|
21
|
+
|
22
|
+
# list these here instead of gem dependencies since there is not a way to
|
23
|
+
# specify ruby version specific dependencies
|
24
|
+
if RUBY_VERSION < "1.9.2"
|
25
|
+
Util.platform_gemspec.add_development_dependency( 'rcov', '~> 0.9.11' )
|
26
|
+
else
|
27
|
+
Util.platform_gemspec.add_development_dependency( 'simplecov', '~> 0.6.4' )
|
28
|
+
end
|
29
|
+
|
30
|
+
puts "Installing gem depedencies needed for development"
|
31
|
+
Util.platform_gemspec.dependencies.each do |dep|
|
32
|
+
if dep.matching_specs.empty? then
|
33
|
+
puts "Installing : #{dep}"
|
34
|
+
installer.install dep
|
35
|
+
else
|
36
|
+
puts "Skipping : #{dep} -> already installed #{dep.matching_specs.first.full_name}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
puts "\n\nNow run 'rake test'"
|
40
|
+
end
|
41
|
+
|
42
|
+
# Create a Gemfile that just references the gemspec
|
43
|
+
file 'Gemfile' => :gemspec do
|
44
|
+
File.open( "Gemfile", "w+" ) do |f|
|
45
|
+
f.puts 'source :rubygems'
|
46
|
+
f.puts 'gemspec'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "Create a bundler Gemfile"
|
51
|
+
task :using_bundler => 'Gemfile' do
|
52
|
+
puts "Now you can 'bundle'"
|
53
|
+
end
|
54
|
+
|
55
|
+
# Gemfiles are build artifacts
|
56
|
+
CLOBBER << FileList['Gemfile*']
|
57
|
+
end
|
58
|
+
desc "Boostrap development"
|
59
|
+
task :develop => "develop:default"
|
60
|
+
|
61
|
+
#------------------------------------------------------------------------------
|
62
|
+
# Minitest - standard TestTask
|
63
|
+
#------------------------------------------------------------------------------
|
64
|
+
begin
|
65
|
+
require 'rake/testtask'
|
66
|
+
Rake::TestTask.new( :test ) do |t|
|
67
|
+
t.ruby_opts = %w[ -w -rubygems ]
|
68
|
+
t.libs = %w[ lib spec ]
|
69
|
+
t.pattern = "spec/**/*_spec.rb"
|
70
|
+
end
|
71
|
+
task :default => :test
|
72
|
+
rescue LoadError
|
73
|
+
Util.task_warning( 'test' )
|
74
|
+
end
|
75
|
+
|
76
|
+
#------------------------------------------------------------------------------
|
77
|
+
# RDoc - standard rdoc rake task, although we must make sure to use a more
|
78
|
+
# recent version of rdoc since it is the one that has 'tomdoc' markup
|
79
|
+
#------------------------------------------------------------------------------
|
80
|
+
begin
|
81
|
+
gem 'rdoc' # otherwise we get the wrong task from stdlib
|
82
|
+
require 'rdoc/task'
|
83
|
+
RDoc::Task.new do |t|
|
84
|
+
t.markup = 'tomdoc'
|
85
|
+
t.rdoc_dir = 'doc'
|
86
|
+
t.main = 'README.rdoc'
|
87
|
+
t.title = "#{This.name} #{This.version}"
|
88
|
+
t.rdoc_files.include( '*.rdoc', 'lib/**/*.rb' )
|
89
|
+
end
|
90
|
+
rescue LoadError => le
|
91
|
+
Util.task_warning( 'rdoc' )
|
92
|
+
end
|
93
|
+
|
94
|
+
#------------------------------------------------------------------------------
|
95
|
+
# Coverage - optional code coverage, rcov for 1.8 and simplecov for 1.9, so
|
96
|
+
# for the moment only rcov is listed.
|
97
|
+
#------------------------------------------------------------------------------
|
98
|
+
if RUBY_VERSION <= "1.9.2"
|
99
|
+
begin
|
100
|
+
require 'rcov/rcovtask'
|
101
|
+
Rcov::RcovTask.new( 'coverage' ) do |t|
|
102
|
+
t.libs << 'spec'
|
103
|
+
t.pattern = 'spec/**/*_spec.rb'
|
104
|
+
t.verbose = true
|
105
|
+
t.rcov_opts << "-x ^/" # remove all the global files
|
106
|
+
t.rcov_opts << "--sort coverage" # so we see the worst files at the top
|
107
|
+
end
|
108
|
+
rescue LoadError
|
109
|
+
Util.task_warning( 'rcov' )
|
110
|
+
end
|
111
|
+
else
|
112
|
+
begin
|
113
|
+
require 'simplecov'
|
114
|
+
desc 'Run tests with code coverage'
|
115
|
+
task :coverage do
|
116
|
+
ENV['COVERAGE'] = 'true'
|
117
|
+
Rake::Task[:test].execute
|
118
|
+
end
|
119
|
+
CLOBBER << FileList["coverage"]
|
120
|
+
rescue LoadError
|
121
|
+
Util.task_warning( 'simplecov' )
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
#------------------------------------------------------------------------------
|
126
|
+
# Manifest - We want an explicit list of thos files that are to be packaged in
|
127
|
+
# the gem. Most of this is from Hoe.
|
128
|
+
#------------------------------------------------------------------------------
|
129
|
+
namespace 'manifest' do
|
130
|
+
desc "Check the manifest"
|
131
|
+
task :check => :clean do
|
132
|
+
files = FileList["**/*", ".*"].exclude( This.exclude_from_manifest ).to_a.sort
|
133
|
+
files = files.select{ |f| File.file?( f ) }
|
134
|
+
|
135
|
+
tmp = "Manifest.tmp"
|
136
|
+
File.open( tmp, 'w' ) do |f|
|
137
|
+
f.puts files.join("\n")
|
138
|
+
end
|
139
|
+
|
140
|
+
begin
|
141
|
+
sh "diff -du Manifest.txt #{tmp}"
|
142
|
+
ensure
|
143
|
+
rm tmp
|
144
|
+
end
|
145
|
+
puts "Manifest looks good"
|
146
|
+
end
|
147
|
+
|
148
|
+
desc "Generate the manifest"
|
149
|
+
task :generate => :clean do
|
150
|
+
files = %x[ git ls-files ].split("\n").sort
|
151
|
+
files.reject! { |f| f =~ This.exclude_from_manifest }
|
152
|
+
File.open( "Manifest.txt", "w" ) do |f|
|
153
|
+
f.puts files.join("\n")
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
#------------------------------------------------------------------------------
|
159
|
+
# Fixme - look for fixmes and report them
|
160
|
+
#------------------------------------------------------------------------------
|
161
|
+
task :fixme => 'manifest:check' do
|
162
|
+
Util.read_manifest.each do |file|
|
163
|
+
next if file == File.basename( __FILE__ )
|
164
|
+
|
165
|
+
puts "FIXME: Rename #{file}" if file =~ /fixme/i
|
166
|
+
|
167
|
+
IO.readlines( file ).each_with_index do |line, idx|
|
168
|
+
prefix = "FIXME: #{file}:#{idx+1}".ljust(42)
|
169
|
+
puts "#{prefix} => #{line.strip}" if line =~ /fixme/i
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
#------------------------------------------------------------------------------
|
175
|
+
# Gem Specification
|
176
|
+
#------------------------------------------------------------------------------
|
177
|
+
This.gemspec = Hash.new
|
178
|
+
This.gemspec['ruby'] = Gem::Specification.new do |spec|
|
179
|
+
spec.name = This.name
|
180
|
+
spec.version = This.version
|
181
|
+
spec.author = This.author
|
182
|
+
spec.email = This.email
|
183
|
+
spec.homepage = This.homepage
|
184
|
+
|
185
|
+
spec.summary = This.summary
|
186
|
+
spec.description = This.description
|
187
|
+
|
188
|
+
spec.files = This.manifest
|
189
|
+
spec.executables = spec.files.grep(/^bin/) { |f| File.basename(f) }
|
190
|
+
spec.test_files = spec.files.grep(/^spec/)
|
191
|
+
|
192
|
+
spec.extra_rdoc_files += spec.files.grep(/(txt|rdoc)$/)
|
193
|
+
spec.rdoc_options = [ "--main" , 'README.rdoc',
|
194
|
+
"--markup", "tomdoc" ]
|
195
|
+
|
196
|
+
# The Runtime Dependencies
|
197
|
+
# FIXME
|
198
|
+
# spec.add_dependency( 'map', '~> 6.2.0')
|
199
|
+
|
200
|
+
# The Development Dependencies
|
201
|
+
spec.add_development_dependency( 'rake' , '~> 0.9.2.2')
|
202
|
+
spec.add_development_dependency( 'minitest' , '~> 3.3.0' )
|
203
|
+
spec.add_development_dependency( 'rdoc' , '~> 3.12' )
|
204
|
+
spec.add_development_dependency( 'zip' , "~> 2.0.2" )
|
205
|
+
end
|
206
|
+
|
207
|
+
|
208
|
+
# The name of the gemspec file on disk
|
209
|
+
This.gemspec_file = "#{This.name}.gemspec"
|
210
|
+
|
211
|
+
# Really this is only here to support those who use bundler
|
212
|
+
desc "Build the #{This.name}.gemspec file"
|
213
|
+
task :gemspec do
|
214
|
+
File.open( This.gemspec_file, "wb+" ) do |f|
|
215
|
+
f.write Util.platform_gemspec.to_ruby
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
# the gemspec is also a dev artifact and should not be kept around.
|
220
|
+
CLOBBER << This.gemspec_file
|
221
|
+
|
222
|
+
# The standard gem packaging task, everyone has it.
|
223
|
+
require 'rubygems/package_task'
|
224
|
+
Gem::PackageTask.new( Util.platform_gemspec ) do
|
225
|
+
# nothing
|
226
|
+
end
|
227
|
+
|
228
|
+
#------------------------------------------------------------------------------
|
229
|
+
# Release - the steps we go through to do a final release, this is pulled from
|
230
|
+
# a compbination of mojombo's rakegem, hoe and hoe-git
|
231
|
+
#
|
232
|
+
# 1) make sure we are on the master branch
|
233
|
+
# 2) make sure there are no uncommitted items
|
234
|
+
# 3) check the manifest and make sure all looks good
|
235
|
+
# 4) build the gem
|
236
|
+
# 5) do an empty commit to have the commit message of the version
|
237
|
+
# 6) tag that commit as the version
|
238
|
+
# 7) push master
|
239
|
+
# 8) push the tag
|
240
|
+
# 7) pus the gem
|
241
|
+
#------------------------------------------------------------------------------
|
242
|
+
task :release_check do
|
243
|
+
unless `git branch` =~ /^\* master$/
|
244
|
+
abort "You must be on the master branch to release!"
|
245
|
+
end
|
246
|
+
unless `git status` =~ /^nothing to commit/m
|
247
|
+
abort "Nope, sorry, you have unfinished business"
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
desc "Create tag v#{This.version}, build and push #{Util.platform_gemspec.full_name} to rubygems.org"
|
252
|
+
task :release => [ :release_check, 'manifest:check', :gem ] do
|
253
|
+
sh "git commit --allow-empty -a -m 'Release #{This.version}'"
|
254
|
+
sh "git tag -a -m 'v#{This.version}' v#{This.version}"
|
255
|
+
sh "git push origin master"
|
256
|
+
sh "git push origin v#{This.version}"
|
257
|
+
sh "gem push pkg/#{Util.platform_gemspec.full_name}.gem"
|
258
|
+
end
|
259
|
+
|
260
|
+
#------------------------------------------------------------------------------
|
261
|
+
# Load the extra rake tasks
|
262
|
+
#------------------------------------------------------------------------------
|
263
|
+
$: << "." unless $:.include?(".")
|
264
|
+
load 'tasks/kestrel.rake'
|
265
|
+
|
266
|
+
#------------------------------------------------------------------------------
|
267
|
+
# Rakefile Support - This is all the guts and utility methods that are
|
268
|
+
# necessary to support the above tasks.
|
269
|
+
#
|
270
|
+
# Lots of Credit for this Rakefile goes to:
|
271
|
+
#
|
272
|
+
# Ara T. Howard - see the Rakefile in all of his projects -
|
273
|
+
# https://github.com/ahoward/
|
274
|
+
# Tom Preston Werner - his Rakegem project https://github.com/mojombo/rakegem
|
275
|
+
# Seattle.rb - Hoe - cuz it has relly good stuff in there
|
276
|
+
#------------------------------------------------------------------------------
|
277
|
+
BEGIN {
|
278
|
+
|
279
|
+
require 'ostruct'
|
280
|
+
require 'rake/clean'
|
281
|
+
require 'rubygems' unless defined? Gem
|
282
|
+
|
283
|
+
module Util
|
284
|
+
def self.version
|
285
|
+
[ "lib/#{ This.name }.rb", "lib/#{ This.name }/version.rb" ].each do |v|
|
286
|
+
line = File.read( v )[/^\s*VERSION\s*=\s*.*/]
|
287
|
+
if line then
|
288
|
+
return line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
# Partition an rdoc file into sections and return the text of the section
|
294
|
+
# as an array of paragraphs
|
295
|
+
def self.section_of( file, section_name )
|
296
|
+
re = /^=+ (.*)$/
|
297
|
+
parts = File.read( file ).split( re )[1..-1]
|
298
|
+
parts.map! { |p| p.strip }
|
299
|
+
|
300
|
+
sections = Hash.new
|
301
|
+
Hash[*parts].each do |k,v|
|
302
|
+
sections[k] = v.split("\n\n")
|
303
|
+
end
|
304
|
+
return sections[section_name]
|
305
|
+
end
|
306
|
+
|
307
|
+
def self.task_warning( task )
|
308
|
+
warn "WARNING: '#{task}' tasks are not defined. Please run 'rake develop'"
|
309
|
+
end
|
310
|
+
|
311
|
+
def self.project_root
|
312
|
+
File.expand_path( File.dirname(__FILE__) )
|
313
|
+
end
|
314
|
+
|
315
|
+
def self.read_manifest
|
316
|
+
abort "You need a Manifest.txt" unless File.readable?( "Manifest.txt" )
|
317
|
+
File.readlines( "Manifest.txt" ).map { |l| l.strip }
|
318
|
+
end
|
319
|
+
|
320
|
+
def self.platform_gemspec
|
321
|
+
This.gemspec[This.platform]
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
# Hold all the metadata about this project
|
326
|
+
This = OpenStruct.new
|
327
|
+
This.platform = (RUBY_PLATFORM == "java") ? 'java' : Gem::Platform::RUBY
|
328
|
+
|
329
|
+
desc = Util.section_of( 'README.rdoc', 'DESCRIPTION')
|
330
|
+
This.summary = desc.first
|
331
|
+
This.description = desc.join(" ").tr("\n", ' ').gsub(/[{}]/,'').gsub(/\[[^\]]+\]/,'') # strip rdoc
|
332
|
+
|
333
|
+
|
334
|
+
This.exclude_from_manifest = %r/tmp$|\.(git|DS_Store)|^(doc|coverage|pkg)|Gemfile*|\.gemspec$|\.swp$|\.jar|\.rvmrc$|^kestrel|~$/
|
335
|
+
This.manifest = Util.read_manifest
|
336
|
+
|
337
|
+
}
|