twitter2campfire 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ run.rb
data/README ADDED
@@ -0,0 +1,27 @@
1
+ twitter2campfire.rb
2
+
3
+ Publish a Twitter summize feed to Campfire
4
+
5
+ This script allows you to monitor a Twitter search feed using Campfire.
6
+
7
+ Here's how to get it set up:
8
+
9
+ Pre-run: make sure to install gem dependencies:
10
+
11
+ sudo gem install tinder rio hpricot htmlentities
12
+
13
+ then:
14
+
15
+ 1) Check out the repo:
16
+
17
+ git clone git://github.com/paulca/twitter2campfire.git
18
+
19
+ 2) Copy 'run_example.rb' to 'run.rb' and edit it with your credentials and a feed url ( from http://search.twitter.com )
20
+
21
+ 3) Set a cron script to run the script every minute. Something like this should do it:
22
+
23
+ * * * * * cd /home/twitter2campfire/; ruby run.rb
24
+
25
+ Hallelujah, you got Twitter in your Campfire, sweet!
26
+
27
+ Follow me on Twitter for updates: http://www.twitter.com/paulca
@@ -0,0 +1,39 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "twitter2campfire"
8
+ gem.summary = %Q{gemification of twitter2campfire script}
9
+ gem.description = %Q{found this code here: [http://github.com/paulca/twitter2campfire]. I just gemified it.}
10
+ gem.email = "james@giraffesoft.ca"
11
+ gem.homepage = "http://github.com/giraffesoft/twitter2campfire"
12
+ gem.authors = ["James Golick"]
13
+ gem.add_development_dependency "rspec", ">= 1.2.9"
14
+ gem.add_dependency "rio"
15
+ gem.add_dependency "tinder"
16
+ gem.add_dependency "hpricot"
17
+ gem.add_dependency "htmlentities"
18
+ gem.add_dependency "thor"
19
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
20
+ end
21
+ rescue LoadError
22
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
23
+ end
24
+
25
+ require 'spec/rake/spectask'
26
+ Spec::Rake::SpecTask.new(:spec) do |spec|
27
+ spec.libs << 'lib' << 'spec'
28
+ spec.spec_files = FileList['spec/**/*_spec.rb']
29
+ end
30
+
31
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
32
+ spec.libs << 'lib' << 'spec'
33
+ spec.pattern = 'spec/**/*_spec.rb'
34
+ spec.rcov = true
35
+ end
36
+
37
+ task :spec => :check_dependencies
38
+ task :default => :spec
39
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'twitter2campfire'
4
+ Twitter2Campfire::CLI.start
5
+
@@ -0,0 +1,8 @@
1
+ subdomain: myco
2
+ cache_file: /var/lib/twitter2campfire.cache
3
+ username: myuser
4
+ password: swordfish
5
+ room: hackers table
6
+ ssl: true
7
+ url: http://search.twitter.com/whatever...
8
+
@@ -0,0 +1,209 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <feed xmlns:google="http://base.google.com/ns/1.0" xml:lang="en-US" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.w3.org/2005/Atom" xmlns:twitter="http://api.twitter.com/">
3
+ <id>tag:search.twitter.com,2005:search/from:paulca OR from:eoghanmccabe OR from:destraynor OR from:davidjrice</id>
4
+ <link type="text/html" rel="alternate" href="http://search.twitter.com/search?q=from%3Apaulca+OR+from%3Aeoghanmccabe+OR+from%3Adestraynor+OR+from%3Adavidjrice"/>
5
+ <link type="application/atom+xml" rel="self" href="http://search.twitter.com/search.atom?q=from%3Apaulca+OR+from%3Aeoghanmccabe+OR+from%3Adestraynor+OR+from%3Adavidjrice"/>
6
+ <title>from:paulca OR from:eoghanmccabe OR from:destraynor OR from:davidjrice - Twitter Search</title>
7
+ <link type="application/opensearchdescription+xml" rel="search" href="http://search.twitter.com/opensearch.xml"/>
8
+ <link type="application/atom+xml" rel="refresh" href="http://search.twitter.com/search.atom?q=from%3Apaulca+OR+from%3Aeoghanmccabe+OR+from%3Adestraynor+OR+from%3Adavidjrice&amp;since_id=1062620135"/>
9
+ <updated>2008-12-17T12:12:01Z</updated>
10
+ <openSearch:itemsPerPage>15</openSearch:itemsPerPage>
11
+ <link type="application/atom+xml" rel="next" href="http://search.twitter.com/search.atom?max_id=1062620135&amp;page=2&amp;q=from%3Apaulca+OR+from%3Aeoghanmccabe+OR+from%3Adestraynor+OR+from%3Adavidjrice"/>
12
+ <entry>
13
+ <id>tag:search.twitter.com,2005:1062620135</id>
14
+ <published>2008-12-17T12:12:01Z</published>
15
+ <link type="text/html" rel="alternate" href="http://twitter.com/paulca/statuses/1062620135"/>
16
+ <title>@svenfuchs &#8212; I'm worried I totally missed something for merging translations ... http://reallytinyurl.com/492 ... is this useful at all?</title>
17
+ <content type="html">&lt;a href="http://twitter.com/svenfuchs"&gt;@svenfuchs&lt;/a&gt; &#8212; I'm worried I totally missed something for merging translations ... &lt;a href="http://reallytinyurl.com/492"&gt;http://reallytinyurl.com/492&lt;/a&gt; ... is this useful at all?</content>
18
+ <updated>2008-12-17T12:12:01Z</updated>
19
+ <link type="image/png" rel="image" href="http://s3.amazonaws.com/twitter_production/profile_images/61449532/paul-picture_normal.png"/>
20
+ <author>
21
+ <name>paulca (Paul Campbell)</name>
22
+ <uri>http://twitter.com/paulca</uri>
23
+ </author>
24
+ </entry>
25
+ <entry>
26
+ <id>tag:search.twitter.com,2005:1062619298</id>
27
+ <published>2008-12-17T12:11:11Z</published>
28
+ <link type="text/html" rel="alternate" href="http://twitter.com/paulca/statuses/1062619298"/>
29
+ <title>I wrote a little plugin to update translation files in Rails 2.2 http://reallytinyurl.com/492 Blogpost: http://reallytinyurl.com/491</title>
30
+ <content type="html">I wrote a little plugin to update translation files in Rails 2.2 &lt;a href="http://reallytinyurl.com/492"&gt;http://reallytinyurl.com/492&lt;/a&gt; Blogpost: &lt;a href="http://reallytinyurl.com/491"&gt;http://reallytinyurl.com/491&lt;/a&gt;</content>
31
+ <updated>2008-12-17T12:11:11Z</updated>
32
+ <link type="image/png" rel="image" href="http://s3.amazonaws.com/twitter_production/profile_images/61449532/paul-picture_normal.png"/>
33
+ <author>
34
+ <name>paulca (Paul Campbell)</name>
35
+ <uri>http://twitter.com/paulca</uri>
36
+ </author>
37
+ </entry>
38
+ <entry>
39
+ <id>tag:search.twitter.com,2005:1062528058</id>
40
+ <published>2008-12-17T10:45:45Z</published>
41
+ <link type="text/html" rel="alternate" href="http://twitter.com/eoghanmccabe/statuses/1062528058"/>
42
+ <title>@karldeeter You're welcome! Glad you get the branding joke. :-)</title>
43
+ <content type="html">&lt;a href="http://twitter.com/karldeeter"&gt;@karldeeter&lt;/a&gt; You're welcome! Glad you get the branding joke. :-)</content>
44
+ <updated>2008-12-17T10:45:45Z</updated>
45
+ <link type="image/png" rel="image" href="http://s3.amazonaws.com/twitter_production/profile_images/61446055/eoghan-picture_normal.png"/>
46
+ <link type="application/atom+xml" rel="thread" href="http://search.twitter.com/search/thread/1062528058.atom"/>
47
+ <author>
48
+ <name>eoghanmccabe (Eoghan McCabe)</name>
49
+ <uri>http://twitter.com/eoghanmccabe</uri>
50
+ </author>
51
+ </entry>
52
+ <entry>
53
+ <id>tag:search.twitter.com,2005:1062509967</id>
54
+ <published>2008-12-17T10:28:15Z</published>
55
+ <link type="text/html" rel="alternate" href="http://twitter.com/paulca/statuses/1062509967"/>
56
+ <title>Congrats to @campbellscott + co for successful launch of igopeople.com this morning. Great to see the lights switch on before Christmas!</title>
57
+ <content type="html">Congrats to &lt;a href="http://twitter.com/campbellscott"&gt;@campbellscott&lt;/a&gt; + co for successful launch of igopeople.com this morning. Great to see the lights switch on before Christmas!</content>
58
+ <updated>2008-12-17T10:28:15Z</updated>
59
+ <link type="image/png" rel="image" href="http://s3.amazonaws.com/twitter_production/profile_images/61449532/paul-picture_normal.png"/>
60
+ <author>
61
+ <name>paulca (Paul Campbell)</name>
62
+ <uri>http://twitter.com/paulca</uri>
63
+ </author>
64
+ </entry>
65
+ <entry>
66
+ <id>tag:search.twitter.com,2005:1062447244</id>
67
+ <published>2008-12-17T09:20:33Z</published>
68
+ <link type="text/html" rel="alternate" href="http://twitter.com/destraynor/statuses/1062447244"/>
69
+ <title>Missing the IGO launch breakfast this morning - academia calls. Best of luck to all involved.</title>
70
+ <content type="html">Missing the IGO launch breakfast this morning - academia calls. Best of luck to all involved.</content>
71
+ <updated>2008-12-17T09:20:33Z</updated>
72
+ <link type="image/png" rel="image" href="http://s3.amazonaws.com/twitter_production/profile_images/61452256/des-picture_normal.png"/>
73
+ <author>
74
+ <name>destraynor (Des Traynor)</name>
75
+ <uri>http://twitter.com/destraynor</uri>
76
+ </author>
77
+ </entry>
78
+ <entry>
79
+ <id>tag:search.twitter.com,2005:1062203697</id>
80
+ <published>2008-12-17T05:15:28Z</published>
81
+ <link type="text/html" rel="alternate" href="http://twitter.com/davidjrice/statuses/1062203697"/>
82
+ <title>@KirinDave I have a lumix lx1, takes great pictures. Only bad news about the lx3 is that it looks like it has time travelled from the 80s.:)</title>
83
+ <content type="html">&lt;a href="http://twitter.com/KirinDave"&gt;@KirinDave&lt;/a&gt; I have a lumix lx1, takes great pictures. Only bad news about the lx3 is that it looks like it has time travelled from the 80s.:)</content>
84
+ <updated>2008-12-17T05:15:28Z</updated>
85
+ <link type="image/png" rel="image" href="http://s3.amazonaws.com/twitter_production/profile_images/64037782/dave-picture_normal.png"/>
86
+ <author>
87
+ <name>davidjrice (David Rice)</name>
88
+ <uri>http://twitter.com/davidjrice</uri>
89
+ </author>
90
+ </entry>
91
+ <entry>
92
+ <id>tag:search.twitter.com,2005:1061999348</id>
93
+ <published>2008-12-17T02:51:57Z</published>
94
+ <link type="text/html" rel="alternate" href="http://twitter.com/destraynor/statuses/1061999348"/>
95
+ <title>Another early start tomorrow, but it looks like I'm staring at another long sleepless night though. God this sucks.</title>
96
+ <content type="html">Another early start tomorrow, but it looks like I'm staring at another long sleepless night though. God this sucks.</content>
97
+ <updated>2008-12-17T02:51:57Z</updated>
98
+ <link type="image/png" rel="image" href="http://s3.amazonaws.com/twitter_production/profile_images/61452256/des-picture_normal.png"/>
99
+ <author>
100
+ <name>destraynor (Des Traynor)</name>
101
+ <uri>http://twitter.com/destraynor</uri>
102
+ </author>
103
+ </entry>
104
+ <entry>
105
+ <id>tag:search.twitter.com,2005:1061887763</id>
106
+ <published>2008-12-17T01:40:04Z</published>
107
+ <link type="text/html" rel="alternate" href="http://twitter.com/davidjrice/statuses/1061887763"/>
108
+ <title>So, I was just about to do a screencast to let a client peek at their eagerly awaited facebook app... and then part of fb dies.</title>
109
+ <content type="html">So, I was just about to do a screencast to let a client peek at their eagerly awaited facebook app... and then part of fb dies.</content>
110
+ <updated>2008-12-17T01:40:04Z</updated>
111
+ <link type="image/png" rel="image" href="http://s3.amazonaws.com/twitter_production/profile_images/64037782/dave-picture_normal.png"/>
112
+ <author>
113
+ <name>davidjrice (David Rice)</name>
114
+ <uri>http://twitter.com/davidjrice</uri>
115
+ </author>
116
+ </entry>
117
+ <entry>
118
+ <id>tag:search.twitter.com,2005:1061790777</id>
119
+ <published>2008-12-17T00:39:16Z</published>
120
+ <link type="text/html" rel="alternate" href="http://twitter.com/destraynor/statuses/1061790777"/>
121
+ <title>You'd need an evil mind to create a GMail labs plugin like "default reply to all" http://url.ie/1053 I'd say that has caused heartbreak</title>
122
+ <content type="html">You'd need an evil mind to create a GMail labs plugin like &amp;quot;default reply to all&amp;quot; &lt;a href="http://url.ie/1053"&gt;http://url.ie/1053&lt;/a&gt; I'd say that has caused heartbreak</content>
123
+ <updated>2008-12-17T00:39:16Z</updated>
124
+ <link type="image/png" rel="image" href="http://s3.amazonaws.com/twitter_production/profile_images/61452256/des-picture_normal.png"/>
125
+ <author>
126
+ <name>destraynor (Des Traynor)</name>
127
+ <uri>http://twitter.com/destraynor</uri>
128
+ </author>
129
+ </entry>
130
+ <entry>
131
+ <id>tag:search.twitter.com,2005:1061702216</id>
132
+ <published>2008-12-16T23:44:46Z</published>
133
+ <link type="text/html" rel="alternate" href="http://twitter.com/paulca/statuses/1061702216"/>
134
+ <title>Just read Roald Dahl's short story "Taste" for first time in a few years. Origin of the world 'claret': http://reallytinyurl.com/489</title>
135
+ <content type="html">Just read Roald Dahl's short story &amp;quot;Taste&amp;quot; for first time in a few years. Origin of the world 'claret': &lt;a href="http://reallytinyurl.com/489"&gt;http://reallytinyurl.com/489&lt;/a&gt;</content>
136
+ <updated>2008-12-16T23:44:46Z</updated>
137
+ <link type="image/png" rel="image" href="http://s3.amazonaws.com/twitter_production/profile_images/61449532/paul-picture_normal.png"/>
138
+ <author>
139
+ <name>paulca (Paul Campbell)</name>
140
+ <uri>http://twitter.com/paulca</uri>
141
+ </author>
142
+ </entry>
143
+ <entry>
144
+ <id>tag:search.twitter.com,2005:1061647813</id>
145
+ <published>2008-12-16T23:12:20Z</published>
146
+ <link type="text/html" rel="alternate" href="http://twitter.com/destraynor/statuses/1061647813"/>
147
+ <title>New Tesla does 0-60 in 3.6 seconds http://tinyurl.com/5rxhrj It's the Lotus Elise, but faster, and friendlier</title>
148
+ <content type="html">New Tesla does 0-60 in 3.6 seconds &lt;a href="http://tinyurl.com/5rxhrj"&gt;http://tinyurl.com/5rxhrj&lt;/a&gt; It's the Lotus Elise, but faster, and friendlier</content>
149
+ <updated>2008-12-16T23:12:20Z</updated>
150
+ <link type="image/png" rel="image" href="http://s3.amazonaws.com/twitter_production/profile_images/61452256/des-picture_normal.png"/>
151
+ <author>
152
+ <name>destraynor (Des Traynor)</name>
153
+ <uri>http://twitter.com/destraynor</uri>
154
+ </author>
155
+ </entry>
156
+ <entry>
157
+ <id>tag:search.twitter.com,2005:1061542523</id>
158
+ <published>2008-12-16T22:13:12Z</published>
159
+ <link type="text/html" rel="alternate" href="http://twitter.com/destraynor/statuses/1061542523"/>
160
+ <title>Some nice touches on this site: http://www.corporateriskwatch.com</title>
161
+ <content type="html">Some nice touches on this site: &lt;a href="http://www.corporateriskwatch.com"&gt;http://www.corporateriskwatch.com&lt;/a&gt;</content>
162
+ <updated>2008-12-16T22:13:12Z</updated>
163
+ <link type="image/png" rel="image" href="http://s3.amazonaws.com/twitter_production/profile_images/61452256/des-picture_normal.png"/>
164
+ <author>
165
+ <name>destraynor (Des Traynor)</name>
166
+ <uri>http://twitter.com/destraynor</uri>
167
+ </author>
168
+ </entry>
169
+ <entry>
170
+ <id>tag:search.twitter.com,2005:1061256927</id>
171
+ <published>2008-12-16T19:39:21Z</published>
172
+ <link type="text/html" rel="alternate" href="http://twitter.com/destraynor/statuses/1061256927"/>
173
+ <title>Performing a programmatic review for a computer science department in Dublin , this could be fun!</title>
174
+ <content type="html">Performing a programmatic review for a computer science department in Dublin , this could be fun!</content>
175
+ <updated>2008-12-16T19:39:21Z</updated>
176
+ <link type="image/png" rel="image" href="http://s3.amazonaws.com/twitter_production/profile_images/61452256/des-picture_normal.png"/>
177
+ <author>
178
+ <name>destraynor (Des Traynor)</name>
179
+ <uri>http://twitter.com/destraynor</uri>
180
+ </author>
181
+ </entry>
182
+ <entry>
183
+ <id>tag:search.twitter.com,2005:1061081990</id>
184
+ <published>2008-12-16T18:07:10Z</published>
185
+ <link type="text/html" rel="alternate" href="http://twitter.com/destraynor/statuses/1061081990"/>
186
+ <title>@Padday Subscribed. Cheers</title>
187
+ <content type="html">&lt;a href="http://twitter.com/Padday"&gt;@Padday&lt;/a&gt; Subscribed. Cheers</content>
188
+ <updated>2008-12-16T18:07:10Z</updated>
189
+ <link type="image/png" rel="image" href="http://s3.amazonaws.com/twitter_production/profile_images/61452256/des-picture_normal.png"/>
190
+ <link type="application/atom+xml" rel="thread" href="http://search.twitter.com/search/thread/1061081990.atom"/>
191
+ <author>
192
+ <name>destraynor (Des Traynor)</name>
193
+ <uri>http://twitter.com/destraynor</uri>
194
+ </author>
195
+ </entry>
196
+ <entry>
197
+ <id>tag:search.twitter.com,2005:1061077916</id>
198
+ <published>2008-12-16T18:05:04Z</published>
199
+ <link type="text/html" rel="alternate" href="http://twitter.com/destraynor/statuses/1061077916"/>
200
+ <title>@gizmomonster LOL that's exactly who I thought you were talking about.</title>
201
+ <content type="html">&lt;a href="http://twitter.com/gizmomonster"&gt;@gizmomonster&lt;/a&gt; LOL that's exactly who I thought you were talking about.</content>
202
+ <updated>2008-12-16T18:05:04Z</updated>
203
+ <link type="image/png" rel="image" href="http://s3.amazonaws.com/twitter_production/profile_images/61452256/des-picture_normal.png"/>
204
+ <author>
205
+ <name>destraynor (Des Traynor)</name>
206
+ <uri>http://twitter.com/destraynor</uri>
207
+ </author>
208
+ </entry>
209
+ </feed>
File without changes
@@ -0,0 +1,2 @@
1
+ be7bb22cc88ff98bfd4ffe3c45ad89a7f3f4e86a
2
+ 81d405cd1e3b4bb6c959419e57c2a5c7abe688cb
@@ -0,0 +1,92 @@
1
+ require 'rubygems'
2
+ require 'tinder'
3
+ require 'rio'
4
+ require 'hpricot'
5
+ require 'ostruct'
6
+ require 'time'
7
+ require 'htmlentities'
8
+ require 'digest/sha1'
9
+ require 'twitter2campfire/cli'
10
+
11
+ class Twitter2Campfire
12
+ attr_accessor :feed, :campfire, :room, :cachefile, :options
13
+
14
+ def initialize(feed,campfire,room, cachefile = 'archived_latest.txt', options = {})
15
+ self.feed = feed
16
+ self.campfire = campfire
17
+ self.room = campfire.find_room_by_name room
18
+ self.cachefile = cachefile
19
+ self.options = options
20
+ end
21
+
22
+ def raw_feed
23
+ @doc ||= Hpricot(rio(feed) > (string ||= ""))
24
+ end
25
+
26
+ def entries
27
+ (raw_feed/'entry').map do |e|
28
+ OpenStruct.new(
29
+ :from => (e/'name').inner_html,
30
+ :text => (e/'title').inner_html,
31
+ :link => (e/'link[@rel=alternate]').first['href'],
32
+ :checksum => Digest::SHA1.hexdigest((e/'title').inner_html),
33
+ :date => Time.parse((e/'updated').inner_html),
34
+ :twicture => "http://twictur.es/i/#{(e/'id').inner_html.split(':').last}.gif"
35
+ )
36
+ end
37
+ end
38
+
39
+ def latest_tweet
40
+ entries.first
41
+ end
42
+
43
+ def save_latest
44
+ f = File.exist?(cachefile)? File.open(cachefile, 'a') : File.new(cachefile, 'w')
45
+ f.write("\n#{new_archive_contents}")
46
+ end
47
+
48
+ def checksums
49
+ entries.map { |e| e.checksum }.to_a
50
+ end
51
+
52
+ def archived_checksums
53
+ archive_file.split("\n")
54
+ end
55
+
56
+ def new_checksums
57
+ checksums.flatten.uniq[0,1000]
58
+ end
59
+
60
+ def archive_file
61
+ begin
62
+ `touch #{cachefile}` unless File.exist?(cachefile)
63
+ return File.read(cachefile)
64
+ #rescue
65
+ # ''
66
+ end
67
+ end
68
+
69
+ def new_archive_contents
70
+ "#{new_checksums.join("\n")}"
71
+ end
72
+
73
+ def posts
74
+ entries.reject { |e| archived_checksums.include?(e.checksum) }
75
+ end
76
+
77
+ def coder
78
+ HTMLEntities.new
79
+ end
80
+
81
+ def publish_entries
82
+ posts.reverse.each do |post|
83
+ if options[:twicture]
84
+ room.speak post.twicture
85
+ else
86
+ room.speak "#{coder.decode(post.from)}: #{coder.decode(post.text)} #{post.link}"
87
+ end
88
+ end
89
+ save_latest
90
+ end
91
+
92
+ end
@@ -0,0 +1,17 @@
1
+ require 'thor'
2
+
3
+ class Twitter2Campfire
4
+ class CLI < Thor
5
+ desc "go /path/to/config/file", "Run twitter2campfire"
6
+ def go(path_to_config_file)
7
+ config = YAML.load(File.read(path_to_config_file))
8
+ cache_file = config['cache_file'] || "/var/lib/twitter2campfire.cache"
9
+
10
+ campfire = Tinder::Campfire.new config['subdomain'], :ssl => config['ssl']
11
+ campfire.login config['username'], config['password']
12
+ t = Twitter2Campfire.new(config['url'], campfire,
13
+ config['room'], cache_file, {})
14
+ t.publish_entries
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,98 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+ require 'twitter2campfire'
4
+
5
+ describe Twitter2Campfire, "with a cachefile" do
6
+ before(:each) do
7
+ campfire = mock(Tinder::Campfire)
8
+ campfire.stub!(:find_room_by_name)
9
+ @t = Twitter2Campfire.new('http://search.twitter.com/search.atom?q=from%3Apaulca+OR+from%3Aeoghanmccabe+OR+from%3Adestraynor+OR+from%3Adavidjrice', campfire, 'Contrast', 'fixtures/test_cachefile.txt')
10
+ @t.stub!(:raw_feed).and_return(Hpricot(File.open('fixtures/sample.xml')))
11
+ end
12
+
13
+ it "should get the latest tweet" do
14
+ @t.latest_tweet.text.should match(/svenfuchs/)
15
+ end
16
+
17
+ it "should get the latest entry" do
18
+ ((@t.raw_feed/'entry').first/'title').first.inner_html.should match(/svenfuchs/)
19
+ end
20
+
21
+
22
+ it "should get the archived checksums" do
23
+ @t.archived_checksums.should == ['be7bb22cc88ff98bfd4ffe3c45ad89a7f3f4e86a', '81d405cd1e3b4bb6c959419e57c2a5c7abe688cb']
24
+ end
25
+
26
+ it "should have all the entries" do
27
+ @t.entries.size.should == 15
28
+ end
29
+
30
+ it "have the first checksum" do
31
+ @t.checksums.first.should == 'be7bb22cc88ff98bfd4ffe3c45ad89a7f3f4e86a'
32
+ end
33
+
34
+ it "have the last checksum" do
35
+ @t.checksums.last.should == '81d405cd1e3b4bb6c959419e57c2a5c7abe688cb'
36
+ end
37
+
38
+ it "should have 15 checksums" do
39
+ @t.checksums.size.should == 15
40
+ end
41
+
42
+ it "should only have 13 posts" do
43
+ @t.posts.size.should == 13
44
+ end
45
+
46
+ it "should have a bunch of new checksums" do
47
+ @t.new_checksums.size.should == 15
48
+ end
49
+
50
+ it "should save the new archive contents" do
51
+ @t.new_archive_contents.split("\n").size.should == 15
52
+ end
53
+ end
54
+
55
+ describe Twitter2Campfire, "with a blank cachefile" do
56
+ before(:each) do
57
+ campfire = mock(Tinder::Campfire)
58
+ campfire.stub!(:find_room_by_name)
59
+ @t = Twitter2Campfire.new('http://search.twitter.com/search.atom?q=from%3Apaulca+OR+from%3Aeoghanmccabe+OR+from%3Adestraynor+OR+from%3Adavidjrice', campfire, 'Contrast', 'fixtures/test_blank_cachefile.txt')
60
+ @t.stub!(:raw_feed).and_return(Hpricot(File.open('fixtures/sample.xml')))
61
+ end
62
+
63
+ it "should get the latest tweet" do
64
+ @t.latest_tweet.text.should match(/svenfuchs/)
65
+ end
66
+
67
+ it "should get the latest entry" do
68
+ ((@t.raw_feed/'entry').first/'title').first.inner_html.should match(/svenfuchs/)
69
+ end
70
+
71
+ it "should get the archived checksums" do
72
+ @t.archived_checksums.should == []
73
+ end
74
+
75
+ it "should have all the entries" do
76
+ @t.entries.size.should == 15
77
+ end
78
+
79
+ it "have the first checksum" do
80
+ @t.checksums.first.should == 'be7bb22cc88ff98bfd4ffe3c45ad89a7f3f4e86a'
81
+ end
82
+
83
+ it "have the last checksum" do
84
+ @t.checksums.last.should == '81d405cd1e3b4bb6c959419e57c2a5c7abe688cb'
85
+ end
86
+
87
+ it "should have 15 checksums" do
88
+ @t.checksums.size.should == 15
89
+ end
90
+
91
+ it "should only have 13 posts" do
92
+ @t.posts.size.should == 15
93
+ end
94
+
95
+ it "should have a bunch of new checksums" do
96
+ @t.new_checksums.size.should == 15
97
+ end
98
+ end
@@ -0,0 +1,72 @@
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{twitter2campfire}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["James Golick"]
12
+ s.date = %q{2009-12-15}
13
+ s.default_executable = %q{twitter2campfire}
14
+ s.description = %q{found this code here: [http://github.com/paulca/twitter2campfire]. I just gemified it.}
15
+ s.email = %q{james@giraffesoft.ca}
16
+ s.executables = ["twitter2campfire"]
17
+ s.extra_rdoc_files = [
18
+ "README"
19
+ ]
20
+ s.files = [
21
+ ".gitignore",
22
+ "README",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "bin/twitter2campfire",
26
+ "examples/archived_latest.txt",
27
+ "examples/config.yml",
28
+ "fixtures/sample.xml",
29
+ "fixtures/test_blank_cachefile.txt",
30
+ "fixtures/test_cachefile.txt",
31
+ "lib/twitter2campfire.rb",
32
+ "lib/twitter2campfire/cli.rb",
33
+ "spec/twitter2campfire_spec.rb"
34
+ ]
35
+ s.homepage = %q{http://github.com/giraffesoft/twitter2campfire}
36
+ s.rdoc_options = ["--charset=UTF-8"]
37
+ s.require_paths = ["lib"]
38
+ s.rubygems_version = %q{1.3.5}
39
+ s.summary = %q{gemification of twitter2campfire script}
40
+ s.test_files = [
41
+ "spec/twitter2campfire_spec.rb"
42
+ ]
43
+
44
+ if s.respond_to? :specification_version then
45
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46
+ s.specification_version = 3
47
+
48
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
49
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
50
+ s.add_runtime_dependency(%q<rio>, [">= 0"])
51
+ s.add_runtime_dependency(%q<tinder>, [">= 0"])
52
+ s.add_runtime_dependency(%q<hpricot>, [">= 0"])
53
+ s.add_runtime_dependency(%q<htmlentities>, [">= 0"])
54
+ s.add_runtime_dependency(%q<thor>, [">= 0"])
55
+ else
56
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
57
+ s.add_dependency(%q<rio>, [">= 0"])
58
+ s.add_dependency(%q<tinder>, [">= 0"])
59
+ s.add_dependency(%q<hpricot>, [">= 0"])
60
+ s.add_dependency(%q<htmlentities>, [">= 0"])
61
+ s.add_dependency(%q<thor>, [">= 0"])
62
+ end
63
+ else
64
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
65
+ s.add_dependency(%q<rio>, [">= 0"])
66
+ s.add_dependency(%q<tinder>, [">= 0"])
67
+ s.add_dependency(%q<hpricot>, [">= 0"])
68
+ s.add_dependency(%q<htmlentities>, [">= 0"])
69
+ s.add_dependency(%q<thor>, [">= 0"])
70
+ end
71
+ end
72
+
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: twitter2campfire
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Golick
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-15 00:00:00 -08:00
13
+ default_executable: twitter2campfire
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.2.9
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rio
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: tinder
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: hpricot
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: htmlentities
57
+ type: :runtime
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
65
+ - !ruby/object:Gem::Dependency
66
+ name: thor
67
+ type: :runtime
68
+ version_requirement:
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: "0"
74
+ version:
75
+ description: "found this code here: [http://github.com/paulca/twitter2campfire]. I just gemified it."
76
+ email: james@giraffesoft.ca
77
+ executables:
78
+ - twitter2campfire
79
+ extensions: []
80
+
81
+ extra_rdoc_files:
82
+ - README
83
+ files:
84
+ - .gitignore
85
+ - README
86
+ - Rakefile
87
+ - VERSION
88
+ - bin/twitter2campfire
89
+ - examples/archived_latest.txt
90
+ - examples/config.yml
91
+ - fixtures/sample.xml
92
+ - fixtures/test_blank_cachefile.txt
93
+ - fixtures/test_cachefile.txt
94
+ - lib/twitter2campfire.rb
95
+ - lib/twitter2campfire/cli.rb
96
+ - spec/twitter2campfire_spec.rb
97
+ - twitter2campfire.gemspec
98
+ has_rdoc: true
99
+ homepage: http://github.com/giraffesoft/twitter2campfire
100
+ licenses: []
101
+
102
+ post_install_message:
103
+ rdoc_options:
104
+ - --charset=UTF-8
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: "0"
112
+ version:
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: "0"
118
+ version:
119
+ requirements: []
120
+
121
+ rubyforge_project:
122
+ rubygems_version: 1.3.5
123
+ signing_key:
124
+ specification_version: 3
125
+ summary: gemification of twitter2campfire script
126
+ test_files:
127
+ - spec/twitter2campfire_spec.rb