Rakefile in god-0.8.0 vs Rakefile in god-0.9.0
- old
+ new
@@ -1,26 +1,12 @@
require 'rubygems'
require 'rake'
+require 'date'
-begin
- require 'jeweler'
- Jeweler::Tasks.new do |gem|
- gem.name = "god"
- gem.rubyforge_project = "god"
- gem.summary = 'Like monit, only awesome'
- gem.description = "God is an easy to configure, easy to extend monitoring framework written in Ruby."
- gem.email = "tom@mojombo.com"
- gem.homepage = "http://god.rubyforge.org/"
- gem.authors = ["Tom Preston-Werner"]
- gem.require_paths = ["lib", "ext"]
- gem.files.include("ext")
- gem.extensions << 'ext/god/extconf.rb'
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
- end
-
-rescue LoadError
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
+def source_version
+ line = File.read('lib/god.rb')[/^\s*VERSION = .*/]
+ line.match(/.*VERSION = '(.*)'/)[1]
end
require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test'
@@ -52,17 +38,47 @@
`open coverage/index.html`
end
require 'rake/rdoctask'
Rake::RDocTask.new do |rdoc|
- if File.exist?('VERSION.yml')
- config = YAML.load(File.read('VERSION.yml'))
- version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
- else
- version = ""
- end
-
rdoc.rdoc_dir = 'rdoc'
- rdoc.title = "god #{version}"
+ rdoc.title = "god #{source_version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
+end
+
+if defined?(Gem)
+ task :release => :build do
+ sh "git commit --allow-empty -a -m 'up to #{source_version}'"
+ sh "git tag v#{source_version}"
+ sh "git push origin master"
+ sh "gem push pkg/god-#{source_version}.gem"
+ end
+
+ task :build => :gemspec do
+ sh 'mkdir -p pkg'
+ sh 'gem build god.gemspec'
+ sh 'mv *.gem pkg'
+ end
+
+ task :gemspec do
+ # read spec file and split out manifest section
+ spec = File.read('god.gemspec')
+ head, manifest, tail = spec.split(" # = MANIFEST =\n")
+ # replace version and date
+ head.sub!(/\.version = '.*'/, ".version = '#{source_version}'")
+ head.sub!(/\.date = '.*'/, ".date = '#{Date.today.to_s}'")
+ # determine file list from git ls-files
+ files = `git ls-files`.
+ split("\n").
+ sort.
+ reject { |file| file =~ /^\./ }.
+ reject { |file| file =~ /^(ideas|init|site)/ }.
+ map { |file| " #{file}" }.
+ join("\n")
+ # piece file back together and write...
+ manifest = " s.files = %w[\n#{files}\n ]\n"
+ spec = [head, manifest, tail].join(" # = MANIFEST =\n")
+ File.open('god.gemspec', 'w') { |io| io.write(spec) }
+ puts "updated god.gemspec"
+ end
end
\ No newline at end of file