ferrum_pdf 3.0.0 → 3.0.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: a0c9bdbd12753b4efc5b29bb208908735218fc2614e45eb74e57b6623ca61688
4
- data.tar.gz: cb96c86e8c45a34037db93555c9ac5d692f7ccc4d0f37c88e211e6dcb17f7aa1
3
+ metadata.gz: efe120091d2cc3eaaf6ce3e7fc5ccb3c34d3fabe59570986fa5b08d89295b58a
4
+ data.tar.gz: b3923cb2306e1cd27023725ddb088ae9f6ed290aab538db1e0d27bdb032d79cd
5
5
  SHA512:
6
- metadata.gz: b3e3efc16d9c2601e6ef725d9d1aa6f73d631c8dcfaff8a4aa76a2254e933d7205e33f00a98ac780c7cf0b99fa074e2d820abee42de372fb68966a00fb533faa
7
- data.tar.gz: 292b03680170140e5e901f8e84128970cb88a17e17147b57142ad686edca9c31da24c327e8c733505e6188a50310cac7d112a3ce1f92f89ed50b301ec7a0cd9b
6
+ metadata.gz: 4e44f85006fc98e28298c2e3720b3066bc59611c32b439791df54d5b70e4dae5eaa62fabe1499d75f7f85599ff79e52ffee60485556f3b1167a1082aeb381702
7
+ data.tar.gz: 86ad9105c1a8e2bf3c867a91e0a409d045d5ffdbc6755bdfa5af02a7948271c32ab063a138f3ff09903daa3f100642ef8f328aea154cb4e316add75944d07680
@@ -0,0 +1,19 @@
1
+ ActiveSupport.on_load(:action_controller) do
2
+ # render ferrum_pdf: { pdf options }, template: "whatever", disposition: :inline, filename: "example.pdf"
3
+ ActionController.add_renderer :ferrum_pdf do |pdf_options, options|
4
+ send_data_options = options.extract!(:disposition, :filename, :status)
5
+ url = pdf_options.delete(:url)
6
+ html = render_to_string(**options.with_defaults(formats: [ :html ])) if url.blank?
7
+ pdf = FerrumPdf.render_pdf(html: html, display_url: request.original_url, url: url, pdf_options: pdf_options)
8
+ send_data(pdf, **send_data_options.with_defaults(type: :pdf))
9
+ end
10
+
11
+ # render ferrum_screenshot: { pdf options }, template: "whatever", disposition: :inline, filename: "example.png"
12
+ ActionController.add_renderer :ferrum_screenshot do |screenshot_options, options|
13
+ send_data_options = options.extract!(:disposition, :filename, :status)
14
+ url = screenshot_options.delete(:url)
15
+ html = render_to_string(**options.with_defaults(formats: [ :html ])) if url.blank?
16
+ screenshot = FerrumPdf.render_screenshot(url: url, html: html, display_url: request.original_url, screenshot_options: screenshot_options)
17
+ send_data(screenshot, **send_data_options.with_defaults(type: screenshot_options.fetch(:format, :png)))
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module FerrumPdf
2
- VERSION = "3.0.0"
2
+ VERSION = "3.0.1"
3
3
  end
data/lib/ferrum_pdf.rb CHANGED
@@ -1,6 +1,8 @@
1
- require "ferrum_pdf/version"
2
- require "ferrum_pdf/railtie"
3
1
  require "ferrum"
2
+ require "action_controller"
3
+
4
+ require "ferrum_pdf/renderers"
5
+ require "ferrum_pdf/version"
4
6
 
5
7
  module FerrumPdf
6
8
  DEFAULT_HEADER_TEMPLATE = "<div class='date text left'></div><div class='title text center'></div>"
@@ -81,14 +83,16 @@ module FerrumPdf
81
83
  end
82
84
  end
83
85
 
86
+ private
87
+
84
88
  # Loads page into the browser to be used for rendering PDFs or screenshots
85
89
  #
86
- def load_page(url: nil, html: nil, display_url: nil, authorize: nil, wait_for_idle_options: nil, timeout_if_open_connections: true, browser: nil, retries: nil)
90
+ def load_page(url: nil, html: nil, display_url: nil, authorize: nil, wait_for_idle_options: nil, timeout_if_open_connections: nil, browser: nil, retries: nil)
87
91
  try ||= 0
88
92
  authorize ||= config.dig(:page_options, :authorize)
89
93
  retries ||= config.page_options.fetch(:retries, 1)
90
94
  wait_for_idle_options = config.page_options.fetch(:wait_for_idle_options, {}).merge(wait_for_idle_options || {})
91
- timeout_if_open_connections ||= config.page_options.fetch(:timeout_if_open_connections, true)
95
+ timeout_if_open_connections = config.page_options.fetch(:timeout_if_open_connections, true) if timeout_if_open_connections.nil?
92
96
 
93
97
  with_browser(browser) do |browser|
94
98
  # Closes page automatically after block finishes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ferrum_pdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Oliver
@@ -10,7 +10,7 @@ cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
- name: rails
13
+ name: actionpack
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - ">="
@@ -49,7 +49,7 @@ files:
49
49
  - README.md
50
50
  - Rakefile
51
51
  - lib/ferrum_pdf.rb
52
- - lib/ferrum_pdf/railtie.rb
52
+ - lib/ferrum_pdf/renderers.rb
53
53
  - lib/ferrum_pdf/version.rb
54
54
  homepage: https://github.com/excid3/ferrum_pdf
55
55
  licenses:
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0'
74
74
  requirements: []
75
- rubygems_version: 3.7.2
75
+ rubygems_version: 3.6.9
76
76
  specification_version: 4
77
77
  summary: PDFs & screenshots for Rails using Ferrum & headless Chrome
78
78
  test_files: []
@@ -1,25 +0,0 @@
1
- module FerrumPdf
2
- class Railtie < ::Rails::Railtie
3
- initializer "ferrum_pdf.controller" do
4
- ActiveSupport.on_load(:action_controller) do
5
- # render ferrum_pdf: { pdf options }, template: "whatever", disposition: :inline, filename: "example.pdf"
6
- ActionController.add_renderer :ferrum_pdf do |pdf_options, options|
7
- send_data_options = options.extract!(:disposition, :filename, :status)
8
- url = pdf_options.delete(:url)
9
- html = render_to_string(**options.with_defaults(formats: [ :html ])) if url.blank?
10
- pdf = FerrumPdf.render_pdf(html: html, display_url: request.original_url, url: url, pdf_options: pdf_options)
11
- send_data(pdf, **send_data_options.with_defaults(type: :pdf))
12
- end
13
-
14
- # render ferrum_screenshot: { pdf options }, template: "whatever", disposition: :inline, filename: "example.png"
15
- ActionController.add_renderer :ferrum_screenshot do |screenshot_options, options|
16
- send_data_options = options.extract!(:disposition, :filename, :status)
17
- url = screenshot_options.delete(:url)
18
- html = render_to_string(**options.with_defaults(formats: [ :html ])) if url.blank?
19
- screenshot = FerrumPdf.render_screenshot(url: url, html: html, display_url: request.original_url, screenshot_options: screenshot_options)
20
- send_data(screenshot, **send_data_options.with_defaults(type: screenshot_options.fetch(:format, :png)))
21
- end
22
- end
23
- end
24
- end
25
- end