topsy 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. data/.gitignore +4 -0
  2. data/.yardoc/checksums +14 -2
  3. data/.yardoc/objects/Topsy/Author/to_s_i.dat +0 -0
  4. data/.yardoc/objects/Topsy/Author/type_i.dat +0 -0
  5. data/.yardoc/objects/Topsy/Author.dat +0 -0
  6. data/.yardoc/objects/Topsy/Client/author_info_i.dat +0 -0
  7. data/.yardoc/objects/Topsy/Client/author_search_i.dat +0 -0
  8. data/.yardoc/objects/Topsy/Client/credit_i.dat +0 -0
  9. data/.yardoc/objects/Topsy/Client/get_rate_limit_status_i.dat +0 -0
  10. data/.yardoc/objects/Topsy/Client/handle_response_i.dat +0 -0
  11. data/.yardoc/objects/Topsy/Client/link_post_count_i.dat +0 -0
  12. data/.yardoc/objects/Topsy/Client/link_posts_i.dat +0 -0
  13. data/.yardoc/objects/Topsy/Client/mashup_i.dat +0 -0
  14. data/.yardoc/objects/Topsy/Client/profile_search_i.dat +0 -0
  15. data/.yardoc/objects/Topsy/Client/raise_errors_i.dat +0 -0
  16. data/.yardoc/objects/Topsy/Client/related_i.dat +0 -0
  17. data/.yardoc/objects/Topsy/Client/search_count_i.dat +0 -0
  18. data/.yardoc/objects/Topsy/Client/search_i.dat +0 -0
  19. data/.yardoc/objects/Topsy/Client/stats_i.dat +0 -0
  20. data/.yardoc/objects/Topsy/Client/tags_i.dat +0 -0
  21. data/.yardoc/objects/Topsy/Client/trackbacks_i.dat +0 -0
  22. data/.yardoc/objects/Topsy/Client/trending_i.dat +0 -0
  23. data/.yardoc/objects/Topsy/Client/url_info_i.dat +0 -0
  24. data/.yardoc/objects/Topsy/Client.dat +0 -0
  25. data/.yardoc/objects/Topsy/LinkSearchResult/to_s_i.dat +0 -0
  26. data/.yardoc/objects/Topsy/LinkSearchResult.dat +0 -0
  27. data/.yardoc/objects/Topsy/Linkpost/target_3D_i.dat +0 -0
  28. data/.yardoc/objects/Topsy/Linkpost/to_s_i.dat +0 -0
  29. data/.yardoc/objects/Topsy/Linkpost.dat +0 -0
  30. data/.yardoc/objects/Topsy/LinkpostCount/to_s_i.dat +0 -0
  31. data/.yardoc/objects/Topsy/LinkpostCount.dat +0 -0
  32. data/.yardoc/objects/Topsy/Page/initialize_i.dat +0 -0
  33. data/.yardoc/objects/Topsy/Page/list_3D_i.dat +0 -0
  34. data/.yardoc/objects/Topsy/Page/to_s_i.dat +0 -0
  35. data/.yardoc/objects/Topsy/Page.dat +0 -0
  36. data/.yardoc/objects/Topsy/RateLimitInfo/refresh_in_seconds_i.dat +0 -0
  37. data/.yardoc/objects/Topsy/RateLimitInfo/reset_i.dat +0 -0
  38. data/.yardoc/objects/Topsy/RateLimitInfo.dat +0 -0
  39. data/.yardoc/objects/Topsy/SearchCounts/all_time_i.dat +0 -0
  40. data/.yardoc/objects/Topsy/SearchCounts/hour_i.dat +0 -0
  41. data/.yardoc/objects/Topsy/SearchCounts/month_i.dat +0 -0
  42. data/.yardoc/objects/Topsy/SearchCounts/overall_i.dat +0 -0
  43. data/.yardoc/objects/Topsy/SearchCounts/this_hour_i.dat +0 -0
  44. data/.yardoc/objects/Topsy/SearchCounts/this_month_i.dat +0 -0
  45. data/.yardoc/objects/Topsy/SearchCounts/this_week_i.dat +0 -0
  46. data/.yardoc/objects/Topsy/SearchCounts/today_i.dat +0 -0
  47. data/.yardoc/objects/Topsy/SearchCounts/week_i.dat +0 -0
  48. data/.yardoc/objects/Topsy/SearchCounts.dat +0 -0
  49. data/.yardoc/objects/Topsy/Stats/to_s_i.dat +0 -0
  50. data/.yardoc/objects/Topsy/Stats.dat +0 -0
  51. data/.yardoc/objects/Topsy/Tag/to_s_i.dat +0 -0
  52. data/.yardoc/objects/Topsy/Tag.dat +0 -0
  53. data/.yardoc/objects/Topsy/Target/to_s_i.dat +0 -0
  54. data/.yardoc/objects/Topsy/Target.dat +0 -0
  55. data/.yardoc/objects/Topsy/Trend/to_s_i.dat +0 -0
  56. data/.yardoc/objects/Topsy/Trend.dat +0 -0
  57. data/.yardoc/objects/Topsy/Tweet/author_3D_i.dat +0 -0
  58. data/.yardoc/objects/Topsy/Tweet/target_3D_i.dat +0 -0
  59. data/.yardoc/objects/Topsy/Tweet/to_s_i.dat +0 -0
  60. data/.yardoc/objects/Topsy/Tweet.dat +0 -0
  61. data/.yardoc/objects/Topsy/UrlInfo/to_s_i.dat +0 -0
  62. data/.yardoc/objects/Topsy/UrlInfo.dat +0 -0
  63. data/.yardoc/objects/Topsy.dat +0 -0
  64. data/.yardoc/objects/root.dat +0 -0
  65. data/.yardoc/proxy_types +0 -0
  66. data/README.markdown +71 -6
  67. data/Rakefile +1 -1
  68. data/TODO +7 -0
  69. data/VERSION +1 -1
  70. data/doc/Topsy/Author.html +201 -0
  71. data/doc/Topsy/Client.html +2096 -0
  72. data/doc/Topsy/LinkSearchResult.html +152 -0
  73. data/doc/Topsy/Linkpost.html +209 -0
  74. data/doc/Topsy/LinkpostCount.html +152 -0
  75. data/doc/Topsy/Page.html +284 -0
  76. data/doc/Topsy/RateLimitInfo.html +201 -0
  77. data/doc/Topsy/SearchCounts.html +91 -0
  78. data/doc/Topsy/Stats.html +152 -0
  79. data/doc/Topsy/Tag.html +152 -0
  80. data/doc/Topsy/Target.html +152 -0
  81. data/doc/Topsy/Trend.html +152 -0
  82. data/doc/Topsy/Tweet.html +266 -0
  83. data/doc/Topsy/UrlInfo.html +152 -0
  84. data/doc/Topsy.html +112 -0
  85. data/doc/_index.html +245 -0
  86. data/doc/class_list.html +177 -0
  87. data/doc/css/common.css +1 -0
  88. data/doc/css/full_list.css +23 -0
  89. data/doc/css/style.css +263 -0
  90. data/doc/file.README.html +151 -0
  91. data/doc/file_list.html +29 -0
  92. data/doc/index.html +151 -0
  93. data/doc/js/app.js +91 -0
  94. data/doc/js/full_list.js +39 -0
  95. data/doc/js/jquery.js +19 -0
  96. data/doc/method_list.html +352 -0
  97. data/doc/top-level-namespace.html +79 -0
  98. data/lib/topsy/author.rb +23 -0
  99. data/lib/topsy/client.rb +48 -21
  100. data/lib/topsy/link_search_result.rb +24 -0
  101. data/lib/topsy/linkpost.rb +33 -0
  102. data/lib/topsy/linkpost_count.rb +15 -0
  103. data/lib/topsy/page.rb +40 -0
  104. data/lib/topsy/rate_limit_info.rb +18 -0
  105. data/lib/topsy/search_counts.rb +9 -30
  106. data/lib/topsy/stats.rb +18 -0
  107. data/lib/topsy/tag.rb +16 -0
  108. data/lib/topsy/target.rb +18 -0
  109. data/lib/topsy/trend.rb +16 -0
  110. data/lib/topsy/tweet.rb +44 -0
  111. data/lib/topsy/url_info.rb +21 -0
  112. data/lib/topsy.rb +36 -4
  113. data/script/console +10 -0
  114. data/script/destroy +14 -0
  115. data/script/generate +14 -0
  116. data/test/fixtures/credit.json +15 -0
  117. data/test/fixtures/urlinfo.json +2 -2
  118. data/test/helper.rb +9 -4
  119. data/test/test_topsy.rb +92 -11
  120. data/topsy.gemspec +194 -0
  121. metadata +86 -5
  122. data/.yardoc/objects/Topsy/SearchCounts/last_hour_i.dat +0 -0
  123. data/.yardoc/objects/Topsy/SearchCounts/last_month_i.dat +0 -0
  124. data/.yardoc/objects/Topsy/SearchCounts/last_week_i.dat +0 -0
