eml2html 0.0.2 → 0.0.4

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: 04bd88a978a506474d0edbcd15a40d9478496aae
4
- data.tar.gz: 21eb52a38f946c0f219b257f06ad1c36e881d142
2
+ SHA256:
3
+ metadata.gz: 88a345ca10d46808f2c617c63478fee61db47bb006a13cfe3f19e67cf3417161
4
+ data.tar.gz: d0433e3934602332c321d6d30a4b325e68c66594b793fb8112ce85212bdb3a38
5
5
  SHA512:
6
- metadata.gz: 2138f2f9723da3307c5f3789e5eb8fb1d16eda39e5d3ae1e70dfefa9333c39b6f2abbad252968db390fa47f919654e02cc99a4e80c12085f7251c71f8b58a2c0
7
- data.tar.gz: 94fe427703da8455f9bfd485488e482025d7021744465db6aa8bbef572146853fac9de3d74385bceaf43e212eb70209ea5135fde1071056007ca8c36026010e1
6
+ metadata.gz: 14aa1f3fb30cf23f05a0a38dd28f9c1d169cbc8818360fda9797c6338661d58a18abcc75cde5ff49202f4ee36157625a318a55b849f8c5051bf95da984c390ff
7
+ data.tar.gz: e0f8c46c26cd16607f5033944dc9d4a823d420211ee5a757609412f754ece05f5ad70931d02d9e40c95e1e7dc33bffdea168241c7dc4f534a1522ad0972a82c1
data/CHANGELOG.md ADDED
@@ -0,0 +1,35 @@
1
+ # Changelog
2
+
3
+ ## [Unreleased]
4
+
5
+ ## [0.0.0] - 2019-09-05
6
+
7
+ ### Added
8
+
9
+ - Public methods to access attachments, attachem by filename and html body (#2)
10
+ - Changelog
11
+
12
+ ### Changed
13
+
14
+ - Minimal required ruby version is 2.3 (#2)
15
+ - Required bundler is ~> 1.17
16
+
17
+ ### Fixed
18
+
19
+ - `undefined method 'name' for nil` (#2)
20
+
21
+ ## [0.0.2] - 2015-03-29
22
+
23
+ ### Added
24
+
25
+ - Basic specs
26
+
27
+ ### Removed
28
+
29
+ - `puts` statements
30
+
31
+ ## [0.0.1] - 2014-11-25
32
+
33
+ ### Added
34
+
35
+ - Inital version
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
1
  eml2html
2
2
  ========
3
3
 
4
+ [![Gem Version](https://badge.fury.io/rb/eml2html.svg)](http://badge.fury.io/rb/eml2html)
5
+
4
6
  Extract html, text and attachments from *.eml files.
data/eml2html.gemspec CHANGED
@@ -17,7 +17,8 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = ['eml2html']
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_development_dependency "bundler", "~> 1.3"
20
+ spec.required_ruby_version = '>= 2.3.0'
21
+ spec.add_development_dependency "bundler", "~> 1.17"
21
22
  spec.add_development_dependency "rake"
22
23
  spec.add_development_dependency "rspec"
23
24
  spec.add_development_dependency "guard"
@@ -13,6 +13,7 @@ module Eml2Html
13
13
  def initialize(message)
14
14
  @message = Mail.read(message)
15
15
  @basename = File.basename(message, '.eml')
16
+ @cids_in_body = []
16
17
  read_attachments
17
18
  end
18
19
 
@@ -55,6 +56,33 @@ module Eml2Html
55
56
  end
56
57
  end
57
58
 
59
+ def attachments(include_in_doc=false)
60
+ rtn_attachments = []
61
+ if include_in_doc
62
+ rtn_attachments = @attachments
63
+ else
64
+ @attachments.each do |a|
65
+ unless @cids_in_body.includes(a.cid)
66
+ rtn_attachments.push(a)
67
+ end
68
+ end
69
+ end
70
+ rtn_attachments
71
+ end
72
+
73
+ def attachment(file_name)
74
+ each_attachment do |name, content|
75
+ if name == file_name
76
+ return content
77
+ end
78
+ end
79
+ nil
80
+ end
81
+
82
+ def html_body
83
+ replace_images_src(@message.html_part.body.to_s)
84
+ end
85
+
58
86
  private
59
87
 
60
88
  def filename(ext = nil)
@@ -65,10 +93,6 @@ module Eml2Html
65
93
  @message.text_part.body.to_s
66
94
  end
67
95
 
68
- def html_body
69
- replace_images_src(@message.html_part.body.to_s)
70
- end
71
-
72
96
  def each_attachment
73
97
  @attachments.each do |a|
74
98
  yield a.name, a.content
@@ -94,7 +118,8 @@ module Eml2Html
94
118
  def replace_images_src(html)
95
119
  html.gsub(/(?<=src=['"])cid:[^'"]+(?=['"])/) do |match|
96
120
  cid = match.sub(/^cid:/, '')
97
- @attachments.find{|a| a.cid == cid}.name
121
+ @cids_in_body.push(cid)
122
+ @attachments.find{|a| a.cid == cid }&.name
98
123
  end
99
124
  end
100
125
  end
@@ -1,3 +1,3 @@
1
1
  module Eml2Html
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eml2html
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bartłomiej Bułat
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-29 00:00:00.000000000 Z
11
+ date: 2019-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
19
+ version: '1.17'
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
- version: '1.3'
26
+ version: '1.17'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -118,6 +118,7 @@ extra_rdoc_files: []
118
118
  files:
119
119
  - ".gitignore"
120
120
  - ".rspec"
121
+ - CHANGELOG.md
121
122
  - Gemfile
122
123
  - Guardfile
123
124
  - LICENSE
@@ -146,7 +147,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
147
  requirements:
147
148
  - - ">="
148
149
  - !ruby/object:Gem::Version
149
- version: '0'
150
+ version: 2.3.0
150
151
  required_rubygems_version: !ruby/object:Gem::Requirement
151
152
  requirements:
152
153
  - - ">="
@@ -154,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
155
  version: '0'
155
156
  requirements: []
156
157
  rubyforge_project:
157
- rubygems_version: 2.4.5
158
+ rubygems_version: 2.7.9
158
159
  signing_key:
159
160
  specification_version: 4
160
161
  summary: eml2html executable for unpacking .eml files into html and attachments