featherdust 0.0.1 → 0.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.
@@ -3,5 +3,8 @@ Manifest.txt
3
3
  README.txt
4
4
  Rakefile
5
5
  lib/featherdust.rb
6
+ lib/particle.rb
6
7
  test/cnn.xml
7
8
  test/test_featherdust.rb
9
+ test/test_particle.rb
10
+ todo.txt
@@ -5,7 +5,7 @@ require 'nokogiri'
5
5
  require 'net/http'
6
6
 
7
7
  class Featherdust
8
- VERSION = '0.0.1'
8
+ VERSION = '0.0.2'
9
9
 
10
10
  attr_accessor :username, :num_posts, :raw_posts, :posts, :url
11
11
  def initialize(username, num_posts = 20)
@@ -14,21 +14,19 @@ class Featherdust
14
14
  @raw_posts = Array.new
15
15
  end
16
16
 
17
- def self.run(username, number)
18
- twitter_list = Featherdust.new(username, number)
17
+ def self.run command
18
+ username = ARGV.shift
19
+ number = ARGV.shift
19
20
 
21
+ twitter_list = Featherdust.new(username, number)
22
+
20
23
  puts twitter_list.display_statuses
21
24
  end
22
-
23
- def url
24
- @url ||= Net::HTTP.get "twitter.com", "/statuses/user_timeline/#{@username}.xml?count=#{@num_posts}"
25
- end
26
-
25
+
27
26
  def get_statuses
28
27
  if is_twitter_up? != "true"
29
28
  raise "Twitter is having issues. Please check back later."
30
29
  else
31
- # status_list = Nokogiri::XML(Net::HTTP.get("twitter.com", "/statuses/user_timeline/#{@username}.xml?count=#{@num_posts}"))
32
30
  status_list = Nokogiri::XML(Net::HTTP.get("twitter.com", "/statuses/user_timeline/#{@username}.xml?count=#{@num_posts}"))
33
31
  status_list.xpath('/statuses/status').each do |statuses|
34
32
  status_hash = {}
@@ -55,9 +53,14 @@ class Featherdust
55
53
  tweets = get_statuses
56
54
  @posts = "<ul>"
57
55
  tweets.each do |tweet|
58
- @posts += "<li><p class=\"twitter_status\">#{tweet[:text]}</p>\n<span><a href=\"http://twitter.com/#{@username}/statuses/#{tweet[:id]}\" title=\"Status update on Twitter\"> on #{tweet[:created_at]}</a>\n</span></li>\n"
56
+ # TODO: This is really ugly, and I think it can be written better.
57
+ @posts += "
58
+ <li>
59
+ <p class=\"twitter_status\">#{tweet[:text]}</p>
60
+ <span><a href=\"http://twitter.com/#{@username}/statuses/#{tweet[:id]}\" title=\"Status update on Twitter\"> on #{tweet[:created_at]}</a></span>
61
+ </li>"
59
62
  end
60
- @posts += "</ul>"
63
+ @posts += "\n</ul>\n"
61
64
  end
62
65
 
63
66
  def is_twitter_up?
@@ -65,4 +68,6 @@ class Featherdust
65
68
  twitter_status.xpath("/ok").inner_text
66
69
  end
67
70
 
68
- end
71
+ end
72
+
73
+ Featherdust.run(ARGV) if $0 == __FILE__
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby -w
2
+
3
+ class Particle
4
+
5
+ ATTRIBUTES = [:created_at, :id, :text, :source, :truncated, :in_reply_to_status_id, :in_reply_to_user_id, :in_reply_to_screen_name, :favorited ]
6
+
7
+ ATTRIBUTES.each do |a|
8
+ attr_accessor a
9
+ end
10
+
11
+ def initialize(song_data)
12
+ ATTRIBUTES.each do |attr|
13
+ self.send("#{attr}=", (song_data[attr] || ""))
14
+ end
15
+ end
16
+ end
@@ -440,4 +440,4 @@
440
440
  <followers_count>14810</followers_count>
441
441
  </user>
442
442
  </status>
443
- </statuses>
443
+ </statuses>
@@ -30,20 +30,263 @@ class TestFeatherdust < Test::Unit::TestCase
30
30
  assert_equal expected, actual
31
31
  end
32
32
 
33
- def test_url_live
34
- assert @live_test.url
35
- end
36
-
37
- def test_url
38
- assert @twitter_account.url
39
- end
40
-
41
33
  def test_get_statuses
42
- assert @twitter_account.get_statuses
34
+ actual = @twitter_account.get_statuses
35
+ expected = [{:location=>"",
36
+ :source=>"<a href=\"http://twitterfeed.com\">twitterfeed</a>",
37
+ :url=>"http://www.cnn.com",
38
+ :profile_image_url=>
39
+ "http://s3.amazonaws.com/twitter_production/profile_images/67228129/icon.cnn_normal.png",
40
+ :in_reply_to_status_id=>"",
41
+ :in_reply_to_screen_name=>"",
42
+ :protected=>"false",
43
+ :in_reply_to_user_id=>"",
44
+ :created_at=>"Thu Dec 18 13:48:21 +0000 2008",
45
+ :name=>"CNN.com",
46
+ :user_id=>"759251",
47
+ :followers_count=>"14965",
48
+ :truncated=>"false",
49
+ :description=>
50
+ "Breaking News, U.S., World, Weather, Entertainment & Video News",
51
+ :text=>
52
+ "20 Iraqi Interior Ministry officers arrested http://tinyurl.com/4xghtt",
53
+ :favorited=>"false",
54
+ :id=>"1064896431",
55
+ :screen_name=>"cnn"},
56
+ {:location=>"",
57
+ :source=>"<a href=\"http://twitterfeed.com\">twitterfeed</a>",
58
+ :url=>"http://www.cnn.com",
59
+ :profile_image_url=>
60
+ "http://s3.amazonaws.com/twitter_production/profile_images/67228129/icon.cnn_normal.png",
61
+ :in_reply_to_status_id=>"",
62
+ :in_reply_to_screen_name=>"",
63
+ :protected=>"false",
64
+ :in_reply_to_user_id=>"",
65
+ :created_at=>"Thu Dec 18 10:49:17 +0000 2008",
66
+ :name=>"CNN.com",
67
+ :user_id=>"759251",
68
+ :followers_count=>"14955",
69
+ :truncated=>"false",
70
+ :description=>
71
+ "Breaking News, U.S., World, Weather, Entertainment & Video News",
72
+ :text=>"Bagosora guilty of Rwanda genocide http://tinyurl.com/3mw72t",
73
+ :favorited=>"false",
74
+ :id=>"1064690521",
75
+ :screen_name=>"cnn"},
76
+ {:location=>"",
77
+ :source=>"<a href=\"http://twitterfeed.com\">twitterfeed</a>",
78
+ :url=>"http://www.cnn.com",
79
+ :profile_image_url=>
80
+ "http://s3.amazonaws.com/twitter_production/profile_images/67228129/icon.cnn_normal.png",
81
+ :in_reply_to_status_id=>"",
82
+ :in_reply_to_screen_name=>"",
83
+ :protected=>"false",
84
+ :in_reply_to_user_id=>"",
85
+ :created_at=>"Thu Dec 18 09:48:46 +0000 2008",
86
+ :name=>"CNN.com",
87
+ :user_id=>"759251",
88
+ :followers_count=>"14954",
89
+ :truncated=>"false",
90
+ :description=>
91
+ "Breaking News, U.S., World, Weather, Entertainment & Video News",
92
+ :text=>"Obama's inaugural choice ignites outrage http://tinyurl.com/52ojol",
93
+ :favorited=>"false",
94
+ :id=>"1064634944",
95
+ :screen_name=>"cnn"},
96
+ {:location=>"",
97
+ :source=>"<a href=\"http://twitterfeed.com\">twitterfeed</a>",
98
+ :url=>"http://www.cnn.com",
99
+ :profile_image_url=>
100
+ "http://s3.amazonaws.com/twitter_production/profile_images/67228129/icon.cnn_normal.png",
101
+ :in_reply_to_status_id=>"",
102
+ :in_reply_to_screen_name=>"",
103
+ :protected=>"false",
104
+ :in_reply_to_user_id=>"",
105
+ :created_at=>"Thu Dec 18 09:48:38 +0000 2008",
106
+ :name=>"CNN.com",
107
+ :user_id=>"759251",
108
+ :followers_count=>"14954",
109
+ :truncated=>"false",
110
+ :description=>
111
+ "Breaking News, U.S., World, Weather, Entertainment & Video News",
112
+ :text=>
113
+ "Alec Baldwin on divorce, custody and Palin http://tinyurl.com/3e6u37",
114
+ :favorited=>"false",
115
+ :id=>"1064634845",
116
+ :screen_name=>"cnn"},
117
+ {:location=>"",
118
+ :source=>"<a href=\"http://twitterfeed.com\">twitterfeed</a>",
119
+ :url=>"http://www.cnn.com",
120
+ :profile_image_url=>
121
+ "http://s3.amazonaws.com/twitter_production/profile_images/67228129/icon.cnn_normal.png",
122
+ :in_reply_to_status_id=>"",
123
+ :in_reply_to_screen_name=>"",
124
+ :protected=>"false",
125
+ :in_reply_to_user_id=>"",
126
+ :created_at=>"Thu Dec 18 08:49:04 +0000 2008",
127
+ :name=>"CNN.com",
128
+ :user_id=>"759251",
129
+ :followers_count=>"14955",
130
+ :truncated=>"false",
131
+ :description=>
132
+ "Breaking News, U.S., World, Weather, Entertainment & Video News",
133
+ :text=>"Holiday health concerns may just be myths http://tinyurl.com/3zx4pd",
134
+ :favorited=>"false",
135
+ :id=>"1064580674",
136
+ :screen_name=>"cnn"},
137
+ {:location=>"",
138
+ :source=>"<a href=\"http://twitterfeed.com\">twitterfeed</a>",
139
+ :url=>"http://www.cnn.com",
140
+ :profile_image_url=>
141
+ "http://s3.amazonaws.com/twitter_production/profile_images/67228129/icon.cnn_normal.png",
142
+ :in_reply_to_status_id=>"",
143
+ :in_reply_to_screen_name=>"",
144
+ :protected=>"false",
145
+ :in_reply_to_user_id=>"",
146
+ :created_at=>"Thu Dec 18 07:48:08 +0000 2008",
147
+ :name=>"CNN.com",
148
+ :user_id=>"759251",
149
+ :followers_count=>"14954",
150
+ :truncated=>"false",
151
+ :description=>
152
+ "Breaking News, U.S., World, Weather, Entertainment & Video News",
153
+ :text=>
154
+ "Exxon Mobil to pay $6.1 million for air pollution http://tinyurl.com/48ohph",
155
+ :favorited=>"false",
156
+ :id=>"1064525536",
157
+ :screen_name=>"cnn"},
158
+ {:location=>"",
159
+ :source=>"<a href=\"http://twitterfeed.com\">twitterfeed</a>",
160
+ :url=>"http://www.cnn.com",
161
+ :profile_image_url=>
162
+ "http://s3.amazonaws.com/twitter_production/profile_images/67228129/icon.cnn_normal.png",
163
+ :in_reply_to_status_id=>"",
164
+ :in_reply_to_screen_name=>"",
165
+ :protected=>"false",
166
+ :in_reply_to_user_id=>"",
167
+ :created_at=>"Thu Dec 18 04:48:37 +0000 2008",
168
+ :name=>"CNN.com",
169
+ :user_id=>"759251",
170
+ :followers_count=>"14947",
171
+ :truncated=>"false",
172
+ :description=>
173
+ "Breaking News, U.S., World, Weather, Entertainment & Video News",
174
+ :text=>
175
+ "Rice talks successes, failures of past 8 years http://tinyurl.com/4uo83q",
176
+ :favorited=>"false",
177
+ :id=>"1064329837",
178
+ :screen_name=>"cnn"},
179
+ {:location=>"",
180
+ :source=>"<a href=\"http://twitterfeed.com\">twitterfeed</a>",
181
+ :url=>"http://www.cnn.com",
182
+ :profile_image_url=>
183
+ "http://s3.amazonaws.com/twitter_production/profile_images/67228129/icon.cnn_normal.png",
184
+ :in_reply_to_status_id=>"",
185
+ :in_reply_to_screen_name=>"",
186
+ :protected=>"false",
187
+ :in_reply_to_user_id=>"",
188
+ :created_at=>"Thu Dec 18 04:48:35 +0000 2008",
189
+ :name=>"CNN.com",
190
+ :user_id=>"759251",
191
+ :followers_count=>"14947",
192
+ :truncated=>"false",
193
+ :description=>
194
+ "Breaking News, U.S., World, Weather, Entertainment & Video News",
195
+ :text=>
196
+ "Credit card holders livid about 'rate-jacking' http://tinyurl.com/3jejsc",
197
+ :favorited=>"false",
198
+ :id=>"1064329783",
199
+ :screen_name=>"cnn"},
200
+ {:location=>"",
201
+ :source=>"<a href=\"http://twitterfeed.com\">twitterfeed</a>",
202
+ :url=>"http://www.cnn.com",
203
+ :profile_image_url=>
204
+ "http://s3.amazonaws.com/twitter_production/profile_images/67228129/icon.cnn_normal.png",
205
+ :in_reply_to_status_id=>"",
206
+ :in_reply_to_screen_name=>"",
207
+ :protected=>"false",
208
+ :in_reply_to_user_id=>"",
209
+ :created_at=>"Thu Dec 18 02:48:53 +0000 2008",
210
+ :name=>"CNN.com",
211
+ :user_id=>"759251",
212
+ :followers_count=>"14933",
213
+ :truncated=>"false",
214
+ :description=>
215
+ "Breaking News, U.S., World, Weather, Entertainment & Video News",
216
+ :text=>"Brown: Obama should be more open to press http://tinyurl.com/4avj8n",
217
+ :favorited=>"false",
218
+ :id=>"1064150989",
219
+ :screen_name=>"cnn"},
220
+ {:location=>"",
221
+ :source=>"<a href=\"http://twitterfeed.com\">twitterfeed</a>",
222
+ :url=>"http://www.cnn.com",
223
+ :profile_image_url=>
224
+ "http://s3.amazonaws.com/twitter_production/profile_images/67228129/icon.cnn_normal.png",
225
+ :in_reply_to_status_id=>"",
226
+ :in_reply_to_screen_name=>"",
227
+ :protected=>"false",
228
+ :in_reply_to_user_id=>"",
229
+ :created_at=>"Wed Dec 17 23:48:50 +0000 2008",
230
+ :name=>"CNN.com",
231
+ :user_id=>"759251",
232
+ :followers_count=>"14925",
233
+ :truncated=>"false",
234
+ :description=>
235
+ "Breaking News, U.S., World, Weather, Entertainment & Video News",
236
+ :text=>
237
+ "Walsh's legacy -- awareness of danger to kids http://tinyurl.com/495kwp",
238
+ :favorited=>"false",
239
+ :id=>"1063867194",
240
+ :screen_name=>"cnn"}]
241
+ assert_equal expected, actual
43
242
  end
44
243
 
45
244
  def test_display_statuses
46
- assert @twitter_account.display_statuses
245
+ actual = @twitter_account.display_statuses
246
+ expected = "<ul>
247
+ <li>
248
+ <p class=\"twitter_status\">20 Iraqi Interior Ministry officers arrested http://tinyurl.com/4xghtt</p>
249
+ <span><a href=\"http://twitter.com/cnn/statuses/1064896431\" title=\"Status update on Twitter\"> on Thu Dec 18 13:48:21 +0000 2008</a></span>
250
+ </li>
251
+ <li>
252
+ <p class=\"twitter_status\">Bagosora guilty of Rwanda genocide http://tinyurl.com/3mw72t</p>
253
+ <span><a href=\"http://twitter.com/cnn/statuses/1064690521\" title=\"Status update on Twitter\"> on Thu Dec 18 10:49:17 +0000 2008</a></span>
254
+ </li>
255
+ <li>
256
+ <p class=\"twitter_status\">Obama's inaugural choice ignites outrage http://tinyurl.com/52ojol</p>
257
+ <span><a href=\"http://twitter.com/cnn/statuses/1064634944\" title=\"Status update on Twitter\"> on Thu Dec 18 09:48:46 +0000 2008</a></span>
258
+ </li>
259
+ <li>
260
+ <p class=\"twitter_status\">Alec Baldwin on divorce, custody and Palin http://tinyurl.com/3e6u37</p>
261
+ <span><a href=\"http://twitter.com/cnn/statuses/1064634845\" title=\"Status update on Twitter\"> on Thu Dec 18 09:48:38 +0000 2008</a></span>
262
+ </li>
263
+ <li>
264
+ <p class=\"twitter_status\">Holiday health concerns may just be myths http://tinyurl.com/3zx4pd</p>
265
+ <span><a href=\"http://twitter.com/cnn/statuses/1064580674\" title=\"Status update on Twitter\"> on Thu Dec 18 08:49:04 +0000 2008</a></span>
266
+ </li>
267
+ <li>
268
+ <p class=\"twitter_status\">Exxon Mobil to pay $6.1 million for air pollution http://tinyurl.com/48ohph</p>
269
+ <span><a href=\"http://twitter.com/cnn/statuses/1064525536\" title=\"Status update on Twitter\"> on Thu Dec 18 07:48:08 +0000 2008</a></span>
270
+ </li>
271
+ <li>
272
+ <p class=\"twitter_status\">Rice talks successes, failures of past 8 years http://tinyurl.com/4uo83q</p>
273
+ <span><a href=\"http://twitter.com/cnn/statuses/1064329837\" title=\"Status update on Twitter\"> on Thu Dec 18 04:48:37 +0000 2008</a></span>
274
+ </li>
275
+ <li>
276
+ <p class=\"twitter_status\">Credit card holders livid about 'rate-jacking' http://tinyurl.com/3jejsc</p>
277
+ <span><a href=\"http://twitter.com/cnn/statuses/1064329783\" title=\"Status update on Twitter\"> on Thu Dec 18 04:48:35 +0000 2008</a></span>
278
+ </li>
279
+ <li>
280
+ <p class=\"twitter_status\">Brown: Obama should be more open to press http://tinyurl.com/4avj8n</p>
281
+ <span><a href=\"http://twitter.com/cnn/statuses/1064150989\" title=\"Status update on Twitter\"> on Thu Dec 18 02:48:53 +0000 2008</a></span>
282
+ </li>
283
+ <li>
284
+ <p class=\"twitter_status\">Walsh's legacy -- awareness of danger to kids http://tinyurl.com/495kwp</p>
285
+ <span><a href=\"http://twitter.com/cnn/statuses/1063867194\" title=\"Status update on Twitter\"> on Wed Dec 17 23:48:50 +0000 2008</a></span>
286
+ </li>
287
+ </ul>
288
+ "
289
+ assert_equal expected, actual
47
290
  end
48
291
 
49
292
  end
File without changes
@@ -0,0 +1,23 @@
1
+ FEATHERDUST: A Twitter gem.
2
+
3
+ TODO:
4
+
5
+ Write Tests that fail!
6
+ Make the tests pass!
7
+ (Ok ... enough of being snarky.)
8
+
9
+ XML Parser
10
+ - take in a username
11
+ base output option
12
+ - limit output based on optional number of status updates (default is 10)
13
+ - HTML Unordered List
14
+ regex to detect/add links
15
+ take in options block
16
+ advanced output methods
17
+ - div vs list (esp. if requested updates number is 1)
18
+ - DL
19
+ - others?
20
+ headings
21
+ default styles?
22
+ examples
23
+ documentation
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: featherdust
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Tierney
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-17 00:00:00 -08:00
12
+ date: 2008-12-18 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -43,14 +43,18 @@ extra_rdoc_files:
43
43
  - History.txt
44
44
  - Manifest.txt
45
45
  - README.txt
46
+ - todo.txt
46
47
  files:
47
48
  - History.txt
48
49
  - Manifest.txt
49
50
  - README.txt
50
51
  - Rakefile
51
52
  - lib/featherdust.rb
53
+ - lib/particle.rb
52
54
  - test/cnn.xml
53
55
  - test/test_featherdust.rb
56
+ - test/test_particle.rb
57
+ - todo.txt
54
58
  has_rdoc: true
55
59
  homepage: http://rubyforge.org/projects/uwruby
56
60
  post_install_message:
@@ -80,3 +84,4 @@ specification_version: 2
80
84
  summary: Featherdust is a simple Twitter gem that grabs and parses data via the Twitter API
81
85
  test_files:
82
86
  - test/test_featherdust.rb
87
+ - test/test_particle.rb