rb_latex 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/lib/rb_latex/maker.rb +11 -3
- data/lib/rb_latex/meta_info.rb +18 -30
- data/lib/rb_latex/version.rb +1 -1
- data/templates/book.tex.erb +3 -0
- data/templates/colophon.tex.erb +18 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dca154aba4bc70953a487e613982442284045992fc03a28b760ca98b4be91efe
|
4
|
+
data.tar.gz: c86e0d3eb16abd4496166dc2fe9951e6912deb60db874e47e74dc01dd687b3d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3abc1eef1e91e6ed289c28b080663a263d6a30e6e11d11a3937de26ea62f34b9a9d332ab020701304b0a6ec1d914edaae09b16d554f939f0031fa2e490aeaea
|
7
|
+
data.tar.gz: 07d05a3045cb831898a51efb068100f50cc887b1643565b0c6aa8e2473a00c040562d1a5914cfbaa0694f70d91bb546098710a6b1ce7c575948a7aaa46961db9
|
data/.gitignore
CHANGED
data/lib/rb_latex/maker.rb
CHANGED
@@ -12,6 +12,7 @@ module RbLatex
|
|
12
12
|
attr_accessor :dvipdf_command
|
13
13
|
attr_accessor :debug
|
14
14
|
attr_accessor :book_name
|
15
|
+
attr_accessor :colophons
|
15
16
|
attr_reader :work_dir
|
16
17
|
|
17
18
|
RbLatex::MetaInfo::ATTRS.each do |name|
|
@@ -20,7 +21,9 @@ module RbLatex
|
|
20
21
|
def_delegator :@meta_info, name_eq
|
21
22
|
end
|
22
23
|
|
23
|
-
def_delegators :@meta_info, :
|
24
|
+
def_delegators :@meta_info, :lastmodified, :lastmodified=, :add_creator
|
25
|
+
def_delegator :@meta_info, :pubdate, :date
|
26
|
+
def_delegator :@meta_info, :pubdate=, :date=
|
24
27
|
|
25
28
|
def initialize(root_dir)
|
26
29
|
@root_dir = root_dir
|
@@ -34,6 +37,7 @@ module RbLatex
|
|
34
37
|
@debug = nil
|
35
38
|
@book_name = "book"
|
36
39
|
@default_option = nil
|
40
|
+
@colophons = nil
|
37
41
|
end
|
38
42
|
|
39
43
|
def add_item(filename, content)
|
@@ -69,12 +73,16 @@ module RbLatex
|
|
69
73
|
@dclass_option += ",tate"
|
70
74
|
end
|
71
75
|
if @latex_command =~ /lualatex/
|
72
|
-
@default_option = "
|
76
|
+
@default_option = "luatex"
|
73
77
|
end
|
74
78
|
book_tex = apply_template("book.tex.erb")
|
75
79
|
File.write(File.join(dir, book_filename(".tex")), book_tex)
|
76
80
|
rblatexdefault_sty = apply_template("rblatexdefault.sty")
|
77
81
|
File.write(File.join(dir, "rblatexdefault.sty"), rblatexdefault_sty)
|
82
|
+
if @colophons
|
83
|
+
colophon_tex = apply_template("colophon.tex.erb")
|
84
|
+
File.write(File.join(dir, "colophon.tex"), colophon_tex)
|
85
|
+
end
|
78
86
|
end
|
79
87
|
|
80
88
|
def compile_latex(dir)
|
@@ -136,7 +144,7 @@ module RbLatex
|
|
136
144
|
|
137
145
|
def apply_template(template_file)
|
138
146
|
template = File.read(File.join(RbLatex::TEMPLATES_DIR, template_file))
|
139
|
-
return ERB.new(template).result(binding)
|
147
|
+
return ERB.new(template, nil, '-').result(binding)
|
140
148
|
end
|
141
149
|
|
142
150
|
end
|
data/lib/rb_latex/meta_info.rb
CHANGED
@@ -4,54 +4,42 @@ module RbLatex
|
|
4
4
|
ATTRS = %i(title creator page_progression_direction language publisher)
|
5
5
|
|
6
6
|
ATTRS.each do |name|
|
7
|
-
|
8
|
-
@info[name]
|
9
|
-
end
|
10
|
-
name_eq = "#{name}=".to_sym
|
11
|
-
define_method(name_eq) do |val|
|
12
|
-
@info[name] = val
|
13
|
-
end
|
7
|
+
attr_accessor name
|
14
8
|
end
|
15
9
|
|
10
|
+
attr_reader :pubdate, :lastmodified
|
11
|
+
|
16
12
|
def initialize
|
17
|
-
@
|
18
|
-
@
|
13
|
+
@creator = Hash.new
|
14
|
+
@pubdate = nil
|
19
15
|
end
|
20
16
|
|
21
|
-
def
|
17
|
+
def pubdate=(time)
|
22
18
|
if time.kind_of? String
|
23
|
-
@
|
19
|
+
@pubdate = Time.parse(time)
|
24
20
|
else
|
25
|
-
@
|
21
|
+
@pubdate = time
|
26
22
|
end
|
27
23
|
end
|
28
24
|
|
29
|
-
def
|
30
|
-
@
|
31
|
-
end
|
32
|
-
|
33
|
-
def date_to_s
|
34
|
-
date_format(@info[:date])
|
25
|
+
def pubdate_to_s
|
26
|
+
date_format(@pubdate)
|
35
27
|
end
|
36
28
|
|
37
29
|
def lastmodified=(time)
|
38
30
|
if time.kind_of? String
|
39
|
-
@
|
31
|
+
@lastmodified = Time.parse(time)
|
40
32
|
else
|
41
|
-
@
|
33
|
+
@lastmodified = time
|
42
34
|
end
|
43
35
|
end
|
44
36
|
|
45
|
-
def lastmodified
|
46
|
-
@info[:lastmodified]
|
47
|
-
end
|
48
|
-
|
49
37
|
def lastmodified_to_s
|
50
|
-
date_format(@
|
38
|
+
date_format(@lastmodified)
|
51
39
|
end
|
52
40
|
|
53
41
|
def all
|
54
|
-
@info
|
42
|
+
## @info
|
55
43
|
end
|
56
44
|
|
57
45
|
def to_latex
|
@@ -67,14 +55,14 @@ module RbLatex
|
|
67
55
|
end
|
68
56
|
|
69
57
|
def add_creator(name, role)
|
70
|
-
if !@
|
71
|
-
!@
|
58
|
+
if !@creator[role]
|
59
|
+
!@creator[role] = Array.new
|
72
60
|
end
|
73
|
-
@
|
61
|
+
@creator[role] << name
|
74
62
|
end
|
75
63
|
|
76
64
|
def author(sep = ", ")
|
77
|
-
aut = @
|
65
|
+
aut = @creator["aut"]
|
78
66
|
if aut
|
79
67
|
aut.join(sep)
|
80
68
|
else
|
data/lib/rb_latex/version.rb
CHANGED
data/templates/book.tex.erb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
\newpage
|
2
|
+
\thispagestyle{empty}
|
3
|
+
\vspace*{\fill}
|
4
|
+
\begin{tabular}{ll}
|
5
|
+
<%- @colophons.each do |key, val| -%>
|
6
|
+
<%- if val.kind_of? Array -%>
|
7
|
+
<%- val.each_with_index do |item, idx| -%>
|
8
|
+
<%- if idx > 0 -%>
|
9
|
+
& <%= item %> \\
|
10
|
+
<%- else -%>
|
11
|
+
<%= key %> & <%= item %> \\
|
12
|
+
<%- end -%>
|
13
|
+
<%- end -%>
|
14
|
+
<%- else -%>
|
15
|
+
<%= key %> & <%= val %> \\
|
16
|
+
<%- end -%>
|
17
|
+
<%- end -%>
|
18
|
+
\end{tabular}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rb_latex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- takahashim
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- lib/rb_latex/version.rb
|
106
106
|
- rb_latex.gemspec
|
107
107
|
- templates/book.tex.erb
|
108
|
+
- templates/colophon.tex.erb
|
108
109
|
- templates/rblatexdefault.sty
|
109
110
|
homepage: https://github.com/takahashim/rb_latex
|
110
111
|
licenses: []
|