gotenberg 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/lib/gotenberg/client.rb +2 -2
- data/lib/gotenberg/helper.rb +14 -2
- data/lib/gotenberg/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2b00fd8125872fab5eaf54be4cef7fca244eac5ae7579a9b46cf5e3f377011e
|
4
|
+
data.tar.gz: 26903108cc7083cdc13f97f821ba8da327cb832c6d40b0777a6f5967537397aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3c3a7b03e8cc60f5b9b375f4f97ccd4d188def9af195e24db03d34f41f6e0caca69cc5fae9d88c2094d1e43d79376be486ce6590af526925f65db76a2761d98
|
7
|
+
data.tar.gz: ecd8f9587285eecf4a9d3410048bfd012dce3d1d5c72cdf8d8591eb61d20f1a6352b15caf43b8b8fd9e696b765d2c02d3f611e559ac72e1b7d223ce484b1847d
|
data/lib/gotenberg/client.rb
CHANGED
@@ -24,7 +24,7 @@ module Gotenberg
|
|
24
24
|
# Convert HTML files to PDF and write it to the output file
|
25
25
|
#
|
26
26
|
# @param htmls [Hash{Symbol => String}] A hash with the file name as the key and the HTML content as the value
|
27
|
-
# @param asset_paths [Array<String>]
|
27
|
+
# @param asset_paths [Array<String>] Optional args, paths to the asset files (like CSS, images) required by the HTML files # rubocop:disable Layout/LineLength
|
28
28
|
# @param properties [Hash] Additional properties for PDF conversion
|
29
29
|
# @option properties [Float] :paperWidth The width of the paper
|
30
30
|
# @option properties [Float] :paperHeight The height of the paper
|
@@ -49,7 +49,7 @@ module Gotenberg
|
|
49
49
|
# pdf_content = client.html(htmls, asset_paths, properties)
|
50
50
|
#
|
51
51
|
# Credit: https://github.com/jbd0101/ruby-gotenberg-client/blob/master/lib/gotenberg.rb
|
52
|
-
def html(htmls, asset_paths, properties = {})
|
52
|
+
def html(htmls, asset_paths = [], properties = {}) # rubocop:disable Metrics/CyclomaticComplexity
|
53
53
|
raise GotenbergDownError unless up?
|
54
54
|
|
55
55
|
raise IndexFileMissing unless (htmls.keys & ["index", :index]).any?
|
data/lib/gotenberg/helper.rb
CHANGED
@@ -66,7 +66,7 @@ module Gotenberg
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
# Returns the base64 encoded content of
|
69
|
+
# Returns the base64 encoded content of an asset.
|
70
70
|
#
|
71
71
|
# @param asset_name [String] the name of the asset
|
72
72
|
# @raise [MissingAsset] if the asset is not found
|
@@ -79,6 +79,19 @@ module Gotenberg
|
|
79
79
|
"data:#{asset.content_type};base64,#{Rack::Utils.escape(base64)}"
|
80
80
|
end
|
81
81
|
|
82
|
+
# Returns the base64 encoded content of a static asset.
|
83
|
+
#
|
84
|
+
# @param asset_name [String] the name of the asset
|
85
|
+
# @raise [MissingAsset] if the asset is not found
|
86
|
+
# @return [String] the base64 encoded content of the asset
|
87
|
+
def goten_static_asset_base64(asset_name)
|
88
|
+
asset = LocalAsset.new(goten_static_asset_path(asset_name))
|
89
|
+
raise MissingAsset.new(asset_name, "Could not find asset '#{asset_name}'") if asset.nil?
|
90
|
+
|
91
|
+
base64 = Base64.encode64(asset.to_s).delete("\n")
|
92
|
+
"data:#{asset.content_type};base64,#{Rack::Utils.escape(base64)}"
|
93
|
+
end
|
94
|
+
|
82
95
|
# Returns the static path of an asset based on its extension.
|
83
96
|
#
|
84
97
|
# @param asset_name [String] the name of the asset
|
@@ -107,7 +120,6 @@ module Gotenberg
|
|
107
120
|
#
|
108
121
|
# @param asset_name [String] the name of the asset
|
109
122
|
# @return [String] the compiled name of the asset
|
110
|
-
|
111
123
|
def goten_compiled_asset_name(asset_name)
|
112
124
|
path = goten_compiled_asset_path(asset_name)
|
113
125
|
path.split("/").last
|
data/lib/gotenberg/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gotenberg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bugloper
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2025-08-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mime-types
|
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
requirements: []
|
79
|
-
rubygems_version: 3.
|
79
|
+
rubygems_version: 3.0.3.1
|
80
80
|
signing_key:
|
81
81
|
specification_version: 4
|
82
82
|
summary: A simple Ruby client for gotenberg
|