-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
114 lines (97 loc) · 3.05 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# -*- coding: utf-8 -*-
require 'bundler/gem_tasks'
require 'rake/testtask'
require 'rdoc/task'
Rake::TestTask.new do |task|
if ((ENV.key? 'RUBY_DEBUG') && (! ENV['RUBY_DEBUG'].empty?)) then
task.ruby_opts << '-d'
end
end
rule '.html' => [ '.md' ] do |t|
sh "pandoc --from=markdown --to=html5 --standalone --self-contained --css=$HOME/.pandoc/github.css --output=#{t.name} #{t.source}"
end
desc 'Build README.html from markdown source'
task :readme => %w[ README.html ]
CLOBBER.include 'README.html'
desc 'Build CHANGELOT.html from markdown source'
task :changelog => %w[ CHANGELOG.html ]
CLOBBER.include 'CHANGELOG.html'
namespace :sample do
desc 'Build sample/README.html from markdown source'
task :readme => %w[ sample/README.html ]
CLOBBER.include 'sample/README.html'
end
namespace :words do
word_count = lambda{|files, pattern|
count_table = Hash.new(0)
for f in files
IO.foreach(f) do |line|
code, _comment = line.split('#', 2)
code.scan(pattern) {|word|
count_table[word] += 1
if (ENV.key? 'DEBUG') then
puts "#{f}: #{word}: #{$`} <<< #{word} >>> #{$'}"
end
}
end
end
count_table
}
desc 'List kanji words'
task :kanji do
rb_files = `git ls-files`.lines.map(&:chomp).grep(/\.rb$/).grep_v(/^test/)
word_count[rb_files, /\p{Han}+/].sort_by{|w, c| [ c, w ] }.reverse_each do |w, c|
puts [ c, w ].join("\t")
end
end
desc 'List hiragana words'
task :hiragana do
rb_files = `git ls-files`.lines.map(&:chomp).grep(/\.rb$/).grep_v(/^test/)
word_count[rb_files, /\p{Hiragana}+/].sort_by{|w, c| [ c, w ] }.reverse_each do |w, c|
puts [ c, w ].join("\t")
end
end
desc 'List katakana words'
task :katakana do
rb_files = `git ls-files`.lines.map(&:chomp).grep(/\.rb$/).grep_v(/^test/)
word_count[rb_files, /[\p{Katakana}ー]+/].sort_by{|w, c| [ c, w ] }.reverse_each do |w, c|
puts [ c, w ].join("\t")
end
end
desc 'List japanese words'
task :japanese do
rb_files = `git ls-files`.lines.map(&:chomp).grep(/\.rb$/).grep_v(/^test/)
word_count[rb_files,
/
[_A-Za-z]*
[\p{Han}\p{Hiragana}\p{Katakana}ー]
[\p{Han}\p{Hiragana}\p{Katakana}ー_A-Za-z0-9]*
[!?]?
/x
].sort_by{|w, c| [ c, w ] }.reverse_each do |w, c|
puts [ c, w ].join("\t")
end
end
end
namespace :lib do
ruby_version_suffix = lambda{
RUBY_DESCRIPTION.split[1].tr('.', '_')
}
task :ruby_version_suffix do
puts ruby_version_suffix.call
end
desc 'Dump built-in libraries'
task :dump do
ruby "misc/dump_lib.rb >misc/lib_#{ruby_version_suffix.call}.yml"
end
CLOBBER.include "misc/lib_#{ruby_version_suffix.call}.yml"
desc 'Dump not japanized methods'
task :no_ja do
ruby "misc/dump_lib.rb --not-defined-ja >misc/lib_no_ja_#{ruby_version_suffix.call}.yml"
end
CLOBBER.include "misc/lib_no_ja_#{ruby_version_suffix.call}.yml"
end
# Local Variables:
# mode: Ruby
# indent-tabs-mode: nil
# End: