cloudrunpdf 0.1.3 → 0.1.5

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: d4dbe3b8044f5a3f789f04626bc507e1499e192c8ba8691791f57da94c33423b
4
+ data.tar.gz: 623e07fd2ed29a55219a81f7eefe5e48dfc22afcc2f8efd6cca301e2f81aea26
5
5
  SHA512:
6
- metadata.gz: 948aa4bcc5e24b531dc2d4708411d1c2bf0a67fd51466b063e53e89ef88d11053d721e9d407ec0c72d451e127b382ddd6beb40fc8dad33c03a2db8578a6e77df
7
- data.tar.gz: 8bef79deec940fb9b359c6b25be2d0ae8ea44e13aaecc9a399f77765bb6af244aa8f7e0db5ea0f253f11c4675b1bd257c2106353a4e862854b1d518b8cf1201b
6
+ metadata.gz: 9a8aad4483175c887cef1ad4ebe2eddfdcb9d37be1479303d17c22e602c8795677165d29d4d36ad267ef3943405484fb3cd3095982dec4f1521df01db5e57674
7
+ data.tar.gz: 30a352ec5b9656bce40559bd7e664b433e80df28550643d1ef8ca549c5a4b9bd1dbb264462887f68604ec729e20d5f8f2300a9d598f646df9fc6258ccdf08490
@@ -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-ew.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.5'
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.5
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: 2023-04-26 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
@@ -66,7 +80,7 @@ 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.33
83
+ rubygems_version: 3.3.7
70
84
  signing_key:
71
85
  specification_version: 4
72
86
  summary: Generate PDF with Google Cloud Function.