tinnef 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +3 -3
- data/README.md +9 -8
- data/Rakefile +1 -1
- data/lib/tinnef.rb +11 -11
- data/lib/tinnef/version.rb +1 -1
- data/test/test_helper.rb +1 -2
- data/test/tinnef_test.rb +5 -5
- data/tinnef.gemspec +1 -2
- metadata +35 -72
- data/.document +0 -5
- data/lib/tinnef/dir_patch.rb +0 -48
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 05dda225e532442a7eb032e915a8ccd5dff80a23
|
4
|
+
data.tar.gz: a4298b76c207d537ac538064b2541eac097aa95b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5da68efc24cfa6a6017b83c1e3272f30d0de1fa1601db6db8990e8fda15a1dea3428b33a4c20f3ae2984e3e3188bb29b09f8ce63b569aa31ccad7716c901fa7b
|
7
|
+
data.tar.gz: 486d4bcf8a3bbb755746f2f0239f5828930900b00b925c03d0936ec41d35a74fbd49b2361e334b5d90696740952b963d8f03c93bf1702116523c8e7c17527b26
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# tinnef
|
2
2
|
|
3
|
-
[![Build Status](https://
|
3
|
+
[![Build Status](https://travis-ci.org/ledermann/tinnef.png?branch=master)](https://travis-ci.org/ledermann/tinnef)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/ledermann/tinnef.png)](https://codeclimate.com/github/ledermann/tinnef)
|
4
5
|
|
5
6
|
This gem handles e-mail attachments packaged in the Microsoft "application/ms-tnef" MIME type. It's a Ruby wrapper for the [tnef converter](http://tnef.sourceforge.net).
|
6
7
|
|
@@ -11,14 +12,14 @@ From [Wikipedia](http://en.wikipedia.org/wiki/Transport_Neutral_Encapsulation_Fo
|
|
11
12
|
|
12
13
|
### Ruby
|
13
14
|
|
14
|
-
Tested with Ruby 1.8.
|
15
|
+
Tested with Ruby 1.8.7, 1.9.3 and 2.0.0
|
15
16
|
|
16
17
|
### tnef
|
17
18
|
|
18
19
|
The binary of tnef is required in a current version, 1.4.6 is ok. Check if this tool already exists on your machine:
|
19
20
|
|
20
21
|
tnef --version
|
21
|
-
|
22
|
+
|
22
23
|
It doesn't exist? You can install it:
|
23
24
|
|
24
25
|
#### Mac OS X
|
@@ -30,13 +31,13 @@ Using Homebrew, just do:
|
|
30
31
|
Using MacPorts, just do:
|
31
32
|
|
32
33
|
sudo ports install tnef
|
33
|
-
|
34
|
+
|
34
35
|
#### Linux
|
35
36
|
|
36
37
|
There are chances that this will work:
|
37
38
|
|
38
39
|
apt-get install tnef
|
39
|
-
|
40
|
+
|
40
41
|
Beware: On older Linux distribution, you will get a too old version of tnef, which does not work (e.g. 1.4.3 in Ubuntu Hardy), so you have to compile it by yourself. It's easy:
|
41
42
|
|
42
43
|
wget http://sourceforge.net/projects/tnef/files/tnef/v1.4.7/tnef-1.4.7.tar.gz/download
|
@@ -68,7 +69,7 @@ The gem defines the class TNEF with a class method to convert a given winmail.da
|
|
68
69
|
unpacked_content = temp_file.read
|
69
70
|
unpacked_filename = File.basename(temp_file.path)
|
70
71
|
|
71
|
-
File.open("/some/path/#{unpacked_filename}", 'w') do |new_file|
|
72
|
+
File.open("/some/path/#{unpacked_filename}", 'w') do |new_file|
|
72
73
|
new_file.write(unpacked_content)
|
73
74
|
end
|
74
75
|
end
|
@@ -79,7 +80,7 @@ The gem defines the class TNEF with a class method to convert a given winmail.da
|
|
79
80
|
"Tinnef" is a german slang word for "rubbish" or "trash". TNEF => TiNnEF => Tinnef - you know?
|
80
81
|
|
81
82
|
## Note on Patches/Pull Requests
|
82
|
-
|
83
|
+
|
83
84
|
* Fork the project.
|
84
85
|
* Make your feature addition or bug fix.
|
85
86
|
* Add tests for it. This is important so I don't break it in a
|
@@ -93,4 +94,4 @@ The gem defines the class TNEF with a class method to convert a given winmail.da
|
|
93
94
|
This code is based on the work by Peter Collingbourne, published as part of the [alaveteli](https://github.com/sebbacon/alaveteli/blob/master/lib/tnef.rb) project.
|
94
95
|
Thank you for sharing!
|
95
96
|
|
96
|
-
Copyright (c) 2010-
|
97
|
+
Copyright (c) 2010-2013 Georg Ledermann. See MIT-LICENSE for details.
|
data/Rakefile
CHANGED
data/lib/tinnef.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
require '
|
1
|
+
require 'tmpdir'
|
2
2
|
|
3
3
|
class TNEF
|
4
4
|
# = convert
|
5
5
|
#
|
6
|
-
# Extract the content of a winmail.dat file and
|
6
|
+
# Extract the content of a winmail.dat file and
|
7
7
|
# executes the given block for every single file in it
|
8
|
-
#
|
8
|
+
#
|
9
9
|
# Parameters:
|
10
10
|
# content => Content of the winmail.dat file
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# Options hash with this keys:
|
13
|
-
# :command
|
13
|
+
# :command
|
14
14
|
# Full path of the tnf binary to execute (defaults to 'tnf', so it has to be in the path)
|
15
15
|
#
|
16
16
|
# Example:
|
@@ -18,8 +18,8 @@ class TNEF
|
|
18
18
|
# TNEF.convert(content, :command => '/opt/local/bin/tnef') do |temp_file|
|
19
19
|
# unpacked_content = temp_file.read
|
20
20
|
# unpacked_filename = File.basename(temp_file.path)
|
21
|
-
#
|
22
|
-
# File.open("/some/path/#{unpacked_filename}", 'w') do |new_file|
|
21
|
+
#
|
22
|
+
# File.open("/some/path/#{unpacked_filename}", 'w') do |new_file|
|
23
23
|
# new_file.write(unpacked_content)
|
24
24
|
# end
|
25
25
|
# end
|
@@ -33,11 +33,11 @@ class TNEF
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def self.extract(content, options={})
|
38
38
|
command = options[:command] || 'tnef'
|
39
39
|
dir = options[:dir]
|
40
|
-
|
40
|
+
|
41
41
|
IO.popen("#{command} -K -C #{dir}", "wb") do |f|
|
42
42
|
f.write(content)
|
43
43
|
f.close
|
@@ -48,7 +48,7 @@ class TNEF
|
|
48
48
|
raise IOError, "tnef exited with status #{$?.exitstatus}"
|
49
49
|
end
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
Dir.new(dir).sort.delete_if { |file_name| File.directory?(file_name) }
|
53
53
|
end
|
54
|
-
end
|
54
|
+
end
|
data/lib/tinnef/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
data/test/tinnef_test.rb
CHANGED
@@ -3,11 +3,11 @@ require 'test_helper'
|
|
3
3
|
class TestDir < Test::Unit::TestCase
|
4
4
|
def test_mktmpdir_path
|
5
5
|
dir = Dir.mktmpdir
|
6
|
-
|
6
|
+
|
7
7
|
assert File.directory?(dir)
|
8
8
|
assert_equal true, File.directory?(dir)
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def test_mktmpdir_block
|
12
12
|
directory = ''
|
13
13
|
Dir.mktmpdir do |dir|
|
@@ -23,16 +23,16 @@ class TestTinnef < Test::Unit::TestCase
|
|
23
23
|
def setup
|
24
24
|
@content = File.new(File.dirname(__FILE__) + '/fixtures/quick-winmail.dat').read
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def test_file_names
|
28
28
|
files = []
|
29
29
|
TNEF.convert(@content) do |temp_file|
|
30
30
|
files << File.basename(temp_file.path)
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
assert_equal %w(quick.doc quick.html quick.pdf quick.txt quick.xml), files
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
def test_content
|
37
37
|
TNEF.convert(@content) do |temp_file|
|
38
38
|
if File.basename(temp_file.path) == 'quick.txt'
|
data/tinnef.gemspec
CHANGED
@@ -17,7 +17,6 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
|
-
|
20
|
+
|
21
21
|
s.add_development_dependency 'rake'
|
22
|
-
s.add_development_dependency 'mocha'
|
23
22
|
end
|
metadata
CHANGED
@@ -1,61 +1,36 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: tinnef
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 2
|
10
|
-
version: 0.1.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Georg Ledermann
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2013-03-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
21
14
|
name: rake
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 3
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
32
20
|
type: :development
|
33
|
-
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: mocha
|
36
21
|
prerelease: false
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
hash: 3
|
43
|
-
segments:
|
44
|
-
- 0
|
45
|
-
version: "0"
|
46
|
-
type: :development
|
47
|
-
version_requirements: *id002
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
48
27
|
description: Handling e-mail attachments with MIME type 'application/ms-tnef'
|
49
|
-
email:
|
28
|
+
email:
|
50
29
|
- mail@georg-ledermann.de
|
51
30
|
executables: []
|
52
|
-
|
53
31
|
extensions: []
|
54
|
-
|
55
32
|
extra_rdoc_files: []
|
56
|
-
|
57
|
-
files:
|
58
|
-
- .document
|
33
|
+
files:
|
59
34
|
- .gitignore
|
60
35
|
- .travis.yml
|
61
36
|
- Gemfile
|
@@ -63,47 +38,35 @@ files:
|
|
63
38
|
- README.md
|
64
39
|
- Rakefile
|
65
40
|
- lib/tinnef.rb
|
66
|
-
- lib/tinnef/dir_patch.rb
|
67
41
|
- lib/tinnef/version.rb
|
68
42
|
- test/fixtures/quick-winmail.dat
|
69
43
|
- test/test_helper.rb
|
70
44
|
- test/tinnef_test.rb
|
71
45
|
- tinnef.gemspec
|
72
|
-
homepage:
|
46
|
+
homepage: ''
|
73
47
|
licenses: []
|
74
|
-
|
48
|
+
metadata: {}
|
75
49
|
post_install_message:
|
76
50
|
rdoc_options: []
|
77
|
-
|
78
|
-
require_paths:
|
51
|
+
require_paths:
|
79
52
|
- lib
|
80
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
none: false
|
91
|
-
requirements:
|
92
|
-
- - ">="
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
hash: 3
|
95
|
-
segments:
|
96
|
-
- 0
|
97
|
-
version: "0"
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
98
63
|
requirements: []
|
99
|
-
|
100
64
|
rubyforge_project: .
|
101
|
-
rubygems_version:
|
65
|
+
rubygems_version: 2.0.2
|
102
66
|
signing_key:
|
103
|
-
specification_version:
|
67
|
+
specification_version: 4
|
104
68
|
summary: Ruby wrapper for tnef, a tool for unpacking 'winmail.dat' files
|
105
|
-
test_files:
|
69
|
+
test_files:
|
106
70
|
- test/fixtures/quick-winmail.dat
|
107
71
|
- test/test_helper.rb
|
108
72
|
- test/tinnef_test.rb
|
109
|
-
has_rdoc:
|
data/.document
DELETED
data/lib/tinnef/dir_patch.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'tmpdir'
|
2
|
-
|
3
|
-
#
|
4
|
-
# Dir.mktmpdir is missing in Ruby 1.8.6 patchlevel 111, so monkeypatch it from
|
5
|
-
# http://www.ruby-doc.org/core-1.9/classes/Dir.src/M002362.html
|
6
|
-
#
|
7
|
-
unless Dir.respond_to?(:mktmpdir)
|
8
|
-
class Dir
|
9
|
-
def self.mktmpdir(prefix_suffix=nil, tmpdir=nil)
|
10
|
-
case prefix_suffix
|
11
|
-
when nil
|
12
|
-
prefix = "d"
|
13
|
-
suffix = ""
|
14
|
-
when String
|
15
|
-
prefix = prefix_suffix
|
16
|
-
suffix = ""
|
17
|
-
when Array
|
18
|
-
prefix = prefix_suffix[0]
|
19
|
-
suffix = prefix_suffix[1]
|
20
|
-
else
|
21
|
-
raise ArgumentError, "unexpected prefix_suffix: #{prefix_suffix.inspect}"
|
22
|
-
end
|
23
|
-
tmpdir ||= Dir.tmpdir
|
24
|
-
t = Time.now.strftime("%Y%m%d")
|
25
|
-
n = nil
|
26
|
-
begin
|
27
|
-
path = "#{tmpdir}/#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
|
28
|
-
path << "-#{n}" if n
|
29
|
-
path << suffix
|
30
|
-
Dir.mkdir(path, 0700)
|
31
|
-
rescue Errno::EEXIST
|
32
|
-
n ||= 0
|
33
|
-
n += 1
|
34
|
-
retry
|
35
|
-
end
|
36
|
-
|
37
|
-
if block_given?
|
38
|
-
begin
|
39
|
-
yield path
|
40
|
-
ensure
|
41
|
-
FileUtils.remove_entry_secure path
|
42
|
-
end
|
43
|
-
else
|
44
|
-
path
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|