rest-core 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.md +23 -0
- data/README.md +6 -0
- data/lib/rest-core.rb +1 -0
- data/lib/rest-core/client.rb +2 -2
- data/lib/rest-core/middleware/default_payload.rb +11 -0
- data/lib/rest-core/middleware/error_detector.rb +2 -1
- data/lib/rest-core/version.rb +1 -1
- data/rest-core.gemspec +8 -3
- data/test/test_error_detector.rb +15 -0
- data/test/test_error_detector_http.rb +6 -3
- data/test/test_payload.rb +29 -0
- metadata +11 -5
data/CHANGES.md
CHANGED
@@ -1,9 +1,32 @@
|
|
1
1
|
# CHANGES
|
2
2
|
|
3
|
+
## rest-core 0.8.2 -- 2012-02-18
|
4
|
+
|
5
|
+
### Enhancement
|
6
|
+
|
7
|
+
* [DefaultPayload] This middleware allows you to have default payload for
|
8
|
+
POST and PUT requests.
|
9
|
+
|
10
|
+
* [Client] Now `lighten` would give all Unserializable to nil instead of false
|
11
|
+
|
12
|
+
### Bugs fixes
|
13
|
+
|
14
|
+
* [ErrorDetector] Now it would do nothing instead of crashing if there's no
|
15
|
+
any error_detector.
|
16
|
+
|
3
17
|
## rest-core 0.8.1 -- 2012-02-09
|
4
18
|
|
19
|
+
### Enhancement
|
20
|
+
|
21
|
+
* [Wrapper] Introducing `Wrapper.default_app` (also `Builder.default_app`)
|
22
|
+
which you can change the default app from `RestClient` to other HTTP
|
23
|
+
clients.
|
24
|
+
|
5
25
|
### Bugs fixes
|
6
26
|
|
27
|
+
* [OAuth1Header] Correctly handle the signature when it comes to multipart
|
28
|
+
requests.
|
29
|
+
|
7
30
|
* [ErrorDetectorHttp] Fixed argument error upon calling `lighten` for
|
8
31
|
clients using this middleware. (e.g. rest-more's Twitter client)
|
9
32
|
|
data/README.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
by Cardinal Blue <http://cardinalblue.com>
|
4
4
|
|
5
|
+
Lin Jen-Shin ([godfat][]) had given a talk about rest-core on [RubyConf Taiwan 2011][talk].
|
6
|
+
The slide is in English, but the talk is in Mandarin.
|
7
|
+
|
8
|
+
[godfat]: https://github.com/godfat
|
9
|
+
[talk]: http://rubyconf.tw/2011/#6
|
10
|
+
|
5
11
|
## LINKS:
|
6
12
|
|
7
13
|
* [github](https://github.com/cardinalblue/rest-core)
|
data/lib/rest-core.rb
CHANGED
@@ -36,6 +36,7 @@ module RestCore
|
|
36
36
|
autoload :CommonLogger , 'rest-core/middleware/common_logger'
|
37
37
|
autoload :DefaultHeaders, 'rest-core/middleware/default_headers'
|
38
38
|
autoload :DefaultQuery , 'rest-core/middleware/default_query'
|
39
|
+
autoload :DefaultPayload, 'rest-core/middleware/default_payload'
|
39
40
|
autoload :DefaultSite , 'rest-core/middleware/default_site'
|
40
41
|
autoload :Defaults , 'rest-core/middleware/defaults'
|
41
42
|
autoload :ErrorDetector , 'rest-core/middleware/error_detector'
|
data/lib/rest-core/client.rb
CHANGED
@@ -68,9 +68,9 @@ module RestCore::Client
|
|
68
68
|
attributes.each{ |k, v| vv = case v;
|
69
69
|
when Hash; lighten_hash(v)
|
70
70
|
when Array; lighten_array(v)
|
71
|
-
when *Unserializable;
|
71
|
+
when *Unserializable; nil
|
72
72
|
else v
|
73
|
-
|
73
|
+
end
|
74
74
|
send("#{k}=", vv)}
|
75
75
|
initialize(o)
|
76
76
|
@app, @dry = lighten_app(app), lighten_app(dry)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
|
2
|
+
require 'rest-core/middleware'
|
3
|
+
|
4
|
+
class RestCore::DefaultPayload
|
5
|
+
def self.members; [:payload]; end
|
6
|
+
include RestCore::Middleware
|
7
|
+
def call env
|
8
|
+
app.call(env.merge(REQUEST_PAYLOAD =>
|
9
|
+
@payload.merge(payload(env)).merge(env[REQUEST_PAYLOAD] || {})))
|
10
|
+
end
|
11
|
+
end
|
data/lib/rest-core/version.rb
CHANGED
data/rest-core.gemspec
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "rest-core"
|
5
|
-
s.version = "0.8.
|
5
|
+
s.version = "0.8.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = [
|
9
9
|
"Cardinal Blue",
|
10
10
|
"Lin Jen-Shin (godfat)"]
|
11
|
-
s.date = "2012-02-
|
11
|
+
s.date = "2012-02-18"
|
12
12
|
s.description = "Modular Ruby clients interface for REST APIs\n\nThere has been an explosion in the number of REST APIs available today.\nTo address the need for a way to access these APIs easily and elegantly,\nwe have developed [rest-core][], which consists of composable middleware\nthat allows you to build a REST client for any REST API. Or in the case of\ncommon APIs such as Facebook, Github, and Twitter, you can simply use the\ndedicated clients provided by [rest-more][].\n\n[rest-core]: http://github.com/cardinalblue/rest-core\n[rest-more]: http://github.com/cardinalblue/rest-more"
|
13
13
|
s.email = ["dev (XD) cardinalblue.com"]
|
14
14
|
s.files = [
|
@@ -42,6 +42,7 @@ Gem::Specification.new do |s|
|
|
42
42
|
"lib/rest-core/middleware/cache.rb",
|
43
43
|
"lib/rest-core/middleware/common_logger.rb",
|
44
44
|
"lib/rest-core/middleware/default_headers.rb",
|
45
|
+
"lib/rest-core/middleware/default_payload.rb",
|
45
46
|
"lib/rest-core/middleware/default_query.rb",
|
46
47
|
"lib/rest-core/middleware/default_site.rb",
|
47
48
|
"lib/rest-core/middleware/defaults.rb",
|
@@ -67,21 +68,25 @@ Gem::Specification.new do |s|
|
|
67
68
|
"test/test_builder.rb",
|
68
69
|
"test/test_client.rb",
|
69
70
|
"test/test_client_oauth1.rb",
|
71
|
+
"test/test_error_detector.rb",
|
70
72
|
"test/test_error_detector_http.rb",
|
71
73
|
"test/test_oauth1_header.rb",
|
74
|
+
"test/test_payload.rb",
|
72
75
|
"test/test_universal.rb",
|
73
76
|
"test/test_wrapper.rb"]
|
74
77
|
s.homepage = "https://github.com/cardinalblue/rest-core"
|
75
78
|
s.require_paths = ["lib"]
|
76
|
-
s.rubygems_version = "1.8.
|
79
|
+
s.rubygems_version = "1.8.16"
|
77
80
|
s.summary = "Modular Ruby clients interface for REST APIs"
|
78
81
|
s.test_files = [
|
79
82
|
"test/test_auth_basic.rb",
|
80
83
|
"test/test_builder.rb",
|
81
84
|
"test/test_client.rb",
|
82
85
|
"test/test_client_oauth1.rb",
|
86
|
+
"test/test_error_detector.rb",
|
83
87
|
"test/test_error_detector_http.rb",
|
84
88
|
"test/test_oauth1_header.rb",
|
89
|
+
"test/test_payload.rb",
|
85
90
|
"test/test_universal.rb",
|
86
91
|
"test/test_wrapper.rb"]
|
87
92
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
require 'rest-core/test'
|
3
|
+
|
4
|
+
describe RC::ErrorDetector do
|
5
|
+
should 'lighten' do
|
6
|
+
client = RC::Builder.client do
|
7
|
+
s = self.class # this is only for ruby 1.8!
|
8
|
+
use s::ErrorDetector
|
9
|
+
run s::Dry
|
10
|
+
end.new.lighten
|
11
|
+
|
12
|
+
client.attributes.should.key?(:error_detector)
|
13
|
+
client.app.call({}).should.eq({})
|
14
|
+
end
|
15
|
+
end
|
@@ -1,12 +1,15 @@
|
|
1
1
|
|
2
2
|
require 'rest-core/test'
|
3
3
|
|
4
|
-
describe RC::
|
4
|
+
describe RC::ErrorDetectorHttp do
|
5
5
|
should 'lighten' do
|
6
|
-
RC::Builder.client do
|
6
|
+
client = RC::Builder.client do
|
7
7
|
s = self.class # this is only for ruby 1.8!
|
8
8
|
use s::ErrorDetectorHttp
|
9
9
|
run s::Dry
|
10
|
-
end.new.lighten
|
10
|
+
end.new.lighten
|
11
|
+
|
12
|
+
client.attributes.should.key?(:error_detector)
|
13
|
+
client.error_detector.should.kind_of?(Proc)
|
11
14
|
end
|
12
15
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
require 'rest-core/test'
|
3
|
+
|
4
|
+
describe RC::DefaultPayload do
|
5
|
+
before do
|
6
|
+
@app = RC::DefaultPayload.new(RC::Dry.new, {})
|
7
|
+
end
|
8
|
+
|
9
|
+
def app
|
10
|
+
@app
|
11
|
+
end
|
12
|
+
|
13
|
+
should 'do nothing' do
|
14
|
+
app.call({})[RC::REQUEST_PAYLOAD].should.eq({})
|
15
|
+
end
|
16
|
+
|
17
|
+
should 'merge payload' do
|
18
|
+
app.instance_eval{@payload = {'pay' => 'load'}}
|
19
|
+
|
20
|
+
app.call({}).should.eq({RC::REQUEST_PAYLOAD =>
|
21
|
+
{'pay' => 'load'}})
|
22
|
+
|
23
|
+
format = {'format' => 'json'}
|
24
|
+
env = {RC::REQUEST_PAYLOAD => format}
|
25
|
+
|
26
|
+
app.call(env).should.eq({RC::REQUEST_PAYLOAD =>
|
27
|
+
{'pay' => 'load'}.merge(format)})
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-02-
|
13
|
+
date: 2012-02-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|
17
|
-
requirement: &
|
17
|
+
requirement: &2157113980 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,7 +22,7 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2157113980
|
26
26
|
description: ! 'Modular Ruby clients interface for REST APIs
|
27
27
|
|
28
28
|
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- lib/rest-core/middleware/cache.rb
|
79
79
|
- lib/rest-core/middleware/common_logger.rb
|
80
80
|
- lib/rest-core/middleware/default_headers.rb
|
81
|
+
- lib/rest-core/middleware/default_payload.rb
|
81
82
|
- lib/rest-core/middleware/default_query.rb
|
82
83
|
- lib/rest-core/middleware/default_site.rb
|
83
84
|
- lib/rest-core/middleware/defaults.rb
|
@@ -103,8 +104,10 @@ files:
|
|
103
104
|
- test/test_builder.rb
|
104
105
|
- test/test_client.rb
|
105
106
|
- test/test_client_oauth1.rb
|
107
|
+
- test/test_error_detector.rb
|
106
108
|
- test/test_error_detector_http.rb
|
107
109
|
- test/test_oauth1_header.rb
|
110
|
+
- test/test_payload.rb
|
108
111
|
- test/test_universal.rb
|
109
112
|
- test/test_wrapper.rb
|
110
113
|
homepage: https://github.com/cardinalblue/rest-core
|
@@ -127,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
130
|
version: '0'
|
128
131
|
requirements: []
|
129
132
|
rubyforge_project:
|
130
|
-
rubygems_version: 1.8.
|
133
|
+
rubygems_version: 1.8.16
|
131
134
|
signing_key:
|
132
135
|
specification_version: 3
|
133
136
|
summary: Modular Ruby clients interface for REST APIs
|
@@ -136,7 +139,10 @@ test_files:
|
|
136
139
|
- test/test_builder.rb
|
137
140
|
- test/test_client.rb
|
138
141
|
- test/test_client_oauth1.rb
|
142
|
+
- test/test_error_detector.rb
|
139
143
|
- test/test_error_detector_http.rb
|
140
144
|
- test/test_oauth1_header.rb
|
145
|
+
- test/test_payload.rb
|
141
146
|
- test/test_universal.rb
|
142
147
|
- test/test_wrapper.rb
|
148
|
+
has_rdoc:
|