gkhtmltopdf 1.0.0 → 1.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 450c50b4a300eb003c28a7d3df213ed05ec5ec0626172ef178966f693af4cf5d
4
- data.tar.gz: 0a80041e7a625a55ba11f7636b25a2ebee2a2500e3a6df9d0d8e60c49300a4c9
3
+ metadata.gz: 074bccbef46db0aaa81947a06ea1a1d7022b75a4916dec8d76751b96bfbc607f
4
+ data.tar.gz: bd007b02950a0e01a6cb1a0a68c30e3f5f16604f0489568bef0899f5f2d1e84d
5
5
  SHA512:
6
- metadata.gz: ca97c9e7eeb874af9258869c4ead4d3dfbdd68f641afed5baaa66f5bdbf20dc1fd9b851039ba7fdc231df8f7ecd7b01b2b5768dddeace29c0c42608c469725ec
7
- data.tar.gz: 2feea957d0d915498bb92378a6ff734ffce7922da83f1cadb4765090eb09d5d3030b38525c3295ec31fe1826453f34a4bfde5f0343aad8fef9d6fc943ac6234c
6
+ metadata.gz: e359baec50a11f2276bd1354269c59667091bbf12f9285d219616569b266f18a63c40be1349667ee7cefd5550109b93c9757705a8135dd15152762c6ab98c09c
7
+ data.tar.gz: 2fe00c3971f0354310bbc946531eb6facb107c7649f0d191b0210ea2fd683a726cabe18613053d498ded52558eb92791a0c522bb87f16f7ad77220c72faf075b
data/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  All noteworthy changes to this project will be documented in this file.
4
4
 
5
+ ## 1.1.1 / 2026-06-29
6
+
7
+ - GeckodriverのSTDOUT/STDERR追加
8
+
9
+ ## 1.1.0 / 2026-06-29
10
+
11
+ - UA設定機能の追加
12
+ - mktmpdirの明示的な削除
13
+ - ubuntuでの動かし方とか修正
14
+
5
15
  ## 1.0.0 / 2026-03-19
6
16
 
7
17
  - Added serial processing for multiple files and URLs.
data/README.md CHANGED
@@ -5,6 +5,10 @@ Gkhtmltopdf is mean Gecko HTML to PDF converter.
5
5
  Developed as an alternative to wkhtmltopdf.
6
6
  This gem converts HTML to PDF using Firefox's Geckodriver.
7
7
 
