forked from twitter/twitter-cldr-rb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
224 lines (187 loc) · 6.3 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# encoding: UTF-8
# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0
require 'rubygems' unless ENV['NO_RUBYGEMS']
require 'bundler'
require 'digest'
require 'rspec/core/rake_task'
require 'rubygems/package_task'
require './lib/twitter_cldr'
Bundler::GemHelper.install_tasks
task :default => :spec
desc 'Run specs'
RSpec::Core::RakeTask.new do |t|
t.pattern = './spec/**/*_spec.rb'
end
namespace :spec do
desc 'Run full specs suit'
task :full => [:full_spec_env, :spec]
task :full_spec_env do
ENV['FULL_SPEC'] = 'true'
end
end
if RUBY_VERSION < '1.9.0'
desc 'Run specs with RCov'
RSpec::Core::RakeTask.new('spec:cov') do |t|
t.rcov = true
t.pattern = './spec/**/*_spec.rb'
t.rcov_opts = '-T --sort coverage --exclude gems/,spec/'
end
desc 'Run full specs suit with RCov'
task 'spec:cov:full' => %w[spec:full_spec_env spec:cov]
else
namespace :spec do
desc 'Run specs with SimpleCov'
task :cov => ['spec:simplecov_env', :spec] do
require 'launchy'
Launchy.open 'coverage/index.html'
end
desc 'Run full specs suit with SimpleCov'
task 'cov:full' => %w[spec:full_spec_env spec:cov]
task :simplecov_env do
puts 'Cleaning up coverage reports'
rm_rf 'coverage'
ENV['SCOV'] = 'true'
end
end
end
task :update do
tasks = [
"update:locales_resources",
"update:tailoring_data",
"update:unicode_data",
"update:unicode_properties",
"update:generate_casefolder", # must come after unicode data
"update:composition_exclusions",
"update:postal_codes",
"update:phone_codes",
"update:language_codes",
"update:collation_tries",
"update:canonical_compositions",
"update:rbnf_tests",
"update:segment_exceptions",
"update:readme"
]
tasks.each do |task|
puts "Executing #{task}"
Rake::Task[task].invoke
end
end
namespace :update do
ICU_JAR = './vendor/icu4j-51_2.jar'
desc 'Import locales resources'
task :locales_resources, :cldr_path do |_, args|
TwitterCldr::Resources::LocalesResourcesImporter.new(
args[:cldr_path] || './vendor/cldr',
'./resources'
).import
end
desc 'Import custom locales resources'
task :custom_locales_resources do
TwitterCldr::Resources::CustomLocalesResourcesImporter.new(
'./resources/custom/locales'
).import
end
desc 'Import tailoring resources from CLDR data (should be executed using JRuby 1.7 in 1.9 mode)'
task :tailoring_data, :cldr_path, :icu4j_jar_path do |_, args|
TwitterCldr::Resources::TailoringImporter.new(
args[:cldr_path] || './vendor/cldr',
'./resources/collation/tailoring',
args[:icu4j_jar_path] || ICU_JAR
).import(TwitterCldr.supported_locales)
end
desc 'Import Unicode data resources'
task :unicode_data, :unicode_data_path do |_, args|
TwitterCldr::Resources::UnicodeDataImporter.new(
args[:unicode_data_path] || './vendor/unicode-data',
'./resources/unicode_data'
).import
end
desc 'Import Unicode property resources'
task :unicode_properties, :unicode_properties_path do |_, args|
TwitterCldr::Resources::UnicodePropertiesImporter.new(
args[:unicode_properties_path] || './vendor/unicode-data/properties',
'./resources/unicode_data/properties'
).import
end
desc 'Generate the casefolder class. Depends on unicode data'
task :generate_casefolder do
TwitterCldr::Resources::CasefolderClassGenerator.new(
'./lib/twitter_cldr/resources/casefolder.rb.erb',
'./lib/twitter_cldr/shared'
).generate
end
desc 'Import composition exclusions resource'
task :composition_exclusions, :derived_normalization_props_path do |_, args|
TwitterCldr::Resources::CompositionExclusionsImporter.new(
args[:derived_normalization_props_path] || './vendor/unicode-data/DerivedNormalizationProps.txt',
'./resources/unicode_data'
).import
end
desc 'Import postal codes resource'
task :postal_codes, :cldr_path do |_, args|
TwitterCldr::Resources::PostalCodesImporter.new(
args[:cldr_path] || './vendor/cldr',
'./resources/shared'
).import
end
desc 'Import phone codes resource'
task :phone_codes, :cldr_path do |_, args|
TwitterCldr::Resources::PhoneCodesImporter.new(
args[:cldr_path] || './vendor/cldr',
'./resources/shared'
).import
end
desc 'Import language codes'
task :language_codes, :language_codes_data do |_, args|
TwitterCldr::Resources::LanguageCodesImporter.new(
args[:language_codes_data] || './vendor/language-codes',
'./resources/shared'
).import
end
desc 'Update default and tailoring tries dumps (should be executed using JRuby 1.7 in 1.9 mode)'
task :collation_tries do
TwitterCldr::Resources::CollationTriesDumper.update_dumps
end
desc 'Update canonical compositions resource'
task :canonical_compositions do
TwitterCldr::Resources::CanonicalCompositionsUpdater.new('./resources/unicode_data').update
end
desc 'Import normalization quick check data'
task :normalization_quick_check do
TwitterCldr::Resources::NormalizationQuickCheckImporter.new(
'./vendor',
'./resources/unicode_data'
).import
end
desc 'Import (generate) bidi tests (should be executed using JRuby 1.7 in 1.9 mode)'
task :bidi_tests do |_, args|
TwitterCldr::Resources::BidiTestImporter.new(
'./spec/bidi'
).import
end
desc 'Import (generate) rule-based number format tests (should be executed using JRuby 1.7 in 1.9 mode)'
task :rbnf_tests, :icu4j_jar_path do |_, args|
TwitterCldr::Resources::RbnfTestImporter.new(
'./spec/formatters/numbers/rbnf/locales',
args[:icu4j_jar_path] || ICU_JAR
).import(TwitterCldr.supported_locales)
end
task :segment_exceptions do
TwitterCldr::Resources::Uli::SegmentExceptionsImporter.new(
'./vendor/uli/segments',
'./resources/uli/segments'
).import([:de, :en, :es, :fr, :it, :pt, :ru]) # only locales ULI supports at the moment
end
task :readme do |_, args|
renderer = TwitterCldr::Resources::ReadmeRenderer.new(
File.read("./README.md.erb")
)
File.open("./README.md", "w+") do |f|
f.write(renderer.render)
end
if renderer.assertion_failures.size > 0
puts "There were errors encountered while updating the README. Please run specs for details"
end
end
end