eml_to_pdf 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.ruby-version +1 -1
- data/.travis.yml +8 -6
- data/README.md +1 -0
- data/eml_to_pdf.gemspec +1 -1
- data/lib/eml_to_pdf/configuration.rb +3 -1
- data/lib/eml_to_pdf/extraction_step.rb +4 -1
- data/lib/eml_to_pdf/version.rb +1 -1
- data/lib/eml_to_pdf/wkhtmltopdf.rb +16 -7
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4ca4521f1d3dd67c4bec67daa9470390d9fb4f2ea6567e2623241699f812a9c2
|
4
|
+
data.tar.gz: beaaf4003bd695c8621e6a81e4afa66c0bb829a0d0d5fa582ca18815e5e93697
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 404e1d85c233b1fb6a8b753a755210b76f8e3cfa571e0fe3ee8b205d83c0d4bf1f5879f31b30f340133ef94057aa4e67af548c10f67e2a1a7a8627c20a3f3505
|
7
|
+
data.tar.gz: 0c8a0d071dad60ce8bfaf43c5b0d33c1250902aa0e032de0f107d8cf7d7996b34c942bd7682b127b4576ecb85b34afc9eccdcd72babdf05facc1748c09cf4bd8
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.1
|
data/.travis.yml
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
language: ruby
|
2
|
+
cache: bundler
|
2
3
|
rvm:
|
3
|
-
- 2.
|
4
|
-
- 2.
|
4
|
+
- 2.6
|
5
|
+
- 2.7
|
6
|
+
|
5
7
|
before_install:
|
6
|
-
- gem install bundler
|
7
|
-
-
|
8
|
-
-
|
9
|
-
-
|
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
data/eml_to_pdf.gemspec
CHANGED
@@ -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", "
|
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)
|
data/lib/eml_to_pdf/version.rb
CHANGED
@@ -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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
+
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:
|
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
|
-
|
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.
|