8
+ [![Gem Version](https://badge.fury.io/rb/gkhtmltopdf.svg)](https://badge.fury.io/rb/gkhtmltopdf)
9
+ ![Gem Total Downloads](https://img.shields.io/gem/dt/gkhtmltopdf)
10
+ ![GitHub License](https://img.shields.io/github/license/fantasia-tech/gkhtmltopdf-rb)
11
+
8
12
  ---
9
13
 
10
14
  ## How to
@@ -12,36 +16,42 @@ This gem converts HTML to PDF using Firefox's Geckodriver.
12
16
  ### 1. Install
13
17
 
14
18
  1. [Firefox](https://www.firefox.com)
15
- - Ubuntu
16
- ```bash
17
- $ apt install -y firefox
18
- $ apt install -y fonts-noto # recommended
19
- ```
20
- - Debian
21
- ```bash
22
- $ apt install -y firefox-esr
23
- $ apt install -y fonts-noto # recommended
24
- ```
19
+ - Ubuntu
20
+ > The snap does not work correctly, so please install it from the [official source](https://support.mozilla.org/en-US/kb/install-firefox-linux).
21
+ ```bash
22
+ $ wget -q https://packages.mozilla.org/apt/repo-signing-key.gpg -O- | sudo tee /etc/apt/keyrings/packages.mozilla.org.asc > /dev/null
23
+ $ echo "deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main" | tee -a /etc/apt/sources.list.d/mozilla.list > /dev/null
24
+ $ tee /etc/apt/preferences.d/mozilla > /dev/null << EOF
25
+ Package: *
26
+ Pin: origin packages.mozilla.org
27
+ Pin-Priority: 1000
28
+ EOF
29
+ $ apt install -y firefox
30
+ $ apt install -y fonts-noto # recommended
31
+ ```
32
+ - Debian
33
+ ```bash
34
+ $ apt install -y firefox-esr
35
+ $ apt install -y fonts-noto # recommended
36
+ ```
25
37
 
26
38
  2. [geckodriver](https://github.com/mozilla/geckodriver)
27
- - Linux (Ubuntu / Debian)
39
+ - Linux (Ubuntu / Debian)
28
40
  ```bash
29
41
  $ wget "https://github.com/mozilla/geckodriver/releases/download/v0.36.0/geckodriver-v0.36.0-linux64.tar.gz" -O /tmp/geckodriver.tar.gz
30
42
  $ tar -xzf /tmp/geckodriver.tar.gz -C /usr/local/bin
31
43
  ```
32
44
 
33
45
  3. gem install
34
- - bundler
46
+ - bundler
35
47
  ```bash
36
48
  $ bundle add gkhtmltopdf
37
49
  ```
38
- - other
50
+ - other
39
51
  ```bash
40
52
  $ gem install gkhtmltopdf
41
53
  ```
42
54
 
43
- ---
44
-
45
55
  ### 2. Using
46
56
 
47
57
  #### Ruby
@@ -57,6 +67,8 @@ Gkhtmltopdf.convert('https://example.com', 'example_com.pdf')
57
67
  Gkhtmltopdf.convert('file:///foo/bar/test.html', 'local.pdf')
58
68
  # with option (print background)
59
69
  Gkhtmltopdf.convert('https://f6a.net/oss/', 'with_bg.pdf', print_options: {background: true})
70
+ # with option (set custom user-agent)
71
+ Gkhtmltopdf.convert('https://f6a.net/oss/', 'ua.pdf', user_agent: 'YOUR USER AGENT')
60
72
  ```
61
73
 
62
74
  Additionally, in version 1.0.0 we added the following syntax.
@@ -69,6 +81,10 @@ Gkhtmltopdf.open do |gkh2p|
69
81
  gkh2p.save_pdf('file:///foo/bar/test.html', 'local.pdf')
70
82
  gkh2p.save_pdf('https://f6a.net/oss/', 'with_bg.pdf', print_options: {background: true})
71
83
  end
84
+ # set custom user-agent
85
+ Gkhtmltopdf.open(user_agent: 'YOUR USER AGENT') do |gkh2p|
86
+ gkh2p.save_pdf('https://f6a.net/oss/', 'ua.pdf')
87
+ end
72
88
  ```
73
89
 
74
90
  #### Shell
@@ -80,6 +96,8 @@ $ gkhtmltopdf https://example.com/ example_com.pdf
80
96
  $ gkhtmltopdf /foo/bar/test.html local.pdf
81
97
  # with option (print background)
82
98
  $ gkhtmltopdf https://f6a.net/oss/ with_bg.pdf --background
99
+ # with option (set custom user-agent)
100
+ $ gkhtmltopdf https://f6a.net/oss/ ua.pdf --user-agent "YOUR USER AGENT"
83
101
  # other option
84
102
  $ gkhtmltopdf --help
85
103
  ```
@@ -105,7 +123,7 @@ Attackers could potentially generate PDFs of internal network resources (e.g., `
105
123
 
106
124
  ---
107
125
 
108
- ## Errors
126
+ ## Expected Errors
109
127
 
110
128
  The following errors inherit `Gkhtmltopdf::Error`, so you can handle them as follows:
111
129
 
@@ -132,6 +150,12 @@ Response from Firefox/Geckodriver is not as expected.
132
150
 
133
151
  ---
134
152
 
153
+ ## Documents
154
+
155
+ - [ForDeveloper](/docs/ForDeveloper.md)
156
+
157
+ ---
158
+
135
159
  ## Acknowledgments & Third-Party Licenses
136
160
 
137
161
  This gem acts as a wrapper and communicates with the following external open-source tools.
data/TODO.md CHANGED
@@ -17,9 +17,24 @@
17
17
  - [x] エラー処理
18
18
  - [x] 起動時の待機時間オプション
19
19
 
20
- ## 今後検討
20
+ ## 完了 v1.1.0
21
+
22
+ - [x] UA設定機能の追加
23
+ - [x] mktmpdirの明示的な削除
24
+
25
+ ## 完了 v1.1.1
26
+
27
+ - [x] GeckodriverのSTDOUT/STDERR追加
28
+
29
+ ## つぎ v1.2.0
30
+
31
+ - [ ] 設定のStruct化?(default切り出し)
32
+ - [ ] pdfをsaveせずバイナリを直接返却するメソッドの追加
33
+ - [ ] 肥大化したconvert.rbの分割( `Gkhtmltopdf::PDF` とかつくるか)
34
+
35
+ ## 検討中
21
36
 
22
- - [ ] UA設定機能
23
37
  - [ ] ポート範囲設定?
24
- - [ ] configファイルからオプションを設定?
25
38
  - [ ] YARD追加
39
+ - [ ] FireFox timeout
40
+ - [ ] configファイルからオプションを設定?
@@ -1,3 +1,4 @@
1
+ # syntax=docker/dockerfile:1.7
1
2
  FROM ruby:3.2-slim
2
3
 
3
4
  RUN apt-get update
@@ -0,0 +1,29 @@
1
+ # syntax=docker/dockerfile:1
2
+ FROM ubuntu:noble
3
+
4
+ RUN apt-get update
5
+ RUN apt-get install -y ruby3.2 bundler
6
+ RUN apt-get install -y git wget xz-utils build-essential libyaml-dev
7
+
8
+ # Install Noto Fonts
9
+ RUN apt-get install -y fonts-noto
10
+
11
+ # Install Firefox
12
+ RUN wget -q https://packages.mozilla.org/apt/repo-signing-key.gpg -O- | tee /etc/apt/keyrings/packages.mozilla.org.asc > /dev/null
13
+ RUN echo "deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main" | tee -a /etc/apt/sources.list.d/mozilla.list > /dev/null
14
+ RUN tee /etc/apt/preferences.d/mozilla > /dev/null << EOF
15
+ Package: *
16
+ Pin: origin packages.mozilla.org
17
+ Pin-Priority: 1000
18
+ EOF
19
+ RUN apt-get update
20
+ RUN apt-get install -y firefox
21
+
22
+ # Install Geckodriver
23
+ RUN wget "https://github.com/mozilla/geckodriver/releases/download/v0.36.0/geckodriver-v0.36.0-linux64.tar.gz" -O geckodriver.tar.gz
24
+ RUN tar -xzf geckodriver.tar.gz -C /usr/local/bin
25
+
26
+ COPY . /app
27
+ WORKDIR /app
28
+ RUN bundle install
29
+ CMD ["bundle", "exec", "rspec"]
@@ -0,0 +1,35 @@
1
+ # syntax=docker/dockerfile:1
2
+ FROM ubuntu:resolute
3
+
4
+ RUN apt-get update
5
+ RUN apt-get install -y ruby3.3 bundler
6
+ RUN apt-get install -y git wget xz-utils build-essential libyaml-dev
7
+
8
+ # Install Noto Fonts
9
+ RUN apt-get install -y fonts-noto
10
+
11
+ # Install Firefox
12
+ RUN wget -q https://packages.mozilla.org/apt/repo-signing-key.gpg -O- | tee /etc/apt/keyrings/packages.mozilla.org.asc > /dev/null
13
+ RUN tee /etc/apt/sources.list.d/mozilla.sources > /dev/null << EOF
14
+ Types: deb
15
+ URIs: https://packages.mozilla.org/apt
16
+ Suites: mozilla
17
+ Components: main
18
+ Signed-By: /etc/apt/keyrings/packages.mozilla.org.asc
19
+ EOF
20
+ RUN tee /etc/apt/preferences.d/mozilla > /dev/null << EOF
21
+ Package: *
22
+ Pin: origin packages.mozilla.org
23
+ Pin-Priority: 1000
24
+ EOF
25
+ RUN apt-get update
26
+ RUN apt-get install -y firefox
27
+
28
+ # Install Geckodriver
29
+ RUN wget "https://github.com/mozilla/geckodriver/releases/download/v0.36.0/geckodriver-v0.36.0-linux64.tar.gz" -O geckodriver.tar.gz
30
+ RUN tar -xzf geckodriver.tar.gz -C /usr/local/bin
31
+
32
+ COPY . /app
33
+ WORKDIR /app
34
+ RUN bundle install
35
+ CMD ["bundle", "exec", "rspec"]
@@ -0,0 +1,22 @@
1
+ # for Developer
2
+
3
+ ## Test
4
+
5
+ ```bash
6
+ $ docker build -f ./dockerfiles/Dockerfile.debian13-ruby32 . -t gkhtmltopdf-d13r32
7
+ $ docker build -f ./dockerfiles/Dockerfile.ubuntu24-ruby32 . -t gkhtmltopdf-u24r32
8
+ $ docker build -f ./dockerfiles/Dockerfile.ubuntu26-ruby33 . -t gkhtmltopdf-u26r33
9
+ $ docker run --rm gkhtmltopdf-d13r32
10
+ $ docker run --rm gkhtmltopdf-u24r32
11
+ $ docker run --rm gkhtmltopdf-u26r33
12
+ $ docker rmi gkhtmltopdf-d13r32
13
+ $ docker rmi gkhtmltopdf-u24r32
14
+ $ docker rmi gkhtmltopdf-u26r33
15
+ ```
16
+
17
+ ## Build
18
+
19
+ ```bash
20
+ $ gem build gkhtmltopdf.gemspec
21
+ $ gem push
22
+ ```
data/exe/gkhtmltopdf CHANGED
@@ -6,42 +6,56 @@ require 'gkhtmltopdf'
6
6
 
7
7
  options = {
8
8
  print_options: {},
9
- firefox_prefs: {}
9
+ firefox_prefs: {},
10
+ gecko_stdout: File::NULL,
11
+ gecko_stderr: File::NULL
10
12
  }
11
13
 
12
14
  parser = OptionParser.new do |opts|
13
15
  opts.banner = "Usage: gkhtmltopdf [options] <URL_OR_FILE> <OUTPUT_PDF>"
14
16
 
15
- opts.on("-O", "--orientation [PORTRAIT|LANDSCAPE]", "default: portrait") do |v|
17
+ opts.on("-O", "--orientation ORIENTATION", ["portrait", "landscape"], "ORIENTATION portrait or landscape (default: portrait)") do |v|
16
18
  options[:print_options][:orientation] = v.downcase
17
19
  end
18
20
 
21
+ opts.on("--user-agent USERAGENT", String, "Browser custom USERAGENT") do |v|
22
+ options[:user_agent] = v
23
+ end
24
+
19
25
  opts.on("--background", "Print background") do
20
26
  options[:print_options][:background] = true
21
27
  end
22
28
 
23
- opts.on("--margin-top [CM]", Float, "margin top (cm)") do |v|
29
+ opts.on("--margin-top CM", Float, "margin top CM") do |v|
24
30
  options[:print_options][:margin] ||= {}
25
31
  options[:print_options][:margin][:top] = v
26
32
  end
27
33
 
28
- opts.on("--margin-bottom [CM]", Float, "margin bottom (cm)") do |v|
34
+ opts.on("--margin-bottom CM", Float, "margin bottom CM") do |v|
29
35
  options[:print_options][:margin] ||= {}
30
36
  options[:print_options][:margin][:bottom] = v
31
37
  end
32
38
 
33
- opts.on("--firefox-path [PATH]", "Firefox custom PATH") do |v|
39
+ opts.on("--firefox-path PATH", String, "Firefox custom PATH") do |v|
34
40
  options[:firefox_path] = v
35
41
  end
36
42
 
37
- opts.on("--geckodriver-path [PATH]", "Geckodriver custom PATH") do |v|
43
+ opts.on("--geckodriver-path PATH", String, "Geckodriver custom PATH") do |v|
38
44
  options[:geckodriver_path] = v
39
45
  end
40
46
 
41
- opts.on("--launch-max-wait-time [NUM]", Integer, "Launch max wait time (approx: NUM * 0.1sec)") do |v|
47
+ opts.on("--launch-max-wait-time NUM", Integer, "Launch max wait time (approx: NUM * 0.1sec)") do |v|
42
48
  options[:wait_time] = v
43
49
  end
44
50
 
51
+ opts.on("--stdout", "Show Geckodriver stdout") do |b|
52
+ options[:gecko_stdout] = b ? (STDOUT) : File::NULL
53
+ end
54
+
55
+ opts.on("--stderr", "Show Geckodriver stderr") do |b|
56
+ options[:gecko_stdout] = b ? (STDERR) : File::NULL
57
+ end
58
+
45
59
  opts.on("-v", "--version", "display version") do
46
60
  puts "Gkhtmltopdf version #{Gkhtmltopdf::VERSION}"
47
61
  exit
@@ -74,6 +88,9 @@ begin
74
88
  init_options[:firefox_path] = options.delete(:firefox_path) if options[:firefox_path]
75
89
  init_options[:geckodriver_path] = options.delete(:geckodriver_path) if options[:geckodriver_path]
76
90
  init_options[:wait_time] = options.delete(:wait_time) if options[:wait_time]
91
+ init_options[:user_agent] = options.delete(:user_agent) if options[:user_agent]
92
+ init_options[:gecko_stdout] = options.delete(:gecko_stdout) if options[:gecko_stdout]
93
+ init_options[:gecko_stdout] = options.delete(:gecko_stdout) if options[:gecko_stdout]
77
94
 
78
95
  Gkhtmltopdf.convert(input_url, output_path, print_options: options[:print_options], **init_options)
79
96
 
data/lib/errors.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gkhtmltopdf
2
4
  class Error < StandardError; end
3
5
 
@@ -1,24 +1,34 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'net/http'
2
4
  require 'json'
3
5
  require 'base64'
4
6
  require 'uri'
5
7
  require 'socket'
8
+ require 'tmpdir'
9
+ require 'fileutils'
6
10
 
7
11
  module Gkhtmltopdf
8
12
  class Converter
9
- def open(geckodriver_path: nil, firefox_path: nil, wait_time: nil, port: nil)
13
+ DEFAULT_FX_USER_AGENT = "gkhtmltopdf-rb(v#{VERSION}) by firefox and gecko".freeze
14
+
15
+ def open(geckodriver_path: nil, firefox_path: nil, wait_time: nil, port: nil, user_agent: nil, gecko_stdout: nil, gecko_stderr: nil)
10
16
  @geckodriver_path = resolve_geckodriver_path!(geckodriver_path)
11
17
  @firefox_path = resolve_firefox_path!(firefox_path)
12
18
  @port = port || get_free_port
13
19
  @base_url = "http://127.0.0.1:#{@port}"
14
- @pid = spawn("#{@geckodriver_path} --port #{@port}", out: File::NULL, err: File::NULL)
20
+ gecko_stdout = File::NULL if gecko_stdout.nil?
21
+ gecko_stderr = File::NULL if gecko_stderr.nil?
22
+ @pid = spawn("#{@geckodriver_path} --port #{@port}", out: gecko_stdout, err: gecko_stderr)
15
23
  wait_time ||= 20
24
+ @profile_path = gen_tmp_profile(user_agent)
16
25
  wait_for_gk(wait_time)
17
26
  create_session!
18
27
  end
19
28
 
20
29
  def close
21
30
  delete_session! if @session_id
31
+ delete_tmp_profile! if @profile_path
22
32
  begin
23
33
  unless @pid.nil?
24
34
  Process.kill('TERM', @pid)
@@ -101,12 +111,24 @@ module Gkhtmltopdf
101
111
  raise BrowserError, "Failed to launch geckodriver (port #{@port})"
102
112
  end
103
113
 
114
+ def gen_tmp_profile(ua = nil)
115
+ tmp_profile_path = Dir.mktmpdir
116
+ ua ||= DEFAULT_FX_USER_AGENT
117
+ escaped_user_agent = JSON.generate(ua)
118
+ profile = []
119
+ profile << '# set gkhtmltopdf default profile'
120
+ profile << "user_pref(\"general.useragent.override\", #{escaped_user_agent});\n"
121
+ File.open(File.join(tmp_profile_path, 'user.js'), 'w') do |f|
122
+ profile.each { |line| f.puts(line) }
123
+ end
124
+ tmp_profile_path
125
+ end
126
+
104
127
  def post(path, payload)
105
128
  uri = URI("#{@base_url}#{path}")
106
129
  req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
107
130
  req.body = payload.to_json
108
131
  res = Net::HTTP.start(uri.hostname, uri.port) { |http| http.request(req) }
109
-
110
132
  begin
111
133
  JSON.parse(res.body)
112
134
  rescue JSON::ParserError
@@ -115,7 +137,7 @@ module Gkhtmltopdf
115
137
  end
116
138
 
117
139
  def create_session!
118
- firefox_options = { args: ["-headless"] }
140
+ firefox_options = { args: ["-headless", '--profile', @profile_path] }
119
141
  firefox_options[:binary] = @firefox_path if @firefox_path != 'firefox'
120
142
 
121
143
  payload = {
@@ -163,6 +185,10 @@ module Gkhtmltopdf
163
185
  @session_id = nil
164
186
  end
165
187
 
188
+ def delete_tmp_profile!
189
+ FileUtils.remove_entry_secure(@profile_path)
190
+ end
191
+
166
192
  def validate_url_scheme!(url_string)
167
193
  parsed_url = URI.parse(url_string)
168
194
  allowed_schemes = ['http', 'https', 'file']
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gkhtmltopdf
2
4
  class DSL
3
5
  def initialize
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gkhtmltopdf
4
- VERSION = "1.0.0"
4
+ VERSION = '1.1.1'
5
5
  end
data/lib/gkhtmltopdf.rb CHANGED
@@ -6,17 +6,17 @@ require_relative 'gkhtmltopdf/dsl'
6
6
  require_relative 'errors'
7
7
 
8
8
  module Gkhtmltopdf
9
- def self.convert(url, output_path, geckodriver_path: nil, firefox_path: nil, wait_time: nil, port: nil, print_options: {})
9
+ def self.convert(url, output_path, geckodriver_path: nil, firefox_path: nil, wait_time: nil, port: nil, user_agent: nil, gecko_stdout: nil, gecko_stderr: nil, print_options: {})
10
10
  converter = DSL.new
11
- converter.open(geckodriver_path: geckodriver_path, firefox_path: firefox_path, wait_time: wait_time, port: port)
11
+ converter.open(geckodriver_path: geckodriver_path, firefox_path: firefox_path, wait_time: wait_time, port: port, user_agent: user_agent, gecko_stdout: gecko_stdout, gecko_stderr: gecko_stderr)
12
12
  converter.save_pdf(url, output_path, print_options: print_options)
13
13
  ensure
14
14
  converter.close
15
15
  end
16
16
 
17
- def self.open(geckodriver_path: nil, firefox_path: nil, wait_time: nil, port: nil, &block)
17
+ def self.open(geckodriver_path: nil, firefox_path: nil, wait_time: nil, port: nil, user_agent: nil, gecko_stdout: nil, gecko_stderr: nil, &block)
18
18
  converter = DSL.new
19
- converter.open(geckodriver_path: geckodriver_path, firefox_path: firefox_path, wait_time: wait_time, port: port)
19
+ converter.open(geckodriver_path: geckodriver_path, firefox_path: firefox_path, wait_time: wait_time, port: port, user_agent: user_agent, gecko_stdout: gecko_stdout, gecko_stderr: gecko_stderr)
20
20
  yield converter
21
21
  ensure
22
22
  converter.close
@@ -17,12 +17,16 @@ RSpec.describe Gkhtmltopdf::Converter do
17
17
  end
18
18
  describe '#save_pdf' do
19
19
  before { converter.open }
20
- subject { converter.save_pdf(url, output_path) }
21
20
  let(:url) { "file://#{file_fixture('test.html')}" }
22
- let(:output_path) { File.join(Dir.mktmpdir, 'output.pdf') }
21
+ let(:output_path) { Dir.mktmpdir }
22
+ let(:output) { File.join(output_path, 'output.pdf') }
23
+ after { FileUtils.remove_entry_secure(output_path) }
24
+
25
+ subject { converter.save_pdf(url, output) }
26
+
23
27
  it {
24
- expect { subject }.to change { Dir.glob(output_path).count }.from(0).to(1)
25
- expect(File.binread(output_path)).to include('/FontName')
28
+ expect { subject }.to change { Dir.glob(output).count }.from(0).to(1)
29
+ expect(File.binread(output)).to include('/FontName')
26
30
  }
27
31
  end
28
32
  describe '#resolve_geckodriver_path!' do
@@ -3,7 +3,9 @@ require 'spec_helper'
3
3
  RSpec.describe Gkhtmltopdf do
4
4
  describe '.convert' do
5
5
  let(:url) { 'https://f6a.net/oss/' }
6
- let(:output) { File.join(Dir.mktmpdir, 'output.pdf') }
6
+ let(:output_path) { Dir.mktmpdir }
7
+ let(:output) { File.join(output_path, 'output.pdf') }
8
+ after { FileUtils.remove_entry_secure(output_path) }
7
9
 
8
10
  subject { Gkhtmltopdf.convert(url, output) }
9
11
 
@@ -21,6 +23,7 @@ RSpec.describe Gkhtmltopdf do
21
23
  describe '.open' do
22
24
  let(:url) { 'https://f6a.net/oss/' }
23
25
  let(:output_path) { Dir.mktmpdir }
26
+ after { FileUtils.remove_entry_secure(output_path) }
24
27
 
25
28
  subject do
26
29
  Gkhtmltopdf.open do |gk|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gkhtmltopdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuki Sakane
@@ -78,11 +78,14 @@ files:
78
78
  - ".rspec"
79
79
  - ".ruby-version"
80
80
  - CHANGELOG.md
81
- - Dockerfile
82
81
  - LICENSE
83
82
  - README.md
84
83
  - Rakefile
85
84
  - TODO.md
85
+ - dockerfiles/Dockerfile.debian13-ruby32
86
+ - dockerfiles/Dockerfile.ubuntu24-ruby32
87
+ - dockerfiles/Dockerfile.ubuntu26-ruby33
88
+ - docs/ForDeveloper.md
86
89
  - exe/gkhtmltopdf
87
90
  - lib/errors.rb
88
91
  - lib/gkhtmltopdf.rb