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.
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <rss version="2.0">
3
+ <channel>
4
+ <title>RSS Title</title>
5
+ <description>This is an example of an RSS feed</description>
6
+ <link>http://www.someexamplerssdomain.com/main.html</link>
7
+ <lastBuildDate>Mon, 06 Sep 2010 00:01:00 +0000 </lastBuildDate>
8
+ <pubDate>Mon, 06 Sep 2009 16:45:00 +0000 </pubDate>
9
+
10
+ <item>
11
+ <title>Text in the title</title>
12
+ <description>This is some text in the description.</description>
13
+ <link>http://www.wikipedia.org/</link>
14
+ <guid>unique string per item</guid>
15
+ <pubDate>Mon, 06 Sep 2009 16:45:00 +0000 </pubDate>
16
+ </item>
17
+
18
+ </channel>
19
+ </rss>
@@ -0,0 +1,17 @@
1
+ <html>
2
+ <head>
3
+
4
+ <title>Title</title>
5
+
6
+ </head>
7
+
8
+ <body>
9
+
10
+ <div>
11
+ <p>
12
+ <span id="here">Keyword</span>
13
+ Another keyword
14
+ </p>
15
+ </div>
16
+
17
+ <!-- intentionally malformed -->
@@ -0,0 +1,29 @@
1
+ # start tests by 'rake test' on root path
2
+
3
+
4
+ require 'herald/notifiers/callback'
5
+ describe Herald::Watcher::Notifier::Callback do
6
+
7
+ after do
8
+ Herald.clear
9
+ end
10
+
11
+ describe "basic initialisation" do
12
+ it "action() must take a block" do
13
+ Herald.watch_twitter do
14
+ _for "#herald"
15
+ action {}
16
+ end
17
+ end
18
+ it "must make Herald::Item available if block contains a parameter" do
19
+ Herald.watch_twitter do
20
+ _for "#herald"
21
+ action do |p|
22
+ p.must_be_kind_of(Herald::Item)
23
+ p.data.must_be_kind_of(Hash)
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ end
@@ -0,0 +1,22 @@
1
+ # start tests by 'rake test' on root path
2
+
3
+ # only run this test on mac os
4
+ if RUBY_PLATFORM.downcase.include?("darwin")
5
+
6
+ require 'herald/notifiers/growl'
7
+ describe Herald::Watcher::Notifier::Growl do
8
+
9
+ after do
10
+ Herald.clear
11
+ end
12
+
13
+ describe "basic initialisation" do
14
+ it "must lazy load ruby-growl" do
15
+ Herald.watch_twitter { _for "#herald"; action :growl }
16
+ defined?(Growl).must_equal("constant")
17
+ end
18
+ end
19
+
20
+ end
21
+
22
+ end
@@ -0,0 +1,30 @@
1
+ # start tests by 'rake test' on root path
2
+
3
+
4
+ require 'herald/notifiers/ping'
5
+ describe Herald::Watcher::Notifier::Ping do
6
+
7
+ after do
8
+ Herald.clear
9
+ end
10
+
11
+ describe "basic initialisation" do
12
+ it "must throw an acception if no 'uri' param is given" do
13
+ assert_raises(ArgumentError) do
14
+ Herald.watch_twitter { _for "example"; action :ping }
15
+ end
16
+ end
17
+ it "must allow uri, uris, url and urls" do
18
+ Herald.watch_twitter { _for "example"; action(:ping, :uri => "test.com") }.must_be_kind_of(Herald)
19
+ Herald.watch_twitter { _for "example"; action(:ping, :uris => ["test.com", "example.com"]) }.must_be_kind_of(Herald)
20
+ Herald.watch_twitter { _for "example"; action(:ping, :url => "test.com") }.must_be_kind_of(Herald)
21
+ Herald.watch_twitter { _for "example"; action(:ping, :urls => ["test.com", "example.com"]) }.must_be_kind_of(Herald)
22
+ end
23
+ it "must be able to resolve various non-perfect uris" do
24
+ Herald.watch_twitter { _for "example"; action(:ping, :uri => "test.com") }.must_be_kind_of(Herald)
25
+ Herald.watch_twitter { _for "example"; action(:ping, :uri => "http://test.com") }.must_be_kind_of(Herald)
26
+ Herald.watch_twitter { _for "example"; action(:ping, :uri => "http://test.com/resource") }.must_be_kind_of(Herald)
27
+ end
28
+ end
29
+
30
+ end
@@ -0,0 +1,30 @@
1
+ # start tests by 'rake test' on root path
2
+
3
+
4
+ require 'herald/notifiers/post'
5
+ describe Herald::Watcher::Notifier::Post do
6
+
7
+ after do
8
+ Herald.clear
9
+ end
10
+
11
+ describe "basic initialisation" do
12
+ it "must throw an acception if no 'uri' param is given" do
13
+ assert_raises(ArgumentError) do
14
+ Herald.watch_twitter { _for "example"; action :post }
15
+ end
16
+ end
17
+ it "must allow uri, uris, url and urls" do
18
+ Herald.watch_twitter { _for "example"; action(:post, :uri => "test.com") }.must_be_kind_of(Herald)
19
+ Herald.watch_twitter { _for "example"; action(:post, :uris => ["test.com", "example.com"]) }.must_be_kind_of(Herald)
20
+ Herald.watch_twitter { _for "example"; action(:post, :url => "test.com") }.must_be_kind_of(Herald)
21
+ Herald.watch_twitter { _for "example"; action(:post, :urls => ["test.com", "example.com"]) }.must_be_kind_of(Herald)
22
+ end
23
+ it "must be able to resolve various non-perfect uris" do
24
+ Herald.watch_twitter { _for "example"; action(:post, :uri => "test.com") }.must_be_kind_of(Herald)
25
+ Herald.watch_twitter { _for "example"; action(:post, :uri => "http://test.com") }.must_be_kind_of(Herald)
26
+ Herald.watch_twitter { _for "example"; action(:post, :uri => "http://test.com/resource") }.must_be_kind_of(Herald)
27
+ end
28
+ end
29
+
30
+ end
@@ -0,0 +1,26 @@
1
+ # start tests by 'rake test' on root path
2
+
3
+ require 'herald/notifiers/stdout'
4
+ describe Herald::Watcher::Notifier::Stdout do
5
+
6
+ after do
7
+ Herald.clear
8
+ end
9
+
10
+ describe "basic initialisation" do
11
+ it "must accept a file parameter" do
12
+ file = File.join(File.dirname(__FILE__), "mocks" "stdout.txt")
13
+ # clean up any previous test
14
+ begin
15
+ File.delete(file)
16
+ rescue Errno::ENOENT => e
17
+ # do nothing
18
+ end
19
+ File.exists?(file).must_equal(false)
20
+ Herald.watch_twitter { _for "#herald"; action(:stdout, :file => file) }
21
+ File.exists?(file).must_equal(true)
22
+ File.delete(file)
23
+ end
24
+ end
25
+
26
+ end
@@ -0,0 +1,38 @@
1
+ # start tests by 'rake test' on root path
2
+
3
+
4
+ describe Herald::Watcher::Notifier do
5
+
6
+ before do
7
+ @notifier = Herald::Watcher::Notifier.new(:callback, {})
8
+ end
9
+
10
+ after do
11
+ Herald.clear
12
+ end
13
+
14
+ describe "basic initialisation" do
15
+ it "must have a default notifier value" do
16
+ Herald::Watcher::Notifier::DEFAULT_NOTIFIER.must_equal(:stdout)
17
+ end
18
+ it "must throw an error if type of notifier unexpected" do
19
+ assert_raises(ArgumentError) do
20
+ Herald::Watcher::Notifier.new(:invalid, {})
21
+ end
22
+ end
23
+ it "must not throw an error if type of notifier is expected" do
24
+ @notifier.must_be_kind_of(Herald::Watcher::Notifier)
25
+ end
26
+ end
27
+
28
+ describe "initialisation through Herald#watch" do
29
+ it "must be passed variables from the Herald class" do
30
+ notifier = Herald.watch_twitter do
31
+ _for "#herald"
32
+ action {}
33
+ end.watchers.first.notifiers.first
34
+ notifier.must_be_kind_of(Herald::Watcher::Notifier)
35
+ end
36
+ end
37
+
38
+ end
@@ -0,0 +1,59 @@
1
+ # start tests by 'rake test' on root path
2
+
3
+ require 'herald/watchers/rss'
4
+ describe Herald::Watcher::Rss do
5
+
6
+ after do
7
+ Herald.clear
8
+ end
9
+
10
+ describe "initialisation" do
11
+ it "must throw an acception if no 'from' param is given" do
12
+ assert_raises(ArgumentError) do
13
+ Herald.watch_rss { _for "example" }
14
+ end
15
+ end
16
+ it "must load Crack and URI libraries" do
17
+ defined?(Crack).must_equal("constant")
18
+ defined?(URI).must_equal("constant")
19
+ end
20
+ it "must accept array of uris" do
21
+ herald = Herald.watch_rss(:from => ["test/mocks/rss.xml", "test/mocks/rss2.xml"]) { _for "example" }
22
+ herald.watchers.first.uris.must_be_kind_of(Array)
23
+ end
24
+ it "must map escape URI strings" do
25
+ uri = "http://example.com/#character"
26
+ herald = Herald.watch_rss(:from => uri) { _for "example" }
27
+ herald.watchers.first.uris.first.wont_match(uri)
28
+ herald.watchers.first.uris.first.must_match(URI.encode(uri))
29
+ end
30
+ end
31
+
32
+ describe "activities" do
33
+ it "must find keywords in title of rss" do
34
+ skip("@items appears as empty because anything assigned in the process fork can't be accessed outside it")
35
+ herald = Herald.once do
36
+ check :rss, :from => "test/mocks/rss.xml"
37
+ _for ["text", "title"]
38
+ end
39
+ herald.watchers.first.items.wont_be_empty
40
+ end
41
+ it "must find keywords in description of rss" do
42
+ skip("@items appears as empty because anything assigned in the process fork can't be accessed outside it")
43
+ herald = Herald.once do
44
+ check :rss, :from => "test/mocks/rss.xml"
45
+ _for ["some", "text", "description"]
46
+ end
47
+ herald.watchers.first.items.wont_be_empty
48
+ end
49
+ it "must return no results if keywords don't match" do
50
+ skip("@items appears as empty because anything assigned in the process fork can't be accessed outside it")
51
+ herald = Herald.once do
52
+ check :rss, :from => "test/mocks/rss.xml"
53
+ _for ["no such", "match"]
54
+ end
55
+ herald.watchers.first.items.must_be_empty
56
+ end
57
+ end
58
+
59
+ end
@@ -0,0 +1,74 @@
1
+ # start tests by 'rake test' on root path
2
+
3
+
4
+ describe Herald::Watcher do
5
+ before do
6
+ @watcher = Herald::Watcher.new(:twitter, {})
7
+ end
8
+
9
+ after do
10
+ Herald.clear
11
+ end
12
+
13
+ describe "basic initialisation" do
14
+ it "must have a default timer value" do
15
+ Herald::Watcher::DEFAULT_TIMER.must_equal(60)
16
+ end
17
+ it "must throw an error if no options are passed in" do
18
+ assert_raises(ArgumentError) do
19
+ Herald::Watcher.new(:twitter)
20
+ end
21
+ end
22
+ it "must throw an error if type of watcher unexpected" do
23
+ assert_raises(ArgumentError) do
24
+ Herald::Watcher.new(:invalid, {})
25
+ end
26
+ end
27
+ it "must not throw an error if type of watcher is expected" do
28
+ @watcher.must_be_kind_of(Herald::Watcher)
29
+ end
30
+ it "must make some variables available" do
31
+ @watcher.type.must_equal(:twitter)
32
+ @watcher.timer.must_equal(Herald::Watcher::DEFAULT_TIMER)
33
+ end
34
+ end
35
+
36
+ describe "initialisation through Herald#watch" do
37
+ it "must be passed variables from the Herald class" do
38
+ watcher = Herald.watch_twitter { _for "test"; every 2 => "minutes" }.watchers.first
39
+ watcher.keep_alive.must_equal(true)
40
+ watcher.timer.must_equal(120)
41
+ end
42
+ end
43
+
44
+ describe "test every() method" do
45
+ it "must convert seconds, minutes, hours and days into quantities of seconds" do
46
+ @watcher.every(2 => "seconds").timer.must_equal(2)
47
+ @watcher.every(2 => "minutes").timer.must_equal(2*60)
48
+ @watcher.every(2 => "hours").timer.must_equal(2*60*60)
49
+ @watcher.every(2 => "days").timer.must_equal(2*60*60*24)
50
+ end
51
+ it "must allow non-pluralised variations" do
52
+ @watcher.every(2 => "second").timer.must_equal(2)
53
+ @watcher.every(2 => "minute").timer.must_equal(2*60)
54
+ @watcher.every(2 => "hour").timer.must_equal(2*60*60)
55
+ @watcher.every(2 => "day").timer.must_equal(2*60*60*24)
56
+ end
57
+ end
58
+
59
+ describe " every() method" do
60
+ it "must convert seconds, minutes, hours and days into quantities of seconds" do
61
+ @watcher.every(2 => "seconds").timer.must_equal(2)
62
+ @watcher.every(2 => "minutes").timer.must_equal(2*60)
63
+ @watcher.every(2 => "hours").timer.must_equal(2*60*60)
64
+ @watcher.every(2 => "days").timer.must_equal(2*60*60*24)
65
+ end
66
+ it "must allow non-pluralised variations" do
67
+ @watcher.every(2 => "second").timer.must_equal(2)
68
+ @watcher.every(2 => "minute").timer.must_equal(2*60)
69
+ @watcher.every(2 => "hour").timer.must_equal(2*60*60)
70
+ @watcher.every(2 => "day").timer.must_equal(2*60*60*24)
71
+ end
72
+ end
73
+
74
+ end
@@ -0,0 +1,17 @@
1
+ # start tests by 'rake test' on root path
2
+
3
+ require 'herald/watchers/twitter'
4
+ describe Herald::Watcher::Twitter do
5
+
6
+ after do
7
+ Herald.clear
8
+ end
9
+
10
+ describe "initialisation" do
11
+ it "must load Crack and URI libraries" do
12
+ defined?(Crack).must_equal("constant")
13
+ defined?(URI).must_equal("constant")
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,33 @@
1
+ # start tests by 'rake test' on root path
2
+
3
+ require 'herald/watchers/website'
4
+ describe Herald::Watcher::Website do
5
+
6
+ after do
7
+ Herald.clear
8
+ end
9
+
10
+ describe "initialisation" do
11
+ it "must throw an acception if no 'from' param is given" do
12
+ assert_raises(ArgumentError) do
13
+ Herald.watch_website { _for "example" }
14
+ end
15
+ end
16
+ it "must load open-uri hpricot and Crack libraries" do
17
+ defined?(Crack).must_equal("constant")
18
+ defined?(URI).must_equal("constant")
19
+ defined?(Hpricot).must_equal("constant")
20
+ end
21
+ it "must accept array of uris" do
22
+ herald = Herald.watch_website(:from => ["test/mocks/web.html", "test/mocks/web.html"]) { _for "example" }
23
+ herald.watchers.first.uris.must_be_kind_of(Array)
24
+ end
25
+ it "must map escape URI strings" do
26
+ uri = "http://example.com/#character"
27
+ herald = Herald.watch_website(:from => uri) { _for "example" }
28
+ herald.watchers.first.uris.first.wont_match(uri)
29
+ herald.watchers.first.uris.first.must_match(URI.encode(uri))
30
+ end
31
+ end
32
+
33
+ end
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: herald
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
5
4
  prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- version: "0.1"
