topsy 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/.gitignore +21 -0
  2. data/.yardoc/checksums +2 -0
  3. data/.yardoc/objects/Topsy.dat +0 -0
  4. data/.yardoc/objects/Topsy/Client.dat +0 -0
  5. data/.yardoc/objects/Topsy/Client/author_info_i.dat +0 -0
  6. data/.yardoc/objects/Topsy/Client/author_search_i.dat +0 -0
  7. data/.yardoc/objects/Topsy/Client/handle_response_i.dat +0 -0
  8. data/.yardoc/objects/Topsy/Client/link_post_count_i.dat +0 -0
  9. data/.yardoc/objects/Topsy/Client/link_posts_i.dat +0 -0
  10. data/.yardoc/objects/Topsy/Client/mashup_i.dat +0 -0
  11. data/.yardoc/objects/Topsy/Client/profile_search_i.dat +0 -0
  12. data/.yardoc/objects/Topsy/Client/raise_errors_i.dat +0 -0
  13. data/.yardoc/objects/Topsy/Client/related_i.dat +0 -0
  14. data/.yardoc/objects/Topsy/Client/search_count_i.dat +0 -0
  15. data/.yardoc/objects/Topsy/Client/search_i.dat +0 -0
  16. data/.yardoc/objects/Topsy/Client/stats_i.dat +0 -0
  17. data/.yardoc/objects/Topsy/Client/tags_i.dat +0 -0
  18. data/.yardoc/objects/Topsy/Client/trackbacks_i.dat +0 -0
  19. data/.yardoc/objects/Topsy/Client/trending_i.dat +0 -0
  20. data/.yardoc/objects/Topsy/Client/url_info_i.dat +0 -0
  21. data/.yardoc/objects/Topsy/SearchCounts.dat +0 -0
  22. data/.yardoc/objects/Topsy/SearchCounts/all_time_i.dat +0 -0
  23. data/.yardoc/objects/Topsy/SearchCounts/last_hour_i.dat +0 -0
  24. data/.yardoc/objects/Topsy/SearchCounts/last_month_i.dat +0 -0
  25. data/.yardoc/objects/Topsy/SearchCounts/last_week_i.dat +0 -0
  26. data/.yardoc/objects/Topsy/SearchCounts/overall_i.dat +0 -0
  27. data/.yardoc/objects/Topsy/SearchCounts/this_hour_i.dat +0 -0
  28. data/.yardoc/objects/Topsy/SearchCounts/this_month_i.dat +0 -0
  29. data/.yardoc/objects/Topsy/SearchCounts/this_week_i.dat +0 -0
  30. data/.yardoc/objects/Topsy/SearchCounts/today_i.dat +0 -0
  31. data/.yardoc/objects/root.dat +0 -0
  32. data/.yardoc/proxy_types +0 -0
  33. data/LICENSE +20 -0
  34. data/README.markdown +34 -0
  35. data/Rakefile +50 -0
  36. data/VERSION +1 -0
  37. data/changelog.markdown +5 -0
  38. data/lib/topsy.rb +174 -0
  39. data/lib/topsy/client.rb +180 -0
  40. data/lib/topsy/search_counts.rb +46 -0
  41. data/test/fixtures/authorinfo.json +19 -0
  42. data/test/fixtures/authorsearch.json +165 -0
  43. data/test/fixtures/linkpostcount.json +14 -0
  44. data/test/fixtures/linkposts.json +135 -0
  45. data/test/fixtures/profilesearch.json +23 -0
  46. data/test/fixtures/related.json +75 -0
  47. data/test/fixtures/search.json +126 -0
  48. data/test/fixtures/searchcount.json +17 -0
  49. data/test/fixtures/stats.json +16 -0
  50. data/test/fixtures/tags.json +51 -0
  51. data/test/fixtures/trackbacks.json +56 -0
  52. data/test/fixtures/trending.json +53 -0
  53. data/test/fixtures/urlinfo.json +19 -0
  54. data/test/helper.rb +45 -0
  55. data/test/test_topsy.rb +99 -0
  56. metadata +170 -0
@@ -0,0 +1,126 @@
1
+ {
2
+ "request": {
3
+ "response_type": "json",
4
+ "resource": "search",
5
+ "parameters": {
6
+ "q": "NYE"
7
+ },
8
+ "url": "http://button.topsy.com/search.json?q=NYE"
9
+ },
10
+ "response": {
11
+ "page": 1,
12
+ "window": "a",
13
+ "total": 117731,
14
+ "perpage": 10,
15
+ "list": [{
16
+ "trackback_permalink": "http://twitter.com/spin/status/5164154014",
17
+ "content": "Science, autotuned, with Sagan, Bill Nye, Tyson, Feynman http://bit.ly/2tDk4y win!",
18
+ "score": 4.70643044,
19
+ "trackback_total": 2268,
20
+ "hits": 397,
21
+ "topsy_trackback_url": "http://topsy.com/trackback?url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DXGK84Poeynk",
22
+ "url": "http://www.youtube.com/watch?v=XGK84Poeynk",
23
+ "title": "YouTube - Symphony of Science - 'We Are All Connected' (ft. Sagan, Feynman, deGrasse Tyson & Bill Nye)",
24
+ "highlight": "Science, autotuned, with Sagan, Bill <span class=\"highlight-term\">Nye</span>, Tyson, Feynman http://bit.ly/2tDk4y win! "
25
+ },
26
+ {
27
+ "trackback_permalink": "http://twitter.com/jimmyeatworld/status/6703729600",
28
+ "content": "Tweet To Win tickets to see us in Atlantic City on New Years Eve http://tweettow.in/jew_nye",
29
+ "score": 3.2793746,
30
+ "trackback_total": 267,
31
+ "hits": 257,
32
+ "topsy_trackback_url": "http://topsy.com/tb/tweettow.in/jew_nye",
33
+ "url": "http://tweettow.in/jew_nye",
34
+ "title": "Jimmy Eat World New Years Eve Tweet To Win! Twitter Contest",
35
+ "highlight": "Tweet To Win tickets to see us in Atlantic City on New Years Eve http://tweettow.in/jew_nye "
36
+ },
37
+ {
38
+ "trackback_permalink": "http://twitter.com/riamarie/status/6704540214",
39
+ "content": "@JimmyEatWorld is performing in Atlantic City on New Years Eve http://bit.ly/jew_nye Tweet To Win tickets here http://tweettow.in/jew_nye",
40
+ "score": 2.46673536,
41
+ "trackback_total": 222,
42
+ "hits": 216,
43
+ "topsy_trackback_url": "http://topsy.com/tb/www.ticketmaster.com/event/0200434E8DC84292",
44
+ "url": "http://www.ticketmaster.com/event/0200434E8DC84292",
45
+ "title": "Jimmy Eat World tickets Harrah's Resort Atlantic City Atlantic City, NJ, Directions, seating chart. Official",
46
+ "highlight": "@JimmyEatWorld is performing in Atlantic City on New Years Eve http://bit.ly/jew_nye Tweet To Win tickets here http://tweettow.in/jew_nye "
47
+ },
48
+ {
49
+ "trackback_permalink": "http://twitter.com/cinevegas/status/5580832629",
50
+ "content": "RT @Vegas: Have you entered the @Vegas Tweepstakes? What’s Your Excuse to come to Vegas this NYE? #lvsweeps Details: http://bit.ly/lvsweeps",
51
+ "score": 2.08547235,
52
+ "trackback_total": 504,
53
+ "hits": 161,
54
+ "topsy_trackback_url": "http://topsy.com/tb/www.visitlasvegas.com/Tweepstakes",
55
+ "url": "http://www.visitlasvegas.com/Tweepstakes",
56
+ "title": "Enter Tweepstakes today to win a New Year’s trip to Vegas & stay at the new Vdara! RT this! #lvsweeps",
57
+ "highlight": "RT @Vegas: Have you entered the @Vegas Tweepstakes? What’s Your Excuse to come to Vegas this <span class=\"highlight-term\">NYE</span>? #lvsweeps Details: http://bit.ly/lvsweeps&#8230;"
58
+ },
59
+ {
60
+ "trackback_permalink": "http://twitter.com/bigepaz/status/7238723956",
61
+ "content": "NIce! A rare Blue Moon tonight for NYE :) http://bit.ly/7SfQt8",
62
+ "score": 1.76893127,
63
+ "trackback_total": 918,
64
+ "hits": 69,
65
+ "topsy_trackback_url": "http://topsy.com/tb/news.yahoo.com/s/ap/20091230/ap_on_sc/us_sci_blue_moon",
66
+ "url": "http://news.yahoo.com/s/ap/20091230/ap_on_sc/us_sci_blue_moon",
67
+ "title": "Rare New Year's Eve 'blue moon' to ring in 2010 - Yahoo! News",
68
+ "highlight": "NIce! A rare Blue Moon tonight for <span class=\"highlight-term\">NYE</span> :) http://bit.ly/7SfQt8 "
69
+ },
70
+ {
71
+ "trackback_permalink": "http://twitter.com/rainnwilson/status/4699688554",
72
+ "content": "Bill Nye the Science Guy VS Religion: http://www.soulpancake.com/",
73
+ "score": 1.73702061,
74
+ "trackback_total": 1373,
75
+ "hits": 55,
76
+ "topsy_trackback_url": "http://topsy.com/tb/www.soulpancake.com/",
77
+ "url": "http://www.soulpancake.com/",
78
+ "title": "SoulPancake | Chew On Life's Big Questions",
79
+ "highlight": "Bill <span class=\"highlight-term\">Nye</span> the Science Guy VS Religion: http://www.soulpancake.com/ "
80
+ },
81
+ {
82
+ "trackback_permalink": "http://twitter.com/problogger/status/7211472899",
83
+ "content": "Preparing for NYE? Check out our Fireworks Photography Tips - http://bit.ly/4qv3IM",
84
+ "score": 1.72081316,
85
+ "trackback_total": 450,
86
+ "hits": 30,
87
+ "topsy_trackback_url": "http://topsy.com/tb/digital-photography-school.com/how-to-photograph-fireworks",
88
+ "url": "http://digital-photography-school.com/how-to-photograph-fireworks",
89
+ "title": "How to Photograph Fireworks Displays",
90
+ "highlight": "Preparing for <span class=\"highlight-term\">NYE</span>? Check out our Fireworks Photography Tips - http://bit.ly/4qv3IM "
91
+ },
92
+ {
93
+ "trackback_permalink": "http://twitter.com/iamdiddy/status/7222027205",
94
+ "content": "RT @sandrinecharles: @iamdiddy promotes safe travels in NYC + Vegas on NYE http://bit.ly/6v5CCZ Get your free ride! (via @perezhilton)",
95
+ "score": 1.59172273,
96
+ "trackback_total": 55,
97
+ "hits": 53,
98
+ "topsy_trackback_url": "http://topsy.com/tb/perezhilton.com/2009-12-30-diddy-cares-about-u-on-nye",
99
+ "url": "http://perezhilton.com/2009-12-30-diddy-cares-about-u-on-nye",
100
+ "title": "Perez Hilton: Diddy Cares About U On NYE!",
101
+ "highlight": "RT @sandrinecharles: @iamdiddy promotes safe travels in NYC + Vegas on <span class=\"highlight-term\">NYE</span> http://bit.ly/6v5CCZ Get your free ride! (via @perezhilton) "
102
+ },
103
+ {
104
+ "trackback_permalink": "http://twitter.com/allisonpeltz/status/7200230271",
105
+ "content": "blue moon shining tomorrow night for NYE - http://bit.ly/4HVlwO",
106
+ "score": 1.40584981,
107
+ "trackback_total": 935,
108
+ "hits": 60,
109
+ "topsy_trackback_url": "http://topsy.com/tb/www.cnn.com/2009/TECH/space/12/30/blue.moon/",
110
+ "url": "http://www.cnn.com/2009/TECH/space/12/30/blue.moon/",
111
+ "title": "Blue moon to shine on New Year's Eve - CNN.com",
112
+ "highlight": "blue moon shining tomorrow night for <span class=\"highlight-term\">NYE</span> - http://bit.ly/4HVlwO "
113
+ },
114
+ {
115
+ "trackback_permalink": "http://twitter.com/web2today/status/2351952044",
116
+ "content": "Best of the Rest: Bill Nye on the iPhone, Retro Twitter (Circa 1935) - Switched: Best of the Rest: Bill Nye on t.. http://tinyurl.com/p9htnf",
117
+ "score": 1.31912446,
118
+ "trackback_total": 49,
119
+ "hits": 44,
120
+ "topsy_trackback_url": "http://topsy.com/tb/www.switched.com/2009/06/26/best-of-the-rest-bill-nye-on-the-iphone-the-original-twitter/",
121
+ "url": "http://www.switched.com/2009/06/26/best-of-the-rest-bill-nye-on-the-iphone-the-original-twitter/",
122
+ "title": "Best of the Rest: Bill Nye on the iPhone, Retro Twitter (Circa 1935)",
123
+ "highlight": "Best of the Rest: Bill <span class=\"highlight-term\">Nye</span> on the iPhone, Retro Twitter (Circa 1935) - Switched: Best of the Rest: Bill <span class=\"highlight-term\">Nye</span> on t.. http://tinyurl.com/p9htnf&#8230;"
124
+ }]
125
+ }
126
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "request": {
3
+ "response_type": "json",
4
+ "resource": "searchcount",
5
+ "parameters": {
6
+ "q": "Balloon Boy"
7
+ },
8
+ "url": "http://button.topsy.com/searchcount.json?q=Balloon+Boy"
9
+ },
10
+ "response": {
11
+ "w": 425,
12
+ "a": 42289,
13
+ "m": 3659,
14
+ "d": 41,
15
+ "h": 0
16
+ }
17
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "request": {
3
+ "response_type": "json",
4
+ "resource": "stats",
5
+ "parameters": {
6
+ "url": "http://github.com/pengwynn/linkedin"
7
+ },
8
+ "url": "http://button.topsy.com/stats.json?url=http%3A%2F%2Fgithub.com%2Fpengwynn%2Flinkedin"
9
+ },
10
+ "response": {
11
+ "influential": 3,
12
+ "all": 11,
13
+ "contains": 0,
14
+ "topsy_trackback_url": "http://topsy.com/tb/github.com/pengwynn/linkedin"
15
+ }
16
+ }
@@ -0,0 +1,51 @@
1
+ {
2
+ "request": {
3
+ "response_type": "json",
4
+ "resource": "tags",
5
+ "parameters": {
6
+ "url": "http://gemcutter.org"
7
+ },
8
+ "url": "http://button.topsy.com/tags.json?url=http%3A%2F%2Fgemcutter.org"
9
+ },
10
+ "response": {
11
+ "page": 1,
12
+ "total": 9,
13
+ "perpage": 10,
14
+ "list": [{
15
+ "name": "itunesu",
16
+ "url": "http://topsy.com/s?q=itunesu"
17
+ },
18
+ {
19
+ "name": "projectsprouts",
20
+ "url": "http://topsy.com/s?q=projectsprouts"
21
+ },
22
+ {
23
+ "name": "gemcutter",
24
+ "url": "http://topsy.com/s?q=gemcutter"
25
+ },
26
+ {
27
+ "name": "rails",
28
+ "url": "http://topsy.com/s?q=rails"
29
+ },
30
+ {
31
+ "name": "ruby",
32
+ "url": "http://topsy.com/s?q=ruby"
33
+ },
34
+ {
35
+ "name": "gems",
36
+ "url": "http://topsy.com/s?q=gems"
37
+ },
38
+ {
39
+ "name": "gem",
40
+ "url": "http://topsy.com/s?q=gem"
41
+ },
42
+ {
43
+ "name": "fail",
44
+ "url": "http://topsy.com/s?q=fail"
45
+ },
46
+ {
47
+ "name": "jruby",
48
+ "url": "http://topsy.com/s?q=jruby"
49
+ }]
50
+ }
51
+ }
@@ -0,0 +1,56 @@
1
+ {
2
+ "request": {
3
+ "response_type": "json",
4
+ "resource": "trackbacks",
5
+ "parameters": {
6
+ "url": "http://orrka.com"
7
+ },
8
+ "url": "http://button.topsy.com/trackbacks.json?url=http%3A%2F%2Forrka.com"
9
+ },
10
+ "response": {
11
+ "page": 1,
12
+ "total": 3,
13
+ "perpage": 10,
14
+ "topsy_trackback_url": "http://topsy.com/tb/orrka.com/",
15
+ "list": [{
16
+ "permalink_url": "http://twitter.com/orrka/status/6435248067",
17
+ "date": 1260204073,
18
+ "content": "Just added some portfolio entries to http://orrka.com/",
19
+ "author": {
20
+ "url": "http://twitter.com/orrka",
21
+ "name": "Orrka",
22
+ "photo_url": "http://a1.twimg.com/profile_images/476284898/avatar_normal.png",
23
+ "topsy_author_url": "http://topsy.com/twitter/orrka"
24
+ },
25
+ "date_alpha": "25 days ago",
26
+ "type": "tweet"
27
+ },
28
+ {
29
+ "permalink_url": "http://twitter.com/chuckmallott/status/5059873467",
30
+ "date": 1256179965,
31
+ "content": "I really like this logo: http://orrka.com",
32
+ "author": {
33
+ "url": "http://twitter.com/chuckmallott",
34
+ "name": "Chuck Mallott",
35
+ "photo_url": "http://a1.twimg.com/profile_images/598852858/me-blueshirt_normal.png",
36
+ "topsy_author_url": "http://topsy.com/twitter/chuckmallott",
37
+ "influence_level": 2
38
+ },
39
+ "date_alpha": "Oct 21, 2009",
40
+ "type": "tweet"
41
+ },
42
+ {
43
+ "permalink_url": "http://twitter.com/orrka/status/4930595271",
44
+ "date": 1255739577,
45
+ "content": "This is going to be killer http://orrka.com",
46
+ "author": {
47
+ "url": "http://twitter.com/orrka",
48
+ "name": "Orrka",
49
+ "photo_url": "http://a1.twimg.com/profile_images/476284898/avatar_normal.png",
50
+ "topsy_author_url": "http://topsy.com/twitter/orrka"
51
+ },
52
+ "date_alpha": "Oct 16, 2009",
53
+ "type": "tweet"
54
+ }]
55
+ }
56
+ }
@@ -0,0 +1,53 @@
1
+ {
2
+ "request": {
3
+ "response_type": "json",
4
+ "resource": "trending",
5
+ "parameters": {},
6
+ "url": "http://button.topsy.com/trending.json"
7
+ },
8
+ "response": {
9
+ "page": 1,
10
+ "total": 1379,
11
+ "perpage": 10,
12
+ "list": [{
13
+ "term": "photoshop photoshop",
14
+ "url": "http://topsy.com/s?q=photoshop+photoshop"
15
+ },
16
+ {
17
+ "term": "swizz beatz",
18
+ "url": "http://topsy.com/s?q=swizz+beatz"
19
+ },
20
+ {
21
+ "term": "limbaugh hospitalized",
22
+ "url": "http://topsy.com/s?q=limbaugh+hospitalized"
23
+ },
24
+ {
25
+ "term": "travis pastrana",
26
+ "url": "http://topsy.com/s?q=travis+pastrana"
27
+ },
28
+ {
29
+ "term": "auld lang syne",
30
+ "url": "http://topsy.com/s?q=auld+lang%20syne"
31
+ },
32
+ {
33
+ "term": "#happynewyear",
34
+ "url": "http://topsy.com/s?q=%23happynewyear"
35
+ },
36
+ {
37
+ "term": "#2010",
38
+ "url": "http://topsy.com/s?q=%232010"
39
+ },
40
+ {
41
+ "term": "#2009",
42
+ "url": "http://topsy.com/s?q=%232009"
43
+ },
44
+ {
45
+ "term": "full body scanners",
46
+ "url": "http://topsy.com/s?q=full+body%20scanners"
47
+ },
48
+ {
49
+ "term": "#10yearsago",
50
+ "url": "http://topsy.com/s?q=%2310yearsago"
51
+ }]
52
+ }
53
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "request": {
3
+ "response_type": "json",
4
+ "resource": "urlinfo",
5
+ "parameters": {
6
+ "url": "http://twitter.com"
7
+ },
8
+ "url": "http://button.topsy.com/urlinfo.json?url=http%3A%2F%2Ftwitter.com"
9
+ },
10
+ "response": {
11
+ "oneforty": "trending topics - -amp09 right up there past the president today! :) http://tiny.cc/3yNbv",
12
+ "description": "",
13
+ "trackback_total": 39379,
14
+ "topsy_trackback_url": "http://topsy.com/tb/twitter.com/",
15
+ "description_attribution": "",
16
+ "url": "http://twitter.com/",
17
+ "title": "trending topics - -amp09 right up there past the president today! :)"
18
+ }
19
+ }
data/test/helper.rb ADDED
@@ -0,0 +1,45 @@
1
+ require 'test/unit'
2
+ require 'pathname'
3
+ require 'rubygems'
4
+
5
+ gem 'thoughtbot-shoulda', '>= 2.10.1'
6
+ gem 'jnunemaker-matchy', '0.4.0'
7
+ gem 'mocha', '0.9.4'
8
+ gem 'fakeweb', '>= 1.2.5'
9
+
10
+ require 'shoulda'
11
+ require 'matchy'
12
+ require 'mocha'
13
+ require 'fakeweb'
14
+
15
+
16
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
17
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
18
+ require 'topsy'
19
+
20
+ FakeWeb.allow_net_connect = false
21
+
22
+ class Test::Unit::TestCase
23
+ end
24
+
25
+ def fixture_file(filename)
26
+ return '' if filename == ''
27
+ file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
28
+ File.read(file_path)
29
+ end
30
+
31
+ def topsy_url(url)
32
+ url =~ /^http/ ? url : "http://otter.topsy.com#{url}"
33
+ end
34
+
35
+ def stub_get(url, filename, status=nil)
36
+ options = {:body => fixture_file(filename)}
37
+ options.merge!({:status => status}) unless status.nil?
38
+
39
+ FakeWeb.register_uri(:get, topsy_url(url), options)
40
+ end
41
+
42
+ def stub_post(url, filename)
43
+ FakeWeb.register_uri(:post, topsy_url(url), :body => fixture_file(filename))
44
+ end
45
+
@@ -0,0 +1,99 @@
1
+ require 'helper'
2
+
3
+ class TestTopsy < Test::Unit::TestCase
4
+
5
+ context "when hitting the Otter API" do
6
+
7
+ should "return author info for a profile url" do
8
+ stub_get("/authorinfo.json?url=http%3A%2F%2Ftwitter.com%2Fpengwynn", "authorinfo.json")
9
+ info = Topsy.author_info("http://twitter.com/pengwynn")
10
+ info.nick.should == 'pengwynn'
11
+ info.influence_level.should == 10
12
+ end
13
+
14
+ should "return search for authors" do
15
+ stub_get("/authorsearch.json?q=pengwynn", "authorsearch.json")
16
+ results = Topsy.author_search("pengwynn")
17
+ results.total.should == 491
18
+ results.list.first.nick.should == 'bradleyjoyce'
19
+ end
20
+
21
+ should "list of urls posted by an author" do
22
+ stub_get("/linkposts.json?url=http%3A%2F%2Ftwitter.com%2Fpengwynn", "linkposts.json")
23
+ results = Topsy.link_posts("http://twitter.com/pengwynn")
24
+ results.total.should == 1004
25
+ results.list.first.content.should == 'For auld lang syne, my dear: http://en.wikipedia.org/wiki/Auld_Lang_Syne#Lyrics'
26
+ end
27
+
28
+ should "return count of links posted by an author" do
29
+ stub_get("/linkpostcount.json?url=http%3A%2F%2Ftwitter.com%2Fpengwynn", "linkpostcount.json")
30
+ counts = Topsy.link_post_count("http://twitter.com/pengwynn")
31
+ counts.all.should == 1004
32
+ counts.contains.should == 0
33
+ end
34
+
35
+ should "return a list of author profiles that match the query." do
36
+ stub_get("/profilesearch.json?q=pengwynn", "profilesearch.json")
37
+ results = Topsy.profile_search("pengwynn")
38
+ results.total.should == 1
39
+ results.list.first.influence_level.should == 10
40
+ end
41
+
42
+ should "return a list of URLs related to a given URL" do
43
+ stub_get("/related.json?url=http%3A%2F%2Fgemcutter.org", "related.json")
44
+ results = Topsy.related("http://gemcutter.org")
45
+ results.total.should == 17
46
+ results.list.first.title.should == 'the update | gemcutter | awesome gem hosting'
47
+ end
48
+
49
+ should "return a list of results for a query" do
50
+ stub_get("/search.json?q=NYE", "search.json")
51
+ results = Topsy.search("NYE")
52
+ results.total.should == 117731
53
+ results.list.first.score.should == 4.70643044
54
+ end
55
+
56
+ should "return search counts for a term" do
57
+ stub_get("/searchcount.json?q=Balloon%20Boy", "searchcount.json")
58
+ counts = Topsy.search_count('Balloon Boy')
59
+ counts.last_hour.should == 0
60
+ counts.last_month.should == 3659
61
+ counts.all_time.should == 42289
62
+ end
63
+
64
+ should "return count of tweets for a url" do
65
+ stub_get("/stats.json?url=http%3A%2F%2Fgithub.com%2Fpengwynn%2Flinkedin", "stats.json")
66
+ stats = Topsy.stats("http://github.com/pengwynn/linkedin")
67
+ stats.all.should == 11
68
+ stats.influential.should == 3
69
+ end
70
+
71
+ should "return a list of tags associated with a url" do
72
+ stub_get("/tags.json?url=http%3A%2F%2Fgemcutter.org", "tags.json")
73
+ results = Topsy.tags("http://gemcutter.org")
74
+ results.total.should == 9
75
+ assert results.list.map{|t| t.name}.include?("ruby")
76
+ end
77
+
78
+ should "return a list of tweets (trackbacks) that mention the query URL" do
79
+ stub_get("/trackbacks.json?url=http%3A%2F%2Forrka.com", "trackbacks.json")
80
+ results = Topsy.trackbacks("http://orrka.com")
81
+ results.total.should == 3
82
+ results.list.first.date.year.should == 2009
83
+ end
84
+
85
+ should "return a list of trending terms" do
86
+ stub_get("/trending.json", "trending.json")
87
+ results = Topsy.trending
88
+ results.total.should == 1379
89
+ assert results.list.map{|t| t.term}.flatten.include?("auld lang syne")
90
+ end
91
+
92
+ should "return info about a url" do
93
+ stub_get("/urlinfo.json?url=http%3A%2F%2Fwynnnetherland.com", 'urlinfo.json')
94
+ results = Topsy.url_info('http://wynnnetherland.com')
95
+ results.trackback_total.should == 39379
96
+ end
97
+ end
98
+
99
+ end