root/platform/tdiary/Rakefile @ 12244

Revision 7823, 2.4 kB (checked in by drry, 5 years ago)

platform/tdiary/Rakefile:

  • 重複した touch を除去しました。
  • ほか、整理。
Line 
1# Rakefile for building tdiary-conrib package
2require 'rake'
3require 'rake/clean'
4require 'rake/packagetask'
5require 'rake/testtask'
6require 'spec/rake/spectask'
7
8package = {
9        :name         => 'tdiary-contrib',
10        :root         => File.expand_path(File.dirname(__FILE__)),
11        :include_dirs => %w[doc filter lib misc plugin spec test util].map{|d| File.join d, '**', '*' },
12        :binary_ext   => %w[swf].map{|ext| ".#{ext}" },
13}
14package[:pkgdir] = File.join package[:root], 'package'
15package[:rev]    = 'r' << `svnversion --no-newline --committed #{package[:root]}`[/\d+[MS]{0,2}$/]
16package.freeze
17
18Rake::TestTask.new do |t|
19        t.libs << File.join(package[:root], 'plugin')
20        t.pattern = File.join 'test', '**', '*_test.rb'
21end
22
23Spec::Rake::SpecTask.new(:spec) do |t|
24        t.spec_opts << '--colour'
25        t.spec_opts << '--options' << File.join('spec', 'spec.opts')
26end
27
28namespace :spec do
29        desc "Run all specs with RCov"
30        Spec::Rake::SpecTask.new(:rcov) do |t|
31                t.spec_opts << '--colour'
32                t.spec_opts << '--options' << File.join('spec', 'spec.opts')
33                t.rcov = true
34                t.rcov_opts = lambda do
35                        IO.readlines(File.join('spec', 'rcov.opts')).map {|l| l.chomp.split " "}.flatten
36                end
37        end
38
39        namespace :rcov do
40                task :clean do
41                        rm_rf "coverage"
42                end
43        end
44end
45
46desc 'Update source and packaging'
47task :default => [:update, :package, :clean]
48
49desc 'Update files from Subversion Repository'
50task :update do |t|
51        sh 'svn', 'update', package[:root]
52end
53
54pkg = Rake::PackageTask.new(package[:name], package[:rev]) do |p|
55        p.package_dir = package[:pkgdir]
56        p.package_files.include package[:include_dirs]
57        p.need_tar_gz  = true
58        #p.need_tar_bz2 = true
59end
60
61desc 'Convert source encoding from UTF-8 to EUC-JP'
62task :to_euc do |t|
63        require 'shell'
64        pkg.package_files.each do |f|
65                filename = File.join pkg.package_dir_path, f
66                # exclude directories and binary files
67                next if File.ftype(filename) != 'file' ||
68                        package[:binary_ext].include?(File.extname(filename))
69
70                case
71                when Shell.new.find_system_command('nkf')
72                        sh <<-EOS.gsub(/^\s+/, '')
73                                nkf -O --euc #{filename}{,.tmp} && \\
74                                touch -m --reference=#{filename} #{filename}.tmp && \\
75                                mv #{filename}{.tmp,}
76                        EOS
77                when Shell.new.find_system_command('iconv')
78                        sh <<-EOS.gsub(/^\s+/, '')
79                                iconv --from-code=utf-8 --to-code=euc-jp --output #{filename}{.tmp,} && \\
80                                touch -m --reference=#{filename} #{filename}.tmp && \\
81                                mv #{filename}{.tmp,}
82                        EOS
83                end
84        end
85end
86
Note: See TracBrowser for help on using the browser.