2008-02-21 11:41:56 -05:00
|
|
|
# Copyright 2008 Scott Barron (scott@elitists.net)
|
|
|
|
# All rights reserved
|
2008-01-07 14:11:38 -05:00
|
|
|
|
2008-02-21 11:41:56 -05:00
|
|
|
# This file may be distributed under an MIT style license.
|
|
|
|
# See MIT-LICENSE for details.
|
2008-01-07 14:11:38 -05:00
|
|
|
|
2008-02-21 11:41:56 -05:00
|
|
|
begin
|
|
|
|
require 'rubygems'
|
|
|
|
require 'rake/gempackagetask'
|
|
|
|
require 'rake/testtask'
|
|
|
|
require 'rake/rdoctask'
|
|
|
|
require 'spec/rake/spectask'
|
|
|
|
rescue Exception
|
|
|
|
nil
|
2008-01-07 14:11:38 -05:00
|
|
|
end
|
|
|
|
|
2008-10-07 10:01:15 -04:00
|
|
|
if `ruby -Ilib -raasm -e "print AASM.Version"` =~ /([0-9.]+)$/
|
2008-02-21 12:37:56 -05:00
|
|
|
CURRENT_VERSION = $1
|
|
|
|
else
|
|
|
|
CURRENT_VERSION = '0.0.0'
|
|
|
|
end
|
2008-02-21 11:41:56 -05:00
|
|
|
$package_version = CURRENT_VERSION
|
|
|
|
|
|
|
|
PKG_FILES = FileList['[A-Z]*',
|
2009-05-27 20:32:02 -04:00
|
|
|
'lib/**/*.rb',
|
|
|
|
'doc/**/*'
|
2008-04-29 02:08:51 -04:00
|
|
|
]
|
2008-01-07 14:11:38 -05:00
|
|
|
|
|
|
|
desc 'Generate documentation for the acts as state machine plugin.'
|
2008-02-21 11:41:56 -05:00
|
|
|
rd = Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
|
|
rdoc.rdoc_dir = 'html'
|
|
|
|
rdoc.template = 'doc/jamis.rb'
|
2008-01-07 14:11:38 -05:00
|
|
|
rdoc.rdoc_dir = 'rdoc'
|
2008-02-21 11:41:56 -05:00
|
|
|
rdoc.title = 'AASM'
|
2008-03-13 13:10:28 -04:00
|
|
|
rdoc.options << '--line-numbers' << '--inline-source' << '--main' << 'README.rdoc' << '--title' << 'AASM'
|
|
|
|
rdoc.rdoc_files.include('README.rdoc', 'MIT-LICENSE', 'TODO', 'CHANGELOG')
|
2009-08-08 16:53:47 -04:00
|
|
|
rdoc.rdoc_files.include('lib/*.rb', 'lib/**/*.rb', 'doc/**/*.rdoc')
|
2008-01-07 14:11:38 -05:00
|
|
|
end
|
|
|
|
|
2008-02-21 11:41:56 -05:00
|
|
|
if !defined?(Gem)
|
|
|
|
puts "Package target requires RubyGEMs"
|
|
|
|
else
|
|
|
|
spec = Gem::Specification.new do |s|
|
|
|
|
s.name = 'aasm'
|
|
|
|
s.version = $package_version
|
|
|
|
s.summary = 'State machine mixin for Ruby objects'
|
2009-05-27 20:32:02 -04:00
|
|
|
s.description = <<EOF
|
|
|
|
AASM is a continuation of the acts as state machine rails plugin, built for plain Ruby objects.
|
|
|
|
EOF
|
|
|
|
|
2008-02-21 11:41:56 -05:00
|
|
|
s.files = PKG_FILES.to_a
|
|
|
|
s.require_path = 'lib'
|
|
|
|
s.has_rdoc = true
|
|
|
|
s.extra_rdoc_files = rd.rdoc_files.reject {|fn| fn =~ /\.rb$/}.to_a
|
|
|
|
s.rdoc_options = rd.options
|
|
|
|
|
2009-08-08 16:53:47 -04:00
|
|
|
s.authors = ['Scott Barron', 'Scott Petersen', 'Travis Tilley']
|
|
|
|
s.email = 'ttilley@gmail.com'
|
|
|
|
s.homepage = 'http://github.com/ttilley/aasm'
|
2008-02-21 11:41:56 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
package_task = Rake::GemPackageTask.new(spec) do |pkg|
|
|
|
|
pkg.need_zip = true
|
|
|
|
pkg.need_tar = true
|
|
|
|
end
|
2008-01-07 14:11:38 -05:00
|
|
|
end
|
|
|
|
|
2008-02-21 11:41:56 -05:00
|
|
|
if !defined?(Spec)
|
|
|
|
puts "spec and cruise targets require RSpec"
|
|
|
|
else
|
|
|
|
desc "Run all examples with RCov"
|
|
|
|
Spec::Rake::SpecTask.new('cruise') do |t|
|
2008-02-21 12:18:08 -05:00
|
|
|
t.spec_files = FileList['spec/**/*.rb']
|
2008-02-21 11:41:56 -05:00
|
|
|
t.rcov = true
|
2008-12-12 10:05:09 -05:00
|
|
|
t.rcov_opts = ['--exclude', 'spec', '--exclude', 'Library', '--exclude', 'rcov.rb']
|
2008-02-21 11:41:56 -05:00
|
|
|
end
|
2008-04-29 02:08:51 -04:00
|
|
|
|
2008-02-21 11:41:56 -05:00
|
|
|
desc "Run all examples"
|
|
|
|
Spec::Rake::SpecTask.new('spec') do |t|
|
2008-02-21 12:18:08 -05:00
|
|
|
t.spec_files = FileList['spec/**/*.rb']
|
2008-02-21 11:41:56 -05:00
|
|
|
t.rcov = false
|
|
|
|
t.spec_opts = ['-cfs']
|
|
|
|
end
|
2008-01-07 14:11:38 -05:00
|
|
|
end
|
|
|
|
|
2008-04-29 02:08:51 -04:00
|
|
|
if !defined?(Gem)
|
|
|
|
puts "Package target requires RubyGEMs"
|
|
|
|
else
|
|
|
|
desc "sudo gem uninstall aasm && rake gem && sudo gem install pkg/aasm-3.0.0.gem"
|
|
|
|
task :reinstall do
|
|
|
|
puts `sudo gem uninstall aasm && rake gem && sudo gem install pkg/aasm-3.0.0.gem`
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2008-02-21 09:25:56 -05:00
|
|
|
task :default => [:spec]
|