twitter-knife 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Dale Ma
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # Simple Twitter Client
2
+
3
+ ## install
4
+ gem install 'twitter-knife'
5
+
6
+ ## use
7
+ ```ruby
8
+ require 'twitter-knife'
9
+
10
+ client = TwitterKnife::Client.new({
11
+ :consumer_key => CONSUMER_KEY,
12
+ :consumer_secret => CONSUMER_SECRET,
13
+ :oauth_token => OAUTH_TOKEN,
14
+ :oauth_token_secret => OAUTH_SECRET
15
+ })
16
+
17
+ client.get('users/show', {:screen_name => 'eguitarz'})
18
+ ```
@@ -0,0 +1,3 @@
1
+ module TwitterKnife
2
+ autoload :Client , 'twitter-knife/client'
3
+ end
@@ -0,0 +1,40 @@
1
+ require 'json'
2
+
3
+ module TwitterKnife
4
+ API_VERSION = '1.1'
5
+ TWITTER_API_HOST = 'api.twitter.com'
6
+ TWITTER_SEARCH_HOST = 'search.twitter.com'
7
+
8
+ class Client
9
+ def initialize(options)
10
+ @options = options
11
+
12
+ # Exchange our oauth_token and oauth_token secret for the AccessToken instance.
13
+ @access_token = prepare_access_token()
14
+ end
15
+
16
+ def get(api, options={})
17
+ args = options.map{|k,v| "#{k}=#{v}" }.join('&')
18
+ response = @access_token.request(:get, "/#{API_VERSION}/#{api}?#{args}")
19
+ response.body
20
+ end
21
+
22
+ def post(api, body='')
23
+ response = @access_token.request(:post, "/#{API_VERSION}/#{api}", body)
24
+ response.body
25
+ end
26
+
27
+ # Exchange your oauth_token and oauth_token_secret for an AccessToken instance.
28
+ def prepare_access_token
29
+ consumer = OAuth::Consumer.new(@options[:consumer_key], @options[:consumer_secret],
30
+ { :site => "https://#{TWITTER_API_HOST}",
31
+ :scheme => :header
32
+ })
33
+ # now create the access token object from passed values
34
+ token_hash = { :oauth_token => @options[:oauth_token],
35
+ :oauth_token_secret => @options[:oauth_token_secret]
36
+ }
37
+ access_token = OAuth::AccessToken.from_hash(consumer, token_hash)
38
+ end
39
+ end
40
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: twitter-knife
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dale Ma
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: oauth
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.4.7
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.4.7
30
+ description: Twitter-knife is a really simple twitter v1.1 API client. It only provides
31
+ get and post methods, user type the API they want in the params.
32
+ email: dalema22@gmail.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - lib/twitter-knife/client.rb
38
+ - lib/twitter-knife.rb
39
+ - LICENSE
40
+ - README.md
41
+ homepage: https://github.com/eguitarz/twitter-knife
42
+ licenses: []
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 1.8.24
62
+ signing_key:
63
+ specification_version: 3
64
+ summary: Simple twitter v1.1 API client
65
+ test_files: []