herald 0.1 → 0.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/LICENSE +22 -0
- data/README.md +72 -59
- data/Rakefile +1 -1
- data/TODO.txt +5 -3
- data/herald.gemspec +15 -5
- data/lib/herald.rb +32 -12
- data/lib/herald/notifiers/callback.rb +5 -1
- data/lib/herald/notifiers/growl.rb +19 -15
- data/lib/herald/notifiers/ping.rb +14 -33
- data/lib/herald/notifiers/post.rb +31 -19
- data/lib/herald/untitled.txt +5 -0
- data/lib/herald/version.rb +1 -1
- data/lib/herald/watcher.rb +17 -15
- data/lib/herald/watchers/rss.rb +12 -5
- data/lib/herald/watchers/twitter.rb +6 -5
- data/lib/herald/watchers/website.rb +95 -0
- data/test/herald_test.rb +3 -9
- data/test/mocks/rss.xml +19 -0
- data/test/mocks/web.html +17 -0
- data/test/notifier_callback_test.rb +29 -0
- data/test/notifier_growl_test.rb +22 -0
- data/test/notifier_ping_test.rb +30 -0
- data/test/notifier_post_test.rb +30 -0
- data/test/notifier_stdout_test.rb +26 -0
- data/test/notifier_test.rb +38 -0
- data/test/watcher_rss_test.rb +59 -0
- data/test/watcher_test.rb +74 -0
- data/test/watcher_twitter_test.rb +17 -0
- data/test/watcher_website_test.rb +33 -0
- metadata +56 -25
- data/lib/herald/watchers/imap.rb +0 -55
data/lib/herald/watchers/imap.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
class Herald
|
2
|
-
class Watcher
|
3
|
-
|
4
|
-
module Imap
|
5
|
-
|
6
|
-
attr_accessor :user, :pass, :host, :mailbox, :last_uid
|
7
|
-
|
8
|
-
# lazy-load net/imap when this Module is used
|
9
|
-
def self.extended(base)
|
10
|
-
Herald.lazy_load('net/imap')
|
11
|
-
Herald.lazy_load('date')
|
12
|
-
end
|
13
|
-
|
14
|
-
def parse_options(options)
|
15
|
-
@user = options.delete(:user)
|
16
|
-
@pass = options.delete(:pass)
|
17
|
-
@host = options.delete(:host)
|
18
|
-
@mailbox = options.delete(:mailbox) || "INBOX"
|
19
|
-
@mailbox.upcase!
|
20
|
-
# start looking a week ago unless option given
|
21
|
-
@start_date = options.delete(:start_date) || (Date.today - 7).strftime("%d-%b-%Y")
|
22
|
-
end
|
23
|
-
|
24
|
-
def prepare; end
|
25
|
-
def cleanup; end
|
26
|
-
|
27
|
-
def to_s
|
28
|
-
"Herald IMAP Watcher, Host: #{@host}, Keywords: '#{@keywords}', Timer: #{@timer}, State: #{@keep_alive ? 'Watching' : 'Stopped'}"
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def activities
|
34
|
-
puts "u: #{@user}"
|
35
|
-
puts "p: #{@pass}"
|
36
|
-
puts "h: #{@host}"
|
37
|
-
imap = Net::IMAP.new(@host)
|
38
|
-
imap.login("LOGIN", @user, @pass)
|
39
|
-
imap.select(@mailbox)
|
40
|
-
@last_look = Time.now
|
41
|
-
# if we have the id of the last email looked at
|
42
|
-
if @last_uid
|
43
|
-
search_result = imap.search(["BODY", @keywords, "SINCE", @start_date])
|
44
|
-
else
|
45
|
-
search_result = imap.search(["BODY", @keywords, "SINCE", @start_date])
|
46
|
-
end
|
47
|
-
puts search_result.inspect
|
48
|
-
imap.logout
|
49
|
-
imap.disconnect
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
end
|