jnunemaker-twitter 0.6.10 → 0.6.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History CHANGED
@@ -1,3 +1,7 @@
1
+ 0.6.11 - May 18, 2009
2
+ * 1 minor addition
3
+ * Added the ability to sign in with twitter instead of authorizing
4
+
1
5
  0.6.10 - May 18, 2009
2
6
  * 1 cool addition
3
7
  * Added full support for trends - current, daily and weekly (even allowing excluding of hashtags and for specific dates)
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 6
4
- :patch: 10
4
+ :patch: 11
data/lib/twitter/oauth.rb CHANGED
@@ -3,14 +3,21 @@ module Twitter
3
3
  extend Forwardable
4
4
  def_delegators :access_token, :get, :post
5
5
 
6
- attr_reader :ctoken, :csecret
6
+ attr_reader :ctoken, :csecret, :consumer_options
7
7
 
8
- def initialize(ctoken, csecret)
9
- @ctoken, @csecret = ctoken, csecret
8
+ # Options
9
+ # :sign_in => true to just sign in with twitter instead of doing oauth authorization
10
+ # (http://apiwiki.twitter.com/Sign-in-with-Twitter)
11
+ def initialize(ctoken, csecret, options={})
12
+ @ctoken, @csecret, @consumer_options = ctoken, csecret, {}
13
+
14
+ if options[:sign_in]
15
+ @consumer_options[:authorize_path] = '/oauth/authenticate'
16
+ end
10
17
  end
11
18
 
12
19
  def consumer
13
- @consumer ||= ::OAuth::Consumer.new(@ctoken, @csecret, {:site => 'http://twitter.com'})
20
+ @consumer ||= ::OAuth::Consumer.new(@ctoken, @csecret, {:site => 'http://twitter.com'}.merge(consumer_options))
14
21
  end
15
22
 
16
23
  def request_token
@@ -8,6 +8,16 @@ class OAuthTest < Test::Unit::TestCase
8
8
  twitter.csecret.should == 'secret'
9
9
  end
10
10
 
11
+ should "set autorization path to '/oauth/authorize' by default" do
12
+ twitter = Twitter::OAuth.new('token', 'secret')
13
+ twitter.consumer.options[:authorize_path].should == '/oauth/authorize'
14
+ end
15
+
16
+ should "set autorization path to '/oauth/authenticate' if sign_in_with_twitter" do
17
+ twitter = Twitter::OAuth.new('token', 'secret', :sign_in => true)
18
+ twitter.consumer.options[:authorize_path].should == '/oauth/authenticate'
19
+ end
20
+
11
21
  should "have a consumer" do
12
22
  consumer = mock('oauth consumer')
13
23
  OAuth::Consumer.expects(:new).with('token', 'secret', {:site => 'http://twitter.com'}).returns(consumer)
@@ -5,7 +5,7 @@ class TrendsTest < Test::Unit::TestCase
5
5
 
6
6
  context "Getting current trends" do
7
7
  should "work" do
8
- stub_get('http://search.twitter.com:80/trends/current.json', 'trends_current.json')
8
+ stub_get 'http://search.twitter.com:80/trends/current.json', 'trends_current.json'
9
9
  trends = Trends.current
10
10
  trends.size.should == 10
11
11
  trends[0].name.should == '#musicmonday'
@@ -15,7 +15,7 @@ class TrendsTest < Test::Unit::TestCase
15
15
  end
16
16
 
17
17
  should "be able to exclude hashtags" do
18
- stub_get('http://search.twitter.com:80/trends/current.json?exclude=hashtags', 'trends_current_exclude.json')
18
+ stub_get 'http://search.twitter.com:80/trends/current.json?exclude=hashtags', 'trends_current_exclude.json'
19
19
  trends = Trends.current(:exclude => 'hashtags')
20
20
  trends.size.should == 10
21
21
  trends[0].name.should == 'New Divide'
@@ -27,7 +27,7 @@ class TrendsTest < Test::Unit::TestCase
27
27
 
28
28
  context "Getting daily trends" do
29
29
  should "work" do
30
- stub_get('http://search.twitter.com:80/trends/daily.json?', 'trends_daily.json')
30
+ stub_get 'http://search.twitter.com:80/trends/daily.json?', 'trends_daily.json'
31
31
  trends = Trends.daily
32
32
  trends.size.should == 480
33
33
  trends[0].name.should == '#3turnoffwords'
@@ -35,7 +35,7 @@ class TrendsTest < Test::Unit::TestCase
35
35
  end
36
36
 
37
37
  should "be able to exclude hastags" do
38
- stub_get('http://search.twitter.com:80/trends/daily.json?exclude=hashtags', 'trends_daily_exclude.json')
38
+ stub_get 'http://search.twitter.com:80/trends/daily.json?exclude=hashtags', 'trends_daily_exclude.json'
39
39
  trends = Trends.daily(:exclude => 'hashtags')
40
40
  trends.size.should == 480
41
41
  trends[0].name.should == 'Star Trek'
@@ -61,7 +61,7 @@ class TrendsTest < Test::Unit::TestCase
61
61
 
62
62
  context "Getting weekly trends" do
63
63
  should "work" do
64
- stub_get('http://search.twitter.com:80/trends/weekly.json?', 'trends_weekly.json')
64
+ stub_get 'http://search.twitter.com:80/trends/weekly.json?', 'trends_weekly.json'
65
65
  trends = Trends.weekly
66
66
  trends.size.should == 210
67
67
  trends[0].name.should == 'Happy Mothers Day'
@@ -69,7 +69,7 @@ class TrendsTest < Test::Unit::TestCase
69
69
  end
70
70
 
71
71
  should "be able to exclude hastags" do
72
- stub_get('http://search.twitter.com:80/trends/weekly.json?exclude=hashtags', 'trends_weekly_exclude.json')
72
+ stub_get 'http://search.twitter.com:80/trends/weekly.json?exclude=hashtags', 'trends_weekly_exclude.json'
73
73
  trends = Trends.weekly(:exclude => 'hashtags')
74
74
  trends.size.should == 210
75
75
  trends[0].name.should == 'Happy Mothers Day'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jnunemaker-twitter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.10
4
+ version: 0.6.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker