rails_pdf 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/rails_pdf/renderer.rb +10 -8
- data/lib/rails_pdf/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44883fce40a90d093e9507abdc4a179c0583607af4b713512936bf9145e2c808
|
4
|
+
data.tar.gz: bd189278cf71f4fb035c2be28d306096094d12dca574ce40f92948acae2c6a63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e96e51f13562c97422edb772c004bae168accfcfcd96c8648841281673e2a1b301deb48f37a7aaeb724d9f46b2e908ac3bd4c304e7dccfaac7eb1087b42efd48
|
7
|
+
data.tar.gz: b2e3351bfb6961bc23ce186e36863460b177fb76016b613786c1f049d6f01dbde7d9d6b5d40808263db6611a1e75e0630ea30c4c30190dc4818addc933fa7831
|
data/README.md
CHANGED
@@ -133,7 +133,7 @@ Installation of gem is very simple, it's just requires one additional step to in
|
|
133
133
|
|
134
134
|
- RelaxedJS 0.2.0+ (check with `relaxed --version`)
|
135
135
|
- Chrome headless (bundled with relaxedjs)
|
136
|
-
- Rails
|
136
|
+
- Rails 4.2+ app
|
137
137
|
|
138
138
|
#### Install RelaxedJS
|
139
139
|
|
data/lib/rails_pdf/renderer.rb
CHANGED
@@ -13,23 +13,25 @@ module RailsPDF
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def render(&block)
|
16
|
-
|
16
|
+
controller = ActionController::Base.new
|
17
|
+
view = ActionView::Base.new(ActionController::Base.view_paths, {}, controller)
|
18
|
+
content = view.render(file: @file, layout: @layout)
|
17
19
|
|
18
20
|
logger.debug "RailsPDF ====="
|
19
21
|
logger.debug "RailsPDF content:\n#{content}"
|
20
22
|
logger.debug "RailsPDF ====="
|
21
|
-
|
23
|
+
|
22
24
|
begin
|
23
25
|
input = BetterTempfile.new("in.pug")
|
24
26
|
output = BetterTempfile.new("out.pdf")
|
25
|
-
|
27
|
+
|
26
28
|
input.write(content)
|
27
29
|
input.flush
|
28
|
-
|
30
|
+
|
29
31
|
command = "#{RailsPDF.relaxed} #{input.path.to_s} #{output.path.to_s} --basedir / --build-once"
|
30
|
-
|
32
|
+
|
31
33
|
logger.debug "RailsPDF ===== #{command}"
|
32
|
-
|
34
|
+
|
33
35
|
err = Open3.popen3(*command) do |_stdin, _stdout, stderr|
|
34
36
|
logger.debug _stdout.read
|
35
37
|
logger.debug '------'
|
@@ -43,8 +45,8 @@ module RailsPDF
|
|
43
45
|
|
44
46
|
yield(data)
|
45
47
|
ensure
|
46
|
-
input
|
47
|
-
output
|
48
|
+
input.try(:close!)
|
49
|
+
output.try(:close!)
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
data/lib/rails_pdf/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_pdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Kasyanchuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 4.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 4.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: better_tempfile
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,7 +122,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
122
|
- !ruby/object:Gem::Version
|
123
123
|
version: '0'
|
124
124
|
requirements: []
|
125
|
-
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 2.7.7
|
126
127
|
signing_key:
|
127
128
|
specification_version: 4
|
128
129
|
summary: Reliable way to generate PDF files of any complexity.
|