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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dad0ca7be7d5e599b0d18cb0f14a5b687375159b581ce703c1f736e06128ac40
4
- data.tar.gz: 901e7d2140823b9faa57d1f8085d8cdc063da5680de6e83489458c9cd4c1e805
3
+ metadata.gz: dca154aba4bc70953a487e613982442284045992fc03a28b760ca98b4be91efe
4
+ data.tar.gz: c86e0d3eb16abd4496166dc2fe9951e6912deb60db874e47e74dc01dd687b3d7
5
5
  SHA512:
6
- metadata.gz: d97a6af5181ee7d18311a73630200dbb0dbb245dcca3971b6e4e95dabe9561832b7afd0b492f4955d173261402c30a8c681a7bf9207ed29948a7150cacfa4410
7
- data.tar.gz: 7be3517b348028970c83a84bad4b90028db1fea4c70a9a257791c384841cb2895a7cd0feeb6e93845f88e92828c9fbc450a06dc9edf6eb4638ad299f478e3463
6
+ metadata.gz: a3abc1eef1e91e6ed289c28b080663a263d6a30e6e11d11a3937de26ea62f34b9a9d332ab020701304b0a6ec1d914edaae09b16d554f939f0031fa2e490aeaea
7
+ data.tar.gz: 07d05a3045cb831898a51efb068100f50cc887b1643565b0c6aa8e2473a00c040562d1a5914cfbaa0694f70d91bb546098710a6b1ce7c575948a7aaa46961db9
data/.gitignore CHANGED
@@ -6,9 +6,10 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ Gemfile.lock
9
10
 
10
11
 
11
12
  \#*#
12
13
  *~
13
14
  *.bak
14
- .DS_Store
15
+ .DS_Store
@@ -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, :date, :date=, :lastmodified, :lastmodified=, :add_creator
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 = "lualatex"
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
@@ -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
- define_method(name) do
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
- @info = Hash.new
18
- @info[:creator] = Hash.new
13
+ @creator = Hash.new
14
+ @pubdate = nil
19
15
  end
20
16
 
21
- def date=(time)
17
+ def pubdate=(time)
22
18
  if time.kind_of? String
23
- @info[:date] = Time.parse(time)
19
+ @pubdate = Time.parse(time)
24
20
  else
25
- @info[:date] = time
21
+ @pubdate = time
26
22
  end
27
23
  end
28
24
 
29
- def date
30
- @info[:date]
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
- @info[:lastmodified] = Time.parse(time)
31
+ @lastmodified = Time.parse(time)
40
32
  else
41
- @info[:lastmodified] = time
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(@info[:lastmodified])
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 !@info[:creator][role]
71
- !@info[:creator][role] = Array.new
58
+ if !@creator[role]
59
+ !@creator[role] = Array.new
72
60
  end
73
- @info[:creator][role] << name
61
+ @creator[role] << name
74
62
  end
75
63
 
76
64
  def author(sep = ", ")
77
- aut = @info[:creator]["aut"]
65
+ aut = @creator["aut"]
78
66
  if aut
79
67
  aut.join(sep)
80
68
  else
@@ -1,3 +1,3 @@
1
1
  module RbLatex
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -15,4 +15,7 @@
15
15
  \rblatexFileSeparator
16
16
  <% end %>
17
17
  <% end %>
18
+
19
+ \InputIfFileExists{colophon.tex}{}{}
20
+
18
21
  \end{document}
@@ -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.3.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-05-20 00:00:00.000000000 Z
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: []