sortah 0.6.0 → 0.7.0
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/CHANGELOG.md +13 -0
- data/KNOWN_BUGS.md +9 -0
- data/lib/sortah/cleanroom.rb +5 -1
- data/lib/sortah/components/destination.rb +4 -0
- data/lib/sortah/components/lens.rb +3 -1
- data/lib/sortah/version.rb +1 -1
- data/spec/fixtures/rc +1 -0
- data/spec/fixtures/semantic_acceptance/rc +1 -0
- data/spec/semantic_spec.rb +28 -15
- metadata +6 -6
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
##11/14/11
|
2
|
+
|
3
|
+
### IMPROVEMENTS
|
4
|
+
|
5
|
+
- added "dynamic" destinations. If you do:
|
6
|
+
|
7
|
+
send_to dynamic: "path/to/your/dynamic/dest"
|
8
|
+
|
9
|
+
sortah will append it to the given maildir with all the usual treatment
|
10
|
+
(maildir support, mostly), useful for dynamically handling things like
|
11
|
+
mailinglists (which is the impetus for creating this).
|
12
|
+
|
13
|
+
|
1
14
|
##11/04/11
|
2
15
|
|
3
16
|
### IMPROVEMENTS
|
data/KNOWN_BUGS.md
CHANGED
@@ -12,3 +12,12 @@ if you do
|
|
12
12
|
--------
|
13
13
|
|
14
14
|
if you try to metaprogram routers or w/e, it doesn't actually define them.
|
15
|
+
|
16
|
+
--------
|
17
|
+
|
18
|
+
I think :abs destinations are handled poorly, and there is some problems of
|
19
|
+
logic location wrt destination handling
|
20
|
+
|
21
|
+
--------
|
22
|
+
|
23
|
+
The sorting logic should get centralized in cleanroom
|
data/lib/sortah/cleanroom.rb
CHANGED
@@ -32,7 +32,11 @@ module Sortah
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def send_to(dest)
|
35
|
-
@pointer =
|
35
|
+
@pointer = if dest.is_a? Hash
|
36
|
+
Destination.dynamic(dest[:dynamic])
|
37
|
+
else
|
38
|
+
@__context__.routers[dest] || @__context__.destinations[dest]
|
39
|
+
end
|
36
40
|
throw :finished_execution
|
37
41
|
end
|
38
42
|
|
@@ -21,8 +21,10 @@ module Sortah
|
|
21
21
|
|
22
22
|
def run!(email, context)
|
23
23
|
@email = email
|
24
|
-
run_dependencies!(email, context)
|
25
24
|
return if already_ran?
|
25
|
+
#XXX: this can be moved to the cleanroom, then the mark_as_run! can be put
|
26
|
+
#after the appropriate
|
27
|
+
run_dependencies!(email, context)
|
26
28
|
result = run_block!
|
27
29
|
email.metadata(name, result) if provides_value?
|
28
30
|
end
|
data/lib/sortah/version.rb
CHANGED
data/spec/fixtures/rc
CHANGED
@@ -35,6 +35,7 @@ sortah do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
router do
|
38
|
+
send_to :dynamic => "bar" if email.from && email.from.any? { |e| e =~ /dynamic/ }
|
38
39
|
send_to :personal if email.to.any? { |r| r =~ /jfredett@place.com/ }
|
39
40
|
send_to :work if email.to.any? { |r| r =~ /joe@work.com/ }
|
40
41
|
send_to :unknown
|
data/spec/semantic_spec.rb
CHANGED
@@ -74,20 +74,16 @@ describe Sortah do
|
|
74
74
|
end
|
75
75
|
|
76
76
|
describe "#sort" do
|
77
|
-
|
78
|
-
basic_sortah_definition
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
it "should sort emails based on the sortah definitions" do
|
88
|
-
basic_sortah_definition
|
89
|
-
sortah.sort(@email).destination.should == "foo/"
|
90
|
-
sortah.sort(@reply_email).destination.should == "bar/"
|
77
|
+
context "when using sortah#sort, " do
|
78
|
+
subject { basic_sortah_definition; sortah.sort(@email) }
|
79
|
+
it { should respond_to :destination }
|
80
|
+
it { should respond_to :metadata }
|
81
|
+
|
82
|
+
subject { basic_sortah_definition; sortah }
|
83
|
+
it "should sort emails based on the sortah definitions" do
|
84
|
+
subject.sort(@email).destination.should == "foo/"
|
85
|
+
subject.sort(@reply_email).destination.should == "bar/"
|
86
|
+
end
|
91
87
|
end
|
92
88
|
|
93
89
|
it "should defer to a second router if it is sent to one" do
|
@@ -341,7 +337,16 @@ describe Sortah do
|
|
341
337
|
end
|
342
338
|
end
|
343
339
|
sortah.sort(@email).full_destination.should == "/tmp/foo/"
|
344
|
-
|
340
|
+
end
|
341
|
+
|
342
|
+
it "should return the correct path when using a dynamic destination" do
|
343
|
+
sortah do
|
344
|
+
maildir '/tmp/'
|
345
|
+
router do
|
346
|
+
send_to :dynamic => "foo.bar.baz"
|
347
|
+
end
|
348
|
+
end
|
349
|
+
sortah.sort(@email).full_destination.should == "/tmp/foo.bar.baz"
|
345
350
|
end
|
346
351
|
end
|
347
352
|
|
@@ -368,9 +373,17 @@ describe Sortah do
|
|
368
373
|
#shuttup, I can dream.
|
369
374
|
end
|
370
375
|
|
376
|
+
dynamic_email = Mail.new do
|
377
|
+
to 'joe@work.com'
|
378
|
+
from 'dynamic@work.com'
|
379
|
+
subject 'this is a dynamic email'
|
380
|
+
#shuttup, I can dream.
|
381
|
+
end
|
382
|
+
|
371
383
|
sortah.sort(@email).destination.should == 'new/'
|
372
384
|
sortah.sort(personal_email).destination.should == 'personal/sarah/new/'
|
373
385
|
sortah.sort(work_email).destination.should == 'work/brian/new/'
|
386
|
+
sortah.sort(dynamic_email).destination.should == 'bar'
|
374
387
|
end
|
375
388
|
end
|
376
389
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sortah
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-11-
|
12
|
+
date: 2011-11-14 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mail
|
16
|
-
requirement: &
|
16
|
+
requirement: &2164370860 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2164370860
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: trollop
|
27
|
-
requirement: &
|
27
|
+
requirement: &2164369620 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2164369620
|
36
36
|
description: ! "\n Sortah provides a simple, declarative internal DSL for sorting
|
37
37
|
\n your email. It provides an executable which may serve as an external\n mail
|
38
38
|
delivery agent for such programs as `getmail`. Finally, since\n your sorting
|