5
+ version: "0.2"
10
6
  platform: ruby
11
7
  authors:
12
8
  - Luke Duncalfe
@@ -14,7 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-04-14 00:00:00 +12:00
13
+ date: 2011-05-03 00:00:00 +12:00
18
14
  default_executable:
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
@@ -25,9 +21,6 @@ dependencies:
25
21
  requirements:
26
22
  - - ">="
27
23
  - !ruby/object:Gem::Version
28
- hash: 3
29
- segments:
30
- - 0
31
24
  version: "0"
32
25
  type: :development
33
26
  version_requirements: *id001
@@ -39,24 +32,45 @@ dependencies:
39
32
  requirements:
40
33
  - - ">="
41
34
  - !ruby/object:Gem::Version
42
- hash: 3
43
- segments:
44
- - 0
45
35
  version: "0"
46
36
  type: :runtime
47
37
  version_requirements: *id002
48
- description: Pass Herald some keywords and sources to watch, and Herald will notify you using Growl, email, pinging a site, or running Ruby code as soon as those keywords appear
38
+ - !ruby/object:Gem::Dependency
39
+ name: hpricot
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: "0.8"
47
+ type: :runtime
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: ruby-growl
51
+ prerelease: false
52
+ requirement: &id004 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ version: "3.0"
58
+ type: :runtime
59
+ version_requirements: *id004
60
+ description: A simple and flexible notifier for Twitter, RSS, or email
49
61
  email:
