twitterland 0.4.4 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
data/History CHANGED
@@ -1,3 +1,5 @@
1
+ 0.4.5 - Applied patch from shingara for BackTweets
2
+ 0.4.4 - Applied patch from pengwynn to update httparty dependency
1
3
  0.4.3 - Applied patch from seboslaw for BackTweets paging params
2
4
  0.4.2 - Added support for Zutual http://zutual.com
3
5
  0.4.1 - Added Auto Follow Friday support http://autoff.com
data/Rakefile CHANGED
@@ -11,10 +11,10 @@ begin
11
11
  gem.authors = ["Wynn Netherland","Bradley Joyce", "Ron Evans"]
12
12
  gem.rubyforge_project = "twitterland"
13
13
  gem.files = FileList["[A-Z]*", "{examples,lib,test}/**/*"]
14
-
14
+
15
15
  gem.add_dependency('mash', '0.0.3')
16
16
  gem.add_dependency('httparty', '>= 0.4.3')
17
-
17
+
18
18
  gem.add_development_dependency('thoughtbot-shoulda')
19
19
  gem.add_development_dependency('jeremymcanally-matchy')
20
20
  gem.add_development_dependency('mocha')
@@ -52,6 +52,7 @@ task :default => :test
52
52
  require 'rake/rdoctask'
53
53
  Rake::RDocTask.new do |rdoc|
54
54
  if File.exist?('VERSION.yml')
55
+ require 'yaml'
55
56
  config = YAML.load(File.read('VERSION.yml'))
56
57
  version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
57
58
  else
@@ -67,7 +68,7 @@ end
67
68
  begin
68
69
  require 'rake/contrib/sshpublisher'
69
70
  namespace :rubyforge do
70
-
71
+
71
72
  desc "Release gem and RDoc documentation to RubyForge"
72
73
  task :release => ["rubyforge:release:gem"]
73
74
  end
@@ -1,5 +1,5 @@
1
1
  ---
2
- :patch: 4
3
2
  :major: 0
4
- :build:
5
3
  :minor: 4
4
+ :patch: 5
5
+ :build:
@@ -1,22 +1,24 @@
1
1
  module Twitterland
2
+
2
3
  class BackTweets
3
4
  include HTTParty
4
5
  base_uri 'backtweets.com'
5
6
  format :json
6
-
7
+
7
8
  # Return tweet referencing a URL
8
9
  # Get your api_key at http://www.backtype.com/developers
9
- #
10
+ #
10
11
  # Twitterland::BackTweets.search('http://squeejee.com', 'OU812')
11
12
  def self.search(q, api_key, options={})
12
13
  options['itemsperpage'] = options.delete(:items_per_page) if options[:items_per_page]
13
14
  rubyize_response(Mash.new(get("/search.json", :query => {:q => q, :key => api_key}.merge(options))))
14
15
  end
15
-
16
-
16
+
17
+
17
18
  # Scrubs the response from Back Tweets to rubyize keys
18
19
  def self.rubyize_response(response)
19
20
  results = Mash.new
21
+ raise BackTweets::Unauthenticated.new if response.has_key?('error')
20
22
  results.total_results = response['totalresults'].to_i
21
23
  results.start_index = response['startindex']
22
24
  results.items_per_page = response['itemsperpage']
@@ -31,4 +33,7 @@ module Twitterland
31
33
  end
32
34
  private_class_method :rubyize_response
33
35
  end
34
- end
36
+
37
+ class BackTweets::Unauthenticated < Exception
38
+ end
39
+ end
@@ -0,0 +1 @@
1
+ {"error":{"errorCode":"unauthenticated"}}
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../test_helper'
2
2
 
3
3
  class BackTweetsTest < Test::Unit::TestCase
4
4
  include Twitterland
5
-
5
+
6
6
  context "Hitting the BackTweets API" do
7
7
  should "return tweets referencing a URL" do
8
8
  stub_get 'http://backtweets.com/search.json?q=http%3A%2F%2Fsqueejee.com&key=OU812', 'backtweets.json'
@@ -14,7 +14,14 @@ class BackTweetsTest < Test::Unit::TestCase
14
14
  last_tweet.id = 1642929098
15
15
  last_tweet.from_user_id = 383935
16
16
  last_tweet.from_user = 'Curvezilla'
17
-
17
+
18
+ end
19
+
20
+ should "raise Invalid key if bad key" do
21
+ stub_get 'http://backtweets.com/search.json?q=http%3A%2F%2Fsqueejee.com&key=OU812', 'backtweets_unauthenticated.json'
22
+ assert_raise Twitterland::BackTweets::Unauthenticated do
23
+ Twitterland::BackTweets.search('http://squeejee.com', 'OU812')
24
+ end
18
25
  end
19
26
  end
20
- end
27
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitterland
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wynn Netherland
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2010-02-27 00:00:00 -06:00
14
+ date: 2010-03-03 00:00:00 -06:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -115,6 +115,7 @@ files:
115
115
  - lib/twitterland/zutual.rb
116
116
  - test/fixtures/autoff.json
117
117
  - test/fixtures/backtweets.json
118
+ - test/fixtures/backtweets_unauthenticated.json
118
119
  - test/fixtures/foller_me_all.json
119
120
  - test/fixtures/foller_me_hashtags.json
120
121
  - test/fixtures/foller_me_mentions.json