rb_latex 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db3bfe51c9acc6a2e9eb70c327a7f6bab5605d02ab49fa89f23060b82c9dd2e3
4
- data.tar.gz: 89b454c60cdcfe0b9394aa52bd67577045c8fe456f5fe2bc3296a3b4b4e9bfb8
3
+ metadata.gz: c0b9a42b31411e59612673356412e6f753f6d8786a0218a144473718e3f49d5f
4
+ data.tar.gz: 271eb929d4d760929d7b4a42ff122022c57dcf91a262669f50dfb9836b9adf86
5
5
  SHA512:
6
- metadata.gz: 6ce641bbd8570ae2d740851f00dec3ab0f17dbe5957e7cf8359a87d30c8de602be8fe3e29a48d83db1a297145f6b8e2889fe729ba3a6a9f5e21bb469482d91f0
7
- data.tar.gz: 5ec6693c83fb2f373c1bd08ca7fd2b25dbad8879ab0f09a05a04154511e6a87b636f0e552104a012f7328bdb74c6fbb0b3ff081c41609daba76b9eed85ba2914
6
+ metadata.gz: 55275c961565f9baf3b50299c59fa2f372ff51424a7868bff72797e60df37d14ea779582664d8836154ef81d98db34cc599c8f81955b835d37804fe6a50d9bfb
7
+ data.tar.gz: 48dfbb3ed6f6be6a48ea1fd486177e64cca9a13ebe5b20220e99c01391af7733777de3a728777b8c06559fbc775a8c33a00cd19484c84310a0c6eba913194bdc
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Masayoshi Takahashi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -52,8 +52,7 @@ module RbLatex
52
52
  copy_files(dir)
53
53
  Dir.chdir(dir) do
54
54
  generate_src(dir)
55
- exec_latex(dir)
56
- exec_dvipdf(dir)
55
+ compile_latex(dir)
57
56
  end
58
57
  FileUtils.cp(File.join(dir, "book.pdf"), filename)
59
58
  end
@@ -61,7 +60,7 @@ module RbLatex
61
60
 
62
61
  def copy_files(dir)
63
62
  Dir.entries(@root_dir).each do |path|
64
- next if path == "." or path == ".." or path =~ /\A\.rblatex/
63
+ next if path == "." or path == ".." or path == @work_dir
65
64
  FileUtils.cp_r(File.join(@root_dir, path), dir, dereference_root: true)
66
65
  end
67
66
  end
@@ -78,8 +77,9 @@ module RbLatex
78
77
  File.write(File.join(dir, "rblatexdefault.sty"), rblatexdefault_sty)
79
78
  end
80
79
 
81
- def exec_latex(dir)
82
- cmd = "#{@latex_command} book.tex"
80
+ def compile_latex(dir)
81
+ texfile = "book.tex"
82
+ cmd = "#{@latex_command} #{texfile}"
83
83
  3.times do |i|
84
84
  out, status = Open3.capture2e(cmd)
85
85
  if !status.success?
@@ -90,11 +90,14 @@ module RbLatex
90
90
  raise RbLatex::Error, "fail to exec latex (#{i}): #{cmd}"
91
91
  end
92
92
  end
93
+ dvifile = File.basename(texfile, ".*") + ".dvi"
94
+ if File.exist?(dvifile)
95
+ exec_dvipdf(dvifile)
96
+ end
93
97
  end
94
98
 
95
- def exec_dvipdf(dir)
96
- return if !File.exist?("book.dvi")
97
- cmd = "#{@dvipdf_command} book.dvi"
99
+ def exec_dvipdf(dvifile)
100
+ cmd = "#{@dvipdf_command} #{dvifile}"
98
101
  out, status = Open3.capture2e(cmd)
99
102
  if !status.success?
100
103
  @error_log = out
@@ -1,3 +1,3 @@
1
1
  module RbLatex
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rb_latex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - takahashim
@@ -90,6 +90,7 @@ files:
90
90
  - ".gitignore"
91
91
  - ".travis.yml"
92
92
  - Gemfile
93
+ - LICENSE
93
94
  - README.md
94
95
  - Rakefile
95
96
  - bin/console