cloudrunpdf 0.2.0 → 0.2.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 +4 -4
- data/Gemfile.lock +8 -1
- data/bitbucket-pipelines.yml +28 -0
- data/lib/cloudrunpdf/builder.rb +5 -26
- data/lib/cloudrunpdf/configuration.rb +14 -2
- data/lib/cloudrunpdf/exceptions.rb +4 -0
- data/lib/cloudrunpdf/providers/aliyun.rb +26 -0
- data/lib/cloudrunpdf/providers/amazon.rb +36 -0
- data/lib/cloudrunpdf/providers/google.rb +44 -0
- data/lib/cloudrunpdf/version.rb +1 -1
- data/lib/cloudrunpdf.rb +5 -0
- metadata +52 -4
- data/.bitbucket-pipelines.yml +0 -22
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ceb097585f4b4e884deb1ae3b6d349009c17060dfb13da34a28138ac95c6e0a0
|
|
4
|
+
data.tar.gz: f21bd07a253112039657802b0a6093aa3fa1c45cca4cccd27804c5339a80d408
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9df0539cc82e2c0125a97501d86000540c0ce9863877cc61a0e9181d819eff459b79b3b4139b8c5a7efda61196a0cdb8677eef1df92945a08a397e97c4f55d90
|
|
7
|
+
data.tar.gz: be691daae2c5236b8ed292e59f511cfe9638a8bfdd57dd02e7a89261da22028070a9e623556a29a4731d9f30ce42760f57b763eafce914a65caccf3c3f620cd3
|
data/Gemfile.lock
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
cloudrunpdf (0.1
|
|
4
|
+
cloudrunpdf (0.2.1)
|
|
5
|
+
base64
|
|
5
6
|
combine_pdf
|
|
6
7
|
faraday
|
|
8
|
+
logger
|
|
9
|
+
ostruct
|
|
7
10
|
|
|
8
11
|
GEM
|
|
9
12
|
remote: https://rubygems.org/
|
|
10
13
|
specs:
|
|
11
14
|
ast (2.4.2)
|
|
15
|
+
base64 (0.3.0)
|
|
12
16
|
combine_pdf (1.0.26)
|
|
13
17
|
matrix
|
|
14
18
|
ruby-rc4 (>= 0.1.5)
|
|
@@ -19,9 +23,11 @@ GEM
|
|
|
19
23
|
net-http
|
|
20
24
|
json (2.7.1)
|
|
21
25
|
language_server-protocol (3.17.0.3)
|
|
26
|
+
logger (1.7.0)
|
|
22
27
|
matrix (0.4.2)
|
|
23
28
|
net-http (0.4.1)
|
|
24
29
|
uri
|
|
30
|
+
ostruct (0.6.0)
|
|
25
31
|
parallel (1.24.0)
|
|
26
32
|
parser (3.3.0.3)
|
|
27
33
|
ast (~> 2.4.1)
|
|
@@ -66,6 +72,7 @@ GEM
|
|
|
66
72
|
PLATFORMS
|
|
67
73
|
arm64-darwin-21
|
|
68
74
|
arm64-darwin-22
|
|
75
|
+
arm64-darwin-24
|
|
69
76
|
|
|
70
77
|
DEPENDENCIES
|
|
71
78
|
cloudrunpdf!
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
image: remarksolutions/ci-image:ruby-31
|
|
2
|
+
|
|
3
|
+
pipelines:
|
|
4
|
+
default:
|
|
5
|
+
# - step:
|
|
6
|
+
# name: Quality Assurance
|
|
7
|
+
# script:
|
|
8
|
+
# - bundle install --local
|
|
9
|
+
# - bin/rspec
|
|
10
|
+
# - bin/rubocop
|
|
11
|
+
# caches:
|
|
12
|
+
# - bundler
|
|
13
|
+
- step:
|
|
14
|
+
name: Build and Upload Gem
|
|
15
|
+
script:
|
|
16
|
+
- gem install geminabox
|
|
17
|
+
- gem build cloudrunpdf.gemspec
|
|
18
|
+
- gem inabox cloudrunpdf-*.gem --host $GEMINABOX_URL
|
|
19
|
+
caches:
|
|
20
|
+
- bundler
|
|
21
|
+
runs-on:
|
|
22
|
+
- self.hosted
|
|
23
|
+
definitions:
|
|
24
|
+
caches:
|
|
25
|
+
bundler: vendor/bundle
|
|
26
|
+
services:
|
|
27
|
+
docker:
|
|
28
|
+
memory: 3072
|
data/lib/cloudrunpdf/builder.rb
CHANGED
|
@@ -5,7 +5,7 @@ module Cloudrunpdf
|
|
|
5
5
|
class Builder
|
|
6
6
|
def initialize
|
|
7
7
|
@configuration = Cloudrunpdf.configuration
|
|
8
|
-
@
|
|
8
|
+
@provider = provider
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def print(data)
|
|
@@ -28,37 +28,16 @@ module Cloudrunpdf
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def generate_pdf(data)
|
|
31
|
-
connection =
|
|
32
|
-
headers: {
|
|
33
|
-
'Content-Type' => 'application/json',
|
|
34
|
-
'Authorization' => ("Bearer #{@token}" if @configuration.google?)
|
|
35
|
-
}.compact
|
|
36
|
-
) do |conn|
|
|
37
|
-
conn.response :raise_error
|
|
38
|
-
end
|
|
31
|
+
connection = @provider.connection
|
|
39
32
|
|
|
40
33
|
connection.post(@configuration.cloud_function_url) do |req|
|
|
41
34
|
req.body = data.to_json
|
|
42
35
|
end
|
|
43
36
|
end
|
|
44
37
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
# We only auth to cloudrun
|
|
49
|
-
return unless @configuration.google?
|
|
50
|
-
|
|
51
|
-
if !ENV['GCLOUD_AUTH_TOKEN'].nil?
|
|
52
|
-
@token ||= ENV.fetch('GCLOUD_AUTH_TOKEN', nil)
|
|
53
|
-
elsif Object.const_defined?(:Rails) && Rails.env.in?(['development', 'test'])
|
|
54
|
-
@token ||= `gcloud auth print-identity-token`.strip
|
|
55
|
-
else
|
|
56
|
-
@token ||= Faraday.get(
|
|
57
|
-
"http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/identity?audience=#{@configuration.cloud_function_url}&format=full",
|
|
58
|
-
{},
|
|
59
|
-
{ metadata_flavor: 'Google' }
|
|
60
|
-
).body
|
|
61
|
-
end
|
|
38
|
+
def provider
|
|
39
|
+
klass = "Cloudrunpdf::Providers::#{@configuration.platform}"
|
|
40
|
+
@provider ||= Object.const_get(klass).new(@configuration)
|
|
62
41
|
end
|
|
63
42
|
end
|
|
64
43
|
end
|
|
@@ -3,16 +3,18 @@
|
|
|
3
3
|
module Cloudrunpdf
|
|
4
4
|
# Configuration options for gem
|
|
5
5
|
class Configuration
|
|
6
|
-
attr_accessor :cloud_function_url, :auth
|
|
6
|
+
attr_accessor :cloud_function_url, :auth, :token
|
|
7
7
|
|
|
8
8
|
AUTHS = [
|
|
9
9
|
:google,
|
|
10
|
-
:aliyun
|
|
10
|
+
:aliyun,
|
|
11
|
+
:amazon
|
|
11
12
|
].freeze
|
|
12
13
|
|
|
13
14
|
def initialize
|
|
14
15
|
@cloud_function_url = 'https://cloudpdf-7zhay37huq-od.a.run.app'
|
|
15
16
|
@auth = :google
|
|
17
|
+
@token = nil
|
|
16
18
|
end
|
|
17
19
|
|
|
18
20
|
AUTHS.each do |auth|
|
|
@@ -20,5 +22,15 @@ module Cloudrunpdf
|
|
|
20
22
|
@auth == auth
|
|
21
23
|
end
|
|
22
24
|
end
|
|
25
|
+
|
|
26
|
+
def platform
|
|
27
|
+
@auth.to_s.capitalize
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def auth=(auth)
|
|
31
|
+
raise Cloudrunpdf::InvalidProviderError unless AUTHS.include?(auth.to_sym)
|
|
32
|
+
|
|
33
|
+
@auth = auth.to_sym
|
|
34
|
+
end
|
|
23
35
|
end
|
|
24
36
|
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Cloudrunpdf
|
|
2
|
+
module Providers
|
|
3
|
+
class Aliyun
|
|
4
|
+
def initialize(configuration = nil)
|
|
5
|
+
@configuration = configuration
|
|
6
|
+
@token = token
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def token
|
|
10
|
+
nil
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def connection
|
|
14
|
+
return unless @configuration
|
|
15
|
+
|
|
16
|
+
Faraday::Connection.new(
|
|
17
|
+
headers: {
|
|
18
|
+
'Content-Type' => 'application/json'
|
|
19
|
+
}.compact
|
|
20
|
+
) do |conn|
|
|
21
|
+
conn.response :raise_error
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module Cloudrunpdf
|
|
2
|
+
module Providers
|
|
3
|
+
class Amazon
|
|
4
|
+
def initialize(configuration = nil)
|
|
5
|
+
@configuration = configuration
|
|
6
|
+
@token = token
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def token
|
|
10
|
+
return unless @configuration
|
|
11
|
+
|
|
12
|
+
if @configuration.token
|
|
13
|
+
return @token ||= @configuration.token
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# To be deprecated
|
|
17
|
+
if !ENV['CLOUD_API_TOKEN'].nil?
|
|
18
|
+
@token ||= ENV.fetch('CLOUD_API_TOKEN', nil)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def connection
|
|
23
|
+
return unless @configuration
|
|
24
|
+
|
|
25
|
+
Faraday::Connection.new(
|
|
26
|
+
headers: {
|
|
27
|
+
'Content-Type' => 'application/json',
|
|
28
|
+
'Authorization' => "Bearer #{@token}"
|
|
29
|
+
}.compact
|
|
30
|
+
) do |conn|
|
|
31
|
+
conn.response :raise_error
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module Cloudrunpdf
|
|
2
|
+
module Providers
|
|
3
|
+
class Google
|
|
4
|
+
def initialize(configuration = nil)
|
|
5
|
+
@configuration = configuration
|
|
6
|
+
@token = token
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def token
|
|
10
|
+
return unless @configuration
|
|
11
|
+
|
|
12
|
+
if @configuration.token
|
|
13
|
+
return @token ||= @configuration.token
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# To be deprecated
|
|
17
|
+
if !ENV['GCLOUD_AUTH_TOKEN'].nil?
|
|
18
|
+
@token ||= ENV.fetch('GCLOUD_AUTH_TOKEN', nil)
|
|
19
|
+
elsif Object.const_defined?(:Rails) && Rails.env.in?(['development', 'test'])
|
|
20
|
+
@token ||= `gcloud auth print-identity-token`.strip
|
|
21
|
+
else
|
|
22
|
+
@token ||= Faraday.get(
|
|
23
|
+
"http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/identity?audience=#{@configuration.cloud_function_url}&format=full",
|
|
24
|
+
{},
|
|
25
|
+
{ metadata_flavor: 'Google' }
|
|
26
|
+
).body
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def connection
|
|
31
|
+
return unless @configuration
|
|
32
|
+
|
|
33
|
+
Faraday::Connection.new(
|
|
34
|
+
headers: {
|
|
35
|
+
'Content-Type' => 'application/json',
|
|
36
|
+
'Authorization' => ("Bearer #{@token}" if @configuration.google?)
|
|
37
|
+
}.compact
|
|
38
|
+
) do |conn|
|
|
39
|
+
conn.response :raise_error
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
data/lib/cloudrunpdf/version.rb
CHANGED
data/lib/cloudrunpdf.rb
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
require_relative 'cloudrunpdf/configuration'
|
|
2
2
|
require_relative 'cloudrunpdf/version'
|
|
3
3
|
require_relative 'cloudrunpdf/builder'
|
|
4
|
+
require_relative 'cloudrunpdf/exceptions'
|
|
5
|
+
|
|
6
|
+
['google', 'aliyun', 'amazon'].each do |platform|
|
|
7
|
+
require_relative "cloudrunpdf/providers/#{platform}"
|
|
8
|
+
end
|
|
4
9
|
|
|
5
10
|
module Cloudrunpdf
|
|
6
11
|
class << self
|
metadata
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cloudrunpdf
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bas Schoenmakers
|
|
8
8
|
- Jasper vd Berg
|
|
9
9
|
- Jesse Tilro
|
|
10
|
+
- Badrul Idris
|
|
10
11
|
autorequire:
|
|
11
12
|
bindir: exe
|
|
12
13
|
cert_chain: []
|
|
13
|
-
date:
|
|
14
|
+
date: 2025-11-14 00:00:00.000000000 Z
|
|
14
15
|
dependencies:
|
|
15
16
|
- !ruby/object:Gem::Dependency
|
|
16
17
|
name: rubocop
|
|
@@ -82,16 +83,58 @@ dependencies:
|
|
|
82
83
|
- - ">="
|
|
83
84
|
- !ruby/object:Gem::Version
|
|
84
85
|
version: '0'
|
|
86
|
+
- !ruby/object:Gem::Dependency
|
|
87
|
+
name: ostruct
|
|
88
|
+
requirement: !ruby/object:Gem::Requirement
|
|
89
|
+
requirements:
|
|
90
|
+
- - ">="
|
|
91
|
+
- !ruby/object:Gem::Version
|
|
92
|
+
version: '0'
|
|
93
|
+
type: :runtime
|
|
94
|
+
prerelease: false
|
|
95
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
96
|
+
requirements:
|
|
97
|
+
- - ">="
|
|
98
|
+
- !ruby/object:Gem::Version
|
|
99
|
+
version: '0'
|
|
100
|
+
- !ruby/object:Gem::Dependency
|
|
101
|
+
name: logger
|
|
102
|
+
requirement: !ruby/object:Gem::Requirement
|
|
103
|
+
requirements:
|
|
104
|
+
- - ">="
|
|
105
|
+
- !ruby/object:Gem::Version
|
|
106
|
+
version: '0'
|
|
107
|
+
type: :runtime
|
|
108
|
+
prerelease: false
|
|
109
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
110
|
+
requirements:
|
|
111
|
+
- - ">="
|
|
112
|
+
- !ruby/object:Gem::Version
|
|
113
|
+
version: '0'
|
|
114
|
+
- !ruby/object:Gem::Dependency
|
|
115
|
+
name: base64
|
|
116
|
+
requirement: !ruby/object:Gem::Requirement
|
|
117
|
+
requirements:
|
|
118
|
+
- - ">="
|
|
119
|
+
- !ruby/object:Gem::Version
|
|
120
|
+
version: '0'
|
|
121
|
+
type: :runtime
|
|
122
|
+
prerelease: false
|
|
123
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
124
|
+
requirements:
|
|
125
|
+
- - ">="
|
|
126
|
+
- !ruby/object:Gem::Version
|
|
127
|
+
version: '0'
|
|
85
128
|
description:
|
|
86
129
|
email:
|
|
87
130
|
- bas.schoenmakers@remarkgroup.com
|
|
88
131
|
- jasper.vandenberg@remarkgroup.com
|
|
89
132
|
- jesse.tilro@remarkgroup.com
|
|
133
|
+
- badrul.idris@scordigitalsolutions.com
|
|
90
134
|
executables: []
|
|
91
135
|
extensions: []
|
|
92
136
|
extra_rdoc_files: []
|
|
93
137
|
files:
|
|
94
|
-
- ".bitbucket-pipelines.yml"
|
|
95
138
|
- ".rspec"
|
|
96
139
|
- ".rubocop.yml"
|
|
97
140
|
- CODE_OF_CONDUCT.md
|
|
@@ -106,9 +149,14 @@ files:
|
|
|
106
149
|
- bin/rubocop
|
|
107
150
|
- bin/setup
|
|
108
151
|
- bin/smoketest
|
|
152
|
+
- bitbucket-pipelines.yml
|
|
109
153
|
- lib/cloudrunpdf.rb
|
|
110
154
|
- lib/cloudrunpdf/builder.rb
|
|
111
155
|
- lib/cloudrunpdf/configuration.rb
|
|
156
|
+
- lib/cloudrunpdf/exceptions.rb
|
|
157
|
+
- lib/cloudrunpdf/providers/aliyun.rb
|
|
158
|
+
- lib/cloudrunpdf/providers/amazon.rb
|
|
159
|
+
- lib/cloudrunpdf/providers/google.rb
|
|
112
160
|
- lib/cloudrunpdf/version.rb
|
|
113
161
|
homepage: https://remarkgroup.com
|
|
114
162
|
licenses:
|
|
@@ -131,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
131
179
|
- !ruby/object:Gem::Version
|
|
132
180
|
version: '0'
|
|
133
181
|
requirements: []
|
|
134
|
-
rubygems_version: 3.
|
|
182
|
+
rubygems_version: 3.5.22
|
|
135
183
|
signing_key:
|
|
136
184
|
specification_version: 4
|
|
137
185
|
summary: Generate PDF with Google Cloud Function.
|
data/.bitbucket-pipelines.yml
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
image: remarksolutions/ci-image:ruby-31
|
|
2
|
-
|
|
3
|
-
pipelines:
|
|
4
|
-
default:
|
|
5
|
-
- step:
|
|
6
|
-
name: Quality Assurance
|
|
7
|
-
script:
|
|
8
|
-
- bundle install --local
|
|
9
|
-
- bin/rspec
|
|
10
|
-
- bin/rubocop
|
|
11
|
-
caches:
|
|
12
|
-
- bundler
|
|
13
|
-
runs-on:
|
|
14
|
-
- self.hosted
|
|
15
|
-
- linux
|
|
16
|
-
- nuc
|
|
17
|
-
definitions:
|
|
18
|
-
caches:
|
|
19
|
-
bundler: vendor/bundle
|
|
20
|
-
services:
|
|
21
|
-
docker:
|
|
22
|
-
memory: 3072
|