-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprep.rb
57 lines (49 loc) · 1.84 KB
/
prep.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
54
55
56
57
# metadata generator for JuliaCon
# DO NOT EDIT
require 'yaml'
metadata = YAML.load_file('paper.yml')
for k in ["title", "authors", "affiliations", "keywords", "bibliography"]
raise "Key #{k} not present in metadata" unless metadata.keys().include?(k)
end
# ENV variables or default for issue/volume/year
issue = ENV["JLCON_ISSUE"] === nil ? 1 : ENV["JLCON_ISSUE"]
volume = ENV["JLCON_VOLUME"] === nil ? 1 : ENV["JLCON_VOLUME"]
year = ENV["JLCON_YEAR"] === nil ? 2021 : ENV["JLCON_YEAR"]
journal_name = "Proceedings of JuliaCon" # hard-coded for now
open('header.tex', 'w') do |f|
f << "% **************GENERATED FILE, DO NOT EDIT**************\n\n"
f << "\\title{#{metadata["title"]}}\n\n"
for auth in metadata["authors"]
f << "\\author[#{auth["affiliation"]}]{#{auth["name"]}}\n"
end
for aff in metadata["affiliations"]
f << "\\affil[#{aff["index"]}]{#{aff["name"]}}\n"
end
f << "\n\\keywords{"
for i in 0...metadata["keywords"].length-1
f << "#{metadata["keywords"][i]}, "
end
f << metadata["keywords"].last
f << "}\n\n"
# hypersetup
f << "\\hypersetup{\n"
f << "pdftitle = {#{metadata["title"]}},\n"
f << "pdfsubject = {JuliaCon 2019 Proceedings},\n"
author_list = metadata['authors'].map { |a| a['name'] }.join(', ')
f << "pdfauthor = {#{author_list}},\n"
keyword_list = metadata['keywords'].join(', ')
f << "pdfkeywords = {#{keyword_list}},\n"
f << "}\n\n"
end
open('journal_dat.tex', 'w') do |f|
f << "% **************GENERATED FILE, DO NOT EDIT**************\n\n"
f << "\\def\\@journalName{#{journal_name}}\n"
f << "\\def\\@volume{#{volume}}\n"
f << "\\def\\@issue{#{issue}}\n"
f << "\\def\\@year{#{year}}\n"
end
open('bib.tex', 'w') do |f|
f << "% **************GENERATED FILE, DO NOT EDIT**************\n\n"
f << "\\bibliographystyle{juliacon}\n"
f << "\\bibliography{#{metadata["bibliography"]}}\n"
end