maildir 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c1fb9ccc7242532f5e36faf35d23d198f3bbaf60
4
+ data.tar.gz: e110f4de262ddefd243c3472b82b28a69881bb87
5
+ SHA512:
6
+ metadata.gz: 1ee591c840b4916db962d5c7cdb865311cd58f54b4bf78710fa32606cdd38867ff5a525ca1d1e53b48bc36fddf27134eacf436ff29f5d355e398cf604aa9eecb
7
+ data.tar.gz: 3ecb6b1ee524b73f321669d5fe734adc8aeac735d5c9a395471ff162a876e00ad2b288ad1d7f3728ff8c0f7d7c3244d7a65371f0d190413fd0b7b40d912b9ffc
@@ -15,6 +15,7 @@ New messages are initially written to a "tmp" directory with an automatically-ge
15
15
  While the maildir format was created for email, it works well for arbitrary data. This library can read & write email messages or arbitrary data. See Pluggable serializers for more.
16
16
 
17
17
  {<img src="https://secure.travis-ci.org/ktheory/maildir.png" />}[http://travis-ci.org/ktheory/maildir]
18
+ {<img src="https://codeclimate.com/github/ktheory/maildir.png" />}[https://codeclimate.com/github/ktheory/maildir]
18
19
 
19
20
 
20
21
  == Install
@@ -119,8 +120,11 @@ As of version 1.0.0, the Maildir::Serializer::Base can write IO streams as well
119
120
 
120
121
  message.add(STDIN)
121
122
 
122
- This will use Ruby 1.9's more efficient IO.copy_stream method if available,
123
- and degrade gracefully in Ruby 1.8.
123
+ This will use the more efficient IO.copy_stream method from Ruby 1.9+ if
124
+ available, and degrade gracefully in Ruby 1.8. (Important note: Please be aware
125
+ that Ruby 1.8.x is no longer officially supported by the maildir gem; see
126
+ [.travis.yml](https://github.com/ktheory/maildir/blob/master/.travis.yml) for a
127
+ list of currently-supported Ruby versions.)
124
128
 
125
129
  As of version 1.0.2, serializers are autoloaded. Thus it is no longer necessary to manually require them.
126
130
 
@@ -147,6 +151,10 @@ It's trivial to create a custom serializer. Implement the following two methods:
147
151
 
148
152
  * Aaron Suggs (github[http://github.com/ktheory])
149
153
 
154
+ == Maintainer
155
+
156
+ * Todd A. Jacobs (github[http://github.com/codegnome])
157
+
150
158
  == Contributors
151
159
 
152
160
  * Niklas E. Cathor (github[http://github.com/nilclass])
@@ -156,4 +164,4 @@ It's trivial to create a custom serializer. Implement the following two methods:
156
164
 
157
165
  == Copyright
158
166
 
159
- Copyright (c) 2010 Aaron Suggs. See LICENSE for details.
167
+ Copyright (c) 2010-2014 Aaron Suggs. See LICENSE for details.
data/Rakefile CHANGED
@@ -1,7 +1,9 @@
1
+ require 'bundler/setup'
1
2
  require 'rake/testtask'
3
+ require 'bundler/gem_tasks'
4
+
2
5
  Rake::TestTask.new do |t|
3
- t.libs << "test"
4
- t.test_files = FileList['test/test*.rb']
6
+ t.pattern = "test/test_*.rb"
5
7
  t.verbose = true
6
8
  end
7
9
 
@@ -134,10 +134,13 @@ class Maildir::Message
134
134
  self.flags = (flags << flag.upcase)
135
135
  end
136
136
 
137
- # Removes a flag from a message.
137
+ # Removes flags from a message.
138
138
  # Returns the message's key if successful, false otherwise.
139
- def remove_flag(flag)
140
- self.flags = flags.delete_if{|f| f == flag.upcase}
139
+ #
140
+ # flags:: String or Array
141
+ def remove_flag(flags)
142
+ return self.flags if flags.blank?
143
+ self.flags = self.flags.reject { |f| f =~ /[#{Array(flags).join}]/i }
141
144
  end
142
145
 
143
146
  # Returns the filename of the message
@@ -1,3 +1,3 @@
1
1
  class Maildir
2
- VERSION = '2.1.0'
2
+ VERSION = '2.2.0'
3
3
  end
@@ -0,0 +1,40 @@
1
+ require 'bundler/setup'
2
+ require 'minitest/autorun'
3
+ require 'minitest/pride'
4
+ require 'shoulda'
5
+ require 'maildir'
6
+
7
+ # Require all the serializers
8
+ serializers = File.expand_path('../../lib/maildir/serializer/*.rb', __FILE__)
9
+ Dir.glob(serializers).each do |serializer|
10
+ require serializer
11
+ end
12
+
13
+ class Minitest::Test
14
+ # Create a reusable maildir that's cleaned up when the tests are done
15
+ def temp_maildir
16
+ Maildir.new("/tmp/maildir_test")
17
+ end
18
+
19
+ def setup
20
+ # Wait until everything's loaded and tests are running to require FakeFS
21
+ require 'fakefs'
22
+ end
23
+
24
+ # create the subdir tree:
25
+ # | INBOX
26
+ # |-- a
27
+ # | |-- x
28
+ # | |-- y
29
+ # |-- b
30
+ def setup_subdirs(maildir)
31
+ %w(a b a.x a.y).each do |x|
32
+ Maildir.new(File.join(maildir.path, ".#{x}"))
33
+ end
34
+ end
35
+
36
+ # Test that objects are neither nil nor empty
37
+ def assert_not_empty(obj, msg='')
38
+ assert !obj.nil? && !obj.empty?, msg
39
+ end
40
+ end
@@ -1,5 +1,5 @@
1
- require 'test_helper'
2
- class TestMaildir < Test::Unit::TestCase
1
+ require_relative 'helper'
2
+ class TestMaildir < Minitest::Test
3
3
 
4
4
  context "A maildir" do
5
5
  setup do
@@ -101,6 +101,33 @@ class TestMaildir < Test::Unit::TestCase
101
101
  end
102
102
  end
103
103
 
104
+ context "multiple flags" do
105
+ should "be added in sorted order" do
106
+ sorted_flags = 'FS'
107
+ unsorted_flags = 'SF'
108
+
109
+ @message = temp_maildir.add("")
110
+ @message.process
111
+ @message.add_flag(unsorted_flags)
112
+
113
+ assert_equal sorted_flags.split(''), @message.flags
114
+ end
115
+
116
+ should "be removed from flag list" do
117
+ flags_to_add = 'FSXYZ'
118
+ flags_to_remove = 'XYZ'
119
+ flags_remaining = 'FS'
120
+
121
+ @message = temp_maildir.add("")
122
+ @message.process
123
+ @message.add_flag(flags_to_add)
124
+ assert_equal flags_to_add.split(''), @message.flags
125
+
126
+ @message.remove_flag(flags_to_remove)
127
+ assert_equal flags_remaining.split(''), @message.flags
128
+ end
129
+ end
130
+
104
131
  context "Maildirs with the same path" do
105
132
  should "be identical" do
106
133
  another_maildir = Maildir.new(temp_maildir.path, false)
@@ -1,5 +1,5 @@
1
- require 'test_helper'
2
- class TestMessage < Test::Unit::TestCase
1
+ require_relative 'helper'
2
+ class TestMessage < Minitest::Test
3
3
 
4
4
  context "A message" do
5
5
  setup do
@@ -53,7 +53,7 @@ class TestMessage < Test::Unit::TestCase
53
53
  end
54
54
 
55
55
  should "not be writable" do
56
- assert_raise RuntimeError do
56
+ assert_raises RuntimeError do
57
57
  @message.write("nope!")
58
58
  end
59
59
  end
@@ -95,7 +95,7 @@ class TestMessage < Test::Unit::TestCase
95
95
  end
96
96
 
97
97
  should "not be writable" do
98
- assert_raise RuntimeError do
98
+ assert_raises RuntimeError do
99
99
  @message.write("nope!")
100
100
  end
101
101
  end
@@ -112,7 +112,7 @@ class TestMessage < Test::Unit::TestCase
112
112
  info = "2,FRS"
113
113
  @message.info = "2,FRS"
114
114
  assert_equal @message.info, info
115
- assert_match /#{info}$/, @message.path
115
+ assert_match(/#{info}$/, @message.path)
116
116
  end
117
117
 
118
118
  should "add and remove flags" do
@@ -141,7 +141,7 @@ class TestMessage < Test::Unit::TestCase
141
141
  @message.flags = arg
142
142
  assert_equal results, @message.flags
143
143
  path_suffix = "#{Maildir::Message::INFO}#{results.join('')}"
144
- assert_match /#{path_suffix}$/, @message.path
144
+ assert_match(/#{path_suffix}$/, @message.path)
145
145
  end
146
146
  end
147
147
  end
@@ -180,14 +180,13 @@ class TestMessage < Test::Unit::TestCase
180
180
  end
181
181
 
182
182
  should "raise error for data" do
183
- assert_raise Errno::ENOENT do
183
+ assert_raises Errno::ENOENT do
184
184
  @message.data
185
185
  end
186
186
  assert @message.frozen?
187
187
  end
188
188
 
189
189
  should "not be processed" do
190
- old_key = @message.key
191
190
  assert_equal false, @message.process
192
191
  assert @message.frozen?
193
192
  end
@@ -208,9 +207,9 @@ class TestMessage < Test::Unit::TestCase
208
207
  should "differ" do
209
208
  @message1 = temp_maildir.add("")
210
209
  @message2 = temp_maildir.add("")
211
- assert_equal -1, @message1 <=> @message2
210
+ assert_equal(-1, @message1 <=> @message2)
212
211
  assert_equal 1, @message2 <=> @message1
213
- assert_not_equal @message1, @message2
212
+ refute_equal @message1, @message2
214
213
  end
215
214
  end
216
215
 
@@ -1,5 +1,5 @@
1
- require 'test_helper'
2
- class TestSerializers < Test::Unit::TestCase
1
+ require_relative 'helper'
2
+ class TestSerializers < Minitest::Test
3
3
 
4
4
 
5
5
  serializers = [
@@ -1,5 +1,5 @@
1
- require 'test_helper'
2
- class TestUniqueName < Test::Unit::TestCase
1
+ require_relative 'helper'
2
+ class TestUniqueName < Minitest::Test
3
3
 
4
4
  context "A UniqueName" do
5
5
  setup do
@@ -17,27 +17,27 @@ class TestUniqueName < Test::Unit::TestCase
17
17
  end
18
18
 
19
19
  should "begin with timestamp" do
20
- assert_match /^#{@now.to_i}/, @name
20
+ assert_match(/^#{@now.to_i}/, @name)
21
21
  end
22
22
 
23
23
  should "end with hostname" do
24
- assert_match /#{Socket.gethostname}$/, @name
24
+ assert_match(/#{Socket.gethostname}$/, @name)
25
25
  end
26
26
 
27
27
  should "be unique when created in the same microsecond" do
28
28
  @new_name = Maildir::UniqueName.new
29
29
  # Set @now be identical in both UniqueName instances
30
30
  @new_name.send(:instance_variable_set, :@now, @now)
31
- assert_not_equal @name, @new_name.to_s
31
+ refute_equal @name, @new_name.to_s
32
32
  end
33
-
33
+
34
34
  should "be chronological" do
35
35
  @name1 = Maildir::UniqueName.new
36
36
  @name1.send(:instance_variable_set, :@now, Time.at(0.000009))
37
-
37
+
38
38
  @name2 = Maildir::UniqueName.new
39
39
  @name2.send(:instance_variable_set, :@now, Time.at(0.100000))
40
-
40
+
41
41
  assert_operator @name2.to_s, :>, @name1.to_s
42
42
  end
43
43
 
metadata CHANGED
@@ -1,94 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maildir
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
5
- prerelease:
4
+ version: 2.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Aaron Suggs
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-09-11 00:00:00.000000000 Z
11
+ date: 2015-02-03 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: shoulda
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: mail
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: json
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: fakefs
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - ">="
84
74
  - !ruby/object:Gem::Version
85
75
  version: 0.3.2
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - ">="
92
81
  - !ruby/object:Gem::Version
93
82
  version: 0.3.2
94
83
  description: A ruby library for reading and writing arbitrary messages in DJB's maildir
@@ -98,6 +87,10 @@ executables: []
98
87
  extensions: []
99
88
  extra_rdoc_files: []
100
89
  files:
90
+ - LICENSE
91
+ - README.rdoc
92
+ - Rakefile
93
+ - lib/maildir.rb
101
94
  - lib/maildir/message.rb
102
95
  - lib/maildir/serializer/base.rb
103
96
  - lib/maildir/serializer/json.rb
@@ -106,43 +99,38 @@ files:
106
99
  - lib/maildir/serializer/yaml.rb
107
100
  - lib/maildir/unique_name.rb
108
101
  - lib/maildir/version.rb
109
- - lib/maildir.rb
110
- - LICENSE
111
- - README.rdoc
112
- - Rakefile
113
- - test/test_helper.rb
102
+ - test/helper.rb
114
103
  - test/test_maildir.rb
115
104
  - test/test_message.rb
116
105
  - test/test_serializers.rb
117
106
  - test/test_unique_name.rb
118
107
  homepage: http://github.com/ktheory/maildir
119
108
  licenses: []
109
+ metadata: {}
120
110
  post_install_message:
121
111
  rdoc_options:
122
- - --charset=UTF-8
112
+ - "--charset=UTF-8"
123
113
  require_paths:
124
114
  - lib
125
115
  required_ruby_version: !ruby/object:Gem::Requirement
126
- none: false
127
116
  requirements:
128
- - - ! '>='
117
+ - - ">="
129
118
  - !ruby/object:Gem::Version
130
- version: '0'
119
+ version: 2.0.0
131
120
  required_rubygems_version: !ruby/object:Gem::Requirement
132
- none: false
133
121
  requirements:
134
- - - ! '>='
122
+ - - ">="
135
123
  - !ruby/object:Gem::Version
136
124
  version: 1.3.5
137
125
  requirements: []
138
126
  rubyforge_project:
139
- rubygems_version: 1.8.23
127
+ rubygems_version: 2.4.5
140
128
  signing_key:
141
- specification_version: 3
129
+ specification_version: 4
142
130
  summary: Read & write messages in the maildir format
143
131
  test_files:
144
- - test/test_helper.rb
145
- - test/test_maildir.rb
146
- - test/test_message.rb
147
132
  - test/test_serializers.rb
148
133
  - test/test_unique_name.rb
134
+ - test/test_maildir.rb
135
+ - test/test_message.rb
136
+ - test/helper.rb
@@ -1,33 +0,0 @@
1
- require 'test/unit'
2
- require 'shoulda'
3
- require 'maildir'
4
-
5
- # Require all the serializers
6
- serializers = File.expand_path('../../lib/maildir/serializer/*.rb', __FILE__)
7
- Dir.glob(serializers).each do |serializer|
8
- require serializer
9
- end
10
-
11
- require 'fakefs'
12
-
13
- # Create a reusable maildir that's cleaned up when the tests are done
14
- def temp_maildir
15
- Maildir.new("/tmp/maildir_test")
16
- end
17
-
18
- # create the subdir tree:
19
- # | INBOX
20
- # |-- a
21
- # | |-- x
22
- # | |-- y
23
- # |-- b
24
- def setup_subdirs(maildir)
25
- %w(a b a.x a.y).each do |x|
26
- Maildir.new(File.join(maildir.path, ".#{x}"))
27
- end
28
- end
29
-
30
- # Test that objects are neither nil nor empty
31
- def assert_not_empty(obj, msg='')
32
- assert !obj.nil? && !obj.empty?, msg
33
- end