nilclass-maildir 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/LICENSE +20 -0
- data/README.rdoc +113 -0
- data/Rakefile +32 -0
- data/VERSION +1 -0
- data/benchmarks/runner +30 -0
- data/lib/maildir.rb +115 -0
- data/lib/maildir/keywords.rb +111 -0
- data/lib/maildir/message.rb +241 -0
- data/lib/maildir/serializer/base.rb +20 -0
- data/lib/maildir/serializer/json.rb +13 -0
- data/lib/maildir/serializer/mail.rb +13 -0
- data/lib/maildir/serializer/marshal.rb +12 -0
- data/lib/maildir/serializer/yaml.rb +13 -0
- data/lib/maildir/subdirs.rb +70 -0
- data/lib/maildir/unique_name.rb +72 -0
- data/maildir.gemspec +81 -0
- data/test/test_helper.rb +38 -0
- data/test/test_keywords.rb +16 -0
- data/test/test_maildir.rb +73 -0
- data/test/test_message.rb +226 -0
- data/test/test_serializers.rb +37 -0
- data/test/test_subdirs.rb +46 -0
- data/test/test_unique_name.rb +43 -0
- metadata +125 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
class TestSerializers < Test::Unit::TestCase
|
3
|
+
|
4
|
+
serializers = [
|
5
|
+
[Maildir::Serializer::Mail, lambda {|data| Mail.new(data).to_s}],
|
6
|
+
[Maildir::Serializer::Marshal, lambda {|data| Marshal.dump(data)}],
|
7
|
+
[Maildir::Serializer::JSON, lambda {|data| JSON.dump(data)}],
|
8
|
+
[Maildir::Serializer::YAML, lambda {|data| YAML.dump(data)}]
|
9
|
+
]
|
10
|
+
|
11
|
+
serializers.each do |klass, dumper|
|
12
|
+
context "A message serialized with #{klass}" do
|
13
|
+
setup do
|
14
|
+
FakeFS::FileSystem.clear
|
15
|
+
@data = case klass.new
|
16
|
+
when Maildir::Serializer::Mail
|
17
|
+
Mail.new
|
18
|
+
else
|
19
|
+
# Test a few common data structures
|
20
|
+
[1, nil, {"foo" => true}]
|
21
|
+
end
|
22
|
+
|
23
|
+
# Set the message serializer
|
24
|
+
Maildir::Message.serializer = klass.new
|
25
|
+
@message = temp_maildir.add(@data)
|
26
|
+
end
|
27
|
+
|
28
|
+
should "have the correct data" do
|
29
|
+
assert_equal @data, @message.data
|
30
|
+
end
|
31
|
+
|
32
|
+
should "have serialized data on disk" do
|
33
|
+
assert_equal dumper.call(@data), File.read(@message.path)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'maildir/subdirs'
|
3
|
+
class TestSubdirs < Test::Unit::TestCase
|
4
|
+
context "A maildir" do
|
5
|
+
setup do
|
6
|
+
FakeFS::FileSystem.clear
|
7
|
+
@maildir = temp_maildir
|
8
|
+
setup_subdirs(@maildir)
|
9
|
+
end
|
10
|
+
|
11
|
+
should "have subdirs" do
|
12
|
+
assert @maildir.subdirs.any?
|
13
|
+
end
|
14
|
+
|
15
|
+
should "be called INBOX" do
|
16
|
+
assert @maildir.name == 'INBOX'
|
17
|
+
end
|
18
|
+
|
19
|
+
should "include direct subdirs" do
|
20
|
+
subdir_names = @maildir.subdirs.map(&:name)
|
21
|
+
assert subdir_names.include?('a') && subdir_names.include?('b')
|
22
|
+
end
|
23
|
+
|
24
|
+
should "not include deeper subdirs" do
|
25
|
+
subdir_names = @maildir.subdirs.map(&:name)
|
26
|
+
assert ! subdir_names.include?('x') && ! subdir_names.include?('a.x')
|
27
|
+
end
|
28
|
+
|
29
|
+
should "create more subdirs" do
|
30
|
+
@maildir.create_subdir("test")
|
31
|
+
assert @maildir.subdirs.map(&:name).include?("test")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "A subdir" do
|
36
|
+
setup do
|
37
|
+
FakeFS::FileSystem.clear
|
38
|
+
@maildir = temp_maildir
|
39
|
+
setup_subdirs(@maildir)
|
40
|
+
end
|
41
|
+
|
42
|
+
should "include more subdirs" do
|
43
|
+
assert_not_empty @maildir.subdirs.select{ |sd| sd.name == 'a'}.first.subdirs
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
class TestUniqueName < Test::Unit::TestCase
|
3
|
+
|
4
|
+
context "A UniqueName" do
|
5
|
+
setup do
|
6
|
+
@raw_name = Maildir::UniqueName.new
|
7
|
+
@name = @raw_name.to_s
|
8
|
+
@now = @raw_name.send(:instance_variable_get, :@now)
|
9
|
+
end
|
10
|
+
|
11
|
+
should "be initialized" do
|
12
|
+
assert @raw_name
|
13
|
+
end
|
14
|
+
|
15
|
+
should "have a name" do
|
16
|
+
assert_not_empty @name
|
17
|
+
end
|
18
|
+
|
19
|
+
should "begin with timestamp" do
|
20
|
+
assert_match /^#{@now.to_i}/, @name
|
21
|
+
end
|
22
|
+
|
23
|
+
should "end with hostname" do
|
24
|
+
assert_match /#{Socket.gethostname}$/, @name
|
25
|
+
end
|
26
|
+
|
27
|
+
should "be unique when created in the same microsecond" do
|
28
|
+
@new_name = Maildir::UniqueName.new
|
29
|
+
# Set @now be identical in both UniqueName instances
|
30
|
+
@new_name.send(:instance_variable_set, :@now, @now)
|
31
|
+
assert_not_equal @name, @new_name.to_s
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
context "The UniqueName counter" do
|
37
|
+
should "increment when called" do
|
38
|
+
value1 = Maildir::UniqueName.counter
|
39
|
+
value2 = Maildir::UniqueName.counter
|
40
|
+
assert_equal value1+1, value2
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nilclass-maildir
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aaron Suggs
|
8
|
+
- Niklas E. Cathor
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2010-01-24 00:00:00 +01:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: shoulda
|
18
|
+
type: :development
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
version:
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: mail
|
28
|
+
type: :development
|
29
|
+
version_requirement:
|
30
|
+
version_requirements: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "0"
|
35
|
+
version:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: json
|
38
|
+
type: :development
|
39
|
+
version_requirement:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: "0"
|
45
|
+
version:
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: ktheory-fakefs
|
48
|
+
type: :development
|
49
|
+
version_requirement:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: "0"
|
55
|
+
version:
|
56
|
+
description: A ruby library for reading and writing arbitrary messages in DJB's maildir format
|
57
|
+
email: aaron@ktheory.com
|
58
|
+
executables: []
|
59
|
+
|
60
|
+
extensions: []
|
61
|
+
|
62
|
+
extra_rdoc_files:
|
63
|
+
- LICENSE
|
64
|
+
- README.rdoc
|
65
|
+
files:
|
66
|
+
- .gitignore
|
67
|
+
- LICENSE
|
68
|
+
- README.rdoc
|
69
|
+
- Rakefile
|
70
|
+
- VERSION
|
71
|
+
- benchmarks/runner
|
72
|
+
- lib/maildir.rb
|
73
|
+
- lib/maildir/keywords.rb
|
74
|
+
- lib/maildir/message.rb
|
75
|
+
- lib/maildir/serializer/base.rb
|
76
|
+
- lib/maildir/serializer/json.rb
|
77
|
+
- lib/maildir/serializer/mail.rb
|
78
|
+
- lib/maildir/serializer/marshal.rb
|
79
|
+
- lib/maildir/serializer/yaml.rb
|
80
|
+
- lib/maildir/subdirs.rb
|
81
|
+
- lib/maildir/unique_name.rb
|
82
|
+
- maildir.gemspec
|
83
|
+
- test/test_helper.rb
|
84
|
+
- test/test_keywords.rb
|
85
|
+
- test/test_maildir.rb
|
86
|
+
- test/test_message.rb
|
87
|
+
- test/test_serializers.rb
|
88
|
+
- test/test_subdirs.rb
|
89
|
+
- test/test_unique_name.rb
|
90
|
+
has_rdoc: true
|
91
|
+
homepage: http://github.com/ktheory/maildir
|
92
|
+
licenses: []
|
93
|
+
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options:
|
96
|
+
- --charset=UTF-8
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: "0"
|
104
|
+
version:
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: "0"
|
110
|
+
version:
|
111
|
+
requirements: []
|
112
|
+
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 1.3.5
|
115
|
+
signing_key:
|
116
|
+
specification_version: 3
|
117
|
+
summary: Read & write messages in the maildir format
|
118
|
+
test_files:
|
119
|
+
- test/test_serializers.rb
|
120
|
+
- test/test_keywords.rb
|
121
|
+
- test/test_helper.rb
|
122
|
+
- test/test_subdirs.rb
|
123
|
+
- test/test_message.rb
|
124
|
+
- test/test_unique_name.rb
|
125
|
+
- test/test_maildir.rb
|