@@ -0,0 +1,352 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html>
4
+ <head>
5
+ <meta name="Content-Type" content="text/html; charset=UTF-8" />
6
+ <link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" charset="utf-8" />
7
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
8
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
9
+ <script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
10
+ <base target="_parent" />
11
+ </head>
12
+ <body>
13
+ <h1 id="full_list_header">Method List</h1>
14
+ <div id="search">Search: <input type="text" /></div>
15
+ <div class="clear"></div>
16
+ <ul id="full_list">
17
+
18
+
19
+ <li class="r1 ">
20
+
21
+ <a href="Topsy/Tweet.html#author%3D-instance_method" title="#author=">#author=</a>
22
+
23
+ <small>(Topsy::Tweet)</small>
24
+
25
+
26
+
27
+ </li>
28
+
29
+ <li class="r2 ">
30
+
31
+ <a href="Topsy/Client.html#author_info-instance_method" title="#author_info">#author_info</a>
32
+
33
+ <small>(Topsy::Client)</small>
34
+
35
+
36
+
37
+ </li>
38
+
39
+ <li class="r1 ">
40
+
41
+ <a href="Topsy/Client.html#author_search-instance_method" title="#author_search">#author_search</a>
42
+
43
+ <small>(Topsy::Client)</small>
44
+
45
+
46
+
47
+ </li>
48
+
49
+ <li class="r2 ">
50
+
51
+ <a href="Topsy/Client.html#credit-instance_method" title="#credit">#credit</a>
52
+
53
+ <small>(Topsy::Client)</small>
54
+
55
+
56
+
57
+ </li>
58
+
59
+ <li class="r1 ">
60
+
61
+ <a href="Topsy/Page.html#initialize-instance_method" title="#initialize">#initialize</a>
62
+
63
+ <small>(Topsy::Page)</small>
64
+
65
+
66
+
67
+ </li>
68
+
69
+ <li class="r2 ">
70
+
71
+ <a href="Topsy/Client.html#link_post_count-instance_method" title="#link_post_count">#link_post_count</a>
72
+
73
+ <small>(Topsy::Client)</small>
74
+
75
+
76
+
77
+ </li>
78
+
79
+ <li class="r1 ">
80
+
81
+ <a href="Topsy/Client.html#link_posts-instance_method" title="#link_posts">#link_posts</a>
82
+
83
+ <small>(Topsy::Client)</small>
84
+
85
+
86
+
87
+ </li>
88
+
89
+ <li class="r2 ">
90
+
91
+ <a href="Topsy/Page.html#list%3D-instance_method" title="#list=">#list=</a>
92
+
93
+ <small>(Topsy::Page)</small>
94
+
95
+
96
+
97
+ </li>
98
+
99
+ <li class="r1 ">
100
+
101
+ <a href="Topsy/Client.html#profile_search-instance_method" title="#profile_search">#profile_search</a>
102
+
103
+ <small>(Topsy::Client)</small>
104
+
105
+
106
+
107
+ </li>
108
+
109
+ <li class="r2 ">
110
+
111
+ <a href="Topsy/RateLimitInfo.html#refresh_in_seconds-instance_method" title="#refresh_in_seconds">#refresh_in_seconds</a>
112
+
113
+ <small>(Topsy::RateLimitInfo)</small>
114
+
115
+
116
+
117
+ </li>
118
+
119
+ <li class="r1 ">
120
+
121
+ <a href="Topsy/Client.html#related-instance_method" title="#related">#related</a>
122
+
123
+ <small>(Topsy::Client)</small>
124
+
125
+
126
+
127
+ </li>
128
+
129
+ <li class="r2 ">
130
+
131
+ <a href="Topsy/RateLimitInfo.html#reset-instance_method" title="#reset">#reset</a>
132
+
133
+ <small>(Topsy::RateLimitInfo)</small>
134
+
135
+
136
+
137
+ </li>
138
+
139
+ <li class="r1 ">
140
+
141
+ <a href="Topsy/Client.html#search-instance_method" title="#search">#search</a>
142
+
143
+ <small>(Topsy::Client)</small>
144
+
145
+
146
+
147
+ </li>
148
+
149
+ <li class="r2 ">
150
+
151
+ <a href="Topsy/Client.html#search_count-instance_method" title="#search_count">#search_count</a>
152
+
153
+ <small>(Topsy::Client)</small>
154
+
155
+
156
+
157
+ </li>
158
+
159
+ <li class="r1 ">
160
+
161
+ <a href="Topsy/Client.html#stats-instance_method" title="#stats">#stats</a>
162
+
163
+ <small>(Topsy::Client)</small>
164
+
165
+
166
+
167
+ </li>
168
+
169
+ <li class="r2 ">
170
+
171
+ <a href="Topsy/Client.html#tags-instance_method" title="#tags">#tags</a>
172
+
173
+ <small>(Topsy::Client)</small>
174
+
175
+
176
+
177
+ </li>
178
+
179
+ <li class="r1 ">
180
+
181
+ <a href="Topsy/Linkpost.html#target%3D-instance_method" title="#target=">#target=</a>
182
+
183
+ <small>(Topsy::Linkpost)</small>
184
+
185
+
186
+
187
+ </li>
188
+
189
+ <li class="r2 ">
190
+
191
+ <a href="Topsy/Tweet.html#target%3D-instance_method" title="#target=">#target=</a>
192
+
193
+ <small>(Topsy::Tweet)</small>
194
+
195
+
196
+
197
+ </li>
198
+
199
+ <li class="r1 ">
200
+
201
+ <a href="Topsy/Linkpost.html#to_s-instance_method" title="#to_s">#to_s</a>
202
+
203
+ <small>(Topsy::Linkpost)</small>
204
+
205
+
206
+
207
+ </li>
208
+
209
+ <li class="r2 ">
210
+
211
+ <a href="Topsy/Stats.html#to_s-instance_method" title="#to_s">#to_s</a>
212
+
213
+ <small>(Topsy::Stats)</small>
214
+
215
+
216
+
217
+ </li>
218
+
219
+ <li class="r1 ">
220
+
221
+ <a href="Topsy/Author.html#to_s-instance_method" title="#to_s">#to_s</a>
222
+
223
+ <small>(Topsy::Author)</small>
224
+
225
+
226
+
227
+ </li>
228
+
229
+ <li class="r2 ">
230
+
231
+ <a href="Topsy/Tag.html#to_s-instance_method" title="#to_s">#to_s</a>
232
+
233
+ <small>(Topsy::Tag)</small>
234
+
235
+
236
+
237
+ </li>
238
+
239
+ <li class="r1 ">
240
+
241
+ <a href="Topsy/Tweet.html#to_s-instance_method" title="#to_s">#to_s</a>
242
+
243
+ <small>(Topsy::Tweet)</small>
244
+
245
+
246
+
247
+ </li>
248
+
249
+ <li class="r2 ">
250
+
251
+ <a href="Topsy/Trend.html#to_s-instance_method" title="#to_s">#to_s</a>
252
+
253
+ <small>(Topsy::Trend)</small>
254
+
255
+
256
+
257
+ </li>
258
+
259
+ <li class="r1 ">
260
+
261
+ <a href="Topsy/LinkSearchResult.html#to_s-instance_method" title="#to_s">#to_s</a>
262
+
263
+ <small>(Topsy::LinkSearchResult)</small>
264
+
265
+
266
+
267
+ </li>
268
+
269
+ <li class="r2 ">
270
+
271
+ <a href="Topsy/UrlInfo.html#to_s-instance_method" title="#to_s">#to_s</a>
272
+
273
+ <small>(Topsy::UrlInfo)</small>
274
+
275
+
276
+
277
+ </li>
278
+
279
+ <li class="r1 ">
280
+
281
+ <a href="Topsy/Page.html#to_s-instance_method" title="#to_s">#to_s</a>
282
+
283
+ <small>(Topsy::Page)</small>
284
+
285
+
286
+
287
+ </li>
288
+
289
+ <li class="r2 ">
290
+
291
+ <a href="Topsy/LinkpostCount.html#to_s-instance_method" title="#to_s">#to_s</a>
292
+
293
+ <small>(Topsy::LinkpostCount)</small>
294
+
295
+
296
+
297
+ </li>
298
+
299
+ <li class="r1 ">
300
+
301
+ <a href="Topsy/Target.html#to_s-instance_method" title="#to_s">#to_s</a>
302
+
303
+ <small>(Topsy::Target)</small>
304
+
305
+
306
+
307
+ </li>
308
+
309
+ <li class="r2 ">
310
+
311
+ <a href="Topsy/Client.html#trackbacks-instance_method" title="#trackbacks">#trackbacks</a>
312
+
313
+ <small>(Topsy::Client)</small>
314
+
315
+
316
+
317
+ </li>
318
+
319
+ <li class="r1 ">
320
+
321
+ <a href="Topsy/Client.html#trending-instance_method" title="#trending">#trending</a>
322
+
323
+ <small>(Topsy::Client)</small>
324
+
325
+
326
+
327
+ </li>
328
+
329
+ <li class="r2 ">
330
+
331
+ <a href="Topsy/Author.html#type-instance_method" title="#type">#type</a>
332
+
333
+ <small>(Topsy::Author)</small>
334
+
335
+
336
+
337
+ </li>
338
+
339
+ <li class="r1 ">
340
+
341
+ <a href="Topsy/Client.html#url_info-instance_method" title="#url_info">#url_info</a>
342
+
343
+ <small>(Topsy::Client)</small>
344
+
345
+
346
+
347
+ </li>
348
+
349
+ </ul>
350
+ </body>
351
+ </html>
352
+
@@ -0,0 +1,79 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta name="Content-Type" content="text/html; charset=UTF-8" />
6
+ <title>Top Level Namespace</title>
7
+ <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
8
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
9
+
10
+ <script type="text/javascript" charset="utf-8">
11
+ relpath = '';
12
+ if (relpath != '') relpath += '/';
13
+ </script>
14
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
15
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
16
+
17
+ </head>
18
+ <body>
19
+ <div id="header">
20
+ <div id="menu">
21
+
22
+ <a href="_index.html">Index</a> &raquo;
23
+
24
+
25
+ <span class="title">Top Level Namespace</span>
26
+
27
+ </div>
28
+
29
+ <div id="search">
30
+ <a id="class_list_link" href="#">Namespace List</a>
31
+ <a id="method_list_link" href="#">Method List</a>
32
+ <a id ="file_list_link" href="#">File List</a>
33
+ </div>
34
+
35
+ <div class="clear"></div>
36
+ </div>
37
+
38
+ <iframe id="search_frame"></iframe>
39
+
40
+ <div id="content"><h1>Top Level Namespace
41
+
42
+
43
+ </h1>
44
+
45
+ <dl class="box">
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+ </dl>
54
+ <div class="clear"></div>
55
+
56
+ <h2>Defined Under Namespace</h2>
57
+ <p class="children">
58
+
59
+
60
+ <strong class="modules">Modules:</strong> <a href="Topsy.html" title="Topsy">Topsy</a>
61
+
62
+
63
+
64
+
65
+ </p>
66
+
67
+
68
+
69
+
70
+ </div>
71
+
72
+ <div id="footer">
73
+ Generated on Wed Jan 6 10:31:57 2010 by
74
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool">yard</a>
75
+ 0.5.2 (ruby-1.8.6).
76
+ </div>
77
+
78
+ </body>
79
+ </html>
@@ -0,0 +1,23 @@
1
+ # This is the author class for the topsy library.
2
+ # An Author has the following attributes:
3
+ # "name" : "Barack Obama"
4
+ # "url" : "http://twitter.com/barackobama",
5
+ # "topsy_type" : "twitter",
6
+ # "nick" : "barackobama",
7
+ # "description" : "44th President of the United States",
8
+ # "topsy_author_url" : "http://topsy.com/twitter/barackobama",
9
+ # "influence_level" : "5"
10
+ #
11
+ # According to the official Topsy doc: http://code.google.com/p/otterapi/wiki/Resources?tm=6#/authorinfo
12
+ module Topsy
13
+
14
+ class Author < Hashie::Mash
15
+ def to_s
16
+ "Topsy Author: #{name}, @#{nick}, #{topsy_author_url}"
17
+ end
18
+
19
+ def type
20
+ self[:type]
21
+ end
22
+ end
23
+ end
data/lib/topsy/client.rb CHANGED
@@ -4,12 +4,20 @@ module Topsy
4
4
  format :json
