oauth_twitter 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2MwNWI3NjEyYTBiNWE1MWRhODJiMjE2YTA3ODIyYzVlM2M2Mzk5MQ==
4
+ MTYwYjRiNGIwZGQ0YzJiZGVjOWU5NWFmZTYzYWQzNzQ5YjlkNWI5Mw==
5
5
  data.tar.gz: !binary |-
6
- MjNiZmMxMjljMGY4ZDQxMTc1ZGU2YWI5NDZiNDJhNjM3YjFhNjc4Mg==
6
+ MTI3NzE5MTFjZWJmOTIyOWU5NjIwZTRlMTA1NzMyNWI5MmI1M2U5Mw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YzM4MTcwMDY4ZjhkNzU0YzQzNmU1M2YwMTM3OWYxMDZjYzRjZTNjOGM0MTFm
10
- ZGYwMmJkMzIyMTYyNDM1ZjhmYjVjYmQ4YjhiNmYyZWUwYWI5Y2EzMWM5YTU1
11
- M2I4YjQ5YTMyYTAwM2FkYzgxZmY2MjBiN2VjNDY3NjQwNjc4MzE=
9
+ ZmVhNzkwOTM1ZWY5ODU2NjhhYmM3OGZhOTA1ZDgwZGIwYzQ0ODZmM2ZkYmY4
10
+ YzU4NGYwN2EzYmFhNmM2Y2Y3OGU1NDgwNWZhZjQwMDgyZDM3NTUzMjIzMzRm
11
+ YWRmODVkY2E1NmY0MDIwMWMyMDEyM2Y1MmMxMGFiMzg5NDNjYTk=
12
12
  data.tar.gz: !binary |-
13
- ZTAwZTAzYTE2MTQwNTk4MGFjZmQ1OTAyY2QxMWQ5OWFiZmRmNjNmOWJkZDdi
14
- ZjdiMDUxMzQ1MzBmZGQwZjhkODg0Nzk3MmE5YmJhNzQ5NjIxZTY1MDIyYWNm
15
- YjkwZjQ2Y2IyNDE4YjRmOTdjM2UxMjQxMzJmZTM3MDIzMjIzNTM=
13
+ MGE5ZTExOTZlMDQ0MTVmMTlmYmI2ODQyZTNhMGJkMTgwZGNlMDYyZjcyNjQ3
14
+ MzZlNTEzZDM0ZjhmOTFiYTMzODE5ZWQwZWFiZmRjMGVmOGVhMDlmNzk0NGZk
15
+ ZWRhMzkyNDdjOTVkYjMyOTgxYjQyYjA2ODE1ODA3ZjcwZjE4Mzk=
@@ -4,7 +4,7 @@ module OauthTwitter
4
4
  PATH = {
5
5
  friends_ids: '/1.1/friends/ids.json'
6
6
  }
7
-
7
+
8
8
  def friends_ids(user_id)
9
9
  oauth = oauth_params(true)
10
10
  query = {
@@ -13,7 +13,7 @@ module OauthTwitter
13
13
  }
14
14
  return send_request(:GET, PATH[:friends_ids], query, oauth)
15
15
  end
16
-
16
+
17
17
  end
18
18
  end
19
19
  end
@@ -5,19 +5,20 @@ module OauthTwitter
5
5
  request_token: '/oauth/request_token',
6
6
  access_token: '/oauth/access_token'
7
7
  }
8
-
8
+
9
9
  def request_token(oauth_callback=nil)
10
+ callback_url = oauth_callback || Config.oauth_callback
10
11
  oauth = oauth_params(
11
- false,
12
- {oauth_callback: Config.oauth_callback})
12
+ false,
13
+ {oauth_callback: callback_url})
13
14
  return send_request(:POST, PATH[:request_token], nil, oauth)
14
15
  end
15
-
16
+
16
17
  def access_token(oauth_verifier)
17
18
  oauth = oauth_params(true)
18
19
  return send_request(:POST, PATH[:access_token], {oauth_verifier: oauth_verifier}, oauth)
19
20
  end
20
-
21
+
21
22
  end
22
23
  end
23
24
  end
@@ -4,7 +4,7 @@ module OauthTwitter
4
4
  PATH = {
5
5
  home_timeline: "/1.1/statuses/home_timeline.json"
6
6
  }
7
-
7
+
8
8
  def home_timeline(since_id=nil)
9
9
  oauth = oauth_params(true)
10
10
  query = {
@@ -17,7 +17,7 @@ module OauthTwitter
17
17
  query[:since_id] = since_id if since_id
18
18
  return send_request(:GET, PATH[:home_timeline], query, oauth)
19
19
  end
20
-
20
+
21
21
  end
22
22
  end
23
23
  end
@@ -4,7 +4,7 @@ module OauthTwitter
4
4
  PATH = {
5
5
  users_lookup: "/1.1/users/lookup.json"
6
6
  }
7
-
7
+
8
8
  def users_lookup(id_array, include_entities=true)
9
9
  oauth = oauth_params(true)
10
10
  # slice id_array for multiple request
@@ -23,7 +23,7 @@ module OauthTwitter
23
23
  end
24
24
  return result
25
25
  end
26
-
26
+
27
27
  end
28
28
  end
29
29
  end
@@ -2,7 +2,7 @@ module OauthTwitter
2
2
  module Config
3
3
  class << self
4
4
  attr_accessor :consumer_key, :consumer_secret, :oauth_callback
5
-
5
+
6
6
  def setup
7
7
  yield self
8
8
  end
@@ -18,12 +18,12 @@ module OauthTwitter
18
18
  oauth[:oauth_token] = self.oauth_token if include_oauth_token
19
19
  return oauth.merge(addional_oauth_params)
20
20
  end
21
-
21
+
22
22
  RESERVED_CHARS = /[^a-zA-Z0-9\-\.\_\~]/
23
23
  def self.percent_encode(raw)
24
24
  return URI.escape(raw.to_s, RESERVED_CHARS)
25
25
  end
26
-
26
+
27
27
  HOST = "https://api.twitter.com"
28
28
  def send_request(method, path, query, oauth)
29
29
  # Make base_str and signing_key
@@ -70,16 +70,16 @@ module OauthTwitter
70
70
  raise "HTTP request failed."
71
71
  end
72
72
  end
73
-
73
+
74
74
  def self.sign(base_str, signing_key)
75
75
  hex_str = OpenSSL::HMAC.hexdigest(
76
- OpenSSL::Digest::Digest.new('sha1'),
77
- signing_key,
76
+ OpenSSL::Digest::Digest.new('sha1'),
77
+ signing_key,
78
78
  base_str)
79
79
  binary_str = Base64.encode64( [hex_str].pack("H*") ).gsub(/\n/, "")
80
80
  return Helper.percent_encode( binary_str )
81
81
  end
82
-
82
+
83
83
  def self.auth_header(signed_oauth)
84
84
  params = signed_oauth.map { |key, val| "#{key}=\"#{val}\"" }
85
85
  return "OAuth " << params.join(",")
@@ -1,3 +1,3 @@
1
1
  module OauthTwitter
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
-
20
+
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_dependency 'rack', '>= 1.4.5'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oauth_twitter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daiwei Lu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-11 00:00:00.000000000 Z
11
+ date: 2013-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler