cotweet-bitly 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,173 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'test_helper.rb')
2
+
3
+ class TestUrl < Test::Unit::TestCase
4
+ context "a new Bitly::Url" do
5
+ should "require a login and api_key" do
6
+ assert_raise ArgumentError do Bitly::Url.new end
7
+ assert_raise ArgumentError do Bitly::Url.new(login) end
8
+ assert_raise ArgumentError do Bitly::Url.new(nil, api_key) end
9
+ assert_nothing_raised do
10
+ Bitly::Url.new(login, api_key)
11
+ Bitly::Url.new(login, api_key, :hash => '3j4ir4')
12
+ Bitly::Url.new(login, api_key, :short_url => 'http://bit.ly/3j4ir4')
13
+ Bitly::Url.new(login, api_key, :long_url => 'http://google.com/')
14
+ end
15
+ end
16
+ context "shortening" do
17
+ context "with a long url" do
18
+ setup do
19
+ stub_get(/^http:\/\/api.bit.ly\/shorten\?.*longUrl=.*cnn.com.*$/,"cnn.json")
20
+ @url = Bitly::Url.new(login, api_key, :long_url => 'http://cnn.com/')
21
+ end
22
+ should "return a short url" do
23
+ assert_equal "http://bit.ly/15DlK", @url.shorten
24
+ end
25
+ should "create bitly and jmp urls" do
26
+ @url.shorten
27
+ assert_equal "http://bit.ly/15DlK", @url.bitly_url
28
+ assert_equal "http://j.mp/15DlK", @url.jmp_url
29
+ end
30
+ end
31
+ context "with no long url" do
32
+ setup do
33
+ @url = Bitly::Url.new(login, api_key)
34
+ end
35
+ should "raise an error" do
36
+ assert_raise ArgumentError do
37
+ @url.shorten
38
+ end
39
+ end
40
+ end
41
+ context "with a short url already" do
42
+ setup do
43
+ @url = Bitly::Url.new(login, api_key, :short_url => 'http://bit.ly/31IqMl')
44
+ flexmock(@url).should_receive(:create_url).never
45
+ end
46
+ should "not need to call the api" do
47
+ assert_equal "http://bit.ly/31IqMl", @url.shorten
48
+ end
49
+ end
50
+ end
51
+ context "expanding" do
52
+ context "with a hash" do
53
+ setup do
54
+ stub_get(/^http:\/\/api.bit.ly\/expand\?.*hash=31IqMl.*$/,"expand_cnn.json")
55
+ @url = Bitly::Url.new(login, api_key, :hash => '31IqMl')
56
+ end
57
+ should "return an expanded url" do
58
+ assert_equal "http://cnn.com/", @url.expand
59
+ end
60
+ end
61
+ context "with a short url" do
62
+ setup do
63
+ stub_get(/^http:\/\/api.bit.ly\/expand\?.*hash=31IqMl.*$/,"expand_cnn.json")
64
+ @url = Bitly::Url.new(login, api_key, :short_url => 'http://bit.ly/31IqMl')
65
+ end
66
+ should "return an expanded url" do
67
+ assert_equal "http://cnn.com/", @url.expand
68
+ end
69
+ end
70
+ context "with no short url or hash" do
71
+ setup do
72
+ @url = Bitly::Url.new(login, api_key)
73
+ end
74
+ should "raise an error" do
75
+ assert_raise ArgumentError do
76
+ @url.expand
77
+ end
78
+ end
79
+ end
80
+ context "with a long url already" do
81
+ setup do
82
+ @url = Bitly::Url.new(login, api_key, :long_url => 'http://google.com')
83
+ flexmock(@url).should_receive(:create_url).never
84
+ end
85
+ should "not need to call the api" do
86
+ assert_equal "http://google.com", @url.expand
87
+ end
88
+ end
89
+ end
90
+ context "info" do
91
+ context "with a hash" do
92
+ setup do
93
+ stub_get(/^http:\/\/api.bit.ly\/info\?.*hash=3j4ir4.*$/,"google_info.json")
94
+ @url = Bitly::Url.new(login, api_key, :hash => '3j4ir4')
95
+ end
96
+ should "return info" do
97
+ assert_equal "Google", @url.info['htmlTitle']
98
+ end
99
+ end
100
+ context "with a short url" do
101
+ setup do
102
+ stub_get(/^http:\/\/api.bit.ly\/info\?.*hash=3j4ir4.*$/,"google_info.json")
103
+ @url = Bitly::Url.new(login, api_key, :short_url => 'http://bit.ly/3j4ir4')
104
+ end
105
+ should "return an expanded url" do
106
+ assert_equal "Google", @url.info['htmlTitle']
107
+ end
108
+ end
109
+ context "without a short url or hash" do
110
+ setup do
111
+ @url = Bitly::Url.new(login, api_key, :long_url => 'http://google.com')
112
+ end
113
+ should "raise an error" do
114
+ assert_raise ArgumentError do
115
+ @url.info
116
+ end
117
+ end
118
+ end
119
+ context "with info already" do
120
+ setup do
121
+ stub_get(/^http:\/\/api.bit.ly\/info\?.*hash=3j4ir4.*$/,"google_info.json")
122
+ @url = Bitly::Url.new(login, api_key, :short_url => 'http://bit.ly/3j4ir4')
123
+ @url.info
124
+ end
125
+ should "not call the api twice" do
126
+ flexmock(@url).should_receive(:create_url).never
127
+ @url.info
128
+ end
129
+ end
130
+ end
131
+ context "stats" do
132
+ context "with a hash" do
133
+ setup do
134
+ stub_get(/^http:\/\/api.bit.ly\/stats\?.*hash=3j4ir4.*$/,"google_stats.json")
135
+ @url = Bitly::Url.new(login, api_key, :hash => '3j4ir4')
136
+ end
137
+ should "return info" do
138
+ assert_equal 2644, @url.stats['clicks']
139
+ end
140
+ end
141
+ context "with a short url" do
142
+ setup do
143
+ stub_get(/^http:\/\/api.bit.ly\/stats\?.*hash=3j4ir4.*$/,"google_stats.json")
144
+ @url = Bitly::Url.new(login, api_key, :short_url => 'http://bit.ly/3j4ir4')
145
+ end
146
+ should "return an expanded url" do
147
+ assert_equal 2644, @url.stats['clicks']
148
+ end
149
+ end
150
+ context "without a short url or hash" do
151
+ setup do
152
+ @url = Bitly::Url.new(login, api_key, :long_url => 'http://google.com')
153
+ end
154
+ should "raise an error" do
155
+ assert_raise ArgumentError do
156
+ @url.stats
157
+ end
158
+ end
159
+ end
160
+ context "with info already" do
161
+ setup do
162
+ stub_get(/^http:\/\/api.bit.ly\/stats\?.*hash=3j4ir4.*$/,"google_stats.json")
163
+ @url = Bitly::Url.new(login, api_key, :short_url => 'http://bit.ly/3j4ir4')
164
+ @url.stats
165
+ end
166
+ should "not call the api twice" do
167
+ flexmock(@url).should_receive(:create_url).never
168
+ @url.stats
169
+ end
170
+ end
171
+ end
172
+ end
173
+ end
@@ -0,0 +1,79 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'test_helper.rb')
2
+
3
+ class TestUtils < Test::Unit::TestCase
4
+ include Bitly::Utils
5
+ API_VERSION = '2.0.1'
6
+
7
+ context "text utils" do
8
+ should "underscore a word" do
9
+ assert_equal "hello_world", underscore("HelloWorld")
10
+ end
11
+ should "create a hash from a bitly url" do
12
+ assert_equal "hello", create_hash_from_url("http://bit.ly/hello")
13
+ end
14
+ should "create a hash from a jmp url" do
15
+ assert_equal "hello", create_hash_from_url("http://j.mp/hello")
16
+ end
17
+ end
18
+
19
+ context "class utils" do
20
+ should "turn a key value pair into an instance variable" do
21
+ attr_define('hello','goodbye')
22
+ assert_equal @hello, "goodbye"
23
+ end
24
+
25
+ should "turn a hash into instance variables" do
26
+ instance_variablise({'hello' => 'goodbye'}, ['hello'])
27
+ assert_equal @hello, "goodbye"
28
+ end
29
+
30
+ should "not turn nonspecified variables into instance variables" do
31
+ instance_variablise({'hello' => 'goodbye'}, [])
32
+ assert_nil @hello
33
+ end
34
+ end
35
+
36
+ context "creating a url" do
37
+ setup do
38
+ @api_key = api_key
39
+ @login = login
40
+ end
41
+ should "contain all the basic information" do
42
+ url = create_url.to_s
43
+ assert url.include?('http://api.bit.ly/')
44
+ assert url.include?("version=#{API_VERSION}")
45
+ assert url.include?("apiKey=#{api_key}")
46
+ assert url.include?("login=#{login}")
47
+ end
48
+ should "contain the right resource" do
49
+ url = create_url('shorten').to_s
50
+ assert url.include?('/shorten')
51
+ end
52
+ should "contain extra parameters" do
53
+ url = create_url('shorten', :longUrl => 'http://google.com').to_s
54
+ assert url.include?("longUrl=#{CGI.escape('http://google.com')}")
55
+ end
56
+ end
57
+
58
+ context "fetching a url" do
59
+ context "successfully" do
60
+ setup do
61
+ stub_get("http://example.com","cnn.json")
62
+ end
63
+ should "return a json object successfully" do
64
+ result = get_result(URI.join("http://example.com"))
65
+ assert_equal Hash, result.class
66
+ end
67
+ end
68
+ context "unsuccessfully" do
69
+ setup do
70
+ stub_get("http://example.com", 'shorten_error.json')
71
+ end
72
+ should "raise BitlyError" do
73
+ assert_raise BitlyError do
74
+ result = get_result(URI.join("http://example.com"))
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1 @@
1
+ { "errorCode": 0, "errorMessage": "", "results": { "http://cnn.com": { "hash": "31IqMl", "shortKeywordUrl": "", "shortUrl": "http://bit.ly/15DlK", "userHash": "15DlK" } }, "statusCode": "OK" }
@@ -0,0 +1 @@
1
+ { "errorCode": 0, "errorMessage": "", "results": { "http://cnn.com": { "hash": "31IqMl", "shortKeywordUrl": "", "shortUrl": "http://bit.ly/15DlK", "userHash": "15DlK" }, "http://google.com": { "hash": "3j4ir4", "shortKeywordUrl": "", "shortUrl": "http://bit.ly/11etr", "userHash": "11etr" } }, "statusCode": "OK" }
@@ -0,0 +1 @@
1
+ { "errorCode": 0, "errorMessage": "", "results": { "31IqMl": { "longUrl": "http://cnn.com/" } }, "statusCode": "OK" }
@@ -0,0 +1 @@
1
+ { "errorCode": 0, "errorMessage": "", "results": { "15DlK": { "longUrl": "http://cnn.com/" }, "3j4ir4": { "longUrl": "http://google.com/" } }, "statusCode": "OK" }
@@ -0,0 +1 @@
1
+ { "errorCode": 0, "errorMessage": "", "results": { "31IqMl": { "calais": {}, "calaisId": "", "calaisResolutions": {}, "contentLegth": 284.0, "contentLength": "", "contentType": "text/html", "exif": {}, "fileExtension": "", "globalHash": "31IqMl", "hash": "31IqMl", "htmlMetaDescription": "CNN.com delivers the latest breaking news and information on the latest top stories, weather, business, entertainment, politics, and more. For in-depth coverage, CNN.com provides special reports, video, audio, photo galleries, and interactive guides.", "htmlMetaKeywords": [ "CNN", "CNN news", "CNN.com", "CNN TV", "news", "news online", "breaking news", "U.S. news", "world news", "weather", "business", "CNN Money", "sports", "politics", "law", "technology", "entertainment", "education", "travel", "health", "special reports", "autos", "developing story", "news video", "CNN Intl" ], "htmlTitle": "CNN.com - Breaking News, U.S., World, Weather, Entertainment & Video News", "id3": {}, "indexed": 1246563927, "keyword": "", "keywords": [], "longUrl": "http://cnn.com/", "metacarta": [], "mirrorUrl": "", "shortenedByUser": "bitly", "surbl": 0, "thumbnail": { "large": "http://s.bit.ly/bitly/31IqMl/thumbnail_large.png", "medium": "http://s.bit.ly/bitly/31IqMl/thumbnail_medium.png", "small": "http://s.bit.ly/bitly/31IqMl/thumbnail_small.png" }, "urlFetched": "http://www.cnn.com/", "userHash": "", "users": [ "shmooved", "bitlybookmarklet", "thepalermoproject", "soundcloud", "todd", "johnb", "gfc", "selias22", "heme", "heavensrevenge", "tedroden", "showpopr", "toma", "invokemedia", "jonsteinberg", "shmoop", "crkn", "spol", "neilw", "superamit", "tadwook", "timkl", "elmerfudd", "directeur", "jamescrowley", "tickerhound", "twitterhound", "mobilemind", "thismagazine", "mpminer", "nok", "eljojo", "dumpkopf", "spreadmob", "nishith", "chorrell", "dave", "isayel", "revrev", "ideacol", "adelevie", "b2c", "zen", "tweepletwak", "stephdau", "jeton", "hiteck", "sonidolocal", "cavorite", "jay", "rajeshkp", "mailplane", "sbtodd", "bitohoney", "detect", "artd", "ivankirigin", "NeilCrosby", "mskadu", "dmpro", "millette", "mm", "aweissman", "nearlybot", "ajasver", "orenus", "yunfan", "vipeers", "michel", "spraycode", "fidlr", "supersuf", "abernathy", "zellmi", "kortina", "bitlyapidemo", "hp", "bojonas", "nickware", "adenner", "sigepjedi", "austinhill", "tigol", "vranx", "fabinho", "simonches", "RichMann", "claystreet", "trendly", "mzehrer", "TheN2S", "ffo", "mcgarty", "unquabain", "d", "springpad", "motuit", "sandya", "jstautz", "polymergirl", "HED", "colbypalmer", "patched", "vx", "trailerreview", "backtype", "nukirk", "tmadge", "garrettw", "runk", "dbingham", "ckaroli", "hsetty", "sharpshoot", "mamund", "gestes", "thesethings", "propel", "marsrc", "halvfet", "berberich", "imath", "mahawkins", "hayduke", "icecoldnews", "bren", "claudine", "munim", "utatane", "tanel", "karuizawa", "hpduong", "fewill", "JDM", "indbs", "chaodoze", "haydenonline", "matyyy", "shanink", "roguepost", "chad", "emrox", "bitlyspreadsheets", "evansolomon", "milq", "twitterfeed", "tweetieapp", "massless", "khuckvale", "iminlikewithyou", "bumpasaurus@gmail.com", "htmiguel", "shorter", "eh270", "Joe", "twittergadget", "quotd", "scotster", "bitlypreview", "gavola", "banterability", "SocialScope", "justhunger", "d2kagw", "Sam@TheCellist42.com", "manderson_ohio@yahoo.com", "bensmithuk", "gamers600", "magicquotes", "tweetthis", "ubervu", "bitlybox", "toledorodney", "retaggr", "sedwot", "Kersny", "bcse", "andy@commadelimited.com", "sreenivas", "z33m", "urlpackager", "dpjanes", "philnash", "bassdread", "Siriquelle", "trixtur", "austinmoody", "tav", "ivansf", "jfredson", "xklark", "srijken", "ttomegachunk", "AsaBerd", "softronic", "bfo", "royboyjoytoy2", "danl", "noelb", "thingsinjars", "commadelimited", "wanderingstan", "tweetdeckapi", "littlesnapper", "tweetmeme", "jps", "droolr", "man0l", "portaldofregues", "jugo", "ktgy", "twitterrific", "elbertf", "shareaholic", "rayd", "kengeo", "api@zensify.com", "shoutnow", "teisam", "bguthrie", "besttechdeals", "zensify", "icyou", "dwellicious", "raven", "kcu", "najimi", "howardbaines", "fitzage", "domado16", "tc", "bradarsenault", "trendyobot", "powertwitter", "netpro2k", "concerthash", "twtcode", "lizzer", "mefeed", "zacwest", "nleveler", "emendappdev", "emendapp", "redbassett", "epage", "codemypantsoff", "Urgo", "calais", "outbrain", "razorfishca", "toutmontreal", "quietube", "twiggler", "samlii", "userfly", "abrahamlloyd", "carlsverre", "dunkjmcd", "rubenolsen", "quotablebooks", "4gemedia", "rival", "operaportal", "charitybuzz", "brant", "chartbeat", "tweeklyfm", "ronn", "concept52", "coupa", "owlread", "scottkarp", "linkbitch", "vodpod", "slashgear", "arnaudsj", "bootstrap", "earthclassmail", "unhub", "kiko", "coldkeyboard", "madnashua", "fabiopili", "kaspar", "larrynichols", "trustmap", "codepress", "tivowatcher", "rossimo", "twhirl", "shanzynga", "ghuru", "allgamblingnews", "betternet", "edwinwang", "jarred", "picnik", "thismoment", "zocdoc", "thetechmogul", "rajesh", "yotify", "brad", "northisup", "dsa", "endurancejunkies", "mybooo", "geekboys", "prit", "altosresearch", "haitai", "vinhkhanhit", "gymsnearby", "snuten", "inewsapp", "flipflopr", "plexium", "cotweet", "mytrade", "wertletheturtle", "joestump", "zimmeee", "dcinzona", "nagesh", "thinkphp", "dailyfill", "vijaypatil", "amarkova1982", "vdibart", "keineahnung", "roosterteeth", "masterbaytor", "eightlines", "boctor", "crunch", "kbychu", "modaira", "sysdomatic", "jeffreytierney", "neonova", "theschnaz", "ez", "feedmy", "twitterauction", "twikini", "johnnywander", "fdeguzman", "oriolfb", "taftech", "mressay", "tbbtsite", "pricegrab", "dbperry", "peraperaprv", "atrothman223", "kcbigring", "theseries", "docgroove", "connections", "mab", "james", "cweider", "mistabell", "glennpmn", "mecravem", "icssidearm", "lewiswebdev", "philipecoutinho", "rmo", "takkyun", "to", "tweetvisor", "bim", "smonev", "krisempire", "petercasier", "laitaowa", "LaptopHeaven", "ruggedelegance", "odtv", "laz75", "eight7teen", "tweetevents", "gamespress", "elfster", "bobbyjason", "matlab", "fanfou", "rakurakuinc", "yegle", "dativestudios", "articleslash", "jrcdude", "adslzone", "shortmoney", "cutethingsinbed", "nealkerickson", "tootairapp", "gksperling", "tzangms", "jparkers", "textcube", "cmccann", "linuxkido", "noviceprogram", "voltron43", "aroussi", "turkerz", "janbui", "stockshouter", "mozbox", "nibirutech", "brotchie", "darkua", "wsmith", "t24kurage", "bodu", "imified", "vgdotd", "chcf", "everynumberone", "tweetnewz", "catshelpdesk", "simplybox", "dailyroads", "cookbot", "anirig", "gamesbond", "invernizzi", "fekaylius", "changents", "vanmacguy", "trendytweetsbitly", "adiumofficial", "webmeme", "leedumond", "jyro", "michaeld", "nsls", "crypto", "karthicksethu", "petermorano", "glipt", "rubayeet", "cutiethread", "insane", "pivotaltweed", "AdamHertz", "merchants", "industrie", "kaku1969", "xtw", "eanders", "discocreative", "astexception", "raineandhorne", "sparwelt", "kabayan", "image01", "tweetquip", "ischa", "godrops", "360works", "pasteshot", "jfinegold", "textlogic", "jmgtan", "aaronrussell", "iwasinturkey", "mattpowell", "captainstupid", "jove", "timanrebel", "delicious", "danielrehner", "aaldrich", "mychurch", "pareshvarde", "shrisha", "earlyshen", "dailymile", "hashads", "jopie", "feedalizr", "kennstdueinen", "md117", "cliqz", "newrelic", "milanzajic", "inkzee", "mikecosentino", "twilightaktuell", "rjae", "kelvinator44", "jobomix", "vitalik", "feedagg", "changcommaalex", "tzah", "24ur", "jobcast", "toratto", "talkwit", "metricstaxi", "nzeltzer", "alexweber", "goodwill", "streetfire", "jurai", "cpgroups", "emptyspaceads", "googlenewsjp", "craigae", "2night", "eoxlive", "kijijicanada", "wiglu", "openaccessweek", "anyclip", "dz0ny", "bawigga", "spazcore", "spazcer", "kevinmarks", "casarotti", "dpctest", "efusionid", "annstark", "cristdrive", "r2d2", "elwoodicious", "infopirat", "snoxd", "codejunky1", "sp33dfr34ksd", "jumpinggrendel", "optifyshorten", "oodlelistings", "blainetology", "iproperty", "twtbks", "prashantm", "drry", "chango", "jreynar", "rdaum", "kikinshare", "odinjobs", "wegame", "twse", "beatter", "launchset", "lyricskeeper", "wolfgang", "clickability", "yamli", "alexbosworth", "cashiesuktest", "meateam", "abartling", "fresheneesz", "dangerbell", "proxifeed", "twatme", "boyplankton", "wbio", "skychirp", "slideshare", "keepertestaccount", "valerietaesch", "splab", "gameproapi", "chssystems", "gobyo", "altcanvas", "ankitparekh", "dylanreeve", "sponsorlab", "socialdeck", "denisgurski", "boblog", "dprothro", "syberplanet", "marcparadise", "moneymakerhyip", "chrisedgemon", "camthompson", "nassersala", "meloco32", "ibiboisms", "mesodata", "jewishtimes", "izual", "infosage", "wac", "googlebooks", "buddybrain", "monk", "krishnan", "dothetest", "aktnow", "solmeliacuba" ], "version": 1.0 }, "3j4ir4": { "calais": {}, "calaisId": "", "calaisResolutions": {}, "contentLength": "", "contentType": "text/html; charset=ISO-8859-1", "exif": {}, "globalHash": "3j4ir4", "hash": "3j4ir4", "htmlMetaDescription": "", "htmlMetaKeywords": "", "htmlTitle": "Google", "id3": {}, "keyword": "", "keywords": [], "longUrl": "http://google.com/", "metacarta": [], "mirrorUrl": "", "shortenedByUser": "bitly", "surbl": 0, "thumbnail": { "large": "http://s.bit.ly/bitly/3j4ir4/thumbnail_large.png", "medium": "http://s.bit.ly/bitly/3j4ir4/thumbnail_medium.png", "small": "http://s.bit.ly/bitly/3j4ir4/thumbnail_small.png" }, "userHash": "", "users": [ "kortina", "jay", "bitlybookmarklet", "runcible", "ideacol", "spol", "adrian33", "debajit", "follow", "cosmic", "bitlyspreadsheets", "bitlyapidemo", "mskadu", "betons42", "colbypalmer", "derekpcollins", "enricus", "twitchboard", "massless", "grader", "nickware", "GeekLad", "bumpasaurus@gmail.com", "wac", "planetsdb", "bitlypreview", "twittergadget", "htmiguel", "shorter", "movies", "books", "tunes", "amelnikova", "Sam@TheCellist42.com", "samferry", "tboid", "manderson_ohio@yahoo.com", "benshead", "tbc", "gabe", "shmooved", "tweetieapp", "tweetthis", "mannincw", "newsx", "thefireus", "bitlybox", "chirp", "ashit@jooners.com", "z33m", "urlpackager", "philnash", "sreenivas", "lagiator", "kissmetrics", "matthewfl", "bobbyw", "cotweet", "alexannese", "richardxthripp", "tanel", "jfredson", "lynettechandler", "louismirra", "mattrobs", "stillframe", "ttomegachunk", "Inverted", "falicon", "royboyjoytoy2", "psifertex", "Dien", "tweetdeckapi", "dropiodev", "jasonkhanlar", "tweetalink", "commadelimited", "bck", "bigbig", "cspath", "bitlytextmate", "addtoany", "fitfindr", "adenner", "maximz2005", "grigs", "spipeshop", "omgig", "kortina101", "c4rves", "thingsinjars", "matthewfallshaw", "bguthrie", "powertwitter", "reduxo", "tweettrackjs", "loucypher", "nullwaver", "troynt", "bseanvt", "tc", "theonion", "dahammer", "twtcode", "mefeed", "emendapp", "emendappdev", "outbrain", "redbassett", "calais", "eurleif", "digomatic", "mc", "garno", "obbyyoyo", "lollapalooza", "twitscoop", "carlsverre", "ktgy", "cstejerean", "4gemedia", "zakgrim", "owlread", "ratsgoboom", "jayhickey", "emojitales", "ringlerun", "kupona", "renjithdas", "copress", "larrynichols", "bitlify", "pathfinder", "searchengineland", "raaartrex", "unhub", "twhirl", "rossimo", "cvertex", "spam4aj", "rrs", "mattietk", "jfdurocher", "josephscott", "imharoon2003", "pope52", "alexmg", "askyourtango", "rajesh", "tejas", "rubsta", "completelynovel", "hi675", "collegejersey", "altosresearch", "haitai", "gymsnearby", "artfire", "vision2000", "ivansf", "polymar", "anadeau", "wealltv", "arc90", "demnow", "labria", "wertletheturtle", "kiwiscanfly", "oliverash", "alexcvo", "dcinzona", "uservoice", "bwillums", "zupadupa", "feedmy", "corinne", "askme", "twikini", "chango", "mp3bible", "agqnetwork", "taftech", "atrothman223", "tbbtsite", "firerabbit", "spbose", "spellrus", "fn7", "bsd4pl", "groupcard", "monitter", "cweider", "mistabell", "ayn", "miki", "twitterrific", "bim", "seb2point0", "moomerman", "avilasexy", "zachera", "ksharkey", "obijan", "lostfilm", "magicscientist", "hmi", "ruggedelegance", "mogeethis", "nishantmodak", "talagy1", "delicious", "nickt", "opccalendar", "brightbold", "samuel", "gnintendo", "aurorafeint", "pkumat", "spinnaker", "opinmind", "drawohara", "ideelitest", "voltron43", "jolleyjoe", "orionlee", "fastdove", "stockshouter", "scrabbly", "darkua", "thangamkvp", "kanjifandom", "360hubs", "vivocom", "jepeng", "joemccann", "allynbauer", "destroytwitter", "medium", "bpark08", "twitknights", "adiumofficial", "leedumond", "confluxgroup", "40limbo", "cwalcott", "karthicksethu", "pron", "planettagger", "switchonthecode", "izeasponsoredtweets", "merchants", "humptydumptyegg", "user121", "andav", "cutiethread", "vmarquez", "hopkinsju", "tweetsimple", "saasbit", "aaad", "gohewitt", "yusuke0927", "vinced45", "fbmore", "northisup", "tt01311", "bleetbox", "gyokojp", "dentest", "headlineshirts", "gethighnote", "hashads", "racevine", "kelvinator44", "ajc308", "tweetw", "ibanezyaya", "abiko", "goseedo", "tzah", "gimmeanswers", "twitiq", "lehrblogger", "metricstaxi", "nzeltzer", "addly", "scph", "jrcdude", "mderk", "pullus", "googlenewsjp", "rjinla", "smithworx", "antiuser", "injeqt", "lovelykby", "wiglu", "demandspot", "spazcore", "ka2hiro", "namnum", "sventures", "twittersales", "buttreygoodness", "nagesh", "tribescape", "ohun002", "orsiso", "orymate", "yossilac", "klango", "sp33dfr34ksd", "tracksite", "tonysteward", "davidwalshblog", "ramses", "rdaum", "ookong", "pieceoflena", "wowgather", "caribryne", "alexbosworth", "apoenam", "keepertestaccount", "slideshare", "splab", "ankitparekh", "xtips", "hexmode", "ryanl229", "syberplanet", "gotwalt", "othman", "bunte", "tmeryu", "e", "pjstadig", "timi", "retweetjs", "sobees" ], "version": 1.0 } }, "statusCode": "OK" }
@@ -0,0 +1 @@
1
+ { "errorCode": 0, "errorMessage": "", "results": { "3j4ir4": { "calais": {}, "calaisId": "", "calaisResolutions": {}, "contentLength": "", "contentType": "text/html; charset=ISO-8859-1", "exif": {}, "globalHash": "3j4ir4", "hash": "3j4ir4", "htmlMetaDescription": "", "htmlMetaKeywords": "", "htmlTitle": "Google", "id3": {}, "keyword": "", "keywords": [], "longUrl": "http://google.com/", "metacarta": [], "mirrorUrl": "", "shortenedByUser": "bitly", "surbl": 0, "thumbnail": { "large": "http://s.bit.ly/bitly/3j4ir4/thumbnail_large.png", "medium": "http://s.bit.ly/bitly/3j4ir4/thumbnail_medium.png", "small": "http://s.bit.ly/bitly/3j4ir4/thumbnail_small.png" }, "userHash": "", "users": [ "kortina", "jay", "bitlybookmarklet", "runcible", "ideacol", "spol", "adrian33", "debajit", "follow", "cosmic", "bitlyspreadsheets", "bitlyapidemo", "mskadu", "betons42", "colbypalmer", "derekpcollins", "enricus", "twitchboard", "massless", "grader", "nickware", "GeekLad", "bumpasaurus@gmail.com", "wac", "planetsdb", "bitlypreview", "twittergadget", "htmiguel", "shorter", "movies", "books", "tunes", "amelnikova", "Sam@TheCellist42.com", "samferry", "tboid", "manderson_ohio@yahoo.com", "benshead", "tbc", "gabe", "shmooved", "tweetieapp", "tweetthis", "mannincw", "newsx", "thefireus", "bitlybox", "chirp", "ashit@jooners.com", "z33m", "urlpackager", "philnash", "sreenivas", "lagiator", "kissmetrics", "matthewfl", "bobbyw", "cotweet", "alexannese", "richardxthripp", "tanel", "jfredson", "lynettechandler", "louismirra", "mattrobs", "stillframe", "ttomegachunk", "Inverted", "falicon", "royboyjoytoy2", "psifertex", "Dien", "tweetdeckapi", "dropiodev", "jasonkhanlar", "tweetalink", "commadelimited", "bck", "bigbig", "cspath", "bitlytextmate", "addtoany", "fitfindr", "adenner", "maximz2005", "grigs", "spipeshop", "omgig", "kortina101", "c4rves", "thingsinjars", "matthewfallshaw", "bguthrie", "powertwitter", "reduxo", "tweettrackjs", "loucypher", "nullwaver", "troynt", "bseanvt", "tc", "theonion", "dahammer", "twtcode", "mefeed", "emendapp", "emendappdev", "outbrain", "redbassett", "calais", "eurleif", "digomatic", "mc", "garno", "obbyyoyo", "lollapalooza", "twitscoop", "carlsverre", "ktgy", "cstejerean", "4gemedia", "zakgrim", "owlread", "ratsgoboom", "jayhickey", "emojitales", "ringlerun", "kupona", "renjithdas", "copress", "larrynichols", "bitlify", "pathfinder", "searchengineland", "raaartrex", "unhub", "twhirl", "rossimo", "cvertex", "spam4aj", "rrs", "mattietk", "jfdurocher", "josephscott", "imharoon2003", "pope52", "alexmg", "askyourtango", "rajesh", "tejas", "rubsta", "completelynovel", "hi675", "collegejersey", "altosresearch", "haitai", "gymsnearby", "artfire", "vision2000", "ivansf", "polymar", "anadeau", "wealltv", "arc90", "demnow", "labria", "wertletheturtle", "kiwiscanfly", "oliverash", "alexcvo", "dcinzona", "uservoice", "bwillums", "zupadupa", "feedmy", "corinne", "askme", "twikini", "chango", "mp3bible", "agqnetwork", "taftech", "atrothman223", "tbbtsite", "firerabbit", "spbose", "spellrus", "fn7", "bsd4pl", "groupcard", "monitter", "cweider", "mistabell", "ayn", "miki", "twitterrific", "bim", "seb2point0", "moomerman", "avilasexy", "zachera", "ksharkey", "obijan", "lostfilm", "magicscientist", "hmi", "ruggedelegance", "mogeethis", "nishantmodak", "talagy1", "delicious", "nickt", "opccalendar", "brightbold", "samuel", "gnintendo", "aurorafeint", "pkumat", "spinnaker", "opinmind", "drawohara", "ideelitest", "voltron43", "jolleyjoe", "orionlee", "fastdove", "stockshouter", "scrabbly", "darkua", "thangamkvp", "kanjifandom", "360hubs", "vivocom", "jepeng", "joemccann", "allynbauer", "destroytwitter", "medium", "bpark08", "twitknights", "adiumofficial", "leedumond", "confluxgroup", "40limbo", "cwalcott", "karthicksethu", "pron", "planettagger", "switchonthecode", "izeasponsoredtweets", "merchants", "humptydumptyegg", "user121", "andav", "cutiethread", "vmarquez", "hopkinsju", "tweetsimple", "saasbit", "aaad", "gohewitt", "yusuke0927", "vinced45", "fbmore", "northisup", "tt01311", "bleetbox", "gyokojp", "dentest", "headlineshirts", "gethighnote", "hashads", "racevine", "kelvinator44", "ajc308", "tweetw", "ibanezyaya", "abiko", "goseedo", "tzah", "gimmeanswers", "twitiq", "lehrblogger", "metricstaxi", "nzeltzer", "addly", "scph", "jrcdude", "mderk", "pullus", "googlenewsjp", "rjinla", "smithworx", "antiuser", "injeqt", "lovelykby", "wiglu", "demandspot", "spazcore", "ka2hiro", "namnum", "sventures", "twittersales", "buttreygoodness", "nagesh", "tribescape", "ohun002", "orsiso", "orymate", "yossilac", "klango", "sp33dfr34ksd", "tracksite", "tonysteward", "davidwalshblog", "ramses", "rdaum", "ookong", "pieceoflena", "wowgather", "caribryne", "alexbosworth", "apoenam", "keepertestaccount", "slideshare", "splab", "ankitparekh", "xtips", "hexmode", "ryanl229", "syberplanet", "gotwalt", "othman", "bunte", "tmeryu", "e", "pjstadig", "timi", "retweetjs", "sobees" ], "version": 1.0 } }, "statusCode": "OK" }
@@ -0,0 +1 @@
1
+ { "errorCode": 0, "errorMessage": "", "results": { "clicks": 2644, "hash": "31IqMl", "referrers": { "": { "/index.html": 1, "None": 5, "direct": 2003 }, "api.bit.ly": { "/shorten": 2 }, "benny-web": { "/jseitel/bitly/install.html": 1 }, "bit.ly": { "/": 3, "/app/demos/info.html": 71, "/app/demos/stats.html": 305, "/app/demos/statsModule.html": 2, "/info/15DlK": 1, "/info/27I9Ll": 1, "/info/31IqMl": 2, "/info/hic4E": 1 }, "code.google.com": { "/p/bitly-api/wiki/ApiDocumentation": 1 }, "dev.chartbeat.com": { "/static/bitly.html": 1 }, "dev.unhub.com": { "/pnG8/": 1 }, "klout.net": { "/profiledetail.php": 1 }, "localhost": { "/New Folder/test1.php": 1 }, "mail.google.com": { "/mail/": 1 }, "partners.bit.ly": { "/td": 8 }, "powertwitter.me": { "/": 1 }, "quietube.com": { "/getbitly.php": 1 }, "search.twitter.com": { "/search": 3 }, "sfbay.craigslist.org": { "/sfc/rnr/891043787.html": 8 }, "spreadsheets.google.com": { "/ccc": 23, "/ccc2": 1 }, "strat.corp.advertising.com": { "/brandmaker/bitly.php": 4 }, "taggytext.com": { "/ganja": 1 }, "twitter.com": { "/": 3, "/SuperTestAcct": 1, "/TattoosOn": 1, "/WilliamWoods": 1, "/home": 6, "/ibiboisms": 2, "/kshanns": 1, "/matraji": 1, "/nathanfolkman": 1, "/pantaleonescu": 1, "/rubyisbeautiful": 1, "/williamwoods": 1 }, "twitturls.com": { "/": 21 }, "twitturly.com": { "": 17, "/urlinfo/url/2168a5e81280538cdbf6ad4c4ab019db/": 1 }, "url.ly": { "/": 19, "/info/27I9Ll": 1, "/info/31IqMl": 3 }, "urly.local:3600": { "/": 7 }, "v2.blogg.no": { "/test.cfm": 1 }, "www.facebook.com": { "/home.php": 1 }, "www.longurlplease.com": { "/": 3 }, "www.microblogbuzz.com": { "": 5 } } }, "statusCode": "OK" }
@@ -0,0 +1 @@
1
+ { "errorCode": 1, "errorMessage": "Test error", "statusCode": "ERROR" }
@@ -0,0 +1,35 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'shoulda'
4
+ require 'flexmock/test_unit'
5
+ require 'fakeweb'
6
+
7
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'bitly')
8
+
9
+ FakeWeb.allow_net_connect = false
10
+
11
+ def fixture_file(filename)
12
+ return '' if filename == ''
13
+ file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
14
+ File.read(file_path)
15
+ end
16
+
17
+ def stub_get(url, filename, status=nil)
18
+ options = {:body => fixture_file(filename)}
19
+ options.merge!({:status => status}) unless status.nil?
20
+
21
+ FakeWeb.register_uri(:get, url, options)
22
+ end
23
+
24
+ def api_key
25
+ 'test_key'
26
+ end
27
+ def login
28
+ 'test_account'
29
+ end
30
+
31
+ class Test::Unit::TestCase
32
+ def teardown
33
+ FakeWeb.clean_registry
34
+ end
35
+ end
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cotweet-bitly
3
+ version: !ruby/object:Gem::Version
4
+ hash: 15
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 5
9
+ - 2
10
+ version: 0.5.2
11
+ platform: ruby
12
+ authors:
13
+ - Phil Nash
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-07-18 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: crack
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 19
30
+ segments:
31
+ - 0
32
+ - 1
33
+ - 4
34
+ version: 0.1.4
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: httparty
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 15
46
+ segments:
47
+ - 0
48
+ - 5
49
+ - 2
50
+ version: 0.5.2
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ description: Use the bit.ly API to shorten or expand URLs
54
+ email: philnash@gmail.com
55
+ executables: []
56
+
57
+ extensions: []
58
+
59
+ extra_rdoc_files:
60
+ - lib/bitly/client.rb
61
+ - lib/bitly/url.rb
62
+ - lib/bitly/utils.rb
63
+ - lib/bitly/v3/bitly.rb
64
+ - lib/bitly/v3/client.rb
65
+ - lib/bitly/v3/missing_url.rb
66
+ - lib/bitly/v3/url.rb
67
+ - lib/bitly/v3.rb
68
+ - lib/bitly/version.rb
69
+ - lib/bitly.rb
70
+ - README.txt
71
+ files:
72
+ - bitly.gemspec
73
+ - History.txt
74
+ - lib/bitly/client.rb
75
+ - lib/bitly/url.rb
76
+ - lib/bitly/utils.rb
77
+ - lib/bitly/v3/bitly.rb
78
+ - lib/bitly/v3/client.rb
79
+ - lib/bitly/v3/missing_url.rb
80
+ - lib/bitly/v3/url.rb
81
+ - lib/bitly/v3.rb
82
+ - lib/bitly/version.rb
83
+ - lib/bitly.rb
84
+ - Manifest
85
+ - Rakefile
86
+ - README.txt
87
+ - test/bitly/test_client.rb
88
+ - test/bitly/test_url.rb
89
+ - test/bitly/test_utils.rb
90
+ - test/fixtures/cnn.json
91
+ - test/fixtures/cnn_and_google.json
92
+ - test/fixtures/expand_cnn.json
93
+ - test/fixtures/expand_cnn_and_google.json
94
+ - test/fixtures/google_and_cnn_info.json
95
+ - test/fixtures/google_info.json
96
+ - test/fixtures/google_stats.json
97
+ - test/fixtures/shorten_error.json
98
+ - test/test_helper.rb
99
+ has_rdoc: true
100
+ homepage: http://github.com/philnash/bitly
101
+ licenses: []
102
+
103
+ post_install_message:
104
+ rdoc_options:
105
+ - --line-numbers
106
+ - --inline-source
107
+ - --title
108
+ - Bitly
109
+ - --main
110
+ - README.txt
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ hash: 3
119
+ segments:
120
+ - 0
121
+ version: "0"
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ hash: 11
128
+ segments:
129
+ - 1
130
+ - 2
131
+ version: "1.2"
132
+ requirements: []
133
+
134
+ rubyforge_project: bitly
135
+ rubygems_version: 1.3.7
136
+ signing_key:
137
+ specification_version: 3
138
+ summary: Use the bit.ly API to shorten or expand URLs
139
+ test_files:
140
+ - test/bitly/test_client.rb
141
+ - test/bitly/test_url.rb
142
+ - test/bitly/test_utils.rb
143
+ - test/test_helper.rb