holidays/rakefile.rb

113 lines
3.4 KiB
Ruby
Raw Normal View History

2007-11-20 01:58:20 +01:00
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/gempackagetask'
2007-12-19 02:06:57 +01:00
require 'yaml'
2007-11-20 01:58:20 +01:00
require 'fileutils'
require 'lib/holidays'
2007-12-05 23:33:01 +01:00
require 'data/build_defs'
2007-11-24 01:45:30 +01:00
2007-12-19 02:06:57 +01:00
desc 'Run all tests'
task :test => ["test:lib", "test:defs"]
2007-11-24 01:45:30 +01:00
2007-12-19 02:06:57 +01:00
namespace :test do
desc 'Run the unit tests.'
Rake::TestTask.new(:lib) do |t|
t.libs << 'lib'
t.test_files = FileList['test/defs/test*.rb'].exclude('test_helper.rb')
t.verbose = false
2007-11-24 01:45:30 +01:00
end
2007-12-19 02:06:57 +01:00
desc 'Run the definition tests.'
Rake::TestTask.new(:defs) do |t|
t.libs << 'lib'
t.test_files = FileList['test/test*.rb'].exclude('test_helper.rb')
t.verbose = false
2007-11-24 01:45:30 +01:00
end
2007-11-22 23:28:38 +01:00
end
2007-12-19 02:06:57 +01:00
task :doc => ["defs:manifest", :rdoc]
desc 'Generate documentation.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'doc'
rdoc.title = 'Ruby Holidays Gem'
rdoc.options << '--all' << '--inline-source' << '--line-numbers'
2007-11-25 00:22:10 +01:00
rdoc.options << '--charset' << 'utf-8'
2007-12-19 02:06:57 +01:00
#rdoc.template = 'extras/rdoc_template.rb'
rdoc.rdoc_files.include('README')
2007-11-30 01:49:33 +01:00
rdoc.rdoc_files.include('data/SYNTAX')
2007-11-25 00:22:10 +01:00
rdoc.rdoc_files.include('lib/holidays/MANIFEST')
rdoc.rdoc_files.include('REFERENCES')
2008-01-15 05:34:39 +01:00
rdoc.rdoc_files.include('CHANGELOG')
rdoc.rdoc_files.include('LICENSE')
rdoc.rdoc_files.include('lib/*.rb')
end
spec = Gem::Specification.new do |s|
s.name = 'holidays'
2008-11-20 06:46:34 +01:00
s.version = '0.9.3'
s.author = 'Alex Dunae'
s.homepage = 'http://code.dunae.ca/holidays'
s.platform = Gem::Platform::RUBY
s.description = <<-EOF
A collection of Ruby methods to deal with statutory and other holidays. You deserve a holiday!
EOF
s.summary = 'A collection of Ruby methods to deal with statutory and other holidays. You deserve a holiday!'
s.files = FileList["{lib}/**/*", "{data}/**/*", "*.rb"].to_a
2007-12-19 23:25:56 +01:00
s.test_files = FileList['test/defs/test*.rb'].exclude('test_helper.rb')
s.has_rdoc = true
2008-01-15 05:34:39 +01:00
s.extra_rdoc_files = ['README', 'data/SYNTAX', 'lib/holidays/MANIFEST', 'REFERENCES', 'CHANGELOG', 'LICENSE']
2007-11-25 00:22:10 +01:00
s.rdoc_options << '--all' << '--inline-source' << '--line-numbers' << '--charset' << 'utf-8'
end
desc 'Build the gem.'
Rake::GemPackageTask.new(spec) do |pkg|
pkg.need_zip = true
pkg.need_tar = true
2007-12-19 02:06:57 +01:00
end
desc 'Definition file tasks'
namespace :defs do
DATA_PATH = 'data'
desc 'Build holiday definition files'
task :build_all do
# load the index
def_index = YAML.load_file("#{DATA_PATH}/index.yaml")
# create a dir for the generated tests
FileUtils.mkdir_p('test/defs')
def_index['defs'].each do |region, files|
puts "Building #{region} definition module:"
files = files.collect { |f| "#{DATA_PATH}/#{f}" }
files.uniq!
module_src, test_src = parse_holiday_defs(region, files)
File.open("lib/holidays/#{region.downcase.to_s}.rb","w") do |file|
2007-12-19 02:06:57 +01:00
file.puts module_src
end
unless test_src.empty?
File.open("test/defs/test_defs_#{region.downcase.to_s}.rb","w") do |file|
2007-12-19 02:06:57 +01:00
file.puts test_src
end
end
puts "Done.\n\n"
end
end
desc 'Build the definition manifest.'
task :manifest do
File.open("lib/holidays/MANIFEST","w") do |file|
file.puts <<-EOH
==== Regional definitions
The following definition files are included in this installation:
EOH
FileList.new('lib/holidays/*.rb').each do |str|
file.puts('* ' + str.gsub(/^lib\/|\.rb$/, ''))
end
end
end
end