5
5
  base_uri "http://otter.topsy.com"
6
6
 
7
+ # Returns info about API rate limiting
8
+ #
9
+ # @return [RateLimitInfo]
10
+ def credit
11
+ handle_response(self.class.get("/credit.json"))
12
+ end
13
+
7
14
  # Returns Profile information for an author (a twitter profile indexed by Topsy). The response contains the name, description (biography) and the influence level of the author
8
15
  #
9
16
  # @param [String] url URL string for the author.
10
- # @return [Hashie::Mash]
17
+ # @return [Topsy::Author]
11
18
  def author_info(url)
12
- handle_response(self.class.get("/authorinfo.json", :query => {:url => url}))
19
+ authorinfo = handle_response(self.class.get("/authorinfo.json", :query => {:url => url}))
20
+ Topsy::Author.new(authorinfo)
13
21
  end
14
22
 
15
23
  # Returns list of authors that talk about the query. The list is sorted by frequency of posts and the influence of authors.
@@ -31,11 +39,12 @@ module Topsy
31
39
  # @option options [String] :contains Query string to filter results
32
40
  # @option options [Integer] :page page number of the result set. (default: 1, max: 10)
33
41
  # @option options [Integer] :perpage limit number of results per page. (default: 10, max: 50)
34
- # @return [Hashie::Mash]
42
+ # @return [Topsy::Page]
35
43
  def link_posts(url, options={})
