gotenberg-ruby 1.0.3 → 1.0.4
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 +4 -4
- data/README.md +16 -1
- data/lib/gotenberg/backtrace.rb +13 -6
- data/lib/gotenberg/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fa54cb50c0f1acb75b9f60323e2609a58e0dfd9dc24598ea329dfeec6903e26
|
4
|
+
data.tar.gz: 473d60ac2f1f4b70d8c53b59032df0fafae5d86ece2d4c5fca7a1e538e93954c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71c2f2768d00baad5f44238fb893b721dfe768f399396a6e750f343af49339a76619095d32471a827f21ed31b5fffbbe99d79fd8b536db9bd73185c64096bf23
|
7
|
+
data.tar.gz: c6facaf037d8ee62c8deb870565c39a70a5897b64241cdc868147eb117715bd54b20e91b17665fb7f4424de6bf986b9e42681bccbb779e77874e8a12fd5d0911
|
data/README.md
CHANGED
@@ -23,6 +23,21 @@ gem "gotenberg-ruby"
|
|
23
23
|
* [Send a request to the API](#send-a-request-to-the-api)
|
24
24
|
* [Chromium](#chromium)
|
25
25
|
|
26
|
+
### Run Gotenberg
|
27
|
+
|
28
|
+
Run microservice with docker-compose:
|
29
|
+
|
30
|
+
```
|
31
|
+
version: "3"
|
32
|
+
|
33
|
+
services:
|
34
|
+
gotenberg:
|
35
|
+
image: gotenberg/gotenberg:7
|
36
|
+
restart: always
|
37
|
+
ports:
|
38
|
+
- 3000:3000
|
39
|
+
```
|
40
|
+
|
26
41
|
### Send a request to the API
|
27
42
|
|
28
43
|
After having created the HTTP request (see below), you have two options:
|
@@ -377,7 +392,7 @@ You may also wait until a given JavaScript expression returns true:
|
|
377
392
|
```ruby
|
378
393
|
document = Gotenberg::Chromium.call(ENV['GOTENBERG_URL']) do |doc|
|
379
394
|
doc.html index_html
|
380
|
-
doc.wait_for_expression
|
395
|
+
doc.wait_for_expression "window.status === 'ready'"
|
381
396
|
end
|
382
397
|
```
|
383
398
|
|
data/lib/gotenberg/backtrace.rb
CHANGED
@@ -6,25 +6,32 @@ module Gotenberg
|
|
6
6
|
|
7
7
|
def initialize files
|
8
8
|
@files = files
|
9
|
-
@backtrace_location = build_backtrace_location
|
10
9
|
end
|
11
10
|
|
12
11
|
def call
|
13
|
-
|
12
|
+
return unless index_available?
|
13
|
+
|
14
|
+
FileUtils.mkdir_p(backtrace_location)
|
14
15
|
|
15
16
|
files.each do |file|
|
16
|
-
File.open(File.join(
|
17
|
+
File.open(File.join(backtrace_location, file.original_filename), 'wb') do |f|
|
17
18
|
f << file.io.read
|
18
19
|
end
|
19
20
|
|
20
21
|
file.io.rewind
|
21
22
|
end
|
22
23
|
|
23
|
-
::Launchy.open(File.join(
|
24
|
+
::Launchy.open(File.join(backtrace_location, 'index.html'))
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def index_available?
|
30
|
+
files.any? { |f| f.original_filename == 'index.html' }
|
24
31
|
end
|
25
32
|
|
26
|
-
def
|
27
|
-
File.join(
|
33
|
+
def backtrace_location
|
34
|
+
@backtrace_location ||= File.join(
|
28
35
|
Gotenberg.configuration.backtrace_dir,
|
29
36
|
"#{Time.now.to_f.to_s.tr('.', '_')}_#{rand(0x100000000).to_s(36)}"
|
30
37
|
)
|
data/lib/gotenberg/version.rb
CHANGED