mailparser 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: acf77838874db7d6c17b1e85420b5027eaea07c5
4
- data.tar.gz: b67ae4ea3374d66de3cb11f40a5fe25074e682d6
3
+ metadata.gz: 396b7e55f0c34b0ad0716023d3393cff1f05acd8
4
+ data.tar.gz: 9877bd098b6ac1988726c3ed9a67273bb945aa15
5
5
  SHA512:
6
- metadata.gz: 790f81bfd597d4b209efb81a29ffa6356484ab5b8570140b16dac2b0e33982269df2a0fa11f16362c06e198c759eef8b087d17a3a50e2967ef4daea6710d9a97
7
- data.tar.gz: 2f2502e6975c84472da8675c4c42d65056e1ec4f3845a2ebe8a5477a3162f4ecaa0f43c37b729da9c189ca5dd12609704bac7c2dba002d095cabe2266ca931ff
6
+ metadata.gz: a42ba94877924f0d4587514dea66929beafc101cc7727b30b4df48f9b308633efdeb3dd5f6d5af8023451f11f985c90588d0b99f498b5e090dba543336033478
7
+ data.tar.gz: 4d5d248a63bd18f40971b9e47d72e0afb234e8bf6cb9aa20f036f0cc2962964a782151263c35369606f293df177a792ae66a59d500685eb9b6aac370fd1bb296
@@ -68,7 +68,7 @@ module MailParser
68
68
  t = Time.now
69
69
  end
70
70
  year = t.year > 9999 ? 9999 : t.year
71
- return RFC2822::DateTime.new(year, t.month, t.day, t.hour, t.min, t.sec, t.zone)
71
+ return RFC2822::DateTime.new(year, t.month, t.day, t.hour, t.min, t.sec, t.utc_offset)
72
72
  end
73
73
 
74
74
  # parse From, To,Cc field
@@ -30,16 +30,13 @@ module MailParser::RFC2822
30
30
  "return-path" => :RETURN_PATH,
31
31
  "received" => :RECEIVED,
32
32
  }
