-
Notifications
You must be signed in to change notification settings - Fork 1
/
runner.rb
53 lines (44 loc) · 1.18 KB
/
runner.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
46
47
48
49
50
51
52
53
require 'yaml'
require 'awesome_print'
require_relative './dubai_hackathon.rb'
require 'json'
module DubaiHackathon
def self.download
countries = DubaiHackathon::Members.new
.list
.map(&:country)
.compact
hist = DubaiHackathon::histogram countries
modified_histogram = DubaiHackathon::adjust_for_canada(hist)
DubaiHackathon::write_as_yaml file_name: 'histogram.yml', content: modified_histogram
end
def self.histogram_hash
@histogram_hash ||= YAML::load File.open('histogram.yml', 'r') { |f| f.read }
end
def self.map_data
'country_data = ' + histogram_hash
.map { |k, v| [k, v] }
.unshift(['Country', 'Participants'])
.to_s
end
def self.write_map_data
File.open('./docs/data.js', 'w') { |f| f.write map_data }
end
def self.write_meta_data
total = histogram_hash
.values
.reduce(:+)
meta = {
total: total,
countries: histogram_hash.count,
updated_at: Time.now.strftime("%b %d")
}.to_json
meta_data = "meta = #{meta}"
File.open('./docs/meta.js', 'w') { |f| f.write meta_data }
end
def self.update
download
write_meta_data
write_map_data
end
end