36
44
  query = {:url => url}
37
45
  query.merge!(options)
38
- handle_response(self.class.get("/linkposts.json", :query => query))
46
+ linkposts = handle_response(self.class.get("/linkposts.json", :query => query))
47
+ Topsy::Page.new(linkposts,Topsy::Linkpost)
39
48
  end
40
49
 
41
50
  # Returns count of links posted by an author. This is the efficient, count-only version of /linkposts
@@ -43,9 +52,10 @@ module Topsy
43
52
  # @param [String] url URL string for the author.
44
53
  # @param [Hash] options method options
45
54
  # @option options [String] :contains Query string to filter results
46
- # @return [Hashie::Mash]
55
+ # @return [Topsy::LinkpostCount]
47
56
  def link_post_count(url, options={})
48
- handle_response(self.class.get("/linkpostcount.json", :query => {:url => url}.merge(options)))
57
+ count = handle_response(self.class.get("/linkpostcount.json", :query => {:url => url}.merge(options)))
58
+ Topsy::LinkpostCount.new(count)
49
59
  end
50
60
 
51
61
  # Returns list list of author profiles that match the query. The query is matched against the nick, name and biography information and the results are sorted by closeness of match and the influence of authors.
@@ -54,9 +64,10 @@ module Topsy
54
64
  # @param [Hash] options method options
55
65
  # @option options [Integer] :page page number of the result set. (default: 1, max: 10)
56
66
  # @option options [Integer] :perpage limit number of results per page. (default: 10, max: 50)
57
- # @return [Hashie::Mash]
67
+ # @return [Topsy::Page]
58
68
  def profile_search(q, options={})
59
- handle_response(self.class.get("/profilesearch.json", :query => {:q => q}.merge(options)))
69
+ results = handle_response(self.class.get("/profilesearch.json", :query => {:q => q}.merge(options)))
70
+ Topsy::Page.new(results,Topsy::Author)
60
71
  end
61
72
 
62
73
  # Returns list of URLs related to a given URL
@@ -65,9 +76,10 @@ module Topsy
65
76
  # @param [Hash] options method options
66
77
  # @option options [Integer] :page page number of the result set. (default: 1, max: 10)
67
78
  # @option options [Integer] :perpage limit number of results per page. (default: 10, max: 50)
68
- # @return [Hashie::Mash]
79
+ # @return [Topsy::Page]
69
80
  def related(url, options={})
70
- handle_response(self.class.get("/related.json", :query => {:url => url}.merge(options)))
81
+ response = handle_response(self.class.get("/related.json", :query => {:url => url}.merge(options)))
82
+ Topsy::Page.new(response,Topsy::LinkSearchResult)
71
83
  end
