jnunemaker-twitter 0.5.0 → 0.5.1
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 +6 -1
- data/Rakefile +14 -2
- data/VERSION.yml +1 -1
- data/examples/connect.rb +3 -5
- data/examples/friendship_existance.rb +13 -0
- data/examples/helpers/config_store.rb +8 -0
- data/lib/twitter/request.rb +8 -4
- data/lib/twitter.rb +16 -6
- metadata +3 -2
data/History
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.1 - April 5, 2009
|
2
|
+
* 1 minor change
|
3
|
+
* Added data error hash returned from twitter to a few of the exceptions to help with debugging
|
4
|
+
* Fixed friendship_exists?. Was throwing mash stringify keys error because it was returning true or false instead of hash or array.
|
5
|
+
|
6
|
+
0.5.0 - April 3, 2009
|
2
7
|
* 1 major rewrite for OAuth
|
3
8
|
* Backwards compatibility thrown to the wind
|
4
9
|
* Proxy no longer supported (someone please add it back in, I never use proxies)
|
data/Rakefile
CHANGED
@@ -62,7 +62,7 @@ begin
|
|
62
62
|
namespace :rubyforge do
|
63
63
|
|
64
64
|
desc "Release gem and RDoc documentation to RubyForge"
|
65
|
-
task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
|
65
|
+
task :release => ["rubyforge:release:gem", "rubyforge:release:website", "rubyforge:release:docs"]
|
66
66
|
|
67
67
|
namespace :release do
|
68
68
|
desc "Publish RDoc to RubyForge."
|
@@ -72,11 +72,23 @@ begin
|
|
72
72
|
)
|
73
73
|
|
74
74
|
host = "#{config['username']}@rubyforge.org"
|
75
|
-
remote_dir = "/var/www/gforge-projects/twitter/"
|
75
|
+
remote_dir = "/var/www/gforge-projects/twitter/rdoc"
|
76
76
|
local_dir = 'rdoc'
|
77
77
|
|
78
78
|
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
79
79
|
end
|
80
|
+
|
81
|
+
task :website do
|
82
|
+
config = YAML.load(
|
83
|
+
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
84
|
+
)
|
85
|
+
|
86
|
+
host = "#{config['username']}@rubyforge.org"
|
87
|
+
remote_dir = "/var/www/gforge-projects/twitter/"
|
88
|
+
local_dir = 'website'
|
89
|
+
|
90
|
+
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
91
|
+
end
|
80
92
|
end
|
81
93
|
end
|
82
94
|
rescue LoadError
|
data/VERSION.yml
CHANGED
data/examples/connect.rb
CHANGED
@@ -7,20 +7,18 @@ oauth = Twitter::OAuth.new(config['token'], config['secret'])
|
|
7
7
|
|
8
8
|
if config['atoken'] && config['asecret']
|
9
9
|
oauth.authorize_from_access(config['atoken'], config['asecret'])
|
10
|
-
# puts oauth.access_token.get("/statuses/friends_timeline.json")
|
11
10
|
twitter = Twitter::Base.new(oauth)
|
12
11
|
pp twitter.friends_timeline
|
13
12
|
|
14
13
|
elsif config['rtoken'] && config['rsecret']
|
15
14
|
oauth.authorize_from_request(config['rtoken'], config['rsecret'])
|
16
|
-
|
15
|
+
twitter = Twitter::Base.new(oauth)
|
16
|
+
pp twitter.friends_timeline
|
17
17
|
|
18
18
|
config.update({
|
19
19
|
'atoken' => oauth.access_token.token,
|
20
20
|
'asecret' => oauth.access_token.secret,
|
21
|
-
|
22
|
-
'rsecret' => nil,
|
23
|
-
})
|
21
|
+
}).delete('rtoken', 'rsecret')
|
24
22
|
else
|
25
23
|
config.update({
|
26
24
|
'rtoken' => oauth.request_token.token,
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
|
2
|
+
require File.join(File.dirname(__FILE__), 'helpers', 'config_store')
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
config = ConfigStore.new("#{ENV['HOME']}/.twitter")
|
6
|
+
|
7
|
+
oauth = Twitter::OAuth.new(config['token'], config['secret'])
|
8
|
+
oauth.authorize_from_access(config['atoken'], config['asecret'])
|
9
|
+
|
10
|
+
client = Twitter::Base.new(oauth)
|
11
|
+
|
12
|
+
puts client.friendship_exists?('jnunemaker', 'orderedlist')
|
13
|
+
puts client.friendship_exists?('jnunemaker', 'biz')
|
@@ -19,12 +19,20 @@ class ConfigStore
|
|
19
19
|
@config[key] = value
|
20
20
|
end
|
21
21
|
|
22
|
+
def delete(*keys)
|
23
|
+
keys.each { |key| @config.delete(key) }
|
24
|
+
save
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
22
28
|
def update(c={})
|
23
29
|
@config.merge!(c)
|
24
30
|
save
|
31
|
+
self
|
25
32
|
end
|
26
33
|
|
27
34
|
def save
|
28
35
|
File.open(file, 'w') { |f| f.write(YAML.dump(@config)) }
|
36
|
+
self
|
29
37
|
end
|
30
38
|
end
|
data/lib/twitter/request.rb
CHANGED
@@ -51,11 +51,13 @@ module Twitter
|
|
51
51
|
def raise_errors(response)
|
52
52
|
case response.code.to_i
|
53
53
|
when 400
|
54
|
-
raise RateLimitExceeded, "(#{response.code}): #{response.message}"
|
54
|
+
raise RateLimitExceeded.new(parse(response)), "(#{response.code}): #{response.message} - #{data['error']}"
|
55
55
|
when 401
|
56
|
-
|
56
|
+
data = parse(response)
|
57
|
+
raise Unauthorized.new(data), "(#{response.code}): #{response.message} - #{data['error']}"
|
57
58
|
when 403
|
58
|
-
|
59
|
+
data = parse(response)
|
60
|
+
raise General.new(data), "(#{response.code}): #{response.message} - #{data['error']}"
|
59
61
|
when 404
|
60
62
|
raise NotFound, "(#{response.code}): #{response.message}"
|
61
63
|
when 500
|
@@ -72,8 +74,10 @@ module Twitter
|
|
72
74
|
def mash(obj)
|
73
75
|
if obj.is_a?(Array)
|
74
76
|
obj.map { |item| Mash.new(item) }
|
75
|
-
|
77
|
+
elsif obj.is_a?(Hash)
|
76
78
|
Mash.new(obj)
|
79
|
+
else
|
80
|
+
obj
|
77
81
|
end
|
78
82
|
end
|
79
83
|
|
data/lib/twitter.rb
CHANGED
@@ -7,12 +7,22 @@ require 'rubygems'
|
|
7
7
|
end
|
8
8
|
|
9
9
|
module Twitter
|
10
|
-
class
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
class TwitterError < StandardError
|
11
|
+
attr_reader :data
|
12
|
+
|
13
|
+
def initialize(data)
|
14
|
+
@data = data
|
15
|
+
super
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class RateLimitExceeded < TwitterError; end
|
20
|
+
class Unauthorized < TwitterError; end
|
21
|
+
class General < TwitterError; end
|
22
|
+
|
23
|
+
class Unavailable < StandardError; end
|
24
|
+
class InformTwitter < StandardError; end
|
25
|
+
class NotFound < StandardError; end
|
16
26
|
|
17
27
|
|
18
28
|
def self.firehose
|
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.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Nunemaker
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-04-
|
12
|
+
date: 2009-04-05 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- README.rdoc
|
49
49
|
- VERSION.yml
|
50
50
|
- examples/connect.rb
|
51
|
+
- examples/friendship_existance.rb
|
51
52
|
- examples/helpers
|
52
53
|
- examples/helpers/config_store.rb
|
53
54
|
- examples/search.rb
|