sup_tag 0.1.2
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/.document +5 -0
- data/.gitignore +22 -0
- data/LICENSE +20 -0
- data/README.markdown +52 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/lib/sup_tag/extensions/Object.rb +30 -0
- data/lib/sup_tag.rb +74 -0
- data/spec/dummy_source.rb +55 -0
- data/spec/object_spec.rb +35 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +56 -0
- data/spec/sup_tag_spec.rb +184 -0
- data/sup_tag.gemspec +66 -0
- metadata +117 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Blake Sweeney
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
Sup Tag
|
2
|
+
========
|
3
|
+
|
4
|
+
A gem to make tagging messages in sup cleaner.
|
5
|
+
|
6
|
+
Usage
|
7
|
+
=====
|
8
|
+
|
9
|
+
This currently supports two methods to add tags, tag and archive. Tag adds tags
|
10
|
+
but does not remove the inbox tag. Archive will add a tag and remove the inbox
|
11
|
+
tag.
|
12
|
+
|
13
|
+
Example
|
14
|
+
-------
|
15
|
+
|
16
|
+
My before-add-message.rb looks like:
|
17
|
+
|
18
|
+
require 'sup_tag'
|
19
|
+
require 'sup_tag/extensions/object'
|
20
|
+
|
21
|
+
# Tag messages
|
22
|
+
tag do
|
23
|
+
from /jnls.cust.serv@oxfordjournals.org/i, :oxford
|
24
|
+
from /some_email/i, :tag1, :tag2
|
25
|
+
end
|
26
|
+
|
27
|
+
# Archive messages
|
28
|
+
archive do
|
29
|
+
subj /sup-talk/i # Tag messages with sup-talk in subject as sup-talk
|
30
|
+
end
|
31
|
+
|
32
|
+
This tags messages from jnls as oxford and leaves them in my inbox. Messages
|
33
|
+
from some\_email are given tag1, tag2. Messages from sup-talk are given the
|
34
|
+
sup-talk label and the inbox label is removed.
|
35
|
+
|
36
|
+
|
37
|
+
Note on Patches/Pull Requests
|
38
|
+
=============================
|
39
|
+
|
40
|
+
* Fork the project.
|
41
|
+
* Make your feature addition or bug fix.
|
42
|
+
* Add tests for it. This is important so I don't break it in a
|
43
|
+
future version unintentionally.
|
44
|
+
* Commit, do not mess with rakefile, version, or history.
|
45
|
+
(if you want to have your own version, that is fine but bump version in a
|
46
|
+
commit by itself I can ignore when I pull)
|
47
|
+
* Send me a pull request. Bonus points for topic branches.
|
48
|
+
|
49
|
+
Copyright
|
50
|
+
=========
|
51
|
+
|
52
|
+
Copyright (c) 2010 Blake Sweeney. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "sup_tag"
|
8
|
+
gem.summary = %Q{Make tagging messages in sup pretty}
|
9
|
+
gem.description = %Q{SupTag lets you clean up the before-add-hook script by providing a clean DSL}
|
10
|
+
gem.email = "blakes.85@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/blakesweeney/sup_tag"
|
12
|
+
gem.authors = ["Blake Sweeney"]
|
13
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
+
gem.add_development_dependency "yard", ">= 0"
|
15
|
+
gem.add_development_dependency "sup", ">= 0.11"
|
16
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
|
+
end
|
18
|
+
Jeweler::GemcutterTasks.new
|
19
|
+
rescue LoadError
|
20
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'spec/rake/spectask'
|
24
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
25
|
+
spec.libs << 'lib' << 'spec'
|
26
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
27
|
+
end
|
28
|
+
|
29
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
30
|
+
spec.libs << 'lib' << 'spec'
|
31
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
32
|
+
spec.rcov = true
|
33
|
+
end
|
34
|
+
|
35
|
+
task :spec => :check_dependencies
|
36
|
+
|
37
|
+
task :default => :spec
|
38
|
+
|
39
|
+
begin
|
40
|
+
require 'yard'
|
41
|
+
YARD::Rake::YardocTask.new
|
42
|
+
rescue LoadError
|
43
|
+
task :yardoc do
|
44
|
+
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
|
45
|
+
end
|
46
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.2
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# Modify Object to support tag and archive methods.
|
2
|
+
|
3
|
+
class Object
|
4
|
+
|
5
|
+
# Tag messages using the given block.
|
6
|
+
#
|
7
|
+
# @param [Block] block Block to tag with.
|
8
|
+
# @return [Set] The Set of tags on the message.
|
9
|
+
def tag(&block)
|
10
|
+
tagger = get_tagger(&block)
|
11
|
+
tagger.tag(&block)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Archive messages using the given block.
|
15
|
+
#
|
16
|
+
# @param [Block] A block to use to tag.
|
17
|
+
# @return [Set] The Set of tags on the message.
|
18
|
+
def archive(&block)
|
19
|
+
tagger = get_tagger(&block)
|
20
|
+
tagger.archive(&block)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Get the SupTag object for the given block.
|
24
|
+
#
|
25
|
+
# @param [Block] A Block to generate the tagger object with.
|
26
|
+
# @return [SupTag] A SupTag object.
|
27
|
+
def get_tagger(&block)
|
28
|
+
return SupTag.new(eval("lambda { message }", block.binding).call)
|
29
|
+
end
|
30
|
+
end
|
data/lib/sup_tag.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Class to make tagging simple.
|
2
|
+
class SupTag
|
3
|
+
|
4
|
+
# Create a new SupTag.
|
5
|
+
#
|
6
|
+
# @param [Redwood::Message] message A Message to tag.
|
7
|
+
def initialize(message)
|
8
|
+
@message = message
|
9
|
+
end
|
10
|
+
|
11
|
+
# Remove the given tags from the message.
|
12
|
+
#
|
13
|
+
# @param [Symbol, Array] tags Tags to remove.
|
14
|
+
# @return [Array] The tags on the message.
|
15
|
+
def remove(tags)
|
16
|
+
Array(tags).each { |t| @message.remove_label(t) }
|
17
|
+
return @message.labels
|
18
|
+
end
|
19
|
+
|
20
|
+
# Archive a message. This adds the matching tags and removes the
|
21
|
+
# inbox tag.
|
22
|
+
#
|
23
|
+
# @param [Block] block Block to add tags.
|
24
|
+
# @return [Array] Tags on the message.
|
25
|
+
def archive(&block)
|
26
|
+
@match = false
|
27
|
+
cloaker(&block).bind(self).call
|
28
|
+
remove(:inbox) if @match
|
29
|
+
return @message.labels
|
30
|
+
end
|
31
|
+
|
32
|
+
# Tag a message.
|
33
|
+
#
|
34
|
+
# @param [Block] Block for adding tags.
|
35
|
+
# @return [Array] The tags on the message.
|
36
|
+
def tag(&block)
|
37
|
+
cloaker(&block).bind(self).call
|
38
|
+
@message.labels
|
39
|
+
end
|
40
|
+
|
41
|
+
# Instance eval for blocks stolen from Trollop. Orignally from:
|
42
|
+
# http://redhanded.hobix.com/inspect/aBlockCostume.html, which now
|
43
|
+
# seems to be down.
|
44
|
+
#
|
45
|
+
# @param [Block] b A block to bind.
|
46
|
+
# @return [Block] The given block bound so it will eval in this
|
47
|
+
# instance context.
|
48
|
+
def cloaker(&b)
|
49
|
+
(class << self; self; end).class_eval do
|
50
|
+
define_method :cloaker_, &b
|
51
|
+
meth = instance_method :cloaker_
|
52
|
+
remove_method :cloaker_
|
53
|
+
meth
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def respond_to?(method, include_private = false)
|
58
|
+
return @message.respond_to?(method) || super
|
59
|
+
end
|
60
|
+
|
61
|
+
def method_missing(method, *args)
|
62
|
+
super if !respond_to?(method)
|
63
|
+
|
64
|
+
match = args.shift
|
65
|
+
match_string = (match.is_a?(Regexp) ? match.source : match.to_s)
|
66
|
+
tags = (args.empty? ? [match_string.downcase] : args).compact
|
67
|
+
query = @message.send(method)
|
68
|
+
if (!query.is_a?(Array) && query.to_s.match(match)) ||
|
69
|
+
(query.is_a?(Array) && query.any? { |q| q.to_s.match(match) } )
|
70
|
+
@match = true
|
71
|
+
tags.map { |t| @message.add_label(t) }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "sup"
|
2
|
+
require 'stringio'
|
3
|
+
require 'rmail'
|
4
|
+
require 'uri'
|
5
|
+
require 'set'
|
6
|
+
|
7
|
+
module Redwood
|
8
|
+
class DummySource < Source
|
9
|
+
|
10
|
+
attr_accessor :messages
|
11
|
+
|
12
|
+
def initialize uri, last_date=nil, usual=true, archived=false, id=nil, labels=[]
|
13
|
+
super uri, last_date, usual, archived, id
|
14
|
+
@messages = nil
|
15
|
+
end
|
16
|
+
|
17
|
+
def start_offset
|
18
|
+
0
|
19
|
+
end
|
20
|
+
|
21
|
+
def end_offset
|
22
|
+
# should contain the number of test messages -1
|
23
|
+
return @messages ? @messages.length - 1 : 0
|
24
|
+
end
|
25
|
+
|
26
|
+
def load_header offset
|
27
|
+
Source.parse_raw_email_header StringIO.new(raw_header(offset))
|
28
|
+
end
|
29
|
+
|
30
|
+
def load_message offset
|
31
|
+
RMail::Parser.read raw_message(offset)
|
32
|
+
end
|
33
|
+
|
34
|
+
def raw_header offset
|
35
|
+
ret = ""
|
36
|
+
f = StringIO.new(@messages[offset])
|
37
|
+
until f.eof? || (l = f.gets) =~ /^$/
|
38
|
+
ret += l
|
39
|
+
end
|
40
|
+
ret
|
41
|
+
end
|
42
|
+
|
43
|
+
def raw_message offset
|
44
|
+
@messages[offset]
|
45
|
+
end
|
46
|
+
|
47
|
+
def each_raw_message_line offset
|
48
|
+
ret = ""
|
49
|
+
f = StringIO.new(@messages[offset])
|
50
|
+
until f.eof?
|
51
|
+
yield f.gets
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/spec/object_spec.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
require 'sup_tag/extensions/object'
|
3
|
+
|
4
|
+
describe 'Object' do
|
5
|
+
before do
|
6
|
+
def message
|
7
|
+
get_short_message
|
8
|
+
end
|
9
|
+
end
|
10
|
+
context 'tagger' do
|
11
|
+
it 'can make the tagger' do
|
12
|
+
(get_tagger { 'a' }).should_not be_nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'tagging' do
|
17
|
+
it 'can tag a message' do
|
18
|
+
tags = tag do
|
19
|
+
subj /test/i
|
20
|
+
end
|
21
|
+
tags.should == Set[:test]
|
22
|
+
end
|
23
|
+
it 'can archive messages' do
|
24
|
+
def message
|
25
|
+
m = get_short_message
|
26
|
+
m.add_label(:inbox)
|
27
|
+
return m
|
28
|
+
end
|
29
|
+
tags = archive do
|
30
|
+
subj /test/i, :bob
|
31
|
+
end
|
32
|
+
tags.should == Set[:bob]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
require 'sup_tag'
|
4
|
+
require "rubygems"
|
5
|
+
require "sup"
|
6
|
+
require 'spec'
|
7
|
+
require 'spec/autorun'
|
8
|
+
require 'stringio'
|
9
|
+
require 'rmail'
|
10
|
+
require 'uri'
|
11
|
+
require 'set'
|
12
|
+
require 'dummy_source'
|
13
|
+
|
14
|
+
SHORT_STR =<<-EOM
|
15
|
+
Return-path: <fake_sender@example.invalid>
|
16
|
+
Envelope-to: fake_receiver@localhost
|
17
|
+
Delivery-date: Sun, 09 Dec 2007 21:48:19 +0200
|
18
|
+
Received: from fake_sender by localhost.localdomain with local (Exim 4.67)
|
19
|
+
(envelope-from <fake_sender@example.invalid>)
|
20
|
+
id 1J1S8R-0006lA-MJ
|
21
|
+
for fake_receiver@localhost; Sun, 09 Dec 2007 21:48:19 +0200
|
22
|
+
Date: Sun, 9 Dec 2007 21:48:19 +0200
|
23
|
+
Mailing-List: contact example-help@example.invalid; run by ezmlm
|
24
|
+
Precedence: bulk
|
25
|
+
List-Id: <example.list-id.example.invalid>
|
26
|
+
List-Post: <mailto:example@example.invalid>
|
27
|
+
List-Help: <mailto:example-help@example.invalid>
|
28
|
+
List-Unsubscribe: <mailto:example-unsubscribe@example.invalid>
|
29
|
+
List-Subscribe: <mailto:example-subscribe@example.invalid>
|
30
|
+
Delivered-To: mailing list example@example.invalid
|
31
|
+
Delivered-To: moderator for example@example.invalid
|
32
|
+
From: Fake Sender <fake_sender@example.invalid>
|
33
|
+
To: Fake Receiver <fake_receiver@localhost>
|
34
|
+
CC: Fake Person <fake_person@someplace>
|
35
|
+
BCC: Important Person <person@important>
|
36
|
+
Subject: Re: Test message subject
|
37
|
+
Message-ID: <20071209194819.GA25972@example.invalid>
|
38
|
+
References: <E1J1Rvb-0006k2-CE@localhost.localdomain>
|
39
|
+
MIME-Version: 1.0
|
40
|
+
Content-Type: text/plain; charset=us-ascii
|
41
|
+
Content-Disposition: inline
|
42
|
+
In-Reply-To: <E1J1Rvb-0006k2-CE@localhost.localdomain>
|
43
|
+
User-Agent: Sup/0.3
|
44
|
+
|
45
|
+
Test message!
|
46
|
+
EOM
|
47
|
+
|
48
|
+
# Simple method to get a short message
|
49
|
+
def get_short_message
|
50
|
+
source = Redwood::DummySource.new("sup-test://test_simple_message")
|
51
|
+
source.messages = [ SHORT_STR ]
|
52
|
+
source_info = 0
|
53
|
+
mess = Redwood::Message.new( {:source => source, :source_info => source_info } )
|
54
|
+
mess.load_from_source!
|
55
|
+
return mess
|
56
|
+
end
|
@@ -0,0 +1,184 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "SupTag" do
|
4
|
+
context 'respond_to' do
|
5
|
+
it 'responds to taggable methods' do
|
6
|
+
[ :from, :subj, :to, :replyto ].each do |meth|
|
7
|
+
SupTag.new(get_short_message).respond_to?(meth).should be_true
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'tags' do
|
13
|
+
before do
|
14
|
+
@mess = get_short_message
|
15
|
+
@tagger = SupTag.new(@mess)
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'removing tags' do
|
19
|
+
it 'can remove a given tag' do
|
20
|
+
@mess.add_label(:t)
|
21
|
+
@tagger.remove(:t)
|
22
|
+
@mess.labels.to_a.should == []
|
23
|
+
end
|
24
|
+
it 'can remove many tags' do
|
25
|
+
@mess.add_label(:t)
|
26
|
+
@mess.add_label(:t2)
|
27
|
+
@tagger.remove([:t, :t2])
|
28
|
+
@mess.labels.to_a.should == []
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'tagging methods' do
|
33
|
+
it 'can tag using from name' do
|
34
|
+
@tagger.tag do
|
35
|
+
from /Fake Sender/i, :test
|
36
|
+
end
|
37
|
+
@mess.labels.to_a.should == [ :test ]
|
38
|
+
end
|
39
|
+
it 'can tag using from email' do
|
40
|
+
@tagger.tag do
|
41
|
+
from /example.invalid/i, :test
|
42
|
+
end
|
43
|
+
@mess.labels.to_a.should == [ :test ]
|
44
|
+
end
|
45
|
+
it 'can tag using to' do
|
46
|
+
@tagger.tag do
|
47
|
+
to /Fake/i, :test
|
48
|
+
end
|
49
|
+
@mess.labels.to_a.should == [ :test ]
|
50
|
+
end
|
51
|
+
it 'can tag using to email' do
|
52
|
+
@tagger.tag do
|
53
|
+
to /@localhost/, :test
|
54
|
+
end
|
55
|
+
@mess.labels.to_a.should == [ :test ]
|
56
|
+
end
|
57
|
+
it 'can tag using subj' do
|
58
|
+
@tagger.tag do
|
59
|
+
subj /Test/, :test
|
60
|
+
end
|
61
|
+
@mess.labels.to_a.should == [ :test ]
|
62
|
+
end
|
63
|
+
it 'can tag using cc' do
|
64
|
+
@tagger.tag do
|
65
|
+
cc /@someplace/, :test
|
66
|
+
end
|
67
|
+
@mess.labels.to_a.should == [ :test ]
|
68
|
+
end
|
69
|
+
it 'can tag using bcc' do
|
70
|
+
@tagger.tag do
|
71
|
+
bcc /@important/, :test
|
72
|
+
end
|
73
|
+
@mess.labels.to_a.should == [ :test ]
|
74
|
+
end
|
75
|
+
it 'can tag using recipients' do
|
76
|
+
@tagger.tag do
|
77
|
+
recipients /@important/, :test
|
78
|
+
end
|
79
|
+
@mess.labels.to_a.should == [ :test ]
|
80
|
+
end
|
81
|
+
it 'can tag using date' do
|
82
|
+
@tagger.tag do
|
83
|
+
date /2007/, :old
|
84
|
+
end
|
85
|
+
@mess.labels.should == Set[:old]
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'adding tags' do
|
90
|
+
it 'can tag using a regexp' do
|
91
|
+
@tagger.tag do
|
92
|
+
subj /Test/, :test
|
93
|
+
end
|
94
|
+
@mess.labels.to_a.should == [ :test ]
|
95
|
+
end
|
96
|
+
it 'can tag using a string' do
|
97
|
+
@tagger.tag do
|
98
|
+
subj 'Test', :test
|
99
|
+
end
|
100
|
+
@mess.labels.to_a.should == [ :test ]
|
101
|
+
end
|
102
|
+
it 'can tag if the method returns an array' do
|
103
|
+
@tagger.tag do
|
104
|
+
to 'Fake', :test
|
105
|
+
end
|
106
|
+
@mess.labels.should == Set[:test]
|
107
|
+
end
|
108
|
+
it 'does not remove any tags' do
|
109
|
+
@mess.add_label :a
|
110
|
+
@mess.add_label :c
|
111
|
+
@tagger.tag do
|
112
|
+
subj 'Test', :test
|
113
|
+
end
|
114
|
+
@mess.labels.should == Set[ :a, :c, :test ]
|
115
|
+
end
|
116
|
+
it 'uses all tags given' do
|
117
|
+
@tagger.tag do
|
118
|
+
subj 'Test', :test, :a, :c
|
119
|
+
end
|
120
|
+
@mess.labels.should == Set[ :a, :c, :test ]
|
121
|
+
end
|
122
|
+
it 'will set the tag to the given downcased string if no tag given' do
|
123
|
+
@tagger.tag do
|
124
|
+
subj 'Test'
|
125
|
+
end
|
126
|
+
@mess.labels.should == Set[ :test ]
|
127
|
+
end
|
128
|
+
it 'will set the tag to the given regexp source if no tag given' do
|
129
|
+
@tagger.tag do
|
130
|
+
subj /Test/i
|
131
|
+
end
|
132
|
+
@mess.labels.should == Set[ :test ]
|
133
|
+
end
|
134
|
+
it 'will not add a nil tag' do
|
135
|
+
@tagger.tag do
|
136
|
+
subj /Test/i, nil
|
137
|
+
end
|
138
|
+
@mess.labels.should == Set[ ]
|
139
|
+
end
|
140
|
+
end
|
141
|
+
it 'does not tag if there is no match' do
|
142
|
+
@tagger.archive do
|
143
|
+
subj /AWESOME/, :me
|
144
|
+
end
|
145
|
+
@mess.labels.should == Set[]
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
context 'archiving' do
|
150
|
+
before do
|
151
|
+
@mess = get_short_message
|
152
|
+
@mess.add_label(:inbox)
|
153
|
+
@tagger = SupTag.new(@mess)
|
154
|
+
end
|
155
|
+
it 'will add a given tag' do
|
156
|
+
@tagger.archive do
|
157
|
+
subj /Test/i, :test
|
158
|
+
end
|
159
|
+
@mess.labels.should == Set[:test]
|
160
|
+
end
|
161
|
+
it 'removes the inbox tag' do
|
162
|
+
@tagger.archive do
|
163
|
+
subj /Test/i, nil
|
164
|
+
end
|
165
|
+
@mess.labels.should == Set[]
|
166
|
+
end
|
167
|
+
it 'does not remove the inbox tag if there is no match' do
|
168
|
+
@tagger.archive do
|
169
|
+
subj /AWESOME/, :me
|
170
|
+
to /other/, :bob
|
171
|
+
from /you/, :joe
|
172
|
+
end
|
173
|
+
@mess.labels.should == Set[:inbox]
|
174
|
+
end
|
175
|
+
it 'removes the inbox tag if any of the rules match' do
|
176
|
+
@tagger.archive do
|
177
|
+
subj /AWESOME/, :me
|
178
|
+
subj /test/i, :me
|
179
|
+
to /people/, :people
|
180
|
+
end
|
181
|
+
@mess.labels.should == Set[:me]
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
data/sup_tag.gemspec
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{sup_tag}
|
8
|
+
s.version = "0.1.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Blake Sweeney"]
|
12
|
+
s.date = %q{2010-10-19}
|
13
|
+
s.description = %q{SupTag lets you clean up the before-add-hook script by providing a clean DSL}
|
14
|
+
s.email = %q{blakes.85@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.markdown"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.markdown",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"lib/sup_tag.rb",
|
27
|
+
"lib/sup_tag/extensions/Object.rb",
|
28
|
+
"spec/dummy_source.rb",
|
29
|
+
"spec/object_spec.rb",
|
30
|
+
"spec/spec.opts",
|
31
|
+
"spec/spec_helper.rb",
|
32
|
+
"spec/sup_tag_spec.rb",
|
33
|
+
"sup_tag.gemspec"
|
34
|
+
]
|
35
|
+
s.homepage = %q{http://github.com/blakesweeney/sup_tag}
|
36
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
37
|
+
s.require_paths = ["lib"]
|
38
|
+
s.rubygems_version = %q{1.3.6}
|
39
|
+
s.summary = %q{Make tagging messages in sup pretty}
|
40
|
+
s.test_files = [
|
41
|
+
"spec/dummy_source.rb",
|
42
|
+
"spec/object_spec.rb",
|
43
|
+
"spec/spec_helper.rb",
|
44
|
+
"spec/sup_tag_spec.rb"
|
45
|
+
]
|
46
|
+
|
47
|
+
if s.respond_to? :specification_version then
|
48
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
49
|
+
s.specification_version = 3
|
50
|
+
|
51
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
52
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
53
|
+
s.add_development_dependency(%q<yard>, [">= 0"])
|
54
|
+
s.add_development_dependency(%q<sup>, [">= 0.11"])
|
55
|
+
else
|
56
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
57
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
58
|
+
s.add_dependency(%q<sup>, [">= 0.11"])
|
59
|
+
end
|
60
|
+
else
|
61
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
62
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
63
|
+
s.add_dependency(%q<sup>, [">= 0.11"])
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sup_tag
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Blake Sweeney
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-10-19 00:00:00 -04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 2
|
30
|
+
- 9
|
31
|
+
version: 1.2.9
|
32
|
+
type: :development
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: yard
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
version: "0"
|
44
|
+
type: :development
|
45
|
+
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: sup
|
48
|
+
prerelease: false
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
segments:
|
54
|
+
- 0
|
55
|
+
- 11
|
56
|
+
version: "0.11"
|
57
|
+
type: :development
|
58
|
+
version_requirements: *id003
|
59
|
+
description: SupTag lets you clean up the before-add-hook script by providing a clean DSL
|
60
|
+
email: blakes.85@gmail.com
|
61
|
+
executables: []
|
62
|
+
|
63
|
+
extensions: []
|
64
|
+
|
65
|
+
extra_rdoc_files:
|
66
|
+
- LICENSE
|
67
|
+
- README.markdown
|
68
|
+
files:
|
69
|
+
- .document
|
70
|
+
- .gitignore
|
71
|
+
- LICENSE
|
72
|
+
- README.markdown
|
73
|
+
- Rakefile
|
74
|
+
- VERSION
|
75
|
+
- lib/sup_tag.rb
|
76
|
+
- lib/sup_tag/extensions/Object.rb
|
77
|
+
- spec/dummy_source.rb
|
78
|
+
- spec/object_spec.rb
|
79
|
+
- spec/spec.opts
|
80
|
+
- spec/spec_helper.rb
|
81
|
+
- spec/sup_tag_spec.rb
|
82
|
+
- sup_tag.gemspec
|
83
|
+
has_rdoc: true
|
84
|
+
homepage: http://github.com/blakesweeney/sup_tag
|
85
|
+
licenses: []
|
86
|
+
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options:
|
89
|
+
- --charset=UTF-8
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
segments:
|
97
|
+
- 0
|
98
|
+
version: "0"
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
segments:
|
104
|
+
- 0
|
105
|
+
version: "0"
|
106
|
+
requirements: []
|
107
|
+
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 1.3.6
|
110
|
+
signing_key:
|
111
|
+
specification_version: 3
|
112
|
+
summary: Make tagging messages in sup pretty
|
113
|
+
test_files:
|
114
|
+
- spec/dummy_source.rb
|
115
|
+
- spec/object_spec.rb
|
116
|
+
- spec/spec_helper.rb
|
117
|
+
- spec/sup_tag_spec.rb
|