eml_to_pdf 0.4.1 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 3937b46f020a4ba5bbac39fdfd2c80beaf47f92b
4
- data.tar.gz: 58105137f1f5b3de7afd8e7560c141d67f230f36
2
+ SHA256:
3
+ metadata.gz: 4ca4521f1d3dd67c4bec67daa9470390d9fb4f2ea6567e2623241699f812a9c2
4
+ data.tar.gz: beaaf4003bd695c8621e6a81e4afa66c0bb829a0d0d5fa582ca18815e5e93697
5
5
  SHA512:
6
- metadata.gz: 933861a07fe0aa3e26dd57f70e3f1f1a1e36b9f58260fd6890b62d90ac2a5873d6211131195f3aa12da86bbc035a8f60809efd42cc2643a1c0dbeedb2503e2e9
7
- data.tar.gz: de3fdd4b821015d8d13dc2da849501ae0d5209d2fcfb959a15cc20a92167f88afb8eab715f399f0c04fcef4c3da731d7e861f5ddbaf3c242976f7052a57f8406
6
+ metadata.gz: 404e1d85c233b1fb6a8b753a755210b76f8e3cfa571e0fe3ee8b205d83c0d4bf1f5879f31b30f340133ef94057aa4e67af548c10f67e2a1a7a8627c20a3f3505
7
+ data.tar.gz: 0c8a0d071dad60ce8bfaf43c5b0d33c1250902aa0e032de0f107d8cf7d7996b34c942bd7682b127b4576ecb85b34afc9eccdcd72babdf05facc1748c09cf4bd8
@@ -1 +1 @@
1
- 2.4.1
1
+ 2.7.1
@@ -1,9 +1,11 @@
1
1
  language: ruby
2
+ cache: bundler
2
3
  rvm:
3
- - 2.2.2
4
- - 2.4.1
4
+ - 2.6
5
+ - 2.7
6
+
5
7
  before_install:
6
- - gem install bundler -v 1.14.6
7
- - wget http://download.gna.org/wkhtmltopdf/0.12/0.12.3/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
8
- - tar -xvf wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
9
- - export PATH=$PATH:$PWD/wkhtmltox/bin/
8
+ - gem install bundler
9
+ - sudo apt-get install xfonts-75dpi xfonts-base
10
+ - wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.xenial_amd64.deb
11
+ - sudo apt install ./wkhtmltox_0.12.5-1.xenial_amd64.deb
data/README.md CHANGED
@@ -31,6 +31,7 @@ Use the `configure` method to configure your labels
31
31
 
32
32
  ```ruby
33
33
  EmlToPdf.configure do |config|
34
+ config.timeout = 60 # Seconds, defaults to 0
34
35
  config.from_label = "From =>"
35
36
  config.to_label = "To =>"
36
37
  config.cc_label = "Cc =>"
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.required_ruby_version = ">= 2.2.0"
23
23
 
24
- spec.add_development_dependency "bundler", "~> 1.10"
24
+ spec.add_development_dependency "bundler", ">= 1.10"
25
25
  spec.add_development_dependency "rake", "~> 12.0"
26
26
  spec.add_development_dependency 'minitest', '~> 5.9'
27
27
 
@@ -1,6 +1,6 @@
1
1
  module EmlToPdf
2
2
  class Configuration
3
- attr_accessor :from_label, :to_label, :cc_label, :date_label
3
+ attr_accessor :from_label, :to_label, :cc_label, :date_label, :wkhtmltopdf, :timeout
4
4
 
5
5
  def initialize
6
6
  @from_label = "From"
@@ -8,6 +8,8 @@ module EmlToPdf
8
8
  @cc_label = "Cc"
9
9
  @date_label = "Date"
10
10
  @date_format = lambda { |date| date.strftime("%Y-%m-%d %H:%M:%S %z") }
11
+ @wkhtmltopdf = 'wkhtmltopdf'
12
+ @timeout = 0
11
13
  end
12
14
 
13
15
  def date_format(&block)
@@ -1,3 +1,6 @@
1
+ require 'eml_to_pdf/extraction_step_list'
2
+ require 'eml_to_pdf/empty_part'
3
+
1
4
  module EmlToPdf
2
5
  class ExtractionStep
3
6
  MIME_TYPES = {
@@ -48,7 +51,7 @@ module EmlToPdf
48
51
  parts.detect(&:multipart?) ||
49
52
  find_body_with_type(parts, :html) ||
50
53
  find_body_with_type(parts, :plain_text) ||
51
- EmptyPart.new
54
+ EmlToPdf::EmptyPart.new
52
55
  end
53
56
 
54
57
  def find_body_with_type(parts, type)
@@ -1,3 +1,3 @@
1
1
  module EmlToPdf
2
- VERSION = "0.4.1"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -1,15 +1,24 @@
1
+ require 'timeout'
2
+
1
3
  module EmlToPdf
2
4
  class Wkhtmltopdf
3
5
  class ConversionError < StandardError; end
6
+ class ConversionTimeoutError < StandardError
7
+ def message
8
+ "Failed to convert within the configured timeout. Use EmlToPdf.configure to increase the timeout if needed."
9
+ end
10
+ end
4
11
 
5
12
  def self.convert(input, output_path)
6
- IO.popen("wkhtmltopdf --encoding utf-8 --footer-center [page] --footer-spacing 2.5 - #{output_path} 2>&1", "r+") do |pipe|
7
- pipe.puts(input)
8
- pipe.close_write
9
- output = pipe.readlines.join
10
- pipe.close
11
- unless $?.success?
12
- raise ConversionError, output
13
+ Timeout.timeout(EmlToPdf.configuration.timeout, ConversionTimeoutError) do
14
+ IO.popen("#{EmlToPdf.configuration.wkhtmltopdf} --encoding utf-8 --footer-center [page] --footer-spacing 2.5 --quiet - #{output_path} 2>&1", "r+") do |pipe|
15
+ pipe.puts(input)
16
+ pipe.close_write
17
+ output = pipe.readlines.join
18
+ pipe.close
19
+ unless $?.success?
20
+ raise ConversionError, output
21
+ end
13
22
  end
14
23
  end
15
24
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eml_to_pdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yves Siegrist
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-18 00:00:00.000000000 Z
11
+ date: 2020-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.10'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.10'
27
27
  - !ruby/object:Gem::Dependency
@@ -154,8 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  - !ruby/object:Gem::Version
155
155
  version: '0'
156
156
  requirements: []
157
- rubyforge_project:
158
- rubygems_version: 2.6.11
157
+ rubygems_version: 3.1.2
159
158
  signing_key:
160
159
  specification_version: 4
161
160
  summary: This gem allows you to convert an eml (email) into a pdf.