springnote_resources 0.6.5.1 → 0.6.6
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/History.txt +3 -0
- data/Manifest.txt +0 -1
- data/lib/exts/request_with_oauth.rb +17 -2
- data/lib/springnote/base.rb +1 -1
- data/lib/springnote/configuration.rb +4 -0
- data/lib/springnote_resources.rb +0 -1
- metadata +2 -3
- data/lib/exts/common_parameters.rb +0 -21
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
|
@@ -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)
|
data/lib/springnote/base.rb
CHANGED
|
@@ -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
|
|
data/lib/springnote_resources.rb
CHANGED
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.
|
|
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-
|
|
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
|