mailcvt 0.0.3 → 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.
- data/lib/line_converter.rb +26 -0
- data/lib/mail_parser.rb +7 -3
- data/lib/mailcvt/version.rb +1 -1
- metadata +4 -3
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
class LineConverter
|
4
|
+
attr_reader :log
|
5
|
+
@@keys = {
|
6
|
+
'D' => {full: 'Date:', begin: 5},
|
7
|
+
'M' => {full: 'Message-ID:', begin: 11},
|
8
|
+
'S' => {full: 'Subject:', begin: 8},
|
9
|
+
'F' => {full: 'From:', begin: 5},
|
10
|
+
'T' => {full: 'To:', begin: 3}
|
11
|
+
}
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@log = ""
|
15
|
+
end
|
16
|
+
|
17
|
+
def convert(line)
|
18
|
+
cap = line[0]
|
19
|
+
return unless @@keys.has_key?(cap)
|
20
|
+
|
21
|
+
key = @@keys[cap]
|
22
|
+
puts key
|
23
|
+
@log << "#{line[key[:begin]..-1].strip}\t" if line.start_with?(key[:full])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
data/lib/mail_parser.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
|
3
|
+
require 'line_converter'
|
3
4
|
|
4
5
|
class MailParser
|
5
6
|
def initialize(input, output)
|
@@ -23,13 +24,16 @@ class MailParser
|
|
23
24
|
File.open(File.join(@output, "test_log.log"), 'w') do |out|
|
24
25
|
Dir.glob(File.join(@input, '*')) do |file|
|
25
26
|
parsefile file, out
|
26
|
-
File.delete file
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
def parsefile(file, out)
|
32
|
-
|
32
|
+
cvt = LineConverter.new
|
33
|
+
File.foreach(file) {|line| cvt.convert line}
|
34
|
+
|
35
|
+
out.puts(cvt.log)
|
33
36
|
out.flush
|
37
|
+
#File.delete file
|
34
38
|
end
|
35
39
|
end
|
data/lib/mailcvt/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailcvt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -89,6 +89,7 @@ files:
|
|
89
89
|
- lib/mailcvt.rb
|
90
90
|
- lib/big_mail_generator.rb
|
91
91
|
- lib/mail_parser.rb
|
92
|
+
- lib/line_converter.rb
|
92
93
|
- README.rdoc
|
93
94
|
- mailcvt.rdoc
|
94
95
|
homepage: http://github.com/ryu-kahou/mailcvt
|
@@ -111,7 +112,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
112
|
version: '0'
|
112
113
|
segments:
|
113
114
|
- 0
|
114
|
-
hash:
|
115
|
+
hash: -4539038824499876121
|
115
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
117
|
none: false
|
117
118
|
requirements:
|
@@ -120,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
121
|
version: '0'
|
121
122
|
segments:
|
122
123
|
- 0
|
123
|
-
hash:
|
124
|
+
hash: -4539038824499876121
|
124
125
|
requirements: []
|
125
126
|
rubyforge_project:
|
126
127
|
rubygems_version: 1.8.25
|