forked from joenoon/libphonenumber-execjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
66 lines (63 loc) · 2.44 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
require 'bundler'
Bundler.require(:default, :development)
require "bundler/gem_tasks"
desc "Build the javascript output for libphonenumber. Needs env variables CLOSURE_PATH and LIBPHONENUMBER_PATH."
task :build_js do
closure = ENV["CLOSURE_PATH"]
libphonenumber = ENV["LIBPHONENUMBER_PATH"]
if !closure
raise "set CLOSURE_PATH"
end
closure = File.join(closure, "")
if !libphonenumber
raise "set LIBPHONENUMBER_PATH"
end
libphonenumber = File.join(libphonenumber, "")
cmd = %Q{
"#{closure}closure/bin/build/closurebuilder.py" \
--root="#{closure}" \
--input="#{libphonenumber}javascript/i18n/phonenumbers/phonemetadata.pb.js" \
--input="#{libphonenumber}javascript/i18n/phonenumbers/phonenumber.pb.js" \
--input="#{libphonenumber}javascript/i18n/phonenumbers/metadata.js" \
--input="#{libphonenumber}javascript/i18n/phonenumbers/phonenumberutil.js" \
--namespace="i18n.phonenumbers.metadata" \
--namespace="i18n.phonenumbers.NumberFormat" \
--namespace="i18n.phonenumbers.PhoneNumberDesc" \
--namespace="i18n.phonenumbers.PhoneMetadata" \
--namespace="i18n.phonenumbers.PhoneMetadataCollection" \
--namespace="i18n.phonenumbers.PhoneNumber" \
--namespace="i18n.phonenumbers.PhoneNumber.CountryCodeSource" \
--namespace="i18n.phonenumbers.Error" \
--namespace="i18n.phonenumbers.PhoneNumberFormat" \
--namespace="i18n.phonenumbers.PhoneNumberType" \
--namespace="i18n.phonenumbers.PhoneNumberUtil" \
--output_mode=script \
"#{libphonenumber}javascript/i18n/phonenumbers/phonemetadata.pb.js" \
"#{libphonenumber}javascript/i18n/phonenumbers/phonenumber.pb.js" \
"#{libphonenumber}javascript/i18n/phonenumbers/metadata.js" \
"#{libphonenumber}javascript/i18n/phonenumbers/phonenumberutil.js"
}
out = `#{cmd.strip}`
simple = CoffeeScript.compile(File.read(File.join(File.dirname(__FILE__), "support", "simple.coffee")))
out = %Q{
(function() {
this.goog = goog = this.goog || {};
this.i18n = i18n = this.i18n || {};
var CLOSURE_NO_DEPS = true;
#{out}
#{simple}
}).call(this);
}
outfile = File.join(File.dirname(__FILE__), "support", "libphonenumber.js")
File.open(outfile, "w") do |f|
f.write out
end
puts "Saved to #{outfile}"
end
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end