postdoc 0.4.0 → 0.4.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: 99100709b8c080b91123f7196ad2da2fa499bdd35c63e300442191c585527104
4
- data.tar.gz: 9958e7e9d1601f4c0e2c1141a8f733cdb29d121bcee3e68e0a65b5a4fb13ec37
3
+ metadata.gz: 2562e31f953afcf27300148e00217e1599424efb39bbb1242e0d29f264260c28
4
+ data.tar.gz: 6b9271a82c70cbe57efd534b1b2d80b8f6be5e952ebdfa167f3cfabb944bbd77
5
5
  SHA512:
6
- metadata.gz: beb118c9f143dfc9801770c0a34908a5f50640c1d11fa4d051a5a3d9f26c5573445342df95615dad76ff8ac8bcaf5ab357439535bea246b97f97227cfe7982c5
7
- data.tar.gz: 2d17c30f6604bd94eeaea2c482bf6d7a7f228a3bfc50ae5853e8c783c9098bb2cc0326ab0bf4cd29a00b528841963745d03a1e3e1721f7ba6953228fcc53bd50
6
+ metadata.gz: 1f71a3cf459f62e022b0f13853084ca2796fb642a6a9c681173b341f961dd257486a141459ec42fe7b3f4caf2c6c6c86aafec2dc7f14e23b7c8c775c8c356ebd
7
+ data.tar.gz: dec210aedf9353c0e96bf25e5b503088508fbe7a79661b75702ce5c372039f762be6d79f417b55313a83e5857ebbb39bd310b5a4304157b4dcbc072ec5853e01
@@ -22,6 +22,9 @@ module Postdoc
22
22
  client.send_cmd 'Page.navigate', url: "file://#{file_path}"
23
23
  client.wait_for 'Page.loadEventFired'
24
24
 
25
+ # prevent race condition
26
+ sleep 0.1 if settings.slow_pc
27
+
25
28
  response = client.send_cmd 'Page.printToPDF', settings.to_cmd
26
29
 
27
30
  Base64.decode64 response['data']
@@ -31,6 +34,10 @@ module Postdoc
31
34
  client.send_cmd 'Page.enable'
32
35
  client.send_cmd 'Page.navigate', url: "file://#{file_path}"
33
36
  client.wait_for 'Page.loadEventFired'
37
+
38
+ # prevent race condition
39
+ sleep 0.1 if settings.slow_pc
40
+
34
41
  response = client.send_cmd 'Page.printToPDF', settings.to_cmd
35
42
 
36
43
  Base64.decode64 response['data']
@@ -2,6 +2,9 @@ module Postdoc
2
2
  # Different prints require different settings. This class is used instead of
3
3
  # passing options arguments throughout all of the code.
4
4
  class PrintSettings
5
+
6
+ attr_accessor :slow_pc
7
+
5
8
  def initialize(
6
9
  header_template: '',
7
10
  footer_template: '',
@@ -10,7 +13,8 @@ module Postdoc
10
13
  margin_top: 1,
11
14
  margin_bottom: 1,
12
15
  margin_left: 1,
13
- margin_right: 1
16
+ margin_right: 1,
17
+ slow_pc: false
14
18
  )
15
19
  @header_template = header_template
16
20
  @footer_template = footer_template
@@ -20,6 +24,7 @@ module Postdoc
20
24
  @margin_bottom = margin_bottom
21
25
  @margin_left = margin_left
22
26
  @margin_right = margin_right
27
+ @slow_pc = slow_pc
23
28
  end
24
29
 
25
30
  def to_cmd
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postdoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Groeneveld
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-26 00:00:00.000000000 Z
11
+ date: 2021-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chrome_remote