-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
93 lines (85 loc) · 2.6 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
# This is free and unencumbered software released into the public domain.
require 'yaml'
require 'active_support/core_ext/hash' # `gem install activesupport`
# @return [Hash<Symbol, Hash>]
def implemented_features
YAML.load_file('etc/features.yaml').deep_symbolize_keys!
end
# @return [Array<Symbol>]
def standard_features
File.open('etc/features.txt').each_line.map { |line| line.chomp.to_sym }.sort
end
# @return [Hash<Symbol, Hash>]
def status_of_features
standard_features.inject({}) do |result, feature_name|
result[feature_name] = implemented_features[feature_name]
result
end
end
# @param [Object] status
# @return [String]
def status_icon(status)
case status
when true, 'runtime' then "✅"
when false then "❌"
else "🚧"
end
end
task default: %w(features:todo)
namespace :features do
task :all do
(implemented_features.keys + standard_features).uniq.each { |f| puts f }
end
task :std do
standard_features.each { |f| puts f }
end
task :nonstd do
(implemented_features.keys - standard_features).each { |f| puts f }
end
task :done do
implemented_features.keys.each { |f| puts f }
end
task :todo do
(standard_features - implemented_features.keys).each { |f| puts f }
end
end
file "README.md" => %w(etc/features.txt etc/features.yaml) do |t|
head = File.read(t.name).split("### Supported Clarity features\n", 2).first
File.open(t.name, 'w') do |file|
file.puts head
file.puts "### Supported Clarity features"
file.puts
file.puts ["Feature", "Type", "JavaScript", "WebAssembly", "Notes"].join(' | ')
file.puts ["-------", "----", "----------", "-----------", "-----"].join(' | ')
status_of_features.each do |feature_name, feature_types|
if feature_types.nil?
file.puts [
"`#{feature_name}`",
"",
status_icon(nil),
status_icon(nil),
"",
].join(' | ').strip
else
feature_types.each do |feature_type, feature_info|
feature_link = feature_info[:link] || '#'
sworn = feature_info[:implementations][:sworn]
sworn_js = sworn[:js]
sworn_wasm = sworn[:wasm]
file.puts [
"[`#{feature_name}`](#{feature_link})",
feature_type,
status_icon(sworn_js),
status_icon(sworn_wasm),
case sworn_js
when false then "Not supported by SmartWeave."
else ""
end
].join(' | ').strip
end
end
end
file.puts
file.puts "**Legend**: ❌ = not supported. 🚧 = work in progress. ✅ = supported."
end
end