html2pdf-rails 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +30 -0
- data/README.md +4 -2
- data/lib/html2pdf/rails/client.rb +4 -2
- data/lib/html2pdf/rails/railtie.rb +3 -1
- data/lib/html2pdf/rails/version.rb +1 -1
- data/lib/html2pdf/rails.rb +6 -3
- metadata +4 -7
- data/.travis.yml +0 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0f36633c9696c0a36149bf8037f20cfcb2c6df4c7d81bbfc5352954126d594e6
|
|
4
|
+
data.tar.gz: a4ae4281240e6bd471fe2f1cdbb99a8b027b3be33d85fb109d05f1855df80002
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 17f3d2b6d2ccf67e17c0975f7c5fa8cb6b1ddc667af0ac72a2e7675d60da987fc1e82a8c2f3c9ce7d73dd6a32c54e64ff8f5f49b99e7399e4617594e5e358af5
|
|
7
|
+
data.tar.gz: 8faccbadc668806d4c57209c5a374fc57709169f8999802ce907464c841ea9990733e33ae5b822b12c112a605ed88b038def6eea42bdfe223a2e99c0082b5fda
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ main ]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
test:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
|
|
14
|
+
strategy:
|
|
15
|
+
fail-fast: false
|
|
16
|
+
matrix:
|
|
17
|
+
ruby-version: ['3.2', '3.3', '3.4', '4.0']
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- name: Checkout code
|
|
21
|
+
uses: actions/checkout@v4
|
|
22
|
+
|
|
23
|
+
- name: Set up Ruby ${{ matrix.ruby-version }}
|
|
24
|
+
uses: ruby/setup-ruby@v1
|
|
25
|
+
with:
|
|
26
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
27
|
+
bundler-cache: true
|
|
28
|
+
|
|
29
|
+
- name: Run tests
|
|
30
|
+
run: bundle exec rspec -fp
|
data/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
1
3
|
# html2pdf-rails
|
|
2
4
|
|
|
3
5
|
PDF generator (from HTML) gem for Ruby on Rails.
|
|
@@ -73,9 +75,9 @@ class ThingsController < ApplicationController
|
|
|
73
75
|
template: 'things/show',
|
|
74
76
|
layout: 'pdf', # for a pdf.pdf.erb file
|
|
75
77
|
show_as_html: params.key?('debug'), # allow debugging based on url param
|
|
76
|
-
pdf_options: { # SEE: https://
|
|
78
|
+
pdf_options: { # SEE: https://pptr.dev/api/puppeteer.pdfoptions
|
|
77
79
|
margin: {
|
|
78
|
-
top: '30px'
|
|
80
|
+
top: '30px',
|
|
79
81
|
bottom: '30px',
|
|
80
82
|
}
|
|
81
83
|
}
|
|
@@ -6,17 +6,19 @@ module Html2Pdf
|
|
|
6
6
|
module Rails
|
|
7
7
|
class Client
|
|
8
8
|
def self.post(**options)
|
|
9
|
-
self.new(Html2Pdf.config.endpoint).post(**options)
|
|
9
|
+
self.new(Html2Pdf.config.endpoint, Html2Pdf.config.app).post(**options)
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
def initialize(endpoint)
|
|
12
|
+
def initialize(endpoint, app)
|
|
13
13
|
@uri = URI.parse(endpoint)
|
|
14
|
+
@app = app
|
|
14
15
|
end
|
|
15
16
|
|
|
16
17
|
def post(html:, put_to_storage: false, file_name: nil, disposition: nil, pdf_options: {})
|
|
17
18
|
http = Net::HTTP.new(@uri.host, @uri.port).tap { |h| h.use_ssl = @uri.scheme == 'https' }
|
|
18
19
|
request = Net::HTTP::Post.new(@uri.request_uri, headers)
|
|
19
20
|
request.body = {
|
|
21
|
+
app: @app,
|
|
20
22
|
html: html,
|
|
21
23
|
putToStorage: put_to_storage,
|
|
22
24
|
fileName: file_name,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'rails'
|
|
3
4
|
require 'html2pdf/rails/rendering'
|
|
4
5
|
require 'html2pdf/rails/helper'
|
|
5
6
|
|
|
@@ -14,10 +15,11 @@ module Html2Pdf
|
|
|
14
15
|
ActionView::Base.include Helper
|
|
15
16
|
end
|
|
16
17
|
|
|
17
|
-
config.after_initialize do
|
|
18
|
+
config.after_initialize do |app|
|
|
18
19
|
if Html2Pdf.config.endpoint.blank?
|
|
19
20
|
raise 'Html2Pdf.config.endpoint is required'
|
|
20
21
|
end
|
|
22
|
+
Html2Pdf.config.app ||= app.class.module_parent_name
|
|
21
23
|
end
|
|
22
24
|
end
|
|
23
25
|
end
|
data/lib/html2pdf/rails.rb
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
require 'active_support/configurable'
|
|
2
1
|
require 'html2pdf/rails/version'
|
|
3
2
|
require 'html2pdf/rails/railtie'
|
|
4
3
|
|
|
5
4
|
module Html2Pdf
|
|
6
5
|
class Config
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
attr_accessor :endpoint, :app
|
|
7
|
+
|
|
8
|
+
def initialize
|
|
9
|
+
@endpoint = nil
|
|
10
|
+
@app = nil
|
|
11
|
+
end
|
|
9
12
|
end
|
|
10
13
|
|
|
11
14
|
class << self
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: html2pdf-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- aki77
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 2026-02-25 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rails
|
|
@@ -87,10 +86,10 @@ executables: []
|
|
|
87
86
|
extensions: []
|
|
88
87
|
extra_rdoc_files: []
|
|
89
88
|
files:
|
|
89
|
+
- ".github/workflows/ci.yml"
|
|
90
90
|
- ".gitignore"
|
|
91
91
|
- ".rspec"
|
|
92
92
|
- ".rubocop.yml"
|
|
93
|
-
- ".travis.yml"
|
|
94
93
|
- CODE_OF_CONDUCT.md
|
|
95
94
|
- Gemfile
|
|
96
95
|
- LICENSE.txt
|
|
@@ -110,7 +109,6 @@ homepage: https://github.com/SonicGarden/html2pdf-rails
|
|
|
110
109
|
licenses:
|
|
111
110
|
- MIT
|
|
112
111
|
metadata: {}
|
|
113
|
-
post_install_message:
|
|
114
112
|
rdoc_options: []
|
|
115
113
|
require_paths:
|
|
116
114
|
- lib
|
|
@@ -125,8 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
125
123
|
- !ruby/object:Gem::Version
|
|
126
124
|
version: '0'
|
|
127
125
|
requirements: []
|
|
128
|
-
rubygems_version: 3.
|
|
129
|
-
signing_key:
|
|
126
|
+
rubygems_version: 3.6.2
|
|
130
127
|
specification_version: 4
|
|
131
128
|
summary: PDF generator (from HTML) gem for Ruby on Rails
|
|
132
129
|
test_files: []
|