rails_pdf 0.1.4 → 0.2.0

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: a742b7784d9de2ff96b957b3d56b2e581f50a9f3391e671a42a3b47ebb9af05e
4
- data.tar.gz: 759a0f0cacce237ce67b4e90fbcfd30b108435d8eabd4ee86cc32a8b55526563
3
+ metadata.gz: 44883fce40a90d093e9507abdc4a179c0583607af4b713512936bf9145e2c808
4
+ data.tar.gz: bd189278cf71f4fb035c2be28d306096094d12dca574ce40f92948acae2c6a63
5
5
  SHA512:
6
- metadata.gz: 2adec1532786547cf080cea01439344dbb4cdb86c0820b17aaf3b2958c61b01247e85601c16201e7056047eec2752db844d646bfeb4a66ca08a5a955ba2b073d
7
- data.tar.gz: 4e075625279ddfb16639f4eae52aeecbdd497697b768b4036f6061ea3977101684ab3e0366e792105a950815075561a80427da62850764e9cde6bc842b70f2d8
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 5+ app
136
+ - Rails 4.2+ app
137
137
 
138
138
  #### Install RelaxedJS
139
139
 
@@ -13,23 +13,25 @@ module RailsPDF
13
13
  end
14
14
 
15
15
  def render(&block)
16
- content = ApplicationController.render(file: @file, layout: @layout)
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&.close!
47
- output&.close!
48
+ input.try(:close!)
49
+ output.try(:close!)
48
50
  end
49
51
  end
50
52
 
@@ -1,3 +1,3 @@
1
1
  module RailsPDF
2
- VERSION = '0.1.4'
2
+ VERSION = '0.2.0'
3
3
  end
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.1.4
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-02-26 00:00:00.000000000 Z
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: 5.0.0
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: 5.0.0
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
- rubygems_version: 3.0.2
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.