72
84
 
73
85
  # Returns list of results for a query.
@@ -77,9 +89,10 @@ module Topsy
77
89
  # @option options [String] :window Time window for results. (default: 'a') Options: auto - automatically pick the most recent and relevant window. h last hour, d last day, w last week, m last month, a all time
78
90
  # @option options [Integer] :page page number of the result set. (default: 1, max: 10)
79
91
  # @option options [Integer] :perpage limit number of results per page. (default: 10, max: 50)
80
- # @return [Hashie::Mash]
92
+ # @return [Topsy::Page]
81
93
  def search(q, options={})
82
- handle_response(self.class.get("/search.json", :query => {:q => q}.merge(options)))
94
+ results = handle_response(self.class.get("/search.json", :query => {:q => q}.merge(options)))
95
+ Topsy::Page.new(results,Topsy::LinkSearchResult)
83
96
  end
84
97
 
85
98
  # Returns count of results for a search query.
@@ -96,11 +109,12 @@ module Topsy
96
109
  # @param [String] url the url to look up
97
110
  # @param [Hash] options method options
98
111
  # @option options [String] :contains Query string to filter results
99
- # @return [Hashie::Mash]
112
+ # @return [Topsy::Stats]
100
113
  def stats(url, options={})
101
114
  query = {:url => url}
