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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c123404efb70278b8339e907fd8e3a6c64db03d8b2dadf105cc37a81a7abf172
4
- data.tar.gz: 6b9719260f7071a262d0c7518760354036d58863a37911acb09b24ab420a4458
3
+ metadata.gz: 11447238b15b41b87efa7f2e22674c77b19fee6ccec67d30d17d3e70d3f83c11
4
+ data.tar.gz: a568eecced86f9aaf1972fd0725c05569c5615396a195a26606e9f6b944c424a
5
5
  SHA512:
6
- metadata.gz: 0bd503bf7b0a8750a8fb83a444bc0c7ac30eef8305f0ea2cedf87b38601fdd10fe700356456112395cfc8b5a83103d07fb0f68e8ce0deb542bc0b90d3d399625
7
- data.tar.gz: 3c6a28a9204a77d0f9328de11b8e02bd1a7380eeda5e3efb11593951a3cda0148c75ed7cf2c61f1e9d6c1b1711adbd41dc7d00188e35a06777f323aa2b883de7
6
+ metadata.gz: 16a6fb7680f96ddedad2887b31ae9a3a96f2af98fb5ddf97d1c318437a03fa96cf95f59bbcfce4fb9d97d9595dd6e52add05e246d5510511b1280caf37e0816c
7
+ data.tar.gz: f2d765fcb0521b649e6a5fa3759e564408e1ba7ddbea28c564f2241bf241abffcf99594acce2da70c012e1cedff2f2ecc3ccdf2402b83827bf57781237372c80
@@ -26,19 +26,25 @@ module Cloudrunpdf
26
26
  end
27
27
 
28
28
  def generate_pdf(data)
29
- Faraday.post(
30
- @configuration.cloud_function_url,
31
- data,
32
- {
33
- 'Authorization' => 'Bearer ' + @token
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
- if Rails.env.in?(['development', 'test'])
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://htmlpdf-newer-7zhay37huq-ew.a.run.app'.freeze
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cloudrunpdf
4
- VERSION = "0.1.2"
4
+ VERSION = '0.1.4'
5
5
  end
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.2
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-06-10 00:00:00.000000000 Z
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
- description:
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.32
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: []