cloudrunpdf 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.bitbucket-pipelines.yml +22 -0
- data/.rspec +1 -0
- data/.rubocop.yml +64 -0
- data/Gemfile.lock +55 -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/lib/cloudrunpdf/builder.rb +17 -11
- data/lib/cloudrunpdf/configuration.rb +1 -1
- data/lib/cloudrunpdf/version.rb +1 -1
- data/lib/cloudrunpdf.rb +0 -2
- metadata +54 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 295dace19af034ae16e7c2a750d8e65e3e2b547b2bb32be072cd8a7881be44d8
|
4
|
+
data.tar.gz: cf548e50c3f0777a138e60e7dfe60099bb1497726d0a2d78ce74c5214e89f33c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24b9a700da788ab7fe92b5354d29d6fa9dcf3efff8870bf2411f55483377fb95e576a80b00ffb4d96a810382e252e024a1566329593cf8c2046832dac04ecf58
|
7
|
+
data.tar.gz: 7d70be974274d51ae125e99ac19c257ea7d83d3f304eb6124318acf26caedbe00a97ccea3c5f972985c64b50bcf9adfc345402a22ba5f32acfff59b59c963cf5
|
@@ -0,0 +1,22 @@
|
|
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
|
+
runs-on:
|
14
|
+
- self.hosted
|
15
|
+
- linux
|
16
|
+
- nuc
|
17
|
+
definitions:
|
18
|
+
caches:
|
19
|
+
bundler: vendor/bundle
|
20
|
+
services:
|
21
|
+
docker:
|
22
|
+
memory: 3072
|
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,78 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cloudrunpdf (0.1.
|
4
|
+
cloudrunpdf (0.1.4)
|
5
5
|
combine_pdf
|
6
6
|
faraday
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
|
11
|
+
ast (2.4.2)
|
12
|
+
combine_pdf (1.0.26)
|
12
13
|
matrix
|
13
14
|
ruby-rc4 (>= 0.1.5)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
faraday-net_http (3.0
|
15
|
+
diff-lcs (1.5.0)
|
16
|
+
faraday (2.9.0)
|
17
|
+
faraday-net_http (>= 2.0, < 3.2)
|
18
|
+
faraday-net_http (3.1.0)
|
19
|
+
net-http
|
20
|
+
json (2.7.1)
|
21
|
+
language_server-protocol (3.17.0.3)
|
18
22
|
matrix (0.4.2)
|
23
|
+
net-http (0.4.1)
|
24
|
+
uri
|
25
|
+
parallel (1.24.0)
|
26
|
+
parser (3.3.0.3)
|
27
|
+
ast (~> 2.4.1)
|
28
|
+
racc
|
29
|
+
racc (1.7.3)
|
30
|
+
rainbow (3.1.1)
|
19
31
|
rake (13.0.6)
|
32
|
+
regexp_parser (2.9.0)
|
33
|
+
rexml (3.2.6)
|
34
|
+
rspec (3.12.0)
|
35
|
+
rspec-core (~> 3.12.0)
|
36
|
+
rspec-expectations (~> 3.12.0)
|
37
|
+
rspec-mocks (~> 3.12.0)
|
38
|
+
rspec-core (3.12.2)
|
39
|
+
rspec-support (~> 3.12.0)
|
40
|
+
rspec-expectations (3.12.3)
|
41
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
42
|
+
rspec-support (~> 3.12.0)
|
43
|
+
rspec-mocks (3.12.6)
|
44
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
45
|
+
rspec-support (~> 3.12.0)
|
46
|
+
rspec-support (3.12.1)
|
47
|
+
rubocop (1.60.0)
|
48
|
+
json (~> 2.3)
|
49
|
+
language_server-protocol (>= 3.17.0)
|
50
|
+
parallel (~> 1.10)
|
51
|
+
parser (>= 3.3.0.2)
|
52
|
+
rainbow (>= 2.2.2, < 4.0)
|
53
|
+
regexp_parser (>= 1.8, < 3.0)
|
54
|
+
rexml (>= 3.2.5, < 4.0)
|
55
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
56
|
+
ruby-progressbar (~> 1.7)
|
57
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
58
|
+
rubocop-ast (1.30.0)
|
59
|
+
parser (>= 3.2.1.0)
|
60
|
+
ruby-progressbar (1.13.0)
|
20
61
|
ruby-rc4 (0.1.5)
|
21
|
-
|
62
|
+
unicode-display_width (2.5.0)
|
63
|
+
uri (0.13.0)
|
64
|
+
vcr (6.2.0)
|
22
65
|
|
23
66
|
PLATFORMS
|
24
67
|
arm64-darwin-21
|
68
|
+
arm64-darwin-22
|
25
69
|
|
26
70
|
DEPENDENCIES
|
27
71
|
cloudrunpdf!
|
28
72
|
rake (~> 13.0)
|
73
|
+
rspec
|
74
|
+
rubocop
|
75
|
+
vcr
|
29
76
|
|
30
77
|
BUNDLED WITH
|
31
|
-
2.
|
78
|
+
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`
|
data/lib/cloudrunpdf/builder.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'faraday'
|
3
2
|
require 'combine_pdf'
|
4
3
|
|
5
4
|
module Cloudrunpdf
|
@@ -11,8 +10,11 @@ module Cloudrunpdf
|
|
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,13 +28,17 @@ module Cloudrunpdf
|
|
26
28
|
end
|
27
29
|
|
28
30
|
def generate_pdf(data)
|
29
|
-
|
30
|
-
|
31
|
-
|
31
|
+
connection = Faraday::Connection.new(
|
32
|
+
headers: {
|
33
|
+
'Content-Type' => 'application/json',
|
34
|
+
'Authorization' => ("Bearer #{@token}" if @configuration.google?)
|
35
|
+
}.compact
|
36
|
+
) do |conn|
|
37
|
+
conn.response :raise_error
|
38
|
+
end
|
32
39
|
|
33
|
-
|
40
|
+
connection.post(@configuration.cloud_function_url) do |req|
|
34
41
|
req.body = data.to_json
|
35
|
-
req.headers = headers
|
36
42
|
end
|
37
43
|
end
|
38
44
|
|
@@ -42,9 +48,9 @@ module Cloudrunpdf
|
|
42
48
|
# We only auth to cloudrun
|
43
49
|
return unless @configuration.google?
|
44
50
|
|
45
|
-
if ENV['GCLOUD_AUTH_TOKEN'].
|
46
|
-
@token ||= ENV
|
47
|
-
elsif Rails.env.in?(['development', 'test'])
|
51
|
+
if !ENV['GCLOUD_AUTH_TOKEN'].nil?
|
52
|
+
@token ||= ENV.fetch('GCLOUD_AUTH_TOKEN', nil)
|
53
|
+
elsif Object.const_defined?(:Rails) && Rails.env.in?(['development', 'test'])
|
48
54
|
@token ||= `gcloud auth print-identity-token`.strip
|
49
55
|
else
|
50
56
|
@token ||= Faraday.get(
|
data/lib/cloudrunpdf/version.rb
CHANGED
data/lib/cloudrunpdf.rb
CHANGED
@@ -1,10 +1,8 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
1
|
require_relative 'cloudrunpdf/configuration'
|
3
2
|
require_relative 'cloudrunpdf/version'
|
4
3
|
require_relative 'cloudrunpdf/builder'
|
5
4
|
|
6
5
|
module Cloudrunpdf
|
7
|
-
# add configuration to Gem
|
8
6
|
class << self
|
9
7
|
def configuration
|
10
8
|
@configuration ||= Configuration.new
|
metadata
CHANGED
@@ -1,16 +1,59 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudrunpdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bas Schoenmakers
|
8
8
|
- Jasper vd Berg
|
9
|
+
- Jesse Tilro
|
9
10
|
autorequire:
|
10
11
|
bindir: exe
|
11
12
|
cert_chain: []
|
12
|
-
date:
|
13
|
+
date: 2024-01-16 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rubocop
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ">="
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '0'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: rspec
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: vcr
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
14
57
|
- !ruby/object:Gem::Dependency
|
15
58
|
name: combine_pdf
|
16
59
|
requirement: !ruby/object:Gem::Requirement
|
@@ -43,10 +86,14 @@ description:
|
|
43
86
|
email:
|
44
87
|
- bas.schoenmakers@remarkgroup.com
|
45
88
|
- jasper.vandenberg@remarkgroup.com
|
89
|
+
- jesse.tilro@remarkgroup.com
|
46
90
|
executables: []
|
47
91
|
extensions: []
|
48
92
|
extra_rdoc_files: []
|
49
93
|
files:
|
94
|
+
- ".bitbucket-pipelines.yml"
|
95
|
+
- ".rspec"
|
96
|
+
- ".rubocop.yml"
|
50
97
|
- CODE_OF_CONDUCT.md
|
51
98
|
- Gemfile
|
52
99
|
- Gemfile.lock
|
@@ -54,7 +101,11 @@ files:
|
|
54
101
|
- README.md
|
55
102
|
- Rakefile
|
56
103
|
- bin/console
|
104
|
+
- bin/rake
|
105
|
+
- bin/rspec
|
106
|
+
- bin/rubocop
|
57
107
|
- bin/setup
|
108
|
+
- bin/smoketest
|
58
109
|
- lib/cloudrunpdf.rb
|
59
110
|
- lib/cloudrunpdf/builder.rb
|
60
111
|
- lib/cloudrunpdf/configuration.rb
|
@@ -80,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
131
|
- !ruby/object:Gem::Version
|
81
132
|
version: '0'
|
82
133
|
requirements: []
|
83
|
-
rubygems_version: 3.
|
134
|
+
rubygems_version: 3.4.10
|
84
135
|
signing_key:
|
85
136
|
specification_version: 4
|
86
137
|
summary: Generate PDF with Google Cloud Function.
|