cloudrunpdf 0.1.3 → 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: fd42ad0d28f30d92c080b40612bacd0f31fb1bc1148845c62cb425596c1fcb6e
4
- data.tar.gz: f13744dd16439f8bdf96bc77b878f6b97972f7f26307a775419cb5ba7845cfb9
3
+ metadata.gz: 11447238b15b41b87efa7f2e22674c77b19fee6ccec67d30d17d3e70d3f83c11
4
+ data.tar.gz: a568eecced86f9aaf1972fd0725c05569c5615396a195a26606e9f6b944c424a
5
5
  SHA512:
6
- metadata.gz: 948aa4bcc5e24b531dc2d4708411d1c2bf0a67fd51466b063e53e89ef88d11053d721e9d407ec0c72d451e127b382ddd6beb40fc8dad33c03a2db8578a6e77df
7
- data.tar.gz: 8bef79deec940fb9b359c6b25be2d0ae8ea44e13aaecc9a399f77765bb6af244aa8f7e0db5ea0f253f11c4675b1bd257c2106353a4e862854b1d518b8cf1201b
6
+ metadata.gz: 16a6fb7680f96ddedad2887b31ae9a3a96f2af98fb5ddf97d1c318437a03fa96cf95f59bbcfce4fb9d97d9595dd6e52add05e246d5510511b1280caf37e0816c
7
+ data.tar.gz: f2d765fcb0521b649e6a5fa3759e564408e1ba7ddbea28c564f2241bf241abffcf99594acce2da70c012e1cedff2f2ecc3ccdf2402b83827bf57781237372c80
@@ -26,18 +26,22 @@ 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
42
+ # We only auth to cloudrun
43
+ return unless @configuration.google?
44
+
41
45
  if ENV['GCLOUD_AUTH_TOKEN'].present?
42
46
  @token ||= ENV['GCLOUD_AUTH_TOKEN']
43
47
  elsif Rails.env.in?(['development', 'test'])
@@ -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.3'
4
+ VERSION = '0.1.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudrunpdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bas Schoenmakers
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2022-09-06 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,6 +25,20 @@ dependencies:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
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'
28
42
  description:
29
43
  email:
30
44
  - bas.schoenmakers@remarkgroup.com