Permalink
Browse files

Copied Rakefile, gemspec, and changelog stuff from Nice-FFI.

  • Loading branch information...
1 parent 0c5a145 commit 9a7114d50ad3c5a126698d081b4c3575a1ef800c @jacius committed Jul 13, 2009
Showing with 143 additions and 2 deletions.
  1. +127 −2 Rakefile
  2. +7 −0 ruby-sdl-ffi.gemspec
  3. +9 −0 scripts/mkchangelog.rb
View
129 Rakefile
@@ -37,9 +37,134 @@ require 'rake'
require 'rake/gempackagetask'
-# Load ffi-sdl.gemspec, which defines $gemspec.
-load File.join( File.dirname(__FILE__), "ffi-sdl.gemspec" )
+# Load ruby-sdl-ffi.gemspec, which defines $gemspec.
+load File.join( File.dirname(__FILE__), "ruby-sdl-ffi.gemspec" )
Rake::GemPackageTask.new( $gemspec ) do |pkg|
pkg.need_tar_bz2 = true
end
+
+
+###############
+## VERSION ##
+###############
+
+task :version do
+ puts "%s-%s"%[$gemspec.name, $gemspec.version.to_s]
+end
+
+rule( /bump:[0-9.]+/ ) do |t|
+ ver = t.name.gsub("bump:","")
+ today = Date.today.to_s
+
+ puts "Updating version to #{ver} and date to #{today}..."
+
+ print " README.rdoc... "
+ `ruby -pi -e '
+ $_.gsub!(/\([Vv]ersion:: +\)[0-9.]+/, "\\\\1#{ver}")
+ $_.gsub!(/\([Dd]ate:: +\)[0-9-]+/, "\\\\1#{today}")
+ ' README.rdoc`
+ puts "done"
+
+ print " ruby-sdl-ffi.gemspec... "
+ `ruby -pi -e '
+ $_.gsub!(/\(s.version *= *\)"[0-9.]+"/, "\\\\1\\"#{ver}\\"")
+ ' ruby-sdl-ffi.gemspec`
+ puts "done"
+
+end
+
+
+#################
+## CHANGELOG ##
+#################
+
+task :changelog do
+ `ruby scripts/mkchangelog.rb ChangeLog.txt`
+end
+
+task "ChangeLog.txt" => [:changelog]
+task :gem => [:changelog]
+task :package => [:changelog]
+
+
+#############
+## CLEAN ##
+#############
+
+require 'rake/clean'
+
+CLEAN.include("ChangeLog.txt")
+
+
+############
+## DOCS ##
+############
+
+require 'rake/rdoctask'
+
+Rake::RDocTask.new do |rd|
+ rd.title = "Ruby-SDL-FFI #{$gemspec.version} Docs"
+ rd.main = "README.rdoc"
+ rd.rdoc_files.include( "lib/**/*.rb", "**/*.rdoc" )
+end
+
+
+#########
+# SPECS #
+#########
+
+begin
+ require 'spec/rake/spectask'
+
+ desc "Run all specs"
+ Spec::Rake::SpecTask.new do |t|
+ t.spec_files = FileList['spec/*_spec.rb']
+ end
+
+ namespace :spec do
+ desc "Run all specs"
+ Spec::Rake::SpecTask.new(:all) do |t|
+ t.spec_files = FileList['spec/*_spec.rb']
+ end
+
+ desc "Run spec/[name]_spec.rb (e.g. 'color')"
+ task :name do
+ puts( "This is just a stand-in spec.",
+ "Run rake spec:[name] where [name] is e.g. 'color', 'music'." )
+ end
+ end
+
+
+rule(/spec:.+/) do |t|
+ name = t.name.gsub("spec:","")
+
+ path = File.join( File.dirname(__FILE__),'spec','%s_spec.rb'%name )
+
+ if File.exist? path
+ Spec::Rake::SpecTask.new(name) do |t|
+ t.spec_files = [path]
+ end
+
+ puts "\nRunning spec/%s_spec.rb"%name
+
+ Rake::Task[name].invoke
+ else
+ puts "File does not exist: %s"%path
+ end
+
+end
+
+rescue LoadError
+
+ error = "ERROR: RSpec is not installed?"
+
+ task :spec do
+ puts error
+ end
+
+ rule( /spec:.*/ ) do
+ puts error
+ end
+
+end
View
7 ruby-sdl-ffi.gemspec
@@ -28,6 +28,13 @@
#++
+# Force create ChangeLog.txt if running from gem (build).
+# This is done in Rakefile when running from rake.
+if /gem/i =~ $0
+ `ruby scripts/mkchangelog.rb ChangeLog.txt`
+end
+
+
$gemspec = Gem::Specification.new do |s|
s.name = "ruby-sdl-ffi"
View
9 scripts/mkchangelog.rb
@@ -0,0 +1,9 @@
+#!/bin/env ruby
+
+# Constructs a ChangeLog from the git log.
+# Strips out commit ids, since they might change (merge, rebase, etc.).
+
+file = (ARGV[0] or "ChangeLog.txt")
+`git log --name-status > #{file}.tmp`
+`sed -e 's/^commit [0-9a-f]\\+$/#{"-"*60}/' #{file}.tmp > #{file}`
+FileUtils.rm "#{file}.tmp"

0 comments on commit 9a7114d

Please sign in to comment.