Rakefile in errand-0.7.3 vs Rakefile in errand-0.7.4
- old
+ new
@@ -1,28 +1,80 @@
#!/usr/bin/env ruby
require 'rubygems'
+require 'bundler/setup'
+require 'colorize'
+require 'pathname'
+$: << Pathname.new(__FILE__).parent.join('lib').expand_path.to_s
+require 'errand/version'
+require 'rspec/core/rake_task'
-begin
- require 'jeweler'
- Jeweler::Tasks.new do |gemspec|
- gemspec.name = "errand"
- gemspec.summary = "Ruby language binding for RRD tool version 1.2+"
- gemspec.description = "Errand provides Ruby bindings for RRD functions (via librrd), and a concise DSL for interacting with RRDs."
- gemspec.email = "lindsay@holmwood.id.au"
- gemspec.homepage = "http://auxesis.github.com/errand"
- gemspec.authors = ["Lindsay Holmwood"]
+RSpec::Core::RakeTask.new(:spec)
+
+desc "build gem"
+task :build => :verify do
+ build_output = `gem build errand.gemspec`
+ puts build_output
+
+ gem_filename = build_output[/File: (.*)/,1]
+ pkg_path = "pkg"
+ FileUtils.mkdir_p(pkg_path)
+ FileUtils.mv(gem_filename, pkg_path)
+
+ puts "Gem built in #{pkg_path}/#{gem_filename}".green
+end
+
+desc "push gem"
+task :push do
+ filenames = Dir.glob("pkg/*.gem")
+ filenames_with_times = filenames.map do |filename|
+ [filename, File.mtime(filename)]
end
-rescue LoadError
- puts "Jeweler not available. Install it with: gem install jeweler"
+
+ newest = filenames_with_times.sort_by { |tuple| tuple.last }.last
+ newest_filename = newest.first
+
+ command = "gem push #{newest_filename}"
+ system(command)
end
-begin
- require 'spec/rake/spectask'
+desc "clean up various generated files"
+task :clean do
+ [ "webrat.log", "pkg/", "_site/"].each do |filename|
+ puts "Removing #{filename}"
+ FileUtils.rm_rf(filename)
+ end
+end
- Spec::Rake::SpecTask.new do |t|
- t.spec_opts = ["--options", "spec/spec.opts"]
+namespace :verify do
+ task :changelog do
+ changelog_filename = "CHANGELOG.md"
+ version = Errand::VERSION
+
+ if not File.exists?(changelog_filename)
+ puts "#{changelog_filename} doesn't exist.".red
+ exit 1
+ end
+
+ if not system("grep ^#{version} #{changelog_filename} >/dev/null 2>&1")
+ puts "#{changelog_filename} doesn't have an entry for the version you are about to build.".red
+ exit 1
+ end
end
-rescue LoadError
- puts "RSpec not available. Install it with: gem install rspec"
+
+ task :uncommitted do
+ uncommitted = `git ls-files -m`.split("\n")
+ if uncommitted.size > 0
+ puts "The following files are uncommitted:".red
+ uncommitted.each do |filename|
+ puts " - #{filename}".red
+ end
+ exit 1
+ end
+ end
+
+ task :all => [ :changelog, :uncommitted ]
end
+task :verify => 'verify:all'
+
+task :default => :spec