springnote_resources 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,6 @@
1
+ == 0.6.1 / 2008-5-9
2
+ * bugfix for OAuth consumer(POST request does not be sent).
3
+
1
4
  == 0.6.0 / 2008-5-6
2
5
  * Support OAuth protocol. Old authententication method will be removed very soon. You should set access_token, access_token_secret, consumer_token, consumer_secret instead of app_key, user_openid, user_key
3
6
 
@@ -21,15 +21,50 @@ module RequestWithOauth
21
21
  # new way
22
22
  logger.debug "(request with oauth)" if logger
23
23
  @http = http
24
- req = "Net::HTTP::#{method.to_s.capitalize}".constantize.new(path, *arguments)
25
- req.oauth! @http, oauth_configuration.consumer, oauth_configuration.token, :signature_method => 'HMAC-SHA1'
26
-
24
+
25
+ req = create_http_request(method, path, arguments)
26
+ req.oauth! @http, oauth_configuration.consumer, oauth_configuration.token, :signature_method => 'HMAC-SHA1', :clobber_request => true
27
+
27
28
  @http.request(req)
28
29
  end
29
30
 
30
31
  def oauth?
31
32
  oauth_configuration && oauth_configuration.consumer && oauth_configuration.token
32
33
  end
34
+
35
+ protected
36
+ # code from ruby-oauth
37
+ # create the http request object for a given http_method and path
38
+ def create_http_request(http_method,path,*arguments)
39
+ http_method=http_method.to_sym
40
+ if [:post,:put].include?(http_method)
41
+ data=arguments.shift
42
+ end
43
+ headers=(arguments.first.is_a?(Hash) ? arguments.shift : {})
44
+ case http_method
45
+ when :post
46
+ request=Net::HTTP::Post.new(path,headers)
47
+ request["Content-Length"]=0 # Default to 0
48
+ when :put
49
+ request=Net::HTTP::Put.new(path,headers)
50
+ request["Content-Length"]=0 # Default to 0
51
+ when :get
52
+ request=Net::HTTP::Get.new(path,headers)
53
+ when :delete
54
+ request=Net::HTTP::Delete.new(path,headers)
55
+ when :head
56
+ request=Net::HTTP::Head.new(path,headers)
57
+ else
58
+ raise ArgumentError, "Don't know how to handle http_method: :#{http_method.to_s}"
59
+ end
60
+ if data.is_a?(Hash)
61
+ request.set_form_data(data)
62
+ elsif data
63
+ request.body=data.to_s
64
+ request["Content-Length"]=request.body.length
65
+ end
66
+ request
67
+ end
33
68
  end
34
69
 
35
70
  ActiveResource::Connection.send :include, RequestWithOauth
@@ -1,5 +1,5 @@
1
1
  module Springnote
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
 
4
4
  class Base < ActiveResource::Base
5
5
  extend ActiveResourceExtension
@@ -17,8 +17,12 @@ module Springnote
17
17
  def load(file)
18
18
  set YAML.load(File.read(file))
19
19
  end
20
-
20
+
21
21
  def set(options = {})
22
+ #reset
23
+ @token = nil
24
+ @consumer = nil
25
+
22
26
  options.each{|k,v| self.send("#{k}=", v)}
23
27
  Springnote::Base.site = self.site
24
28
  self
@@ -35,7 +39,7 @@ module Springnote
35
39
  end
36
40
 
37
41
  def token
38
- @token ||= OAuth::Token.new @access_token, @access_secret if @access_token && @access_secret
42
+ @token ||= OAuth::AccessToken.new consumer, @access_token, @access_secret if @access_token && @access_secret
39
43
  end
40
44
 
41
45
  def consumer
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: springnote_resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Kang
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-05-06 00:00:00 +09:00
12
+ date: 2008-05-09 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency