texd 0.2.0 → 0.2.1

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: 676222ee01af1a31facb86ee1a4416f4f5b3307e0c8e7de9b6ee7357b5e8a838
4
- data.tar.gz: 153a30b56379209ba62ec860de87ae3fc6dd322b6828df73557bef90cb526bc9
3
+ metadata.gz: c54956eeb977294ed946d8f961d16c15e41eff3eca556d31787174c07852de97
4
+ data.tar.gz: cd603c3d2e9af5b04c43a8c0f9e542fddd18b815a5a01c3d8483f3729b8dd9f1
5
5
  SHA512:
6
- metadata.gz: 210eab22723d4f043cad09601022fa577769a3235bbbac5984c538594d83015559b2f1d92d8f537cd230e301fc97425c75aca12a310d210f60ff85a05b3e0df8
7
- data.tar.gz: 82c1ebfedabb268f92871ad707aa0b1d611440bb641a134a449e112eac76d24476e3ddcf25c788b6620b364650085e09a2e5ffad0a8fcc4592b04e953d2583c5
6
+ metadata.gz: 979a9503f9e4c38817d0c54b42c0ae288592819a65d0db1bd9ccf0dcaad81005d27842f35b49fc9b7869bfbb8563817e5e447413a865499d93993b95e0749081
7
+ data.tar.gz: a9d55ce2394c5bf940360ef4f11c7524c50149a0989da9a4c62ee186ecf6fddfcdba695a753ae9f20db20d55720179acecb4e9f5d6f08cc4dab4ec1f8850a81d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- texd (0.2.0)
4
+ texd (0.2.1)
5
5
  multipart-post (~> 2.0)
6
6
  rails (>= 6.0, < 8)
7
7
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- texd (0.2.0)
4
+ texd (0.2.1)
5
5
  multipart-post (~> 2.0)
6
6
  rails (>= 6.0, < 8)
7
7
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- texd (0.2.0)
4
+ texd (0.2.1)
5
5
  multipart-post (~> 2.0)
6
6
  rails (>= 6.0, < 8)
7
7
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- texd (0.2.0)
4
+ texd (0.2.1)
5
5
  multipart-post (~> 2.0)
6
6
  rails (>= 6.0, < 8)
7
7
 
data/lib/texd/document.rb CHANGED
@@ -18,16 +18,16 @@ module Texd
18
18
  # Compile converts templates into TeX sources and collects file
19
19
  # references (created with `texd_attach` and `texd_reference` helpers).
20
20
  #
21
- # @param args are forwarded to ApplicationController#render (which in turn
22
- # forwards to ActionView::Renderer#render).
21
+ # @param [String] template name of template file in ActionView's lookup
22
+ # context.
23
+ # @param [Hash, nil] locals will be made available as getter methods in
24
+ # the template.
23
25
  # @return [Compilation]
24
- def compile(*args)
25
- locals = args.last.delete(:locals) if args.last.is_a?(Hash)
26
+ def compile(template:, locals: {})
26
27
  helper_mod = ::Texd.helpers(attachments, locals)
27
-
28
28
  tex_source = Class.new(ApplicationController) {
29
29
  helper helper_mod
30
- }.render(*args)
30
+ }.render(template: template, format: :tex)
31
31
 
32
32
  main = attachments.main_input(tex_source)
33
33
  Compilation.new(main.name, attachments)
data/lib/texd/helpers.rb CHANGED
@@ -28,8 +28,9 @@ module Texd
28
28
 
29
29
  # Escapes the given text, making it safe for use in TeX documents.
30
30
  def escape(text, line_break = "\\\\\\", typographic: true)
31
- text = +text.to_s # text might be nil or a frozen string
32
- text.tap do |str|
31
+ return "" if text.blank?
32
+
33
+ text.to_s.dup.tap do |str|
33
34
  str.gsub!(ESCAPE_RE) do |m|
34
35
  if Regexp.last_match(1)
35
36
  "\\#{m}"
data/lib/texd/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Texd
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
data/lib/texd.rb CHANGED
@@ -94,8 +94,8 @@ module Texd
94
94
  # Render compiles a template, uploads the files to the texd instance,
95
95
  # and returns the PDF.
96
96
  #
97
- # The arguments are directly forwarded to ApplicationController#render
98
- # (which in turn delegates to ActionView::Renderer#render).
97
+ # The arguments are directly forwarded to Texd::Document (and end up in
98
+ # ActionView::Renderer#render).
99
99
  #
100
100
  # @example Render app/views/document/document.tex.erb
101
101
  # begin
@@ -114,12 +114,16 @@ module Texd
114
114
  # # something went wrong before we even got to sent data to the server
115
115
  # end
116
116
  #
117
+ # @param [String] template name of template file in ActionView's lookup
118
+ # context.
119
+ # @param [Hash, nil] locals will be made available as getter methods in
120
+ # the template.
117
121
  # @raise [Texd::Client::ResponseError] on input and queue errors. Also on
118
122
  # compilation errors, if Texd.config.error_format is set to JSON.
119
123
  # @raise [Texd::Error] on other Texd related errors.
120
124
  # @return [String] the PDF object
121
- def render(*args)
122
- doc = Document.compile(*args)
125
+ def render(template:, locals: {})
126
+ doc = Document.compile(template: template, locals: locals)
123
127
 
124
128
  client.render doc.to_upload_ios,
125
129
  input: doc.main_input_name
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: texd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Menke
@@ -140,7 +140,7 @@ metadata:
140
140
  rubygems_mfa_required: 'true'
141
141
  homepage_uri: https://github.com/digineo/texd-ruby
142
142
  source_code_uri: https://github.com/digineo/texd-ruby
143
- changelog_uri: https://github.com/digineo/texd-ruby/blob/v0.2.0/CHANGELOG.md
143
+ changelog_uri: https://github.com/digineo/texd-ruby/blob/v0.2.1/CHANGELOG.md
144
144
  post_install_message:
145
145
  rdoc_options: []
146
146
  require_paths: