unfuddle_my_email 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +2 -2
- data/configuration-sample.yml +1 -1
- data/lib/unfuddle_my_email/fetcher.rb +3 -4
- data/lib/unfuddle_my_email/tmail_adapter.rb +19 -0
- data/lib/unfuddle_my_email.rb +1 -0
- data/test/fetcher_test.rb +8 -9
- metadata +4 -3
data/VERSION.yml
CHANGED
data/configuration-sample.yml
CHANGED
@@ -3,7 +3,7 @@ unfuddle_username: 'username'
|
|
3
3
|
unfuddle_password: 'password'
|
4
4
|
unfuddle_ssl: true # set to true only if enabled for your account, false otherwise
|
5
5
|
unfuddle_project_id: 1234
|
6
|
-
unfuddle_api_url: '/api/v1/'
|
6
|
+
unfuddle_api_url: '/api/v1' # No trailing '/'
|
7
7
|
pop3_server: 'pop.example.com'
|
8
8
|
pop3_port: 995
|
9
9
|
pop3_ssl: true
|
@@ -1,10 +1,9 @@
|
|
1
1
|
require 'net/pop3_ssl'
|
2
|
-
require 'tmail'
|
3
2
|
|
4
3
|
module UnfuddleMyEmail
|
5
4
|
# Fetcher iterates through all emails in the given POP3 mailbox and
|
6
5
|
# yields each one, optionally deleting the message after yield. The
|
7
|
-
# message yielded is an instance of
|
6
|
+
# message yielded is an instance of TmailAdapter.
|
8
7
|
#
|
9
8
|
# Example:
|
10
9
|
#
|
@@ -14,7 +13,7 @@ module UnfuddleMyEmail
|
|
14
13
|
# end
|
15
14
|
#
|
16
15
|
# # Enumerable is included so you can use those features (except for sort,min,max) as well:
|
17
|
-
# fetcher.to_a # => [#<
|
16
|
+
# fetcher.to_a # => [#<TmailAdapter instance>]
|
18
17
|
class Fetcher
|
19
18
|
def initialize(server, port, ssl, username, password, delete=false)
|
20
19
|
@pop3_server = server
|
@@ -31,7 +30,7 @@ module UnfuddleMyEmail
|
|
31
30
|
end
|
32
31
|
Net::POP3.start(@pop3_server, @pop3_port, @pop3_username, @pop3_password) do |pop|
|
33
32
|
pop.each_mail { |message|
|
34
|
-
mail_item =
|
33
|
+
mail_item = TmailAdapter.new(message.pop)
|
35
34
|
yield mail_item
|
36
35
|
message.delete if @pop3_delete
|
37
36
|
}
|
data/lib/unfuddle_my_email.rb
CHANGED
data/test/fetcher_test.rb
CHANGED
@@ -2,7 +2,6 @@ require 'flexmock/test_unit'
|
|
2
2
|
require 'net/pop3_ssl'
|
3
3
|
require 'shoulda'
|
4
4
|
require 'test/unit'
|
5
|
-
require 'tmail'
|
6
5
|
require 'unfuddle_my_email'
|
7
6
|
|
8
7
|
class FetcherTest < Test::Unit::TestCase
|
@@ -12,11 +11,11 @@ class FetcherTest < Test::Unit::TestCase
|
|
12
11
|
setup do
|
13
12
|
@fetcher = Fetcher.new('pop.example.com', 110, false, 'user', 'password')
|
14
13
|
|
15
|
-
@message = flexmock('message', :
|
14
|
+
@message = flexmock('message', :tested => true)
|
16
15
|
@message.should_receive(:pop).and_return(
|
17
16
|
"From: john@example.com\n" +
|
18
17
|
"Subject: Test subject\n\n" +
|
19
|
-
"This is a test.\n
|
18
|
+
"This is a test.\n\n"
|
20
19
|
)
|
21
20
|
|
22
21
|
@pop3_int = flexmock('pop3_int')
|
@@ -24,17 +23,17 @@ class FetcherTest < Test::Unit::TestCase
|
|
24
23
|
|
25
24
|
@pop3_lib = flexmock(Net::POP3)
|
26
25
|
@pop3_lib.should_receive(:start).and_yield(@pop3_int)
|
27
|
-
|
28
|
-
@tmail_lib = flexmock(TMail::Mail)
|
29
|
-
@tmail_lib.should_receive(:parse).and_return(@message)
|
30
26
|
end
|
31
27
|
|
32
28
|
should "yield each message" do
|
33
|
-
|
29
|
+
test_message = nil
|
34
30
|
@fetcher.each do |message|
|
35
|
-
|
31
|
+
test_message = message
|
36
32
|
end
|
37
|
-
|
33
|
+
|
34
|
+
assert_equal "john@example.com", test_message.from
|
35
|
+
assert_equal "Test subject", test_message.subject
|
36
|
+
assert_equal "This is a test.", test_message.body
|
38
37
|
end
|
39
38
|
end
|
40
39
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unfuddle_my_email
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Haley
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-01-21 00:00:00 -07:00
|
13
13
|
default_executable: unfuddle_my_email
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- lib/unfuddle_my_email/fetcher.rb
|
35
35
|
- lib/unfuddle_my_email/poster.rb
|
36
36
|
- lib/unfuddle_my_email/runner.rb
|
37
|
+
- lib/unfuddle_my_email/tmail_adapter.rb
|
37
38
|
- test/configuration_test.rb
|
38
39
|
- test/email_ticket_test.rb
|
39
40
|
- test/fetcher_test.rb
|
@@ -70,6 +71,6 @@ specification_version: 3
|
|
70
71
|
summary: Post emails from POP server as Unfuddle Tickets.
|
71
72
|
test_files:
|
72
73
|
- test/poster_test.rb
|
73
|
-
- test/configuration_test.rb
|
74
74
|
- test/fetcher_test.rb
|
75
75
|
- test/email_ticket_test.rb
|
76
|
+
- test/configuration_test.rb
|