102
115
  query.merge!(options)
103
- handle_response(self.class.get("/stats.json", :query => query))
116
+ response = handle_response(self.class.get("/stats.json", :query => query))
117
+ Topsy::Stats.new(response)
104
118
  end
105
119
 
106
120
  # Returns list of tags for a URL.
@@ -109,9 +123,10 @@ module Topsy
109
123
  # @param [Hash] options method options
110
124
  # @option options [Integer] :page page number of the result set. (default: 1, max: 10)
111
125
  # @option options [Integer] :perpage limit number of results per page. (default: 10, max: 50)
112
- # @return [Hashie::Mash]
126
+ # @return [Topsy::Page]
113
127
  def tags(url, options={})
114
- handle_response(self.class.get("/tags.json", :query => {:url => url}.merge(options)))
128
+ response = handle_response(self.class.get("/tags.json", :query => {:url => url}.merge(options)))
129
+ Topsy::Page.new(response,Topsy::Tag)
115
130
  end
116
131
 
117
132
  # Returns list of tweets (trackbacks) that mention the query URL, most recent first.
@@ -122,13 +137,13 @@ module Topsy
122
137
  # @option options [Boolean] :infonly filters trackbacks to influential only (default 0)
123
138
  # @option options [Integer] :page page number of the result set. (default: 1, max: 10)
124
139
  # @option options [Integer] :perpage limit number of results per page. (default: 10, max: 50)
125
- # @return [Hashie::Mash]
140
+ # @return [Topsy::Page]
126
141
  def trackbacks(url, options={})
127
142
  results = handle_response(self.class.get("/trackbacks.json", :query => {:url => url}.merge(options)))
128
143
  results.list.each do |trackback|
129
144
  trackback.date = Time.at(trackback.date)
130
145
  end
131
- results
146
+ Topsy::Page.new(results,Topsy::Tweet)
132
147
  end
133
148
 
134
149
  # Returns list of trending terms
@@ -138,21 +153,24 @@ module Topsy
138
153
  # @option options [Integer] :perpage limit number of results per page. (default: 10, max: 50)
139
154
  # @return [Hashie::Mash]
140
155
  def trending(options={})
141
- handle_response(self.class.get("/trending.json", :query => options))
156
+ response = handle_response(self.class.get("/trending.json", :query => options))
157
+ Topsy::Page.new(response,Topsy::Trend)
142
158
  end
