gotenberg 1.0.0 → 1.0.2
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 +1 -0
- data/lib/gotenberg/helper.rb +26 -2
- data/lib/gotenberg/version.rb +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f53f3f0cd1c87eae43c03fb07bc9bd9096deaa27fe9d6c2cb85f2dbf04f2e24
|
4
|
+
data.tar.gz: c79d077d87f6f60513fe293c92442527847fab4fc9c269780375c21b18b098de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5628e26404b94a39b1215be8ef597987493a01a61d9a1bddd28a912bd457bc499f99b25d0b67425bb7daf6b85d8ad37d0a478afcca231863b53631012424895d
|
7
|
+
data.tar.gz: '069da1f064e1b24b87d494efda58e2eb80387aae039db6a06067bb2f89db3dd7f6a0764623bb634623dcf5683b4cce7f0b931ae922371afebf3e6711432107ca'
|
data/lib/gotenberg/client.rb
CHANGED
@@ -48,6 +48,7 @@ module Gotenberg
|
|
48
48
|
# client = Gotenberg::Client.new("http://localhost:3000")
|
49
49
|
# pdf_content = client.html(htmls, asset_paths, properties)
|
50
50
|
#
|
51
|
+
# Credit: https://github.com/jbd0101/ruby-gotenberg-client/blob/master/lib/gotenberg.rb
|
51
52
|
def html(htmls, asset_paths, properties = {}) # rubocop:disable Metrics/CyclomaticComplexity
|
52
53
|
raise GotenbergDownError unless up?
|
53
54
|
|
data/lib/gotenberg/helper.rb
CHANGED
@@ -4,7 +4,8 @@ module Gotenberg
|
|
4
4
|
module Helper # rubocop:disable Style/Documentation
|
5
5
|
class ExtensionMissing < StandardError; end
|
6
6
|
|
7
|
-
|
7
|
+
# Credits: https://github.com/mileszs/wicked_pdf/blob/master/lib/wicked_pdf/wicked_pdf_helper/assets.rb
|
8
|
+
class PropshaftAsset
|
8
9
|
attr_reader :asset
|
9
10
|
|
10
11
|
def initialize(asset)
|
@@ -63,6 +64,11 @@ module Gotenberg
|
|
63
64
|
end
|
64
65
|
end
|
65
66
|
|
67
|
+
# Returns the base64 encoded content of a static asset.
|
68
|
+
#
|
69
|
+
# @param asset_name [String] the name of the asset
|
70
|
+
# @raise [MissingAsset] if the asset is not found
|
71
|
+
# @return [String] the base64 encoded content of the asset
|
66
72
|
def goten_asset_base64(asset_name)
|
67
73
|
asset = find_asset(goten_static_asset_path(asset_name))
|
68
74
|
raise MissingAsset.new(asset_name, "Could not find asset '#{asset_name}'") if asset.nil?
|
@@ -71,6 +77,11 @@ module Gotenberg
|
|
71
77
|
"data:#{asset.content_type};base64,#{Rack::Utils.escape(base64)}"
|
72
78
|
end
|
73
79
|
|
80
|
+
# Returns the static path of an asset based on its extension.
|
81
|
+
#
|
82
|
+
# @param asset_name [String] the name of the asset
|
83
|
+
# @raise [ExtensionMissing] if the asset extension is missing
|
84
|
+
# @return [String] the static path of the asset
|
74
85
|
def goten_static_asset_path(asset_name)
|
75
86
|
ext = File.extname(asset_name).delete(".")
|
76
87
|
|
@@ -86,6 +97,10 @@ module Gotenberg
|
|
86
97
|
determine_static_path(asset_type, asset_name)
|
87
98
|
end
|
88
99
|
|
100
|
+
# Returns the compiled path of an asset.
|
101
|
+
#
|
102
|
+
# @param asset_name [String] the name of the asset
|
103
|
+
# @return [String] the compiled path of the asset
|
89
104
|
def goten_compiled_asset_path(asset_name)
|
90
105
|
Rails.public_path.to_s +
|
91
106
|
ActionController::Base.helpers.asset_path(asset_name)
|
@@ -93,6 +108,12 @@ module Gotenberg
|
|
93
108
|
|
94
109
|
private
|
95
110
|
|
111
|
+
# Determines and returns the static path of an asset.
|
112
|
+
#
|
113
|
+
# @param asset_type [String] the type of the asset (e.g., "javascripts", "stylesheets", "images")
|
114
|
+
# @param asset_name [String] the name of the asset
|
115
|
+
# @raise [MissingAsset] if the asset is not found
|
116
|
+
# @return [String] the static path of the asset
|
96
117
|
def determine_static_path(asset_type, asset_name)
|
97
118
|
asset_root = Rails.root.join("app", "assets")
|
98
119
|
path = asset_root.join(asset_type, asset_name)
|
@@ -107,7 +128,10 @@ module Gotenberg
|
|
107
128
|
path.to_s
|
108
129
|
end
|
109
130
|
|
110
|
-
#
|
131
|
+
# Finds and returns the asset for the given path.
|
132
|
+
#
|
133
|
+
# @param path [String] the path of the asset
|
134
|
+
# @return [PropshaftAsset, LocalAsset, Sprockets::Asset, nil] the found asset or nil if not found
|
111
135
|
def find_asset(path)
|
112
136
|
if Rails.application.assets.respond_to?(:find_asset)
|
113
137
|
Rails.application.assets.find_asset(path, base_path: Rails.application.root.to_s)
|
data/lib/gotenberg/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bugloper
|
8
8
|
- teknatha136
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-06-
|
12
|
+
date: 2024-06-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mime-types
|
@@ -51,16 +51,16 @@ files:
|
|
51
51
|
- lib/gotenberg/helper.rb
|
52
52
|
- lib/gotenberg/railtie.rb
|
53
53
|
- lib/gotenberg/version.rb
|
54
|
-
homepage: https://github.com/SELISEdigitalplatforms/
|
54
|
+
homepage: https://github.com/SELISEdigitalplatforms/gotenberg
|
55
55
|
licenses:
|
56
56
|
- MIT
|
57
57
|
metadata:
|
58
58
|
allowed_push_host: https://rubygems.org
|
59
|
-
homepage_uri: https://github.com/SELISEdigitalplatforms/
|
60
|
-
source_code_uri: https://github.com/SELISEdigitalplatforms/
|
61
|
-
changelog_uri: https://github.com/SELISEdigitalplatforms/
|
59
|
+
homepage_uri: https://github.com/SELISEdigitalplatforms/gotenberg
|
60
|
+
source_code_uri: https://github.com/SELISEdigitalplatforms/gotenberg
|
61
|
+
changelog_uri: https://github.com/SELISEdigitalplatforms/gotenberg/blob/main/CHANGELOG.md
|
62
62
|
rubygems_mfa_required: 'false'
|
63
|
-
post_install_message:
|
63
|
+
post_install_message:
|
64
64
|
rdoc_options: []
|
65
65
|
require_paths:
|
66
66
|
- lib
|
@@ -75,8 +75,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0'
|
77
77
|
requirements: []
|
78
|
-
rubygems_version: 3.
|
79
|
-
signing_key:
|
78
|
+
rubygems_version: 3.4.10
|
79
|
+
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: A simple Ruby client for gotenberg
|
82
82
|
test_files: []
|