Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathRakefile
More file actions
Latest commit
141 lines (113 loc) · 3.65 KB
/
Copy pathRakefile
File metadata and controls
141 lines (113 loc) · 3.65 KB
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
require"bundler/setup"
require"bundler/gem_tasks"
require"rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
task:compile,[:compiler,:target]do |t,args|
require"interscript"
compiler,ext=caseargs[:compiler]
when"ruby"
require"interscript/compiler/ruby"
[Interscript::Compiler::Ruby,"rb"]
when"javascript"
require"interscript/compiler/javascript"
[Interscript::Compiler::Javascript,"js"]
when"python"
require"interscript/compiler/python"
[Interscript::Compiler::Python,"py"]
end
FileUtils.mkdir_p(args[:target])
maplist={}
maps=Interscript.maps
maps=Interscript.exclude_maps(maps,compiler: compiler,platform: false)
maps.eachdo |map|
code=compiler.call(map).code
File.write(args[:target] + "/" + map + "." + ext,code)
maplist[map]=nil
end
Interscript.maps(libraries: true).eachdo |map|
code=compiler.call(map).code
File.write(args[:target] + "/" + map + "." + ext,code)
end
File.write(args[:target] + "/index.json",maplist.to_json)ifargs[:compiler] == "javascript"
end
task:generate_visualization_htmldo
require"fileutils"
require"interscript"
require"interscript/visualize"
FileUtils.rm_rf(dir=__dir__ + "/visualizations/")
FileUtils.mkdir_p(dir)
Interscript.maps.eachdo |map|
html=Interscript::Visualize.call(map)
File.write(dir + map + ".html",html)
end
end
task:generate_metadata_jsondo
require"fileutils"
require"json"
require"interscript"
require"interscript/compiler/javascript"
FileUtils.rm_rf(file=__dir__ + "/metadata.json")
hash=Interscript.maps.mapdo |map|
parsed_map=Interscript.parse(map)
md=parsed_map.metadata.to_hash
md["test"]=parsed_map.tests&.data&.first
md["skip_js"]=Interscript.exclude_maps([map],
compiler: Interscript::Compiler::Javascript,
platform: false).empty?
[map,md]
end.to_h
File.write(file,JSON.pretty_generate(hash))
end
task:generate_jsondo
require"fileutils"
require"json"
require"interscript"
FileUtils.rm_rf(dir=__dir__ + "/json/")
FileUtils.mkdir_p(dir)
(Interscript.maps + Interscript.maps(libraries: true)).eachdo |map|
json=JSON.pretty_generate(Interscript.parse(map).to_hash)
File.write(dir + map + ".json",json)
end
end
task:generate_visualization_jsondo
require"fileutils"
require"interscript"
require"json"
require"interscript/visualize"
FileUtils.rm_rf(dir=__dir__ + "/vis_json/")
FileUtils.mkdir_p(dir)
(Interscript.maps + Interscript.maps(libraries: true)).eachdo |map_name|
map=Interscript.parse(map_name)
map.stages.eachdo |stage_name,stage|
json=JSON.pretty_generate(stage.to_visualization_array(map))
File.write(dir + map_name + "_#{stage_name}.json",json)
end
end
end
task:generate_authority_jsondo
require"interscript"
require"json"
require"iso-639-data"
FileUtils.rm_rf(dir=__dir__ + "/auth_json/")
FileUtils.mkdir_p(dir)
%w[isoicaodin].eachdo |auth|
out=Interscript.maps.selectdo |map_name|
map_name.start_with?"#{auth}-"
end.sort.mapdo |map_name|
map=Interscript.parse(map_name)
tests=map.tests&.data&.first(2)&.transpose || []
std,lang=map.metadata.data[:language].split(":")
{
lang: std.end_with?("-3") ? Iso639Data.iso_639_3[lang]["Ref_Name"] : Iso639Data.iso_639_2[lang]["eng"],
isoName: map.metadata.data[:name],
systemName: map_name,
samples: tests[0] || [],
english: [],
result: []
}
end
json=JSON.pretty_generate(out)
File.write(dir + auth + ".json",json)
end
end
taskdefault: :spec