springnote_resources 0.6.5.1 → 0.6.6

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.6 / 2008-10-23
2
+ * fix for Rails 2.1.x
3
+
1
4
  == 0.6.5 / 2008-10-6
2
5
  * Springnote::Comment added
3
6
 
data/Manifest.txt CHANGED
@@ -15,7 +15,6 @@ lib/springnote/page.rb
15
15
  lib/springnote/import_file.rb
16
16
  lib/springnote/revision.rb
17
17
  lib/exts/active_resource_extension.rb
18
- lib/exts/common_parameters.rb
19
18
  lib/exts/request_with_oauth.rb
20
19
  spec/base_spec.rb
21
20
  spec/configuration_spec.rb
@@ -1,17 +1,32 @@
1
1
  module RequestWithOauth
2
2
  def self.included(mod)
3
+ mod.send :cattr_accessor, :common_params
4
+ mod.common_params = {}
5
+
3
6
  mod.alias_method_chain :request, :oauth
4
- mod.send :cattr_accessor, :oauth_configuration
7
+ mod.send :cattr_accessor, :oauth_configuration
5
8
  end
6
9
 
10
+ def common_params
11
+ self.class.common_params
12
+ end
13
+
7
14
  delegate :oauth_configuration, :to => "self.class"
8
15
 
9
16
  def request_with_oauth(method, path, *arguments)
17
+ # append common parameters
18
+ unless common_params.empty?
19
+ path += path.include?('?') ? '&' : '?'
20
+ path += common_params.to_query
21
+ end
22
+
10
23
  logger.info "#{method.to_s.upcase} #{site.scheme}://#{site.host}:#{site.port}#{path}" if logger
11
24
  result = nil
12
25
  time = Benchmark.realtime { result = http_request(method, path, arguments) }
13
- logger.info "--> #{result.code} #{result.message} (#{result.body ? result.body : 0}b %.2fs)" % time if logger
26
+ logger.info "--> #{result.code} #{result.message} (#{result.body ? result.body.length : 0}b %.2fs)" % time if logger
14
27
  handle_response(result)
28
+ rescue Timeout::Error => e
29
+ raise TimeoutError.new(e.message)
15
30
  end
16
31
 
17
32
  def http_request(method, path, arguments)
@@ -1,5 +1,5 @@
1
1
  module Springnote
2
- VERSION = "0.6.5.1"
2
+ VERSION = "0.6.6"
3
3
 
4
4
  class Base < ActiveResource::Base
5
5
  extend ActiveResourceExtension
@@ -25,6 +25,10 @@ module Springnote
25
25
 
26
26
  options.each{|k,v| self.send("#{k}=", v)}
27
27
  Springnote::Base.site = self.site
28
+ if @app_key && Springnote::Base.respond_to?(:user=)
29
+ Springnote::Base.user = self.username
30
+ Springnote::Base.password = self.password
31
+ end
28
32
  self
29
33
  end
30
34
 
@@ -15,7 +15,6 @@ unless defined?(ActiveResource)
15
15
  end
16
16
 
17
17
  # extend activeresource
18
- require 'exts/common_parameters'
19
18
  require 'exts/request_with_oauth'
20
19
  require 'exts/active_resource_extension'
21
20
 
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.5.1
4
+ version: 0.6.6
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-10-06 00:00:00 +09:00
12
+ date: 2008-10-23 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -82,7 +82,6 @@ files:
82
82
  - lib/springnote/import_file.rb
83
83
  - lib/springnote/revision.rb
84
84
  - lib/exts/active_resource_extension.rb
85
- - lib/exts/common_parameters.rb
86
85
  - lib/exts/request_with_oauth.rb
87
86
  - spec/base_spec.rb
88
87
  - spec/configuration_spec.rb
@@ -1,21 +0,0 @@
1
- module CommonParameters
2
- def self.included(mod)
3
- mod.alias_method_chain :request, :commons
4
- mod.send :cattr_accessor, :common_params
5
- mod.common_params = {}
6
- end
7
-
8
- def request_with_commons(method, path, *arguments)
9
- unless common_params.empty?
10
- path += path.include?('?') ? '&' : '?'
11
- path += common_params.to_query
12
- end
13
- request_without_commons(method, path, *arguments)
14
- end
15
-
16
- def common_params
17
- self.class.common_params
18
- end
19
- end
20
-
21
- ActiveResource::Connection.send :include, CommonParameters