cloudrunpdf 0.1.6 → 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/.rspec +1 -0
- data/.rubocop.yml +64 -0
- data/Gemfile.lock +62 -8
- data/README.md +3 -17
- data/Rakefile +2 -2
- data/bin/console +3 -11
- data/bin/rake +8 -0
- data/bin/rspec +9 -0
- data/bin/rubocop +8 -0
- data/bin/setup +0 -2
- data/bin/smoketest +24 -0
- data/bitbucket-pipelines.yml +28 -0
- data/lib/cloudrunpdf/builder.rb +11 -26
- data/lib/cloudrunpdf/configuration.rb +15 -3
- 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 -2
- metadata +102 -3
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/.rspec
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--require spec_helper
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
NewCops: enable
|
|
3
|
+
Exclude:
|
|
4
|
+
- '*.gemspec'
|
|
5
|
+
- Gemfile
|
|
6
|
+
|
|
7
|
+
Layout/MultilineMethodCallIndentation:
|
|
8
|
+
EnforcedStyle: indented
|
|
9
|
+
IndentationWidth: 4
|
|
10
|
+
Layout/MultilineOperationIndentation:
|
|
11
|
+
EnforcedStyle: indented
|
|
12
|
+
IndentationWidth: 2
|
|
13
|
+
Layout/ArrayAlignment:
|
|
14
|
+
Enabled: false
|
|
15
|
+
Layout/HashAlignment:
|
|
16
|
+
Enabled: false
|
|
17
|
+
Layout/ParameterAlignment:
|
|
18
|
+
EnforcedStyle: with_fixed_indentation
|
|
19
|
+
IndentationWidth: 4
|
|
20
|
+
Layout/ArgumentAlignment:
|
|
21
|
+
EnforcedStyle: with_fixed_indentation
|
|
22
|
+
IndentationWidth: 4
|
|
23
|
+
Layout/FirstHashElementIndentation:
|
|
24
|
+
Enabled: false
|
|
25
|
+
Layout/FirstArgumentIndentation:
|
|
26
|
+
Enabled: false
|
|
27
|
+
Layout/FirstArrayElementIndentation:
|
|
28
|
+
Enabled: false
|
|
29
|
+
Layout/LineLength:
|
|
30
|
+
Max: 100
|
|
31
|
+
|
|
32
|
+
Style/WordArray:
|
|
33
|
+
EnforcedStyle: brackets
|
|
34
|
+
Style/SymbolArray:
|
|
35
|
+
EnforcedStyle: brackets
|
|
36
|
+
Style/NumericPredicate:
|
|
37
|
+
EnforcedStyle: comparison
|
|
38
|
+
Style/ZeroLengthPredicate:
|
|
39
|
+
Enabled: false
|
|
40
|
+
Style/ConditionalAssignment:
|
|
41
|
+
EnforcedStyle: assign_inside_condition
|
|
42
|
+
Style/Documentation:
|
|
43
|
+
Enabled: false
|
|
44
|
+
Style/EmptyMethod:
|
|
45
|
+
EnforcedStyle: expanded
|
|
46
|
+
Style/FrozenStringLiteralComment:
|
|
47
|
+
Enabled: false
|
|
48
|
+
Style/GuardClause:
|
|
49
|
+
Enabled: false
|
|
50
|
+
Style/IfUnlessModifier:
|
|
51
|
+
Enabled: false
|
|
52
|
+
|
|
53
|
+
Metrics/ClassLength:
|
|
54
|
+
Enabled: false
|
|
55
|
+
Metrics/PerceivedComplexity:
|
|
56
|
+
Enabled: false
|
|
57
|
+
Metrics/CyclomaticComplexity:
|
|
58
|
+
Enabled: false
|
|
59
|
+
Metrics/AbcSize:
|
|
60
|
+
Enabled: false
|
|
61
|
+
Metrics/MethodLength:
|
|
62
|
+
Enabled: false
|
|
63
|
+
Metrics/BlockLength:
|
|
64
|
+
Enabled: false
|
data/Gemfile.lock
CHANGED
|
@@ -1,31 +1,85 @@
|
|
|
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)
|
|
16
|
+
combine_pdf (1.0.26)
|
|
12
17
|
matrix
|
|
13
18
|
ruby-rc4 (>= 0.1.5)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
faraday-net_http (3.0
|
|
19
|
+
diff-lcs (1.5.0)
|
|
20
|
+
faraday (2.9.0)
|
|
21
|
+
faraday-net_http (>= 2.0, < 3.2)
|
|
22
|
+
faraday-net_http (3.1.0)
|
|
23
|
+
net-http
|
|
24
|
+
json (2.7.1)
|
|
25
|
+
language_server-protocol (3.17.0.3)
|
|
26
|
+
logger (1.7.0)
|
|
18
27
|
matrix (0.4.2)
|
|
28
|
+
net-http (0.4.1)
|
|
29
|
+
uri
|
|
30
|
+
ostruct (0.6.0)
|
|
31
|
+
parallel (1.24.0)
|
|
32
|
+
parser (3.3.0.3)
|
|
33
|
+
ast (~> 2.4.1)
|
|
34
|
+
racc
|
|
35
|
+
racc (1.7.3)
|
|
36
|
+
rainbow (3.1.1)
|
|
19
37
|
rake (13.0.6)
|
|
38
|
+
regexp_parser (2.9.0)
|
|
39
|
+
rexml (3.2.6)
|
|
40
|
+
rspec (3.12.0)
|
|
41
|
+
rspec-core (~> 3.12.0)
|
|
42
|
+
rspec-expectations (~> 3.12.0)
|
|
43
|
+
rspec-mocks (~> 3.12.0)
|
|
44
|
+
rspec-core (3.12.2)
|
|
45
|
+
rspec-support (~> 3.12.0)
|
|
46
|
+
rspec-expectations (3.12.3)
|
|
47
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
48
|
+
rspec-support (~> 3.12.0)
|
|
49
|
+
rspec-mocks (3.12.6)
|
|
50
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
51
|
+
rspec-support (~> 3.12.0)
|
|
52
|
+
rspec-support (3.12.1)
|
|
53
|
+
rubocop (1.60.0)
|
|
54
|
+
json (~> 2.3)
|
|
55
|
+
language_server-protocol (>= 3.17.0)
|
|
56
|
+
parallel (~> 1.10)
|
|
57
|
+
parser (>= 3.3.0.2)
|
|
58
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
59
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
60
|
+
rexml (>= 3.2.5, < 4.0)
|
|
61
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
|
62
|
+
ruby-progressbar (~> 1.7)
|
|
63
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
|
64
|
+
rubocop-ast (1.30.0)
|
|
65
|
+
parser (>= 3.2.1.0)
|
|
66
|
+
ruby-progressbar (1.13.0)
|
|
20
67
|
ruby-rc4 (0.1.5)
|
|
21
|
-
|
|
68
|
+
unicode-display_width (2.5.0)
|
|
69
|
+
uri (0.13.0)
|
|
70
|
+
vcr (6.2.0)
|
|
22
71
|
|
|
23
72
|
PLATFORMS
|
|
24
73
|
arm64-darwin-21
|
|
74
|
+
arm64-darwin-22
|
|
75
|
+
arm64-darwin-24
|
|
25
76
|
|
|
26
77
|
DEPENDENCIES
|
|
27
78
|
cloudrunpdf!
|
|
28
79
|
rake (~> 13.0)
|
|
80
|
+
rspec
|
|
81
|
+
rubocop
|
|
82
|
+
vcr
|
|
29
83
|
|
|
30
84
|
BUNDLED WITH
|
|
31
|
-
2.
|
|
85
|
+
2.5.4
|
data/README.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# Cloudrunpdf
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
|
3
|
+
The cloudrunpdf Ruby gem allows delegating the rendering of HTML to PDF to a dedicated Google Cloud Run container. This container should be based on the [cloudpdf](https://bitbucket.org/remark_innovation_center/cloudpdf/src/main/) container image.
|
|
6
4
|
|
|
7
5
|
## Installation
|
|
8
6
|
|
|
@@ -22,22 +20,10 @@ Or install it yourself as:
|
|
|
22
20
|
|
|
23
21
|
## Usage
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
See `bin/smoketest` for a concrete usage example.
|
|
26
24
|
|
|
27
25
|
## Development
|
|
28
26
|
|
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment. After making any changes, for quality assurance you can execute the rspec test suite by running `bin/rspec`. In addition, static analysis can be performed by running `bin/rubocop`.
|
|
30
28
|
|
|
31
29
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
32
|
-
|
|
33
|
-
## Contributing
|
|
34
|
-
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cloudrunpdf. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/cloudrunpdf/blob/master/CODE_OF_CONDUCT.md).
|
|
36
|
-
|
|
37
|
-
## License
|
|
38
|
-
|
|
39
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
40
|
-
|
|
41
|
-
## Code of Conduct
|
|
42
|
-
|
|
43
|
-
Everyone interacting in the Cloudrunpdf project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/cloudrunpdf/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
2
|
|
|
4
|
-
require
|
|
5
|
-
require
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
require 'cloudrunpdf'
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
# with your gem easier. You can also use a different console, if you like.
|
|
9
|
-
|
|
10
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
11
|
-
# require "pry"
|
|
12
|
-
# Pry.start
|
|
13
|
-
|
|
14
|
-
require "irb"
|
|
6
|
+
require 'irb'
|
|
15
7
|
IRB.start(__FILE__)
|
data/bin/rake
ADDED
data/bin/rspec
ADDED
data/bin/rubocop
ADDED
data/bin/setup
CHANGED
data/bin/smoketest
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
require 'cloudrunpdf'
|
|
5
|
+
|
|
6
|
+
require 'base64'
|
|
7
|
+
|
|
8
|
+
if ENV['GCLOUD_AUTH_TOKEN'].nil? || ENV['GCLOUD_AUTH_TOKEN'].empty?
|
|
9
|
+
puts <<~MSG
|
|
10
|
+
|
|
11
|
+
Please run the following before executing the smoketest:
|
|
12
|
+
|
|
13
|
+
gcloud auth login; gcloud auth application-default login; export GCLOUD_AUTH_TOKEN=$(gcloud auth print-identity-token)
|
|
14
|
+
|
|
15
|
+
MSG
|
|
16
|
+
exit(1)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
builder = Cloudrunpdf::Builder.new
|
|
20
|
+
result = builder.print({ document: Base64.encode64('<html><body>Hello, world!</body></html>') })
|
|
21
|
+
|
|
22
|
+
FileUtils.mkdir_p('tmp')
|
|
23
|
+
File.write('tmp/result.pdf', result)
|
|
24
|
+
`open tmp/result.pdf`
|
|
@@ -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
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
require 'faraday'
|
|
3
2
|
require 'combine_pdf'
|
|
4
3
|
|
|
5
4
|
module Cloudrunpdf
|
|
6
5
|
class Builder
|
|
7
6
|
def initialize
|
|
8
7
|
@configuration = Cloudrunpdf.configuration
|
|
9
|
-
@
|
|
8
|
+
@provider = provider
|
|
10
9
|
end
|
|
11
10
|
|
|
12
11
|
def print(data)
|
|
13
12
|
threads = []
|
|
13
|
+
data = [data] unless data.is_a?(Array)
|
|
14
|
+
|
|
15
|
+
Thread.report_on_exception = false
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
data.each do |entry|
|
|
16
18
|
threads.append(
|
|
17
19
|
Thread.new { Thread.current[:pdf] = generate_pdf(entry) }
|
|
18
20
|
)
|
|
@@ -26,33 +28,16 @@ module Cloudrunpdf
|
|
|
26
28
|
end
|
|
27
29
|
|
|
28
30
|
def generate_pdf(data)
|
|
29
|
-
|
|
30
|
-
headers = { 'Content-Type' => 'application/json' }
|
|
31
|
-
headers['Authorization'] = 'Bearer ' + @token if @configuration.google?
|
|
31
|
+
connection = @provider.connection
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
connection.post(@configuration.cloud_function_url) do |req|
|
|
34
34
|
req.body = data.to_json
|
|
35
|
-
req.headers = headers
|
|
36
35
|
end
|
|
37
36
|
end
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
# We only auth to cloudrun
|
|
43
|
-
return unless @configuration.google?
|
|
44
|
-
|
|
45
|
-
if ENV['GCLOUD_AUTH_TOKEN'].present?
|
|
46
|
-
@token ||= ENV['GCLOUD_AUTH_TOKEN']
|
|
47
|
-
elsif Rails.env.in?(['development', 'test'])
|
|
48
|
-
@token ||= `gcloud auth print-identity-token`.strip
|
|
49
|
-
else
|
|
50
|
-
@token ||= Faraday.get(
|
|
51
|
-
"http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/identity?audience=#{@configuration.cloud_function_url}&format=full",
|
|
52
|
-
{},
|
|
53
|
-
{ metadata_flavor: 'Google' }
|
|
54
|
-
).body
|
|
55
|
-
end
|
|
38
|
+
def provider
|
|
39
|
+
klass = "Cloudrunpdf::Providers::#{@configuration.platform}"
|
|
40
|
+
@provider ||= Object.const_get(klass).new(@configuration)
|
|
56
41
|
end
|
|
57
42
|
end
|
|
58
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
|
-
@cloud_function_url = 'https://cloudpdf-7zhay37huq-od.a.run.app'
|
|
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,10 +1,13 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
1
|
require_relative 'cloudrunpdf/configuration'
|
|
3
2
|
require_relative 'cloudrunpdf/version'
|
|
4
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
|
|
5
9
|
|
|
6
10
|
module Cloudrunpdf
|
|
7
|
-
# add configuration to Gem
|
|
8
11
|
class << self
|
|
9
12
|
def configuration
|
|
10
13
|
@configuration ||= Configuration.new
|
metadata
CHANGED
|
@@ -1,16 +1,60 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cloudrunpdf
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bas Schoenmakers
|
|
8
8
|
- Jasper vd Berg
|
|
9
|
+
- Jesse Tilro
|
|
10
|
+
- Badrul Idris
|
|
9
11
|
autorequire:
|
|
10
12
|
bindir: exe
|
|
11
13
|
cert_chain: []
|
|
12
|
-
date:
|
|
14
|
+
date: 2025-11-14 00:00:00.000000000 Z
|
|
13
15
|
dependencies:
|
|
16
|
+
- !ruby/object:Gem::Dependency
|
|
17
|
+
name: rubocop
|
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
|
19
|
+
requirements:
|
|
20
|
+
- - ">="
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '0'
|
|
23
|
+
type: :development
|
|
24
|
+
prerelease: false
|
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
+
requirements:
|
|
27
|
+
- - ">="
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '0'
|
|
30
|
+
- !ruby/object:Gem::Dependency
|
|
31
|
+
name: rspec
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
33
|
+
requirements:
|
|
34
|
+
- - ">="
|
|
35
|
+
- !ruby/object:Gem::Version
|
|
36
|
+
version: '0'
|
|
37
|
+
type: :development
|
|
38
|
+
prerelease: false
|
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
40
|
+
requirements:
|
|
41
|
+
- - ">="
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: '0'
|
|
44
|
+
- !ruby/object:Gem::Dependency
|
|
45
|
+
name: vcr
|
|
46
|
+
requirement: !ruby/object:Gem::Requirement
|
|
47
|
+
requirements:
|
|
48
|
+
- - ">="
|
|
49
|
+
- !ruby/object:Gem::Version
|
|
50
|
+
version: '0'
|
|
51
|
+
type: :development
|
|
52
|
+
prerelease: false
|
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
54
|
+
requirements:
|
|
55
|
+
- - ">="
|
|
56
|
+
- !ruby/object:Gem::Version
|
|
57
|
+
version: '0'
|
|
14
58
|
- !ruby/object:Gem::Dependency
|
|
15
59
|
name: combine_pdf
|
|
16
60
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -39,14 +83,60 @@ dependencies:
|
|
|
39
83
|
- - ">="
|
|
40
84
|
- !ruby/object:Gem::Version
|
|
41
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'
|
|
42
128
|
description:
|
|
43
129
|
email:
|
|
44
130
|
- bas.schoenmakers@remarkgroup.com
|
|
45
131
|
- jasper.vandenberg@remarkgroup.com
|
|
132
|
+
- jesse.tilro@remarkgroup.com
|
|
133
|
+
- badrul.idris@scordigitalsolutions.com
|
|
46
134
|
executables: []
|
|
47
135
|
extensions: []
|
|
48
136
|
extra_rdoc_files: []
|
|
49
137
|
files:
|
|
138
|
+
- ".rspec"
|
|
139
|
+
- ".rubocop.yml"
|
|
50
140
|
- CODE_OF_CONDUCT.md
|
|
51
141
|
- Gemfile
|
|
52
142
|
- Gemfile.lock
|
|
@@ -54,10 +144,19 @@ files:
|
|
|
54
144
|
- README.md
|
|
55
145
|
- Rakefile
|
|
56
146
|
- bin/console
|
|
147
|
+
- bin/rake
|
|
148
|
+
- bin/rspec
|
|
149
|
+
- bin/rubocop
|
|
57
150
|
- bin/setup
|
|
151
|
+
- bin/smoketest
|
|
152
|
+
- bitbucket-pipelines.yml
|
|
58
153
|
- lib/cloudrunpdf.rb
|
|
59
154
|
- lib/cloudrunpdf/builder.rb
|
|
60
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
|
|
61
160
|
- lib/cloudrunpdf/version.rb
|
|
62
161
|
homepage: https://remarkgroup.com
|
|
63
162
|
licenses:
|
|
@@ -80,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
80
179
|
- !ruby/object:Gem::Version
|
|
81
180
|
version: '0'
|
|
82
181
|
requirements: []
|
|
83
|
-
rubygems_version: 3.
|
|
182
|
+
rubygems_version: 3.5.22
|
|
84
183
|
signing_key:
|
|
85
184
|
specification_version: 4
|
|
86
185
|
summary: Generate PDF with Google Cloud Function.
|