50
62
  - lduncalfe@eml.cc
51
63
  executables: []
52
64
 
53
65
  extensions: []
54
66
 
55
- extra_rdoc_files: []
56
-
67
+ extra_rdoc_files:
68
+ - README.md
69
+ - LICENSE
57
70
  files:
58
71
  - .gitignore
59
72
  - Gemfile
73
+ - LICENSE
60
74
  - README.md
61
75
  - Rakefile
62
76
  - TODO.txt
@@ -69,12 +83,25 @@ files:
69
83
  - lib/herald/notifiers/ping.rb
70
84
  - lib/herald/notifiers/post.rb
71
85
  - lib/herald/notifiers/stdout.rb
86
+ - lib/herald/untitled.txt
72
87
  - lib/herald/version.rb
73
88
  - lib/herald/watcher.rb
74
- - lib/herald/watchers/imap.rb
75
89
  - lib/herald/watchers/rss.rb
76
90
  - lib/herald/watchers/twitter.rb
91
+ - lib/herald/watchers/website.rb
77
92
  - test/herald_test.rb
93
+ - test/mocks/rss.xml
94
+ - test/mocks/web.html
95
+ - test/notifier_callback_test.rb
96
+ - test/notifier_growl_test.rb
97
+ - test/notifier_ping_test.rb
98
+ - test/notifier_post_test.rb
99
+ - test/notifier_stdout_test.rb
100
+ - test/notifier_test.rb
101
+ - test/watcher_rss_test.rb
102
+ - test/watcher_test.rb
103
+ - test/watcher_twitter_test.rb
104
+ - test/watcher_website_test.rb
78
105
  has_rdoc: true
