cloudrunpdf 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cloudrunpdf/builder.rb +14 -8
- data/lib/cloudrunpdf/configuration.rb +14 -2
- data/lib/cloudrunpdf/version.rb +1 -1
- metadata +21 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11447238b15b41b87efa7f2e22674c77b19fee6ccec67d30d17d3e70d3f83c11
|
4
|
+
data.tar.gz: a568eecced86f9aaf1972fd0725c05569c5615396a195a26606e9f6b944c424a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16a6fb7680f96ddedad2887b31ae9a3a96f2af98fb5ddf97d1c318437a03fa96cf95f59bbcfce4fb9d97d9595dd6e52add05e246d5510511b1280caf37e0816c
|
7
|
+
data.tar.gz: f2d765fcb0521b649e6a5fa3759e564408e1ba7ddbea28c564f2241bf241abffcf99594acce2da70c012e1cedff2f2ecc3ccdf2402b83827bf57781237372c80
|
data/lib/cloudrunpdf/builder.rb
CHANGED
@@ -26,19 +26,25 @@ module Cloudrunpdf
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def generate_pdf(data)
|
29
|
-
Faraday.
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
conn = Faraday.new
|
30
|
+
headers = { 'Content-Type' => 'application/json' }
|
31
|
+
headers['Authorization'] = 'Bearer ' + @token if @configuration.google?
|
32
|
+
|
33
|
+
conn.post(@configuration.cloud_function_url) do |req|
|
34
|
+
req.body = data.to_json
|
35
|
+
req.headers = headers
|
36
|
+
end
|
36
37
|
end
|
37
38
|
|
38
39
|
private
|
39
40
|
|
40
41
|
def retrieve_authentication_token
|
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'])
|
42
48
|
@token ||= `gcloud auth print-identity-token`.strip
|
43
49
|
else
|
44
50
|
@token ||= Faraday.get(
|
@@ -3,10 +3,22 @@
|
|
3
3
|
module Cloudrunpdf
|
4
4
|
# Configuration options for gem
|
5
5
|
class Configuration
|
6
|
-
attr_accessor :cloud_function_url
|
6
|
+
attr_accessor :cloud_function_url, :auth
|
7
|
+
|
8
|
+
AUTHS = [
|
9
|
+
:google,
|
10
|
+
:aliyun
|
11
|
+
].freeze
|
7
12
|
|
8
13
|
def initialize
|
9
|
-
@cloud_function_url = 'https://
|
14
|
+
@cloud_function_url = 'https://cloudpdf-7zhay37huq-od.a.run.app'.freeze
|
15
|
+
@auth = :google
|
16
|
+
end
|
17
|
+
|
18
|
+
AUTHS.each do |auth|
|
19
|
+
define_method "#{auth}?" do
|
20
|
+
@auth == auth
|
21
|
+
end
|
10
22
|
end
|
11
23
|
end
|
12
24
|
end
|
data/lib/cloudrunpdf/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudrunpdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bas Schoenmakers
|
8
8
|
- Jasper vd Berg
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-09-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: combine_pdf
|
@@ -25,7 +25,21 @@ dependencies:
|
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
|
-
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: faraday
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
description:
|
29
43
|
email:
|
30
44
|
- bas.schoenmakers@remarkgroup.com
|
31
45
|
- jasper.vandenberg@remarkgroup.com
|
@@ -51,7 +65,7 @@ licenses:
|
|
51
65
|
metadata:
|
52
66
|
homepage_uri: https://remarkgroup.com
|
53
67
|
rubygems_mfa_required: 'true'
|
54
|
-
post_install_message:
|
68
|
+
post_install_message:
|
55
69
|
rdoc_options: []
|
56
70
|
require_paths:
|
57
71
|
- lib
|
@@ -66,8 +80,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
80
|
- !ruby/object:Gem::Version
|
67
81
|
version: '0'
|
68
82
|
requirements: []
|
69
|
-
rubygems_version: 3.2.
|
70
|
-
signing_key:
|
83
|
+
rubygems_version: 3.2.33
|
84
|
+
signing_key:
|
71
85
|
specification_version: 4
|
72
86
|
summary: Generate PDF with Google Cloud Function.
|
73
87
|
test_files: []
|