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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 489dc50093dc4d7dfcf8934e4f7f1e66c42c3ee331b8f6712206a4f9e4bb3f95
4
- data.tar.gz: 32a0dacebb19c92447cc448ea93fa94de7081cc7fdff11a5fd271d20d262ae1e
3
+ metadata.gz: f2b00fd8125872fab5eaf54be4cef7fca244eac5ae7579a9b46cf5e3f377011e
4
+ data.tar.gz: 26903108cc7083cdc13f97f821ba8da327cb832c6d40b0777a6f5967537397aa
5
5
  SHA512:
6
- metadata.gz: a39d81adfa325e16a1a9e5105103e1e9f68acd22600d6b56fcf951f8a45c97353eb676dc1e36c17f6f9113ef20c4bfe05280cc0fa53552a18f4a6d3d176d6674
7
- data.tar.gz: dc6294d7356a315e002eb47e8a311908c541c18b0980e3d29325558fd72612bcb628f999f9b841b88c7e68480796a4adb49437a8bd20690f990c76a2771bb2c9
6
+ metadata.gz: c3c3a7b03e8cc60f5b9b375f4f97ccd4d188def9af195e24db03d34f41f6e0caca69cc5fae9d88c2094d1e43d79376be486ce6590af526925f65db76a2761d98
7
+ data.tar.gz: ecd8f9587285eecf4a9d3410048bfd012dce3d1d5c72cdf8d8591eb61d20f1a6352b15caf43b8b8fd9e696b765d2c02d3f611e559ac72e1b7d223ce484b1847d
@@ -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>] Paths to the asset files (like CSS, images) required by the HTML files
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?
@@ -66,7 +66,7 @@ module Gotenberg
66
66
  end
67
67
  end
68
68
 
69
- # Returns the base64 encoded content of a static asset.
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gotenberg
4
- VERSION = "1.0.3"
4
+ VERSION = "1.0.4"
5
5
  end
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.3
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: 2024-06-24 00:00:00.000000000 Z
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.4.10
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