puppeteer-ruby 0.31.3 → 0.31.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c29d76a1dd9f52a59eecdb311ab8c110a3393bc1500aea3df7d5defdc469d4f
4
- data.tar.gz: 296188c1573813718e0f3d320ceff5bbd8f036f8326f04499e6d81a77ca92051
3
+ metadata.gz: ff91cc32cf078ad68ba001f02b0f9f3e614778e3b40f0622fd63570a6915ad52
4
+ data.tar.gz: b12ef40943838b16f0cafc9f7cc2b0c046bab5dc03e99729f8726cc912fbbef8
5
5
  SHA512:
6
- metadata.gz: 25411b18a7d0279ebc736981cc47db542340d49c01429b8419e95e3f3d3c66ce633de11c8b645a0eb1643dc41adedb215522d0f2a06d173cd6140aeedb44156f
7
- data.tar.gz: e1cc9c01f114534c4c44df4f036a9c9743b7330c1cfee710799381d9cdafe736d2c04498c673e3d79cd64671d4f270fcd37fc7cd0cbebf07d423736a5705851f
6
+ metadata.gz: a84bdfa144789d50926e0d2177711b7ff43f025948e6832b11c7105a3923c84597909bd142db54cac1b09c4ede013bd6f9b94a991888d0c4c420aaf5c2f4511b
7
+ data.tar.gz: 6558efa9f6ba92544a236aa17a9e879332ab2f03bbc2115e2035930b15b5ebb8a5d85b93558f961a8ee9258c22a766ce4fc9baf45a586c6836dede1511bab6dd
data/CHANGELOG.md CHANGED
@@ -1,7 +1,13 @@
1
- ### master [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.31.3...master)]
1
+ ### master [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.31.4...master)]
2
2
 
3
3
  * xxx
4
4
 
5
+ ### 0.31.4 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.31.3...0.31.4)]
6
+
7
+ Bugfix:
8
+
9
+ * Fix PDF options (format, margin, omit_background) to work.
10
+
5
11
  ### 0.31.3 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.31.1...0.31.3)]
6
12
 
7
13
  Bugfix:
data/docs/api_coverage.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # API coverages
2
2
  - Puppeteer version: v8.0.0
3
- - puppeteer-ruby version: 0.31.3
3
+ - puppeteer-ruby version: 0.31.4
4
4
 
5
5
  ## Puppeteer
6
6
 
@@ -587,6 +587,16 @@ class Puppeteer::Page
587
587
  emit_event(PageEmittedEvents::Dialog, dialog)
588
588
  end
589
589
 
590
+ private def set_transparent_background_color(&block)
591
+ @client.send_message(
592
+ 'Emulation.setDefaultBackgroundColorOverride',
593
+ color: { r: 0, g: 0, b: 0, a: 0 })
594
+ end
595
+
596
+ private def reset_default_background_color(&block)
597
+ @client.send_message('Emulation.setDefaultBackgroundColorOverride')
598
+ end
599
+
590
600
  # @return [String]
591
601
  def url
592
602
  main_frame.url
@@ -949,18 +959,14 @@ class Puppeteer::Page
949
959
  end
950
960
 
951
961
  should_set_default_background = screenshot_options.omit_background? && format == 'png'
952
- if should_set_default_background
953
- @client.send_message('Emulation.setDefaultBackgroundColorOverride', color: { r: 0, g: 0, b: 0, a: 0 })
954
- end
962
+ set_transparent_background_color if should_set_default_background
955
963
  screenshot_params = {
956
964
  format: format,
957
965
  quality: screenshot_options.quality,
958
966
  clip: clip,
959
967
  }.compact
960
968
  result = @client.send_message('Page.captureScreenshot', screenshot_params)
961
- if should_set_default_background
962
- @client.send_message('Emulation.setDefaultBackgroundColorOverride')
963
- end
969
+ reset_default_background_color if should_set_default_background
964
970
 
965
971
  if screenshot_options.full_page? && @viewport
966
972
  self.viewport = @viewport
@@ -1018,7 +1024,10 @@ class Puppeteer::Page
1018
1024
  # @return [String]
1019
1025
  def pdf(options = {})
1020
1026
  pdf_options = PDFOptions.new(options)
1027
+ omit_background = options[:omit_background]
1028
+ set_transparent_background_color if omit_background
1021
1029
  result = @client.send_message('Page.printToPDF', pdf_options.page_print_args)
1030
+ reset_default_background_color if omit_background
1022
1031
  ProtocolStreamReader.new(client: @client, handle: result['stream'], path: pdf_options.path).read
1023
1032
  rescue => err
1024
1033
  if err.message.include?('PrintToPDF is not implemented')
@@ -52,24 +52,24 @@ class Puppeteer::Page
52
52
  end
53
53
 
54
54
  PAPER_FORMATS = {
55
- letter: PaperSize.new(width: 8.5, height: 11),
56
- legal: PaperSize.new(width: 8.5, height: 14),
57
- tabloid: PaperSize.new(width: 11, height: 17),
58
- ledger: PaperSize.new(width: 17, height: 11),
59
- a0: PaperSize.new(width: 33.1, height: 46.8),
60
- a1: PaperSize.new(width: 23.4, height: 33.1),
61
- a2: PaperSize.new(width: 16.54, height: 23.4),
62
- a3: PaperSize.new(width: 11.7, height: 16.54),
63
- a4: PaperSize.new(width: 8.27, height: 11.7),
64
- a5: PaperSize.new(width: 5.83, height: 8.27),
65
- a6: PaperSize.new(width: 4.13, height: 5.83),
55
+ 'letter' => PaperSize.new(width: 8.5, height: 11),
56
+ 'legal' => PaperSize.new(width: 8.5, height: 14),
57
+ 'tabloid' => PaperSize.new(width: 11, height: 17),
58
+ 'ledger' => PaperSize.new(width: 17, height: 11),
59
+ 'a0' => PaperSize.new(width: 33.1, height: 46.8),
60
+ 'a1' => PaperSize.new(width: 23.4, height: 33.1),
61
+ 'a2' => PaperSize.new(width: 16.54, height: 23.4),
62
+ 'a3' => PaperSize.new(width: 11.7, height: 16.54),
63
+ 'a4' => PaperSize.new(width: 8.27, height: 11.7),
64
+ 'a5' => PaperSize.new(width: 5.83, height: 8.27),
65
+ 'a6' => PaperSize.new(width: 4.13, height: 5.83),
66
66
  }
67
67
 
68
68
  UNIT_TO_PIXELS = {
69
- px: 1,
70
- in: 96,
71
- cm: 37.8,
72
- mm: 3.78,
69
+ 'px' => 1,
70
+ 'in' => 96,
71
+ 'cm' => 37.8,
72
+ 'mm' => 3.78,
73
73
  }
74
74
 
75
75
  # @param parameter [String|Integer|nil]
@@ -1,3 +1,3 @@
1
1
  module Puppeteer
2
- VERSION = '0.31.3'
2
+ VERSION = '0.31.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppeteer-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.31.3
4
+ version: 0.31.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - YusukeIwaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-26 00:00:00.000000000 Z
11
+ date: 2021-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby