weary 0.2.1 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -15,12 +15,33 @@ Browse the documentation here: [http://rdoc.info/projects/mwunsch/weary](http://
15
15
 
16
16
  + Crack >= 0.1.2
17
17
  + Nokogiri >= 1.3.1 (if you want to use the #search method)
18
+ + Rspec (for running the tests)
18
19
 
19
20
  ## Installation
20
21
 
21
22
  You do have Rubygems right?
22
23
 
23
24
  sudo gem install weary
25
+
26
+ ## Quick Start
27
+
28
+ # http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-users%C2%A0show
29
+ class TwitterUser
30
+ extend Weary
31
+
32
+ on_domain "http://twitter.com/users/"
33
+
34
+ get "show" do |resource|
35
+ resource.with = [:id, :user_id, :screen_name]
36
+ end
37
+ end
38
+
39
+ user = TwitterUser.new
40
+ me = user.show(:id => "markwunsch")
41
+ puts me["name"]
42
+
43
+ Hey, that's me!
44
+
24
45
 
25
46
  ## How it works
26
47
 
@@ -55,6 +76,22 @@ So this would form a method:
55
76
 
56
77
  That method would return a Weary::Response object that you could then parse or examine.
57
78
 
79
+ ### Parsing the Body
80
+
81
+ Once you make your request with the fancy method that Weary created for you, you can do stuff with what it returns...which could be a good reason you're using Weary in the first place. Let's look at the above example:
82
+
83
+ x = Foo.new
84
+ y = x.foo(:id => "mwunsch", :bar => 123).parse
85
+ y["foos"]["user"]
86
+
87
+ Weary parses with Crack. If you have some XML or HTML and want to search it with XPath or CSS selectors, you can use Nokogiri magic:
88
+
89
+ x = Foo.new
90
+ y = x.foo(:id => "mwunsch", :bar => 123)
91
+ y.search("foos > user")
92
+
93
+ If you try to #search a non-XMLesque document, Weary will just throw the selector away and use the #parse method.
94
+
58
95
  ### Shortcuts
59
96
 
60
97
  Of course, you don't always have to use `declare`; that is a little too ambiguous. You can also use `get`, `post`, `delete`, etc. Those do the obvious.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.3
@@ -27,15 +27,15 @@ module Weary
27
27
 
28
28
  def format=(type)
29
29
  @format = case type
30
- when 'text/xml', 'application/xml'
31
- :xml
32
- when 'application/json', 'text/json', 'application/javascript', 'text/javascript'
30
+ when *ContentTypes[:json]
33
31
  :json
34
- when 'text/html'
32
+ when *ContentTypes[:xml]
33
+ :xml
34
+ when *ContentTypes[:html]
35
35
  :html
36
- when 'application/x-yaml', 'text/yaml'
36
+ when *ContentTypes[:yaml]
37
37
  :yaml
38
- when 'text/plain'
38
+ when *ContentTypes[:plain]
39
39
  :plain
40
40
  else
41
41
  nil
@@ -66,11 +66,18 @@ module Weary
66
66
  end
67
67
  end
68
68
 
69
+ def [](key)
70
+ parse[key]
71
+ end
72
+
69
73
  # Search the body with a CSS/XPath selector with Nokogiri
70
74
  def search(selector)
71
- raise ArgumentError, "Search can only be used with an XML or HTML document." unless @format != (:xml || :html)
72
- doc = Nokogiri.parse(@body)
73
- doc.search(selector)
75
+ if @format == (:xml || :html)
76
+ doc = Nokogiri.parse(@body)
77
+ doc.search(selector)
78
+ else
79
+ parse
80
+ end
74
81
  end
75
82
 
76
83
  private
@@ -0,0 +1,11 @@
1
+ ---
2
+ repository:
3
+ :description: Ruby on Rails
4
+ :owner: rails
5
+ :forks: 600
6
+ :name: rails
7
+ :private: false
8
+ :url: http://github.com/rails/rails
9
+ :fork: false
10
+ :watchers: 3743
11
+ :homepage: http://rubyonrails.org
@@ -0,0 +1,763 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <statuses type="array">
3
+ <status>
4
+ <created_at>Tue Jun 16 01:42:52 +0000 2009</created_at>
5
+ <id>2186350626</id>
6
+ <text>RT @Dean_L #TCOT Refuting Obama with Democrat quotes http://tinyurl.com/knrz5l</text>
7
+ <source>web</source>
8
+ <truncated>false</truncated>
9
+ <in_reply_to_status_id></in_reply_to_status_id>
10
+ <in_reply_to_user_id></in_reply_to_user_id>
11
+ <favorited>false</favorited>
12
+ <in_reply_to_screen_name></in_reply_to_screen_name>
13
+ <user>
14
+ <id>27329169</id>
15
+ <name>Stella Y.</name>
16
+ <screen_name>stellacotton</screen_name>
17
+ <location> AZ</location>
18
+ <description>An enigmatic figure about whom little is known, but rumors abound...</description>
19
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/113289934/12696-LARGE-img_1701_normal.jpg</profile_image_url>
20
+ <url>http://tinyurl.com/cwt77k</url>
21
+ <protected>false</protected>
22
+ <followers_count>1557</followers_count>
23
+ <profile_background_color>9AE4E8</profile_background_color>
24
+ <profile_text_color>333333</profile_text_color>
25
+ <profile_link_color>0084B4</profile_link_color>
26
+ <profile_sidebar_fill_color>9aa9bc</profile_sidebar_fill_color>
27
+ <profile_sidebar_border_color>c4d0d4</profile_sidebar_border_color>
28
+ <friends_count>1450</friends_count>
29
+ <created_at>Sat Mar 28 23:04:35 +0000 2009</created_at>
30
+ <favourites_count>70</favourites_count>
31
+ <utc_offset>-28800</utc_offset>
32
+ <time_zone>Pacific Time (US &amp; Canada)</time_zone>
33
+ <profile_background_image_url>http://s3.amazonaws.com/twitter_production/profile_background_images/7323604/sky.jpg</profile_background_image_url>
34
+ <profile_background_tile>true</profile_background_tile>
35
+ <statuses_count>2139</statuses_count>
36
+ <notifications></notifications>
37
+ <verified_profile>false</verified_profile>
38
+ <following></following>
39
+ </user>
40
+ </status>
41
+ <status>
42
+ <created_at>Tue Jun 16 01:42:52 +0000 2009</created_at>
43
+ <id>2186350619</id>
44
+ <text>2 and a half hours until I am released to retire for the evening... somebody help me pass the time, there are no sports on tonight... FML</text>
45
+ <source>web</source>
46
+ <truncated>false</truncated>
47
+ <in_reply_to_status_id></in_reply_to_status_id>
48
+ <in_reply_to_user_id></in_reply_to_user_id>
49
+ <favorited>false</favorited>
50
+ <in_reply_to_screen_name></in_reply_to_screen_name>
51
+ <user>
52
+ <id>22860561</id>
53
+ <name>Anthony D. Williams</name>
54
+ <screen_name>DatBoiTony</screen_name>
55
+ <location>Austin, TX</location>
56
+ <description>Just tryna live... AIM: AphrozBraidz</description>
57
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/254810199/fatherandson2_normal.jpg</profile_image_url>
58
+ <url>http://www.xanga.com/datboitony</url>
59
+ <protected>false</protected>
60
+ <followers_count>154</followers_count>
61
+ <profile_background_color>000000</profile_background_color>
62
+ <profile_text_color>e4b10c</profile_text_color>
63
+ <profile_link_color>e4b10c</profile_link_color>
64
+ <profile_sidebar_fill_color>252429</profile_sidebar_fill_color>
65
+ <profile_sidebar_border_color>0cbae4</profile_sidebar_border_color>
66
+ <friends_count>153</friends_count>
67
+ <created_at>Thu Mar 05 01:33:20 +0000 2009</created_at>
68
+ <favourites_count>43</favourites_count>
69
+ <utc_offset>-21600</utc_offset>
70
+ <time_zone>Central Time (US &amp; Canada)</time_zone>
71
+ <profile_background_image_url>http://s3.amazonaws.com/twitter_production/profile_background_images/10423286/dbt_blkbg.jpg</profile_background_image_url>
72
+ <profile_background_tile>true</profile_background_tile>
73
+ <statuses_count>743</statuses_count>
74
+ <notifications></notifications>
75
+ <verified_profile>false</verified_profile>
76
+ <following></following>
77
+ </user>
78
+ </status>
79
+ <status>
80
+ <created_at>Tue Jun 16 01:42:52 +0000 2009</created_at>
81
+ <id>2186350609</id>
82
+ <text>Incubus- Black Hearts Inertia &amp;lt;3 i love it</text>
83
+ <source>&lt;a href=&quot;http://twitterfox.net/&quot;&gt;TwitterFox&lt;/a&gt;</source>
84
+ <truncated>false</truncated>
85
+ <in_reply_to_status_id></in_reply_to_status_id>
86
+ <in_reply_to_user_id></in_reply_to_user_id>
87
+ <favorited>false</favorited>
88
+ <in_reply_to_screen_name></in_reply_to_screen_name>
89
+ <user>
90
+ <id>18532576</id>
91
+ <name>Camila Alejandra </name>
92
+ <screen_name>camilalovescake</screen_name>
93
+ <location>Chile :3</location>
94
+ <description>my name is camila, i'm 16 3</description>
95
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/147195416/_a_a_a_a__11__normal.JPG</profile_image_url>
96
+ <url>http://www.myspace.com/fuckxfuck</url>
97
+ <protected>false</protected>
98
+ <followers_count>43</followers_count>
99
+ <profile_background_color>1A1B1F</profile_background_color>
100
+ <profile_text_color>c0cbce</profile_text_color>
101
+ <profile_link_color>c0cbce</profile_link_color>
102
+ <profile_sidebar_fill_color>ffffff</profile_sidebar_fill_color>
103
+ <profile_sidebar_border_color>ffffff</profile_sidebar_border_color>
104
+ <friends_count>101</friends_count>
105
+ <created_at>Thu Jan 01 18:28:41 +0000 2009</created_at>
106
+ <favourites_count>6</favourites_count>
107
+ <utc_offset>-14400</utc_offset>
108
+ <time_zone>Santiago</time_zone>
109
+ <profile_background_image_url>http://s3.amazonaws.com/twitter_production/profile_background_images/18062839/156706591_97a4eb232d_o.jpg</profile_background_image_url>
110
+ <profile_background_tile>true</profile_background_tile>
111
+ <statuses_count>94</statuses_count>
112
+ <notifications></notifications>
113
+ <verified_profile>false</verified_profile>
114
+ <following></following>
115
+ </user>
116
+ </status>
117
+ <status>
118
+ <created_at>Tue Jun 16 01:42:52 +0000 2009</created_at>
119
+ <id>2186350605</id>
120
+ <text>left me hanging. =l</text>
121
+ <source>web</source>
122
+ <truncated>false</truncated>
123
+ <in_reply_to_status_id></in_reply_to_status_id>
124
+ <in_reply_to_user_id></in_reply_to_user_id>
125
+ <favorited>false</favorited>
126
+ <in_reply_to_screen_name></in_reply_to_screen_name>
127
+ <user>
128
+ <id>30800971</id>
129
+ <name>joan lopez</name>
130
+ <screen_name>roanimic</screen_name>
131
+ <location></location>
132
+ <description>You'll be surprised to know how far you can go from the point where you thought it was the end. </description>
133
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/256274155/quest_136_normal.jpg</profile_image_url>
134
+ <url></url>
135
+ <protected>false</protected>
136
+ <followers_count>6</followers_count>
137
+ <profile_background_color>843ecc</profile_background_color>
138
+ <profile_text_color>c819c2</profile_text_color>
139
+ <profile_link_color>2a92bb</profile_link_color>
140
+ <profile_sidebar_fill_color>b8b9ac</profile_sidebar_fill_color>
141
+ <profile_sidebar_border_color>55c2e7</profile_sidebar_border_color>
142
+ <friends_count>7</friends_count>
143
+ <created_at>Mon Apr 13 03:49:37 +0000 2009</created_at>
144
+ <favourites_count>33</favourites_count>
145
+ <utc_offset>-18000</utc_offset>
146
+ <time_zone>Quito</time_zone>
147
+ <profile_background_image_url>http://s3.amazonaws.com/twitter_production/profile_background_images/8399977/quotes.png</profile_background_image_url>
148
+ <profile_background_tile>true</profile_background_tile>
149
+ <statuses_count>194</statuses_count>
150
+ <notifications></notifications>
151
+ <verified_profile>false</verified_profile>
152
+ <following></following>
153
+ </user>
154
+ </status>
155
+ <status>
156
+ <created_at>Tue Jun 16 01:42:52 +0000 2009</created_at>
157
+ <id>2186350601</id>
158
+ <text>These slow songs remind me of when I was in middle school</text>
159
+ <source>&lt;a href=&quot;http://help.twitter.com/index.php?pg=kb.page&amp;id=75&quot;&gt;txt&lt;/a&gt;</source>
160
+ <truncated>false</truncated>
161
+ <in_reply_to_status_id></in_reply_to_status_id>
162
+ <in_reply_to_user_id></in_reply_to_user_id>
163
+ <favorited>false</favorited>
164
+ <in_reply_to_screen_name></in_reply_to_screen_name>
165
+ <user>
166
+ <id>15595386</id>
167
+ <name>mara [von]</name>
168
+ <screen_name>maravon</screen_name>
169
+ <location>Halfway between the gutters an</location>
170
+ <description></description>
171
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/206247801/mo2_normal.jpg</profile_image_url>
172
+ <url>http://www.youtube.com/iamakinkychicken</url>
173
+ <protected>false</protected>
174
+ <followers_count>265</followers_count>
175
+ <profile_background_color>000000</profile_background_color>
176
+ <profile_text_color>808080</profile_text_color>
177
+ <profile_link_color>c01117</profile_link_color>
178
+ <profile_sidebar_fill_color>20361b</profile_sidebar_fill_color>
179
+ <profile_sidebar_border_color>000000</profile_sidebar_border_color>
180
+ <friends_count>126</friends_count>
181
+ <created_at>Fri Jul 25 07:17:07 +0000 2008</created_at>
182
+ <favourites_count>0</favourites_count>
183
+ <utc_offset>-18000</utc_offset>
184
+ <time_zone>Eastern Time (US &amp; Canada)</time_zone>
185
+ <profile_background_image_url>http://s3.amazonaws.com/twitter_production/profile_background_images/17114648/nvboombox.br.jpg</profile_background_image_url>
186
+ <profile_background_tile>false</profile_background_tile>
187
+ <statuses_count>1759</statuses_count>
188
+ <notifications></notifications>
189
+ <verified_profile>false</verified_profile>
190
+ <following></following>
191
+ </user>
192
+ </status>
193
+ <status>
194
+ <created_at>Tue Jun 16 01:42:52 +0000 2009</created_at>
195
+ <id>2186350597</id>
196
+ <text>&#20170;&#26085;&#12399;&#26257;&#12356;&#65288;&#65307;&#180;&#1076;&#65344;&#65289;</text>
197
+ <source>&lt;a href=&quot;http://movatwitter.jp/&quot;&gt;movatwitter&lt;/a&gt;</source>
198
+ <truncated>false</truncated>
199
+ <in_reply_to_status_id></in_reply_to_status_id>
200
+ <in_reply_to_user_id></in_reply_to_user_id>
201
+ <favorited>false</favorited>
202
+ <in_reply_to_screen_name></in_reply_to_screen_name>
203
+ <user>
204
+ <id>39979196</id>
205
+ <name>&#12411;&#12398;&#12473;&#12465;</name>
206
+ <screen_name>hono10</screen_name>
207
+ <location></location>
208
+ <description></description>
209
+ <profile_image_url>http://static.twitter.com/images/default_profile_normal.png</profile_image_url>
210
+ <url></url>
211
+ <protected>false</protected>
212
+ <followers_count>3</followers_count>
213
+ <profile_background_color>BADFCD</profile_background_color>
214
+ <profile_text_color>0C3E53</profile_text_color>
215
+ <profile_link_color>FF0000</profile_link_color>
216
+ <profile_sidebar_fill_color>FFF7CC</profile_sidebar_fill_color>
217
+ <profile_sidebar_border_color>F2E195</profile_sidebar_border_color>
218
+ <friends_count>5</friends_count>
219
+ <created_at>Thu May 14 12:04:13 +0000 2009</created_at>
220
+ <favourites_count>0</favourites_count>
221
+ <utc_offset>-36000</utc_offset>
222
+ <time_zone>Hawaii</time_zone>
223
+ <profile_background_image_url>http://static.twitter.com/images/themes/theme12/bg.gif</profile_background_image_url>
224
+ <profile_background_tile>false</profile_background_tile>
225
+ <statuses_count>52</statuses_count>
226
+ <notifications></notifications>
227
+ <verified_profile>false</verified_profile>
228
+ <following></following>
229
+ </user>
230
+ </status>
231
+ <status>
232
+ <created_at>Tue Jun 16 01:42:52 +0000 2009</created_at>
233
+ <id>2186350596</id>
234
+ <text>http://www.youtube.com/user/narutorulesya m</text>
235
+ <source>web</source>
236
+ <truncated>false</truncated>
237
+ <in_reply_to_status_id></in_reply_to_status_id>
238
+ <in_reply_to_user_id></in_reply_to_user_id>
239
+ <favorited>false</favorited>
240
+ <in_reply_to_screen_name></in_reply_to_screen_name>
241
+ <user>
242
+ <id>32587988</id>
243
+ <name>Jake Izotov</name>
244
+ <screen_name>JaketheSnake12x</screen_name>
245
+ <location>lantana florida</location>
246
+ <description>I am kid and I live in Florida.I Like Playing games, read, Tae Kwon Do, exotic foods,Computers/tech, and working out. DOUBLE DSSS.</description>
247
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/263335401/picture_of_me_normal.jpg</profile_image_url>
248
+ <url>http://jakescorner.weebly.com/</url>
249
+ <protected>false</protected>
250
+ <followers_count>154</followers_count>
251
+ <profile_background_color>352726</profile_background_color>
252
+ <profile_text_color>3E4415</profile_text_color>
253
+ <profile_link_color>D02B55</profile_link_color>
254
+ <profile_sidebar_fill_color>99CC33</profile_sidebar_fill_color>
255
+ <profile_sidebar_border_color>829D5E</profile_sidebar_border_color>
256
+ <friends_count>483</friends_count>
257
+ <created_at>Fri Apr 17 21:12:58 +0000 2009</created_at>
258
+ <favourites_count>2</favourites_count>
259
+ <utc_offset>-28800</utc_offset>
260
+ <time_zone>Pacific Time (US &amp; Canada)</time_zone>
261
+ <profile_background_image_url>http://s3.amazonaws.com/twitter_production/profile_background_images/15084838/Jakes_logo_copy.jpg</profile_background_image_url>
262
+ <profile_background_tile>true</profile_background_tile>
263
+ <statuses_count>96</statuses_count>
264
+ <notifications></notifications>
265
+ <verified_profile>false</verified_profile>
266
+ <following></following>
267
+ </user>
268
+ </status>
269
+ <status>
270
+ <created_at>Tue Jun 16 01:42:52 +0000 2009</created_at>
271
+ <id>2186350594</id>
272
+ <text>ver garfield, escuta musika ate durmir, acordar as 5e30h da matina e ir praqele infernuh estudantil.. bejuh galere;*</text>
273
+ <source>web</source>
274
+ <truncated>false</truncated>
275
+ <in_reply_to_status_id></in_reply_to_status_id>
276
+ <in_reply_to_user_id></in_reply_to_user_id>
277
+ <favorited>false</favorited>
278
+ <in_reply_to_screen_name></in_reply_to_screen_name>
279
+ <user>
280
+ <id>46941138</id>
281
+ <name>Raissa R.</name>
282
+ <screen_name>sissah</screen_name>
283
+ <location></location>
284
+ <description></description>
285
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/261591802/eo_normal.jpg</profile_image_url>
286
+ <url>http://www.orkut.com.br/Main#Profile.aspx?uid=10680503233950685433&amp;rl=t</url>
287
+ <protected>false</protected>
288
+ <followers_count>25</followers_count>
289
+ <profile_background_color>1A1B1F</profile_background_color>
290
+ <profile_text_color>660099</profile_text_color>
291
+ <profile_link_color>000000</profile_link_color>
292
+ <profile_sidebar_fill_color>000000</profile_sidebar_fill_color>
293
+ <profile_sidebar_border_color>181A1E</profile_sidebar_border_color>
294
+ <friends_count>32</friends_count>
295
+ <created_at>Sat Jun 13 18:54:48 +0000 2009</created_at>
296
+ <favourites_count>0</favourites_count>
297
+ <utc_offset>-10800</utc_offset>
298
+ <time_zone>Brasilia</time_zone>
299
+ <profile_background_image_url>http://s3.amazonaws.com/twitter_production/profile_background_images/17945147/planow.bmp</profile_background_image_url>
300
+ <profile_background_tile>true</profile_background_tile>
301
+ <statuses_count>59</statuses_count>
302
+ <notifications></notifications>
303
+ <verified_profile>false</verified_profile>
304
+ <following></following>
305
+ </user>
306
+ </status>
307
+ <status>
308
+ <created_at>Tue Jun 16 01:42:52 +0000 2009</created_at>
309
+ <id>2186350593</id>
310
+ <text>@kimmyt22 Just watching today's GL, so hoping there will not be a Frank character in Venice who is a &quot;good guy&quot; BTW Grew up by ND Rudy Rudy</text>
311
+ <source>web</source>
312
+ <truncated>false</truncated>
313
+ <in_reply_to_status_id></in_reply_to_status_id>
314
+ <in_reply_to_user_id>44045511</in_reply_to_user_id>
315
+ <favorited>false</favorited>
316
+ <in_reply_to_screen_name>KimmyT22</in_reply_to_screen_name>
317
+ <user>
318
+ <id>35214017</id>
319
+ <name>Becky Matanic</name>
320
+ <screen_name>Quigley20</screen_name>
321
+ <location>San Antonio</location>
322
+ <description></description>
323
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/251377924/quigley5_normal.jpg</profile_image_url>
324
+ <url></url>
325
+ <protected>false</protected>
326
+ <followers_count>61</followers_count>
327
+ <profile_background_color>9AE4E8</profile_background_color>
328
+ <profile_text_color>333333</profile_text_color>
329
+ <profile_link_color>0084B4</profile_link_color>
330
+ <profile_sidebar_fill_color>DDFFCC</profile_sidebar_fill_color>
331
+ <profile_sidebar_border_color>BDDCAD</profile_sidebar_border_color>
332
+ <friends_count>87</friends_count>
333
+ <created_at>Sat Apr 25 13:48:19 +0000 2009</created_at>
334
+ <favourites_count>3</favourites_count>
335
+ <utc_offset>-21600</utc_offset>
336
+ <time_zone>Central Time (US &amp; Canada)</time_zone>
337
+ <profile_background_image_url>http://s3.amazonaws.com/twitter_production/profile_background_images/16816716/quigley4.jpg</profile_background_image_url>
338
+ <profile_background_tile>true</profile_background_tile>
339
+ <statuses_count>273</statuses_count>
340
+ <notifications></notifications>
341
+ <verified_profile>false</verified_profile>
342
+ <following></following>
343
+ </user>
344
+ </status>
345
+ <status>
346
+ <created_at>Tue Jun 16 01:42:52 +0000 2009</created_at>
347
+ <id>2186350591</id>
348
+ <text>HOT INFO!!!! CHECK OUT MILLIMETER'S 2009 VFX RESOURCE REPORT!!!! http://TwitPWR.com/i8Q/ @millimeter</text>
349
+ <source>web</source>
350
+ <truncated>false</truncated>
351
+ <in_reply_to_status_id></in_reply_to_status_id>
352
+ <in_reply_to_user_id></in_reply_to_user_id>
353
+ <favorited>false</favorited>
354
+ <in_reply_to_screen_name></in_reply_to_screen_name>
355
+ <user>
356
+ <id>25010710</id>
357
+ <name>Jason Dorris</name>
358
+ <screen_name>Ozzmodia</screen_name>
359
+ <location>Waterloo, IA</location>
360
+ <description>Your Source for Graphic Design, Video Production, and Multimedia Development!</description>
361
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/101040672/Ozzmodia_Multimedia_Logo_normal.jpg</profile_image_url>
362
+ <url>http://www.ozzmodia.com</url>
363
+ <protected>false</protected>
364
+ <followers_count>183</followers_count>
365
+ <profile_background_color>1A1B1F</profile_background_color>
366
+ <profile_text_color>666666</profile_text_color>
367
+ <profile_link_color>2FC2EF</profile_link_color>
368
+ <profile_sidebar_fill_color>252429</profile_sidebar_fill_color>
369
+ <profile_sidebar_border_color>181A1E</profile_sidebar_border_color>
370
+ <friends_count>238</friends_count>
371
+ <created_at>Wed Mar 18 02:29:26 +0000 2009</created_at>
372
+ <favourites_count>0</favourites_count>
373
+ <utc_offset>-21600</utc_offset>
374
+ <time_zone>Central Time (US &amp; Canada)</time_zone>
375
+ <profile_background_image_url>http://s3.amazonaws.com/twitter_production/profile_background_images/6025091/Ozzmodia_TwitterPic.jpg</profile_background_image_url>
376
+ <profile_background_tile>false</profile_background_tile>
377
+ <statuses_count>118</statuses_count>
378
+ <notifications></notifications>
379
+ <verified_profile>false</verified_profile>
380
+ <following></following>
381
+ </user>
382
+ </status>
383
+ <status>
384
+ <created_at>Tue Jun 16 01:42:52 +0000 2009</created_at>
385
+ <id>2186350589</id>
386
+ <text>@AmyNicolee woohoo yes i know i am =)</text>
387
+ <source>&lt;a href=&quot;http://www.twhirl.org/&quot;&gt;twhirl&lt;/a&gt;</source>
388
+ <truncated>false</truncated>
389
+ <in_reply_to_status_id>2186316710</in_reply_to_status_id>
390
+ <in_reply_to_user_id>27828814</in_reply_to_user_id>
391
+ <favorited>false</favorited>
392
+ <in_reply_to_screen_name>AmyNicolee</in_reply_to_screen_name>
393
+ <user>
394
+ <id>14940489</id>
395
+ <name>Jerrold Rogers</name>
396
+ <screen_name>silentsintheday</screen_name>
397
+ <location>New York</location>
398
+ <description>I am who I am. I walk through doors I find interesting. Many forget me but i'll always remember them.</description>
399
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/140294615/Photo_24_normal.jpg</profile_image_url>
400
+ <url></url>
401
+ <protected>false</protected>
402
+ <followers_count>12</followers_count>
403
+ <profile_background_color>9ae4e8</profile_background_color>
404
+ <profile_text_color>000000</profile_text_color>
405
+ <profile_link_color>0000ff</profile_link_color>
406
+ <profile_sidebar_fill_color>e0ff92</profile_sidebar_fill_color>
407
+ <profile_sidebar_border_color>87bc44</profile_sidebar_border_color>
408
+ <friends_count>40</friends_count>
409
+ <created_at>Thu May 29 03:20:19 +0000 2008</created_at>
410
+ <favourites_count>0</favourites_count>
411
+ <utc_offset>-18000</utc_offset>
412
+ <time_zone>Eastern Time (US &amp; Canada)</time_zone>
413
+ <profile_background_image_url>http://static.twitter.com/images/themes/theme1/bg.gif</profile_background_image_url>
414
+ <profile_background_tile>false</profile_background_tile>
415
+ <statuses_count>162</statuses_count>
416
+ <notifications></notifications>
417
+ <verified_profile>false</verified_profile>
418
+ <following></following>
419
+ </user>
420
+ </status>
421
+ <status>
422
+ <created_at>Tue Jun 16 01:42:52 +0000 2009</created_at>
423
+ <id>2186350587</id>
424
+ <text>akhirnya punya twitter lagi.. :D</text>
425
+ <source>web</source>
426
+ <truncated>false</truncated>
427
+ <in_reply_to_status_id></in_reply_to_status_id>
428
+ <in_reply_to_user_id></in_reply_to_user_id>
429
+ <favorited>false</favorited>
430
+ <in_reply_to_screen_name></in_reply_to_screen_name>
431
+ <user>
432
+ <id>47506995</id>
433
+ <name>alfika dinar fitri</name>
434
+ <screen_name>alfikadinar</screen_name>
435
+ <location></location>
436
+ <description></description>
437
+ <profile_image_url>http://static.twitter.com/images/default_profile_normal.png</profile_image_url>
438
+ <url></url>
439
+ <protected>false</protected>
440
+ <followers_count>0</followers_count>
441
+ <profile_background_color>9ae4e8</profile_background_color>
442
+ <profile_text_color>000000</profile_text_color>
443
+ <profile_link_color>0000ff</profile_link_color>
444
+ <profile_sidebar_fill_color>e0ff92</profile_sidebar_fill_color>
445
+ <profile_sidebar_border_color>87bc44</profile_sidebar_border_color>
446
+ <friends_count>0</friends_count>
447
+ <created_at>Tue Jun 16 01:40:38 +0000 2009</created_at>
448
+ <favourites_count>0</favourites_count>
449
+ <utc_offset></utc_offset>
450
+ <time_zone></time_zone>
451
+ <profile_background_image_url>http://static.twitter.com/images/themes/theme1/bg.gif</profile_background_image_url>
452
+ <profile_background_tile>false</profile_background_tile>
453
+ <statuses_count>1</statuses_count>
454
+ <notifications></notifications>
455
+ <verified_profile>false</verified_profile>
456
+ <following></following>
457
+ </user>
458
+ </status>
459
+ <status>
460
+ <created_at>Tue Jun 16 01:42:52 +0000 2009</created_at>
461
+ <id>2186350584</id>
462
+ <text>Warped Tour is going to be fun and Martin is coming! TWO YEARS IN A ROW AND COUNTING</text>
463
+ <source>&lt;a href=&quot;http://twitterrific.com&quot;&gt;Twitterrific&lt;/a&gt;</source>
464
+ <truncated>false</truncated>
465
+ <in_reply_to_status_id></in_reply_to_status_id>
466
+ <in_reply_to_user_id></in_reply_to_user_id>
467
+ <favorited>false</favorited>
468
+ <in_reply_to_screen_name></in_reply_to_screen_name>
469
+ <user>
470
+ <id>30252853</id>
471
+ <name>Miles De Jesus</name>
472
+ <screen_name>mondayeyesmiles</screen_name>
473
+ <location>Los Angeles</location>
474
+ <description>Musician/Friend</description>
475
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/132079976/Photo_124_normal.jpg</profile_image_url>
476
+ <url></url>
477
+ <protected>false</protected>
478
+ <followers_count>17</followers_count>
479
+ <profile_background_color>352726</profile_background_color>
480
+ <profile_text_color>3E4415</profile_text_color>
481
+ <profile_link_color>D02B55</profile_link_color>
482
+ <profile_sidebar_fill_color>99CC33</profile_sidebar_fill_color>
483
+ <profile_sidebar_border_color>829D5E</profile_sidebar_border_color>
484
+ <friends_count>44</friends_count>
485
+ <created_at>Fri Apr 10 16:36:22 +0000 2009</created_at>
486
+ <favourites_count>0</favourites_count>
487
+ <utc_offset>-28800</utc_offset>
488
+ <time_zone>Pacific Time (US &amp; Canada)</time_zone>
489
+ <profile_background_image_url>http://s3.amazonaws.com/twitter_production/profile_background_images/13088169/IMG_1089.jpg</profile_background_image_url>
490
+ <profile_background_tile>false</profile_background_tile>
491
+ <statuses_count>70</statuses_count>
492
+ <notifications></notifications>
493
+ <verified_profile>false</verified_profile>
494
+ <following></following>
495
+ </user>
496
+ </status>
497
+ <status>
498
+ <created_at>Tue Jun 16 01:42:52 +0000 2009</created_at>
499
+ <id>2186350582</id>
500
+ <text>eu vou camar....camar...laranjas....a....bananas........</text>
501
+ <source>&lt;a href=&quot;http://www.twhirl.org/&quot;&gt;twhirl&lt;/a&gt;</source>
502
+ <truncated>false</truncated>
503
+ <in_reply_to_status_id></in_reply_to_status_id>
504
+ <in_reply_to_user_id></in_reply_to_user_id>
505
+ <favorited>false</favorited>
506
+ <in_reply_to_screen_name></in_reply_to_screen_name>
507
+ <user>
508
+ <id>19889866</id>
509
+ <name>Luis Costa</name>
510
+ <screen_name>luismcmc</screen_name>
511
+ <location></location>
512
+ <description></description>
513
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/79538241/Imagem0000_normal.jpg</profile_image_url>
514
+ <url></url>
515
+ <protected>false</protected>
516
+ <followers_count>40</followers_count>
517
+ <profile_background_color>1A1B1F</profile_background_color>
518
+ <profile_text_color>666666</profile_text_color>
519
+ <profile_link_color>2FC2EF</profile_link_color>
520
+ <profile_sidebar_fill_color>252429</profile_sidebar_fill_color>
521
+ <profile_sidebar_border_color>181A1E</profile_sidebar_border_color>
522
+ <friends_count>40</friends_count>
523
+ <created_at>Mon Feb 02 02:42:57 +0000 2009</created_at>
524
+ <favourites_count>1</favourites_count>
525
+ <utc_offset>0</utc_offset>
526
+ <time_zone>Lisbon</time_zone>
527
+ <profile_background_image_url>http://static.twitter.com/images/themes/theme9/bg.gif</profile_background_image_url>
528
+ <profile_background_tile>false</profile_background_tile>
529
+ <statuses_count>68</statuses_count>
530
+ <notifications></notifications>
531
+ <verified_profile>false</verified_profile>
532
+ <following></following>
533
+ </user>
534
+ </status>
535
+ <status>
536
+ <created_at>Tue Jun 16 01:42:52 +0000 2009</created_at>
537
+ <id>2186350580</id>
538
+ <text>Can't believe Andy and I just broke up .. with our awesome landlords. Time to move!</text>
539
+ <source>&lt;a href=&quot;http://orangatame.com/products/twitterberry/&quot;&gt;TwitterBerry&lt;/a&gt;</source>
540
+ <truncated>false</truncated>
541
+ <in_reply_to_status_id></in_reply_to_status_id>
542
+ <in_reply_to_user_id></in_reply_to_user_id>
543
+ <favorited>false</favorited>
544
+ <in_reply_to_screen_name></in_reply_to_screen_name>
545
+ <user>
546
+ <id>15633777</id>
547
+ <name>Vivian Loar</name>
548
+ <screen_name>misovivi</screen_name>
549
+ <location>Portland, Oregon</location>
550
+ <description>inspired by frequent flier miles, humbled by non-profit work, humanized through yoga, powered by bike.</description>
551
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/130506398/Photo_68_normal.jpg</profile_image_url>
552
+ <url></url>
553
+ <protected>false</protected>
554
+ <followers_count>56</followers_count>
555
+ <profile_background_color>9ae4e8</profile_background_color>
556
+ <profile_text_color>000000</profile_text_color>
557
+ <profile_link_color>0000ff</profile_link_color>
558
+ <profile_sidebar_fill_color>e0ff92</profile_sidebar_fill_color>
559
+ <profile_sidebar_border_color>87bc44</profile_sidebar_border_color>
560
+ <friends_count>39</friends_count>
561
+ <created_at>Mon Jul 28 16:13:51 +0000 2008</created_at>
562
+ <favourites_count>0</favourites_count>
563
+ <utc_offset>-28800</utc_offset>
564
+ <time_zone>Pacific Time (US &amp; Canada)</time_zone>
565
+ <profile_background_image_url>http://s3.amazonaws.com/twitter_production/profile_background_images/2850365/header_08.14.07_full.jpg</profile_background_image_url>
566
+ <profile_background_tile>true</profile_background_tile>
567
+ <statuses_count>1577</statuses_count>
568
+ <notifications></notifications>
569
+ <verified_profile>false</verified_profile>
570
+ <following></following>
571
+ </user>
572
+ </status>
573
+ <status>
574
+ <created_at>Tue Jun 16 01:42:52 +0000 2009</created_at>
575
+ <id>2186350579</id>
576
+ <text>LOVES KATIE HER BFF</text>
577
+ <source>web</source>
578
+ <truncated>false</truncated>
579
+ <in_reply_to_status_id></in_reply_to_status_id>
580
+ <in_reply_to_user_id></in_reply_to_user_id>
581
+ <favorited>false</favorited>
582
+ <in_reply_to_screen_name></in_reply_to_screen_name>
583
+ <user>
584
+ <id>16215674</id>
585
+ <name>clavey430</name>
586
+ <screen_name>clavey430</screen_name>
587
+ <location></location>
588
+ <description></description>
589
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/264476976/Photo_151_normal.jpg</profile_image_url>
590
+ <url></url>
591
+ <protected>false</protected>
592
+ <followers_count>9</followers_count>
593
+ <profile_background_color>352726</profile_background_color>
594
+ <profile_text_color>3E4415</profile_text_color>
595
+ <profile_link_color>D02B55</profile_link_color>
596
+ <profile_sidebar_fill_color>99CC33</profile_sidebar_fill_color>
597
+ <profile_sidebar_border_color>829D5E</profile_sidebar_border_color>
598
+ <friends_count>8</friends_count>
599
+ <created_at>Wed Sep 10 02:50:59 +0000 2008</created_at>
600
+ <favourites_count>0</favourites_count>
601
+ <utc_offset>-21600</utc_offset>
602
+ <time_zone>Central Time (US &amp; Canada)</time_zone>
603
+ <profile_background_image_url>http://static.twitter.com/images/themes/theme5/bg.gif</profile_background_image_url>
604
+ <profile_background_tile>false</profile_background_tile>
605
+ <statuses_count>5</statuses_count>
606
+ <notifications></notifications>
607
+ <verified_profile>false</verified_profile>
608
+ <following></following>
609
+ </user>
610
+ </status>
611
+ <status>
612
+ <created_at>Tue Jun 16 01:42:52 +0000 2009</created_at>
613
+ <id>2186350578</id>
614
+ <text>home, tired n feeling out of it again</text>
615
+ <source>web</source>
616
+ <truncated>false</truncated>
617
+ <in_reply_to_status_id></in_reply_to_status_id>
618
+ <in_reply_to_user_id></in_reply_to_user_id>
619
+ <favorited>false</favorited>
620
+ <in_reply_to_screen_name></in_reply_to_screen_name>
621
+ <user>
622
+ <id>43255900</id>
623
+ <name>Barbara Piacenza</name>
624
+ <screen_name>steelersgrl0407</screen_name>
625
+ <location>East Stroudsburg, PA</location>
626
+ <description>20something, living wit my bf in pa (hoping to move somewhere, anywhere else); I love the World Champ Steelers n Twilight! </description>
627
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/237457062/best_picof_us_normal.jpg</profile_image_url>
628
+ <url></url>
629
+ <protected>false</protected>
630
+ <followers_count>10</followers_count>
631
+ <profile_background_color>0099B9</profile_background_color>
632
+ <profile_text_color>3C3940</profile_text_color>
633
+ <profile_link_color>0099B9</profile_link_color>
634
+ <profile_sidebar_fill_color>95E8EC</profile_sidebar_fill_color>
635
+ <profile_sidebar_border_color>5ED4DC</profile_sidebar_border_color>
636
+ <friends_count>13</friends_count>
637
+ <created_at>Fri May 29 02:48:57 +0000 2009</created_at>
638
+ <favourites_count>0</favourites_count>
639
+ <utc_offset>-18000</utc_offset>
640
+ <time_zone>Eastern Time (US &amp; Canada)</time_zone>
641
+ <profile_background_image_url>http://static.twitter.com/images/themes/theme4/bg.gif</profile_background_image_url>
642
+ <profile_background_tile>false</profile_background_tile>
643
+ <statuses_count>22</statuses_count>
644
+ <notifications></notifications>
645
+ <verified_profile>false</verified_profile>
646
+ <following></following>
647
+ </user>
648
+ </status>
649
+ <status>
650
+ <created_at>Tue Jun 16 01:42:52 +0000 2009</created_at>
651
+ <id>2186350577</id>
652
+ <text>@hermeselsabio Hola HERMES me encantan tus criticas, me rio a morir, eres muy chistoso, saludos</text>
653
+ <source>web</source>
654
+ <truncated>false</truncated>
655
+ <in_reply_to_status_id></in_reply_to_status_id>
656
+ <in_reply_to_user_id>18148305</in_reply_to_user_id>
657
+ <favorited>false</favorited>
658
+ <in_reply_to_screen_name>hermeselsabio</in_reply_to_screen_name>
659
+ <user>
660
+ <id>47021426</id>
661
+ <name>Andrea Mu&#241;oz Mu&#241;oz</name>
662
+ <screen_name>andreamunozm</screen_name>
663
+ <location>Chile</location>
664
+ <description></description>
665
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/262059691/Foto-0021_normal.jpg</profile_image_url>
666
+ <url></url>
667
+ <protected>false</protected>
668
+ <followers_count>2</followers_count>
669
+ <profile_background_color>9ae4e8</profile_background_color>
670
+ <profile_text_color>000000</profile_text_color>
671
+ <profile_link_color>0000ff</profile_link_color>
672
+ <profile_sidebar_fill_color>e0ff92</profile_sidebar_fill_color>
673
+ <profile_sidebar_border_color>87bc44</profile_sidebar_border_color>
674
+ <friends_count>7</friends_count>
675
+ <created_at>Sun Jun 14 03:12:18 +0000 2009</created_at>
676
+ <favourites_count>0</favourites_count>
677
+ <utc_offset>-18000</utc_offset>
678
+ <time_zone>Quito</time_zone>
679
+ <profile_background_image_url>http://static.twitter.com/images/themes/theme1/bg.gif</profile_background_image_url>
680
+ <profile_background_tile>false</profile_background_tile>
681
+ <statuses_count>2</statuses_count>
682
+ <notifications></notifications>
683
+ <verified_profile>false</verified_profile>
684
+ <following></following>
685
+ </user>
686
+ </status>
687
+ <status>
688
+ <created_at>Tue Jun 16 01:42:52 +0000 2009</created_at>
689
+ <id>2186350576</id>
690
+ <text>At laurens!</text>
691
+ <source>&lt;a href=&quot;http://help.twitter.com/index.php?pg=kb.page&amp;id=75&quot;&gt;txt&lt;/a&gt;</source>
692
+ <truncated>false</truncated>
693
+ <in_reply_to_status_id></in_reply_to_status_id>
694
+ <in_reply_to_user_id></in_reply_to_user_id>
695
+ <favorited>false</favorited>
696
+ <in_reply_to_screen_name></in_reply_to_screen_name>
697
+ <user>
698
+ <id>28930290</id>
699
+ <name>Alana N.</name>
700
+ <screen_name>4polo4</screen_name>
701
+ <location></location>
702
+ <description></description>
703
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/129238015/spring__09_053_normal.jpg</profile_image_url>
704
+ <url></url>
705
+ <protected>false</protected>
706
+ <followers_count>28</followers_count>
707
+ <profile_background_color>9ae4e8</profile_background_color>
708
+ <profile_text_color>000000</profile_text_color>
709
+ <profile_link_color>0000ff</profile_link_color>
710
+ <profile_sidebar_fill_color>e0ff92</profile_sidebar_fill_color>
711
+ <profile_sidebar_border_color>87bc44</profile_sidebar_border_color>
712
+ <friends_count>13</friends_count>
713
+ <created_at>Sun Apr 05 03:16:51 +0000 2009</created_at>
714
+ <favourites_count>0</favourites_count>
715
+ <utc_offset></utc_offset>
716
+ <time_zone></time_zone>
717
+ <profile_background_image_url>http://static.twitter.com/images/themes/theme1/bg.gif</profile_background_image_url>
718
+ <profile_background_tile>false</profile_background_tile>
719
+ <statuses_count>878</statuses_count>
720
+ <notifications></notifications>
721
+ <verified_profile>false</verified_profile>
722
+ <following></following>
723
+ </user>
724
+ </status>
725
+ <status>
726
+ <created_at>Tue Jun 16 01:42:52 +0000 2009</created_at>
727
+ <id>2186350575</id>
728
+ <text>Ahhhn found nicholi on facebook! @jonasbrothers lvatt will be the best!!!</text>
729
+ <source>&lt;a href=&quot;http://help.twitter.com/index.php?pg=kb.page&amp;id=75&quot;&gt;txt&lt;/a&gt;</source>
730
+ <truncated>false</truncated>
731
+ <in_reply_to_status_id></in_reply_to_status_id>
732
+ <in_reply_to_user_id></in_reply_to_user_id>
733
+ <favorited>false</favorited>
734
+ <in_reply_to_screen_name></in_reply_to_screen_name>
735
+ <user>
736
+ <id>22433725</id>
737
+ <name>Heidi Box</name>
738
+ <screen_name>heidi_inthe_box</screen_name>
739
+ <location></location>
740
+ <description></description>
741
+ <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/241363533/DSC00497_normal.JPG</profile_image_url>
742
+ <url></url>
743
+ <protected>false</protected>
744
+ <followers_count>35</followers_count>
745
+ <profile_background_color>ffffff</profile_background_color>
746
+ <profile_text_color>128df3</profile_text_color>
747
+ <profile_link_color>14ff00</profile_link_color>
748
+ <profile_sidebar_fill_color>4f258e</profile_sidebar_fill_color>
749
+ <profile_sidebar_border_color>f1f004</profile_sidebar_border_color>
750
+ <friends_count>44</friends_count>
751
+ <created_at>Mon Mar 02 01:28:29 +0000 2009</created_at>
752
+ <favourites_count>17</favourites_count>
753
+ <utc_offset></utc_offset>
754
+ <time_zone></time_zone>
755
+ <profile_background_image_url>http://s3.amazonaws.com/twitter_production/profile_background_images/14673490/peacehs.jpg</profile_background_image_url>
756
+ <profile_background_tile>true</profile_background_tile>
757
+ <statuses_count>815</statuses_count>
758
+ <notifications></notifications>
759
+ <verified_profile>false</verified_profile>
760
+ <following></following>
761
+ </user>
762
+ </status>
763
+ </statuses>
@@ -0,0 +1 @@
1
+ [{"title":"\"The Noises Rest\"","url":"http:\/\/vimeo.com\/2748889","clip_id":"2748889","caption":"We of You Look Nice Today (\"the Talent\") were invited, nay, commissioned to make a thing for a thing - http:\/\/bit.ly\/momedy - to be screened at a big fancy place in New York with a lot of fancy people and some interesting paintings. Okay, it was the MoMA. Perhaps you've heard of it.<br \/>\n<br \/>\nExplain ourselves at http:\/\/youlooknicetoday.com","upload_date":"2009-01-07 07:10:47","thumbnail_small":"http:\/\/images.vimeo.com\/24\/21\/93\/242193881\/242193881_80.jpg","thumbnail_medium":"http:\/\/images.vimeo.com\/24\/21\/93\/242193881\/242193881_100.jpg","thumbnail_large":"http:\/\/images.vimeo.com\/24\/21\/93\/242193881\/242193881_160.jpg","user_name":"lonelysandwich","user_url":"http:\/\/vimeo.com\/lonelysandwich","user_thumbnail_small":"http:\/\/20.media.vimeo.com\/d1\/5\/29\/58\/06\/portrait-29580642.jpg","user_thumbnail_large":"http:\/\/10.media.vimeo.com\/d1\/5\/29\/38\/95\/portrait-29389521.jpg","stats_number_of_likes":"595","stats_number_of_plays":"57039","stats_number_of_comments":78,"duration":"379","width":"504","height":"284","tags":"You Look Nice Today, MoMA, silent film, comedy, foley art"}]
@@ -0,0 +1,54 @@
1
+ require 'rubygems'
2
+ gem 'rspec'
3
+ require 'spec'
4
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'weary')
5
+
6
+ def get_fixture(filename)
7
+ open(File.join(File.dirname(__FILE__), 'fixtures', "#{filename.to_s}")).read
8
+ end
9
+
10
+ def mock_response(request_method = :get, code=200, header={}, body=nil)
11
+ response_class = Net::HTTPResponse::CODE_TO_OBJ[code.to_s]
12
+ message = case code
13
+ when 200
14
+ "OK"
15
+ when 301
16
+ "Moved Permanently"
17
+ when 302
18
+ "Moved Temporarily"
19
+ when 400
20
+ "Bad Request"
21
+ when 401
22
+ "Unauthorized"
23
+ when 403
24
+ "Forbidden"
25
+ when 404
26
+ "Not Found"
27
+ when 405
28
+ "Method Not Allowed"
29
+ when 409
30
+ "Conflict"
31
+ when 422
32
+ "Unprocessable Entity"
33
+ when 401...500
34
+ "Client Error"
35
+ when 500...600
36
+ "Server Error"
37
+ else
38
+ "Unknown"
39
+ end
40
+ response = response_class.new("1.1", code, "Hello World!")
41
+ response.initialize_http_header(header)
42
+ response.stub!(:body).and_return(body)
43
+ response.stub!(:message).and_return(message)
44
+
45
+ response
46
+ end
47
+
48
+ def mock_request(url, method = :get, options={}, mock_header={}, mock_body=nil)
49
+ request = Weary::Request.new(url, method, options)
50
+ http_response = mock_response(method, 200, mock_header, mock_body)
51
+ request.stub!(:perform).and_return Weary::Response.new(http_response, method)
52
+
53
+ request
54
+ end
@@ -1,7 +1,4 @@
1
- require 'rubygems'
2
- gem 'rspec'
3
- require 'spec'
4
- require File.join(File.dirname(__FILE__), '../..', 'lib', 'weary')
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
5
2
 
6
3
  describe Weary::Request do
7
4
 
@@ -20,7 +17,25 @@ describe Weary::Request do
20
17
  test.class.should == Net::HTTP
21
18
  end
22
19
 
20
+ it "should perform the request and retrieve a response" do
21
+ test = Weary::Request.new("http://foo.bar")
22
+ method = test.method
23
+ response = Weary::Response.new(mock_response(method, 301, {'Location' => 'http://bar.foo'}), method)
24
+ test.stub!(:perform).and_return(response)
25
+ test.perform.code.should == 301
26
+ test.perform.redirected?.should == true
27
+ end
28
+
23
29
  it "should follow redirects" do
24
- pending "Not sure how to test this"
30
+ test = Weary::Request.new("http://foo.bar")
31
+ method = test.method
32
+ response = Weary::Response.new(mock_response(method, 301, {'Location' => 'http://bar.foo'}), method)
33
+ response.stub!(:follow_redirect).and_return Weary::Response.new(mock_response(method, 200, {}), method)
34
+ test.stub!(:perform).and_return(response)
35
+ test.perform.code.should == 301
36
+ test.perform.redirected?.should == true
37
+ test.perform.follow_redirect.code.should == 200
38
+ # not exactly kosher.
25
39
  end
40
+
26
41
  end
@@ -1,7 +1,4 @@
1
- require 'rubygems'
2
- gem 'rspec'
3
- require 'spec'
4
- require File.join(File.dirname(__FILE__), '../..', 'lib', 'weary')
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
5
2
 
6
3
  describe Weary::Resource do
7
4
  before do
@@ -45,17 +42,18 @@ describe Weary::Resource do
45
42
  @test.via.should == :post
46
43
  lambda { @test.via = :foobar }.should raise_error
47
44
  end
45
+
46
+ it 'format should be a symbol' do
47
+ @test.format = "xml"
48
+ @test.format.class.should == Symbol
49
+ end
50
+
51
+ it 'format should be an allowed format' do
52
+ @test.format = 'text/json'
53
+ @test.format.should == :json
54
+ lambda { @test.format = :foobar }.should raise_error
55
+ end
48
56
 
49
-
50
- it 'format should be a symbol' do
51
- @test.format = "xml"
52
- @test.format.class.should == Symbol
53
- end
54
-
55
- it 'format should be an allowed format' do
56
- @test.format = 'text/json'
57
- @test.format.should == :json
58
- lambda { @test.format = :foobar }.should raise_error
59
- end
57
+ it 'should be able to set Headers'
60
58
 
61
59
  end
@@ -0,0 +1,76 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
+
3
+ describe Weary::Response do
4
+ before do
5
+ @test = Weary::Response.new(mock_response, :get)
6
+ end
7
+
8
+ it 'should wrap a Net::Response' do
9
+ @test.raw.is_a?(Net::HTTPResponse).should == true
10
+ end
11
+
12
+ it 'should store the HTTP method' do
13
+ @test.method.should == :get
14
+ end
15
+
16
+ it 'should have an HTTP code' do
17
+ @test.code.should == 200
18
+ end
19
+
20
+ it 'should have an HTTP message' do
21
+ @test.message.should == "OK"
22
+ end
23
+
24
+ it 'should know if the request was successful' do
25
+ @test.success?.should == true
26
+ end
27
+
28
+ it 'should parse JSON' do
29
+ test = Weary::Response.new(mock_response(:get, 200, {'content-type' => 'text/json'}, get_fixture("vimeo.json")), :get)
30
+ test.parse[0]["title"].should == "\"The Noises Rest\""
31
+ end
32
+
33
+ it 'should parse XML' do
34
+ test = Weary::Response.new(mock_response(:get, 200, {'content-type' => 'text/xml'}, get_fixture("twitter.xml")), :get)
35
+ test.parse.class.should == Hash
36
+ test.parse['statuses'][0]['id'].should == "2186350626"
37
+ end
38
+
39
+ it 'should parse YAML' do
40
+ test = Weary::Response.new(mock_response(:get, 200, {'content-type' => 'text/yaml'}, get_fixture("github.yml")), :get)
41
+ test.parse.class.should == Hash
42
+ test.parse["repository"][:name].should == "rails"
43
+ end
44
+
45
+ it 'should be able to search XML or HTML with Nokogiri' do
46
+ test = Weary::Response.new(mock_response(:get, 200, {'content-type' => 'text/xml'}, get_fixture("twitter.xml")), :get)
47
+ test.search("status:first > id").text.should == "2186350626"
48
+ end
49
+
50
+ it 'should use [] to parse the document' do
51
+ test = Weary::Response.new(mock_response(:get, 200, {'content-type' => 'text/xml'}, get_fixture("twitter.xml")), :get).parse
52
+ test['statuses'][0]['id'].should == "2186350626"
53
+ end
54
+
55
+ it 'should parse the document to a hash if we try to search a non-XMLish document' do
56
+ test = Weary::Response.new(mock_response(:get, 200, {'content-type' => 'text/yaml'}, get_fixture("github.yml")), :get)
57
+ test.search("foo bar").class.should == Hash
58
+ test.search("foo bar")["repository"][:name].should == "rails"
59
+ end
60
+
61
+ it 'should raise an exception if there was a Server Error' do
62
+ test = Weary::Response.new(mock_response(:get, 500), :get)
63
+ lambda { test.parse }.should raise_error
64
+ end
65
+
66
+ it 'should raise an exception if there was a Client Error' do
67
+ test = Weary::Response.new(mock_response(:get, 404), :get)
68
+ lambda { test.parse }.should raise_error
69
+ end
70
+
71
+ it 'should follow HTTP redirects' do
72
+ test = Weary::Response.new(mock_response(:get, 301), :get)
73
+ test.redirected?.should == true
74
+ end
75
+
76
+ end
data/spec/weary_spec.rb CHANGED
@@ -1,7 +1,4 @@
1
- require 'rubygems'
2
- gem 'rspec'
3
- require 'spec'
4
- require File.join(File.dirname(__FILE__), '..', 'lib', 'weary')
1
+ require File.join(File.dirname(__FILE__), 'spec_helper')
5
2
 
6
3
  describe Weary do
7
4
  before do
data/weary.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{weary}
5
- s.version = "0.2.1"
5
+ s.version = "0.2.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Mark Wunsch"]
9
- s.date = %q{2009-06-12}
9
+ s.date = %q{2009-06-15}
10
10
  s.description = %q{The Weary need REST: a tiny DSL that makes the consumption of RESTful web services simple.}
11
11
  s.email = %q{mark@markwunsch.com}
12
12
  s.extra_rdoc_files = [
@@ -26,8 +26,13 @@ Gem::Specification.new do |s|
26
26
  "lib/weary/request.rb",
27
27
  "lib/weary/resource.rb",
28
28
  "lib/weary/response.rb",
29
+ "spec/fixtures/github.yml",
30
+ "spec/fixtures/twitter.xml",
31
+ "spec/fixtures/vimeo.json",
32
+ "spec/spec_helper.rb",
29
33
  "spec/weary/request_spec.rb",
30
34
  "spec/weary/resource_spec.rb",
35
+ "spec/weary/response_spec.rb",
31
36
  "spec/weary_spec.rb",
32
37
  "weary.gemspec"
33
38
  ]
@@ -38,8 +43,10 @@ Gem::Specification.new do |s|
38
43
  s.rubygems_version = %q{1.3.4}
39
44
  s.summary = %q{A little DSL for consuming RESTful web services}
40
45
  s.test_files = [
41
- "spec/weary/request_spec.rb",
46
+ "spec/spec_helper.rb",
47
+ "spec/weary/request_spec.rb",
42
48
  "spec/weary/resource_spec.rb",
49
+ "spec/weary/response_spec.rb",
43
50
  "spec/weary_spec.rb",
44
51
  "examples/repo.rb",
45
52
  "examples/status.rb"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weary
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Wunsch
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-12 00:00:00 -04:00
12
+ date: 2009-06-15 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -44,8 +44,13 @@ files:
44
44
  - lib/weary/request.rb
45
45
  - lib/weary/resource.rb
46
46
  - lib/weary/response.rb
47
+ - spec/fixtures/github.yml
48
+ - spec/fixtures/twitter.xml
49
+ - spec/fixtures/vimeo.json
50
+ - spec/spec_helper.rb
47
51
  - spec/weary/request_spec.rb
48
52
  - spec/weary/resource_spec.rb
53
+ - spec/weary/response_spec.rb
49
54
  - spec/weary_spec.rb
50
55
  - weary.gemspec
51
56
  has_rdoc: true
@@ -77,8 +82,10 @@ signing_key:
77
82
  specification_version: 3
78
83
  summary: A little DSL for consuming RESTful web services
79
84
  test_files:
85
+ - spec/spec_helper.rb
80
86
  - spec/weary/request_spec.rb
81
87
  - spec/weary/resource_spec.rb
88
+ - spec/weary/response_spec.rb
82
89
  - spec/weary_spec.rb
83
90
  - examples/repo.rb
84
91
  - examples/status.rb