-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathRakefile
36 lines (33 loc) · 897 Bytes
/
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
require 'csv'
require 'yaml'
require 'open-uri'
def clean(t)
t.strip if t
end
file '_data/press.yml' do |t|
sheet = 'https://docs.google.com/spreadsheets/d/1xkunaEW258tDvt-_iGai-IytvzKFWYVY3nxSfasWJak/pub?gid=607933394&single=true&output=csv'
data = []
CSV.new(open(sheet).read.force_encoding('utf-8'), headers: true).each do |item|
puts item
data << {
'title' => {
'de' => clean(item['title-de']),
'en' => clean(item['title-en'])
},
'author' => clean(item['Autor']),
'source' => clean(item['Wer']),
'date' => clean(item['Datum']),
'link' => {
'de' => clean(item['link-de']),
'en' => clean(item['link-en']),
},
'teaser' => {
'de' => clean(item['teaser-de']),
'en' => clean(item['teaser-en']),
}
}
end
File.open(t.name, 'w') do |h|
h.write(data.to_yaml)
end
end