forked from minad/olelo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
111 lines (93 loc) · 3.68 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
task default: :test
def shrink_js(t)
#sh "cat #{t.prerequisites.sort.join(' ')} > #{t.name}"
sh 'java -jar tools/google-compiler*.jar --dev_mode EVERY_PASS --compilation_level SIMPLE_OPTIMIZATIONS ' +
t.prerequisites.sort.map {|x| "--js #{x}" }.join(' ') + " > #{t.name}"
end
def sass(file)
`sass -C -I #{File.dirname(file)} -I static/themes -t compressed #{file}`
end
def spew(file, content)
File.open(file, 'w') {|f| f.write(content) }
end
file 'plugins/utils/pygments.scss' do
sh "pygmentize -S default -f html -a .highlight > plugins/utils/pygments.scss"
end
file('static/themes/atlantis/style.css' => Dir.glob('static/themes/atlantis/*.scss') + Dir.glob('static/themes/lib/*.scss')) do |t|
puts "Creating #{t.name}..."
content = "@media screen{#{sass(t.name.gsub('style.css', 'screen.scss'))}}@media print{#{sass(t.name.gsub('style.css', 'print.scss'))}}"
spew(t.name, content)
end
rule '.css' => ['.scss'] do |t|
puts "Creating #{t.name}..."
spew(t.name, sass(t.source))
end
file('static/script.js' => Dir.glob('static/script/*.js')) { |t| shrink_js(t) }
file('plugins/treeview/script.js' => Dir.glob('plugins/treeview/script/*.js')) {|t| shrink_js(t) }
file('plugins/misc/fancybox/script.js' => Dir.glob('plugins/misc/fancybox/script/*.js')) {|t| shrink_js(t) }
file('plugins/editor/markup/script.js' => Dir.glob('plugins/editor/markup/script/*.js')) {|t| shrink_js(t) }
namespace :gen do
desc('Shrink JS files')
task js: %w(static/script.js plugins/treeview/script.js plugins/misc/fancybox/script.js plugins/editor/markup/script.js)
desc('Compile CSS files')
task css: %w(static/themes/atlantis/style.css
plugins/treeview/treeview.css
plugins/utils/pygments.css
plugins/aspects/gallery/gallery.css
plugins/misc/fancybox/jquery.fancybox.css
plugins/blog/blog.css)
end
desc 'Run tests with bacon'
task test: FileList['test/*_test.rb'] do |t|
sh "bacon -q -Ilib:test test/run.rb"
end
desc 'Cleanup'
task :clean do |t|
FileUtils.rm_rf 'doc/api'
FileUtils.rm_rf 'coverage'
FileUtils.rm_rf '.wiki/cache'
FileUtils.rm_rf '.wiki/log'
end
namespace :doc do
desc 'Generate documentation'
task :gen do; sh "yard doc -o doc/api 'lib/**/*.rb' 'plugins/**/*.rb'"; end
desc 'Start YARD documentation server'
task :server do; sh 'yard server --reload'; end
desc 'Check YARD documentation'
task :check do; sh "yardcheck 'lib/**/*.rb' 'plugins/**/*.rb'"; end
end
namespace :locale do
desc 'Sort locale yaml files'
task :sort do
# You need the i18n_yaml_sorter gem
Dir['**/locale.yml'].each do |file|
puts "Sorting #{file}"
system("sort_yaml < #{file} > #{file}.sorted; mv #{file}.sorted #{file}")
end
end
desc 'Check locales for missing keys'
task :check do
require 'yaml'
Dir['**/locale.yml'].each do |file|
puts "Checking #{file}"
translations = YAML.load_file(file)
puts 'en locale missing' unless translations['en']
keys = translations['en'].keys
translations.each do |locale,hash|
delta = hash.keys - keys
puts "\tLocale #{locale} has additional keys #{delta.join(' ')}" unless delta.empty?
delta = keys - hash.keys
puts "\tLocale #{locale} has missing keys #{delta.join(' ')}" unless delta.empty?
end
end
end
end
namespace :notes do
task :todo do; sh('ack T''ODO'); end
task :fixme do; sh('ack F''IXME'); end
task :hack do; sh('ack H''ACK'); end
task :warning do; sh('ack W''ARNING'); end
task :important do; sh('ack I''MPORTANT'); end
end
desc 'Show annotations'
task notes: %w(notes:todo notes:fixme notes:hack notes:warning notes:important)