Rakefile in cairo-1.4.1 vs Rakefile in cairo-1.5.0

- old
+ new

@@ -10,12 +10,15 @@ base_dir = File.join(File.dirname(__FILE__)) truncate_base_dir = Proc.new do |x| x.gsub(/^#{Regexp.escape(base_dir + File::SEPARATOR)}/, '') end -$LOAD_PATH.unshift(File.join(base_dir, 'src')) -$LOAD_PATH.unshift(File.join('src', 'lib')) +cairo_ext_dir = File.join(base_dir, 'src') +cairo_lib_dir = File.join(cairo_ext_dir, 'lib') +$LOAD_PATH.unshift(cairo_ext_dir) +$LOAD_PATH.unshift(cairo_lib_dir) +ENV["RUBYLIB"] = "#{cairo_lib_dir}:#{cairo_ext_dir}:#{ENV['RUBYLIB']}" require 'cairo' manifest = File.join(base_dir, "Manifest.txt") manifest_contents = [] base_dir_included_components = %w(AUTHORS COPYING ChangeLog GPL @@ -40,11 +43,12 @@ at_exit do FileUtils.rm_f(manifest) end ENV["VERSION"] ||= Cairo.bindings_version -project = Hoe.new('cairo', ENV["VERSION"]) do |project| +version = ENV["VERSION"] +project = Hoe.new('cairo', version) do |project| project.rubyforge_name = 'cairo' authors = File.join(base_dir, "AUTHORS") project.author = File.readlines(authors).collect do |line| if /\s*<[^<>]*>$/ =~ line $PREMATCH @@ -60,13 +64,14 @@ :extensions => ['extconf.rb'], :require_paths => ['src/lib', 'src'], :has_rdoc => false, } news = File.join(base_dir, "NEWS") - project.changes = project.paragraphs_of(news, 0..1).join("\n\n") + project.changes = File.read(news).gsub(/\n+^Release(?m:.*)/, '') project.description = "Ruby bindings for cairo" project.need_tar = false + project.remote_rdoc_dir = "doc" end project.spec.dependencies.delete_if {|dependency| dependency.name == "hoe"} # fix Hoe's incorrect guess. @@ -97,7 +102,86 @@ Dir.chdir Hoe::RUBYLIB do rm_f project.lib_files.collect {|f| f.sub(/^lib#{File::SEPARATOR}/, '')} end Dir.chdir File.join(Hoe::PREFIX, 'bin') do rm_f project.bin_files.collect {|f| f.sub(/^bin#{File::SEPARATOR}/, '')} + end +end + + +# for releasing +task :dist do + sh "./dist.sh", version +end + +# for documentation +langs = [ + ["en", "English"], + ["ja", "日本語"], +] + +rcairo_doc_dir = File.expand_path(File.join(base_dir, "..", "rcairo-doc")) +rcairo_doc_css = File.join(rcairo_doc_dir, "doc.css") +rcairo_doc_title_image = File.join(rcairo_doc_dir, "rcairo-title.png") +doc_dir = "doc" +doc_index = File.join(doc_dir, "index.html") +doc_css = File.join(doc_dir, "doc.css") +doc_title_image = File.join(doc_dir, "rcairo-title.png") +task(doc_index).instance_variable_get("@actions").clear + +file doc_index => doc_dir do + mkdir_p doc_dir +end + +file doc_title_image => rcairo_doc_title_image do + cp rcairo_doc_title_image, doc_title_image +end + +file doc_css => [rcairo_doc_css, doc_title_image] do + cp rcairo_doc_css, doc_css +end + +file doc_index => doc_css do + File.open(doc_index, "w") do |index| + index << <<-EOH +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> + <head> + <title>rcairo reference manual</title> + <meta http-equiv="Content-type" content="text/html; charset=utf-8"> + </head> + + <body> + <h1>rcairo reference manual</h1> + + <ul> +EOH + + langs.each do |lang, native_lang| + index << <<-EOH + <li><a href="#{lang}/">#{native_lang}</a></li> +EOH + end + + index << <<-EOH + </ui> + + <p><a href="../">Up</a></p> + </body> +</html> +EOH + end +end + +langs.each do |lang,| + lang_doc_index = File.join(doc_dir, lang, "index.html") + task doc_index => lang_doc_index + file lang_doc_index do + lang_doc_dir = File.join(doc_dir, lang) + lang_rcairo_doc_dir = File.join(rcairo_doc_dir, lang) + mkdir_p lang_doc_dir + cp Dir[File.join(lang_rcairo_doc_dir, "*.rd")], lang_doc_dir + ruby File.join(rcairo_doc_dir, "update-html.rb"), lang_doc_dir + ruby File.join(rcairo_doc_dir, "update-html.rb"), lang_doc_dir + rm Dir[File.join(lang_doc_dir, "*.{rd,rdc,rbl}")] end end