143
159
 
144
160
  # Returns info about a URL
145
161
  #
146
162
  # @param [String] url the url to look up
147
- # @return [Hashie::Mash]
163
+ # @return [Topsy::UrlInfo]
148
164
  def url_info(url)
149
- handle_response(self.class.get("/urlinfo.json", :query => {:url => url}))
165
+ response = handle_response(self.class.get("/urlinfo.json", :query => {:url => url}))
166
+ Topsy::UrlInfo.new(response)
150
167
  end
151
168
 
152
169
  private
153
170
 
154
171
  def handle_response(response)
155
172
  raise_errors(response)
173
+ get_rate_limit_status(response)
156
174
  mashup(response)
157
175
  end
158
176
 
@@ -175,6 +193,15 @@ module Topsy
175
193
  def mashup(response)
176
194
  Hashie::Mash.new(response).response
177
195
  end
196
+
197
+ def get_rate_limit_status(response)
198
+ headers = {
199
+ 'limit' => response.headers['x-ratelimit-limit'].first.to_i,
200
+ 'remaining' => response.headers['x-ratelimit-remaining'].first.to_i,
201
+ 'reset' => response.headers['x-ratelimit-reset'].first.to_i
202
+ }
203
+ Topsy.rate_limit = Topsy::RateLimitInfo.new(headers)
204
+ end
178
205
 
179
206
  end
180
207
  end
@@ -0,0 +1,24 @@
1
+ # This is the link_search_result class for the topsy library.
2
+ # A LinkSearchResult has the following attributes:
3
+ # "trackback_permalink" : "http://twitter.com/ewerickson/status/3562164195",
4
+ # "hits" : 38,
5
+ # "trackback_total" : 157,
6
+ # "topsy_trackback_url" : "http://topsy.com/tb/www.redstate.com/erick/2009/08/26/breaking-rumors-surface-that-leon-panetta-is-resigning/",
7
+ # "url" : "http://www.redstate.com/erick/2009/08/26/breaking-rumors-surface-that-leon-panetta-is-resigning/",
8
+ # "content" : "Panetta is rumored to have sent a resignation letter to Barack Obama today: http://bit.ly/CDMg9",
9
+ # "title" : "BREAKING: Rumors Surface That Leon Panetta is Resigning - Erick’s blog - RedState",
10
+ # "score" : 0.75521481,
11
+ # "highlight" : "Panetta is rumored to have sent a resignation letter to
12
+ # <span class=\"highlight-term\">Barack</span> <span class=\"highlight-term\">Obama</span> today: http://bit.ly/CDMg9"
13
+ # According to the official Topsy doc: http://code.google.com/p/otterapi/wiki/Resources?tm=6#/search
14
+ #
15
+ module Topsy
16
+
17
+ class LinkSearchResult < Hashie::Mash
18
+
19
+ def to_s
20
+ "Topsy LinkSearchResult: #{url}, @#{title}, hits: #{hits}"
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,33 @@
1
+ # This is the linkpost class for the topsy library.
2
+ # A Linkpost has the following attributes:
3
+ # "permalink_url" : "http://twitter.com/barackobama/status/3569838653",
4
+ # "target" : target instance
5
+ # "date" : "1251337427",
6
+ # "content" : "Highlights from the tribute to Sen. Kennedy's life and
7
+ # accomplishments from last year's Democratic National Convention: http://bit.ly/TJcyr",
8
+ # "date_alpha" : "3 hours ago"
9
+ # According to the official Topsy doc: http://code.google.com/p/otterapi/wiki/Resources?tm=6#/linkposts
10
+ #
11
+ module Topsy
12
+
13
+ class Linkpost < Hashie::Dash
14
+ property :permalink_url
15
+ property :target
16
+ property :date
17
+ property :content
18
+ property :date_alpha
19
+
20
+ def to_s
21
+ "Topsy Linkpost: #{permalink_url}, @#{content}"
22
+ end
23
+
24
+ def target=(value)
25
+ if value
26
+ self[:target] = Topsy::Target.new(value)
27
+ else
28
+ self[:target] = value
29
+ end
30
+ end
31
+
32
+ end
33
+ end