moomerman-twitter_oauth 0.1.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.
@@ -0,0 +1,12 @@
1
+ require 'rubygems'
2
+ require 'oauth'
3
+ require 'json'
4
+
5
+ require 'twitter_oauth/client'
6
+
7
+ module TwitterOAuth
8
+ def self.version
9
+ yml = YAML.load(File.read(File.join(File.dirname(__FILE__), *%w[.. VERSION.yml])))
10
+ "#{yml[:major]}.#{yml[:minor]}.#{yml[:patch]}"
11
+ end
12
+ end
@@ -0,0 +1,49 @@
1
+ module TwitterOAuth
2
+ class Client
3
+
4
+ def initialize(options = {})
5
+ @username = options[:username]
6
+ @token = options[:token]
7
+ @secret = options[:secret]
8
+ end
9
+
10
+ def show(username = @username)
11
+ oauth_response = access_token.get("/users/show/#{username}.json")
12
+ JSON.parse(oauth_response.body)
13
+ end
14
+
15
+ def authorized?
16
+ oauth_response = access_token.get('/account/verify_credentials.json')
17
+ return oauth_response.class == Net::HTTPOK
18
+ end
19
+
20
+ def friends
21
+ oauth_response = access_token.get('/statuses/friends_timeline.json')
22
+ JSON.parse(oauth_response.body)
23
+ end
24
+
25
+ def update(message)
26
+ oauth_response = access_token.post('/statuses/update.json', :status => message)
27
+ JSON.parse(oauth_response.body)
28
+ end
29
+
30
+ def message(user, text)
31
+ oauth_response = access_token.post('/direct_messages/new.format', :user => user, :text => text)
32
+ JSON.parse(oauth_response.body)
33
+ end
34
+
35
+ private
36
+ def consumer
37
+ @consumer ||= OAuth::Consumer.new(
38
+ CLIENT_KEY,
39
+ CLIENT_SECRET,
40
+ { :site=>"http://twitter.com" }
41
+ )
42
+ end
43
+
44
+ def access_token
45
+ @access_token ||= OAuth::AccessToken.new(consumer, @token, @secret)
46
+ end
47
+ end
48
+ end
49
+
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: moomerman-twitter_oauth
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Richard Taylor
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-03-20 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: oauth
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.3.1
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: json
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.1.2
34
+ version:
35
+ description: twitter_oauth is a Ruby library for talking to twitter using the new oauth method.
36
+ email: moomerman@gmail.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files: []
42
+
43
+ files:
44
+ - README.txt
45
+ - VERSION.yml
46
+ - lib/twitter_oauth
47
+ - lib/twitter_oauth.rb
48
+ - lib/twitter_oauth/client.rb
49
+ has_rdoc: false
50
+ homepage: http://github.com/moomerman/twitter_oauth
51
+ post_install_message:
52
+ rdoc_options:
53
+ - --inline-source
54
+ - --charset=UTF-8
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: "0"
62
+ version:
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ version:
69
+ requirements: []
70
+
71
+ rubyforge_project: twitter_oauth
72
+ rubygems_version: 1.2.0
73
+ signing_key:
74
+ specification_version: 2
75
+ summary: twitter_oauth is a Ruby library for talking to twitter using the new oauth method.
76
+ test_files: []
77
+