Skip to content

Commit

Permalink
Copied Rakefile, gemspec, and changelog stuff from Nice-FFI.
Browse files Browse the repository at this point in the history
  • Loading branch information
jacius committed Jul 13, 2009
1 parent 0c5a145 commit 9a7114d
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 2 deletions.
129 changes: 127 additions & 2 deletions Rakefile
Expand Up @@ -37,9 +37,134 @@ require 'rake'


require 'rake/gempackagetask' require 'rake/gempackagetask'


# Load ffi-sdl.gemspec, which defines $gemspec. # Load ruby-sdl-ffi.gemspec, which defines $gemspec.
load File.join( File.dirname(__FILE__), "ffi-sdl.gemspec" ) load File.join( File.dirname(__FILE__), "ruby-sdl-ffi.gemspec" )


Rake::GemPackageTask.new( $gemspec ) do |pkg| Rake::GemPackageTask.new( $gemspec ) do |pkg|
pkg.need_tar_bz2 = true pkg.need_tar_bz2 = true
end 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
7 changes: 7 additions & 0 deletions ruby-sdl-ffi.gemspec
Expand Up @@ -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| $gemspec = Gem::Specification.new do |s|


s.name = "ruby-sdl-ffi" s.name = "ruby-sdl-ffi"
Expand Down
9 changes: 9 additions & 0 deletions 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.