9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/trufflepig/feature_list.rb', line 9
def self.build
caniuse = JSON.parse File.read("#{File.dirname(__FILE__)}/../../data/caniuse.json")
patterns = JSON.parse File.read("#{File.dirname(__FILE__)}/../../data/patterns.json")
features = caniuse["data"]
output = []
patterns.keys.each do |key|
features[key].merge!({"detection_pattern" => patterns[key]})
end
features.each do |key, feature|
output << feature.merge({"id" => key})
end
output.sort!{|a, b| a["id"] <=> b["id"] }
of = File.open "#{File.dirname(__FILE__)}/../../data/features.json", "w"
of.syswrite output.to_json
of.close
end
|