-
Notifications
You must be signed in to change notification settings - Fork 0
/
combine.rb
executable file
·45 lines (36 loc) · 1.21 KB
/
combine.rb
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
#!/usr/bin/ruby
require 'fileutils'
require 'json'
FileUtils.rm("data/bills.json", :force => true)
bills = Hash.new
Dir["data/bills/*.json"].each do |file|
billName = File.basename(file).split('.').first
jsonBillPath = "data/bills/#{billName}.json"
json = JSON.parse(File.read(jsonBillPath))
bills[billName] = json
end
Dir["data/bills/bernies/*.md"].each do |file|
billName = File.basename(file).split('.').first
markdownPath = "data/bills/bernies/#{billName}.md"
markdownText = File.read(markdownPath).strip.gsub("\"","\"").gsub("\n", '\n')
if (bills[billName] == nil) then
puts "Could not find bernie comments for " + billName;
bills[billName] = Hash.new
end
bills[billName]["bernie"] = markdownText
end
Dir["data/bills/summary/*.md"].each do |file|
billName = File.basename(file).split('.').first
summary = File.read(file).strip.gsub("\"","\"")
if (bills[billName] == nil) then
bills[billName] = Hash.new
puts "Could not find summary for " + billName;
end
bills[billName]["summary"] = summary
end
billArray = Array.new
bills.each do |billName, json|
billArray.push(json)
end
combinedBillPath = "data/bills.json"
File.open(combinedBillPath, 'w') { |f| f.write(billArray.to_json) }