breezy_pdf 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/breezy_pdf/{html.rb → _html.rb} +0 -0
- data/lib/breezy_pdf/{intercept.rb → _intercept.rb} +2 -0
- data/lib/breezy_pdf/_resources.rb +9 -0
- data/lib/breezy_pdf/{uploads.rb → _uploads.rb} +0 -0
- data/lib/breezy_pdf/html/publicize.rb +1 -1
- data/lib/breezy_pdf/html_2_pdf.rb +1 -1
- data/lib/breezy_pdf/intercept/private_url.rb +10 -4
- data/lib/breezy_pdf/{private_assets → resources}/asset.rb +3 -2
- data/lib/breezy_pdf/{private_assets → resources}/html.rb +1 -1
- data/lib/breezy_pdf/version.rb +1 -1
- data/lib/breezy_pdf.rb +5 -4
- metadata +8 -8
- data/lib/breezy_pdf/private_assets.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: add1f9d8633c6f6ba66b8b2cbb4e94e6f01e12ed
|
4
|
+
data.tar.gz: 37e1354e85de2a33037a147154130d08c301cd5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e7d729d03be2baa8f78ca02e389447fe28ab8d9c596ff1f16a774cde46b1e76ed7efea82b64f1a19acb351df708002d8283a38ef810f14e42a153f26f387bc4
|
7
|
+
data.tar.gz: 98a1f90425c3f0eca15df24fc62fba57fb6c34f7a4ca0b86e5ab091c15e1d3ad9ceb0c740466c769220dce10888ddb6eab9f1f39ba40816b11dcc7442abd4f5b
|
data/README.md
CHANGED
@@ -163,7 +163,7 @@ BreezyPDF.setup do |config|
|
|
163
163
|
#
|
164
164
|
# Only applicable when `config.treat_urls_as_private == true`
|
165
165
|
#
|
166
|
-
# config.
|
166
|
+
# config.filter_elements = false
|
167
167
|
|
168
168
|
|
169
169
|
# Filter Elements Selectors
|
@@ -173,7 +173,7 @@ BreezyPDF.setup do |config|
|
|
173
173
|
#
|
174
174
|
# Only applicable when `config.treat_urls_as_private == true`
|
175
175
|
#
|
176
|
-
# config.
|
176
|
+
# config.filter_elements_selectors = %w[.breezy-pdf-remove]
|
177
177
|
|
178
178
|
# Logger
|
179
179
|
#
|
@@ -250,7 +250,7 @@ def invoice_mailer(user, invoice)
|
|
250
250
|
html = ActionController::Renderer.render(template "invoices/show", assigns: { invoice: invoice }, locals: { current_user: user })
|
251
251
|
pdf = BreezyPDF::HTML2PDF.new(, html)
|
252
252
|
|
253
|
-
attachments["invoice-#{invoice.id}.pdf"] = pdf.to_file
|
253
|
+
attachments["invoice-#{invoice.id}.pdf"] = pdf.to_file.read
|
254
254
|
@pdf_url = pdf.to_url
|
255
255
|
end
|
256
256
|
```
|
File without changes
|
File without changes
|
@@ -47,7 +47,7 @@ module BreezyPDF::HTML
|
|
47
47
|
|
48
48
|
def replace_asset_element_attr(asset_element, attr)
|
49
49
|
thread_pool.post do
|
50
|
-
asset = BreezyPDF::
|
50
|
+
asset = BreezyPDF::Resources::Asset.new(@base_url, asset_element[attr])
|
51
51
|
|
52
52
|
asset_element[attr] = BreezyPDF::Uploads::Base.new(
|
53
53
|
asset.filename, asset.content_type, asset.file_path
|
@@ -4,18 +4,24 @@ module BreezyPDF::Intercept
|
|
4
4
|
# :nodoc
|
5
5
|
class PrivateUrl < Base
|
6
6
|
def call
|
7
|
+
raise BreezyPDF::Intercept::UnRenderable unless (200..299).cover?(status)
|
8
|
+
|
7
9
|
BreezyPDF.logger.info(
|
8
10
|
"[BreezyPDF] Requesting render of #{public_url} with metadata: #{html_private_asset.metadata}"
|
9
11
|
)
|
10
12
|
|
11
|
-
|
13
|
+
render_request = BreezyPDF::RenderRequest.new(public_url, html_private_asset.metadata).submit
|
12
14
|
|
13
|
-
BreezyPDF.logger.info("[BreezyPDF] Redirect to pdf at #{
|
15
|
+
BreezyPDF.logger.info("[BreezyPDF] Redirect to pdf at #{render_request.download_url}")
|
14
16
|
[
|
15
17
|
302,
|
16
|
-
{ "Location" =>
|
18
|
+
{ "Location" => render_request.download_url, "Content-Type" => "text/html", "Content-Length" => "0" },
|
17
19
|
[]
|
18
20
|
]
|
21
|
+
rescue BreezyPDF::Intercept::UnRenderable
|
22
|
+
BreezyPDF.logger.fatal("[BreezyPDF] Unable to render HTML, server responded with HTTP Status #{status}")
|
23
|
+
|
24
|
+
response
|
19
25
|
end
|
20
26
|
|
21
27
|
private
|
@@ -27,7 +33,7 @@ module BreezyPDF::Intercept
|
|
27
33
|
end
|
28
34
|
|
29
35
|
def html_private_asset
|
30
|
-
@html_private_asset ||= BreezyPDF::
|
36
|
+
@html_private_asset ||= BreezyPDF::Resources::HTML.new(base_url, body)
|
31
37
|
end
|
32
38
|
|
33
39
|
def status
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module BreezyPDF::
|
3
|
+
module BreezyPDF::Resources
|
4
4
|
# :nodoc
|
5
5
|
class Asset
|
6
6
|
def initialize(base_url, asset_path_or_url)
|
@@ -25,7 +25,8 @@ module BreezyPDF::PrivateAssets
|
|
25
25
|
def file
|
26
26
|
@file ||= if io_object.is_a?(StringIO)
|
27
27
|
Tempfile.new.tap do |f|
|
28
|
-
f.write io_object.
|
28
|
+
f.write io_object.tap(&:rewind).read
|
29
|
+
f.flush
|
29
30
|
end
|
30
31
|
else
|
31
32
|
io_object
|
data/lib/breezy_pdf/version.rb
CHANGED
data/lib/breezy_pdf.rb
CHANGED
@@ -19,16 +19,17 @@ require "breezy_pdf/gzip"
|
|
19
19
|
module BreezyPDF
|
20
20
|
extend BreezyPDF::Util
|
21
21
|
|
22
|
+
autoload :Uploads, "breezy_pdf/_uploads"
|
23
|
+
autoload :Intercept, "breezy_pdf/_intercept"
|
24
|
+
autoload :Resources, "breezy_pdf/_resources"
|
25
|
+
autoload :HTML, "breezy_pdf/_html"
|
26
|
+
|
22
27
|
autoload :VERSION, "breezy_pdf/version"
|
23
28
|
autoload :RenderRequest, "breezy_pdf/render_request"
|
24
29
|
autoload :Client, "breezy_pdf/client"
|
25
30
|
autoload :Response, "breezy_pdf/response"
|
26
31
|
autoload :Middleware, "breezy_pdf/middleware"
|
27
32
|
autoload :Interceptor, "breezy_pdf/interceptor"
|
28
|
-
autoload :Uploads, "breezy_pdf/uploads"
|
29
|
-
autoload :Intercept, "breezy_pdf/intercept"
|
30
|
-
autoload :PrivateAssets, "breezy_pdf/private_assets"
|
31
|
-
autoload :HTML, "breezy_pdf/html"
|
32
33
|
autoload :HTML2PDF, "breezy_pdf/html_2_pdf"
|
33
34
|
|
34
35
|
BreezyPDFError = Class.new(StandardError)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: breezy_pdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Westendorf
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -142,24 +142,24 @@ files:
|
|
142
142
|
- bin/setup
|
143
143
|
- breezy_pdf.gemspec
|
144
144
|
- lib/breezy_pdf.rb
|
145
|
+
- lib/breezy_pdf/_html.rb
|
146
|
+
- lib/breezy_pdf/_intercept.rb
|
147
|
+
- lib/breezy_pdf/_resources.rb
|
148
|
+
- lib/breezy_pdf/_uploads.rb
|
145
149
|
- lib/breezy_pdf/client.rb
|
146
150
|
- lib/breezy_pdf/gzip.rb
|
147
|
-
- lib/breezy_pdf/html.rb
|
148
151
|
- lib/breezy_pdf/html/publicize.rb
|
149
152
|
- lib/breezy_pdf/html/strip.rb
|
150
153
|
- lib/breezy_pdf/html_2_pdf.rb
|
151
|
-
- lib/breezy_pdf/intercept.rb
|
152
154
|
- lib/breezy_pdf/intercept/base.rb
|
153
155
|
- lib/breezy_pdf/intercept/private_url.rb
|
154
156
|
- lib/breezy_pdf/intercept/public_url.rb
|
155
157
|
- lib/breezy_pdf/interceptor.rb
|
156
158
|
- lib/breezy_pdf/middleware.rb
|
157
|
-
- lib/breezy_pdf/private_assets.rb
|
158
|
-
- lib/breezy_pdf/private_assets/asset.rb
|
159
|
-
- lib/breezy_pdf/private_assets/html.rb
|
160
159
|
- lib/breezy_pdf/render_request.rb
|
160
|
+
- lib/breezy_pdf/resources/asset.rb
|
161
|
+
- lib/breezy_pdf/resources/html.rb
|
161
162
|
- lib/breezy_pdf/response.rb
|
162
|
-
- lib/breezy_pdf/uploads.rb
|
163
163
|
- lib/breezy_pdf/uploads/base.rb
|
164
164
|
- lib/breezy_pdf/uploads/file_form_data.rb
|
165
165
|
- lib/breezy_pdf/util.rb
|