79
106
  homepage: http://github.com/lukes/herald
80
107
  licenses: []
@@ -89,21 +116,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
116
  requirements:
90
117
  - - ">="
91
118
  - !ruby/object:Gem::Version
92
- hash: 3
93
- segments:
94
- - 0
95
119
  version: "0"
96
120
  required_rubygems_version: !ruby/object:Gem::Requirement
97
121
  none: false
98
122
  requirements:
99
123
  - - ">="
100
124
  - !ruby/object:Gem::Version
101
- hash: 23
102
- segments:
103
- - 1
104
- - 3
105
- - 6
106
- version: 1.3.6
125
+ version: "0"
107
126
  requirements: []
108
127
 
109
128
  rubyforge_project: herald
@@ -113,3 +132,15 @@ specification_version: 3
113
132
  summary: A simple notifier for Twitter, RSS, or email
114
133
  test_files:
115
134
  - test/herald_test.rb
135
+ - test/mocks/rss.xml
136
+ - test/mocks/web.html
137
+ - test/notifier_callback_test.rb
138
+ - test/notifier_growl_test.rb
139
+ - test/notifier_ping_test.rb
140
+ - test/notifier_post_test.rb
141
+ - test/notifier_stdout_test.rb
142
+ - test/notifier_test.rb
143
+ - test/watcher_rss_test.rb
144
+ - test/watcher_test.rb
145
+ - test/watcher_twitter_test.rb
146
+ - test/watcher_website_test.rb