33
-
33
+
34
34
  ZONE = {
35
35
  "UT" => "+0000",
36
36
  "GMT" => "+0000",
37
37
  "EDT" => "-0400",
38
38
  "EST" => "-0500",
39
39
  "CDT" => "-0500",
40
- "EDT" => "-0400",
41
- "EST" => "-0500",
42
- "CDT" => "-0500",
43
40
  "CST" => "-0600",
44
41
  "MDT" => "-0600",
45
42
  "MST" => "-0700",
@@ -156,10 +153,10 @@ module MailParser::RFC2822
156
153
  class DateTime
157
154
  def self.now
158
155
  t = Time.now
159
- self.new(t.year, t.month, t.day, t.hour, t.min, t.sec, t.zone)
156
+ self.new(t.year, t.month, t.day, t.hour, t.min, t.sec, t.utc_offset)
160
157
  end
161
158
 
162
- def initialize(year, month, day, hour, min, sec, zone)
159
+ def initialize(year, month, day, hour, min, sec, zone_or_offset)
163
160
  y, m, d, h, mi, s = year.to_i, month.to_i, day.to_i, hour.to_i, min.to_i, sec.to_i
164
161
  raise ArgumentError, "invalid year" if y < 0 or 9999 < y
165
162
  raise ArgumentError, "invalid month" if m < 1 or 12 < m
@@ -178,13 +175,21 @@ module MailParser::RFC2822
178
175
  raise ArgumentError, "invalid hour" if h > 23
179
176
  raise ArgumentError, "invalid minute" if mi > 59
180
177
  raise ArgumentError, "invalid second" if s > 60
178
+ @year, @month, @day, @hour, @min, @sec = y, m, d, h, mi, s
179
+ if zone_or_offset.is_a? Integer
180
+ offset = zone_or_offset
181
+ @zone_sec = offset
182
+ @zone = format("%03d%02d", offset/3600, offset%3600).sub(/^0/, '+')
183
+ return
184
+ end
185
+ zone = zone_or_offset
181
186
  if zone =~ /^[+-]\d\d(\d\d)$/ then
182
187
  raise ArgumentError, "invalid zone" if $1.to_i > 59
183
188
  else
184
- zone = ZONE[zone.upcase] || "-0000"
189
+ zone = (zone && ZONE[zone.upcase]) || "-0000"
185
190
  end
186
- @year, @month, @day, @hour, @min, @sec, @zone = y, m, d, h, mi, s, zone
187
191
  z = zone[1,4].to_i
192
+ @zone = zone
188
193
  @zone_sec = z/100*3600 + z%100*60
189
194
  @zone_sec = -@zone_sec if zone[0] == ?-
190
195
  end
data/test/test_loose.rb CHANGED
@@ -22,10 +22,18 @@ class TC_Loose < Test::Unit::TestCase
22
22
  assert_equal(2007, d.year)
23
23
  assert_equal(1, d.month)
24
24
  assert_equal(10, d.day)
25
- assert_equal(3, d.hour)
25
+ if RUBY_VERSION >= '2.2'
26
+ assert_equal(12, d.hour)
27
+ else
28
+ assert_equal(3, d.hour)
29
+ end
26
30
  assert_equal(53, d.min)
27
31
  assert_equal(55, d.sec)
28
- assert_equal("+0000", d.zone)
32
+ if RUBY_VERSION >= '2.2'
33
+ assert_equal("+0900", d.zone)
34
+ else
35
+ assert_equal("+0000", d.zone)
36
+ end
29
37
  ensure
30
38
  ENV["TZ"] = tzbak
31
39
  end
@@ -39,10 +47,18 @@ class TC_Loose < Test::Unit::TestCase
39
47
  assert_equal(9999, d.year)
40
48
  assert_equal(1, d.month)
41
49
  assert_equal(10, d.day)
42
- assert_equal(3, d.hour)
50
+ if RUBY_VERSION >= '2.2'
51
+ assert_equal(12, d.hour)
52
+ else
53
+ assert_equal(3, d.hour)
54
+ end
43
55
  assert_equal(53, d.min)
44
56
  assert_equal(55, d.sec)
45
- assert_equal("+0000", d.zone)
57
+ if RUBY_VERSION >= '2.2'
58
+ assert_equal("+0900", d.zone)
59
+ else
60
+ assert_equal("+0000", d.zone)
61
+ end
46
62
  ensure
47
63
  ENV["TZ"] = tzbak
48
64
  end
@@ -86,10 +102,18 @@ class TC_Loose < Test::Unit::TestCase
86
102
  assert_equal(2007, r.date_time.year)
87
103
  assert_equal(1, r.date_time.month)
88
104
  assert_equal(10, r.date_time.day)
89
- assert_equal(3, r.date_time.hour)
105
+ if RUBY_VERSION >= '2.2'
106
+ assert_equal(12, r.date_time.hour)
107
+ else
108
+ assert_equal(3, r.date_time.hour)
109
+ end
90
110
  assert_equal(9, r.date_time.min)
91
111
  assert_equal(55, r.date_time.sec)
92
- assert_equal("+0000", r.date_time.zone)
112
+ if RUBY_VERSION >= '2.2'
113
+ assert_equal("+0900", r.date_time.zone)
114
+ else
115
+ assert_equal("+0000", r.date_time.zone)
116
+ end
93
117
  assert_equal("host.example.com", r.name_val["from"])
94
118
  assert_equal("my.server", r.name_val["by"])
95
119
  assert_equal("<user@domain.name>", r.name_val["for"])
@@ -185,10 +209,18 @@ class TC_Loose < Test::Unit::TestCase
185
209
  assert_equal(2007, r.date_time.year)
186
210
  assert_equal(1, r.date_time.month)
187
211
  assert_equal(10, r.date_time.day)
188
- assert_equal(3, r.date_time.hour)
212
+ if RUBY_VERSION >= '2.2'
213
+ assert_equal("+0900", r.date_time.zone)
214
+ else
215
+ assert_equal("+0000", r.date_time.zone)
216
+ end
189
217
  assert_equal(9, r.date_time.min)
190
218
  assert_equal(55, r.date_time.sec)
191
- assert_equal("+0000", r.date_time.zone)
219
+ if RUBY_VERSION >= '2.2'
220
+ assert_equal("+0900", r.date_time.zone)
221
+ else
222
+ assert_equal("+0000", r.date_time.zone)
223
+ end
192
224
  assert_equal("ほげ".force_encoding("utf-8"), r.name_val["from"])
193
225
  assert_equal("ふが".force_encoding("utf-8"), r.name_val["by"])
194
226
  assert_equal("ぴよ".force_encoding("utf-8"), r.name_val["for"])
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailparser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - TOMITA Masahiro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-18 00:00:00.000000000 Z
11
+ date: 2015-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mmapscanner
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '0.3'
20
20
  type: :runtime
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: '0'
26
+ version: '0.3'
27
27
  description: MailParser is a parser for mail message
28
28
  email: tommy@tmtm.org
29
29
  executables: []
@@ -32,28 +32,28 @@ extra_rdoc_files: []
32
32
  files:
33
33
  - README.md
34
34
  - lib/mailparser.rb
35
- - lib/mailparser/rfc2183/scanner.rb
36
- - lib/mailparser/rfc2183/parser.rb
35
+ - lib/mailparser/conv_charset.rb
37
36
  - lib/mailparser/error.rb
38
- - lib/mailparser/rfc2045/scanner.rb
37
+ - lib/mailparser/loose.rb
38
+ - lib/mailparser/rfc2045.rb
39
39
  - lib/mailparser/rfc2045/parser.rb
40
+ - lib/mailparser/rfc2045/scanner.rb
40
41
  - lib/mailparser/rfc2047.rb
41
- - lib/mailparser/conv_charset.rb
42
- - lib/mailparser/loose.rb
43
42
  - lib/mailparser/rfc2183.rb
44
- - lib/mailparser/rfc2045.rb
43
+ - lib/mailparser/rfc2183/parser.rb
44
+ - lib/mailparser/rfc2183/scanner.rb
45
+ - lib/mailparser/rfc2231.rb
45
46
  - lib/mailparser/rfc2822.rb
46
- - lib/mailparser/rfc2822/scanner.rb
47
47
  - lib/mailparser/rfc2822/parser.rb
48
- - lib/mailparser/rfc2231.rb
48
+ - lib/mailparser/rfc2822/scanner.rb
49
49
  - test.rb
50
50
  - test/test_loose.rb
51
- - test/test_rfc2231.rb
52
- - test/test_rfc2183.rb
53
- - test/test_rfc2047.rb
54
- - test/test_rfc2822.rb
55
51
  - test/test_mailparser.rb
56
52
  - test/test_rfc2045.rb
53
+ - test/test_rfc2047.rb
54
+ - test/test_rfc2183.rb
55
+ - test/test_rfc2231.rb
56
+ - test/test_rfc2822.rb
57
57
  homepage: http://github.com/tmtm/mailparser
58
58
  licenses:
59
59
  - Ruby's
@@ -64,17 +64,17 @@ require_paths:
64
64
  - lib
65
65
  required_ruby_version: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - '>='
67
+ - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - '>='
72
+ - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  requirements: []
76
76
  rubyforge_project:
77
- rubygems_version: 2.0.0
77
+ rubygems_version: 2.4.5
78
78
  signing_key:
79
79
  specification_version: 4
80
80
  summary: Mail Parser
@@ -87,3 +87,4 @@ test_files:
87
87
  - test/test_rfc2822.rb
88
88
  - test/test_mailparser.rb
89
89
  - test/test_rfc2045.rb
90
+ has_rdoc: