rest-core 3.5.6 → 3.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +15 -0
- data/lib/rest-core/engine.rb +6 -1
- data/lib/rest-core/middleware.rb +6 -0
- data/lib/rest-core/middleware/json_request.rb +1 -3
- data/lib/rest-core/version.rb +1 -1
- data/rest-core.gemspec +3 -3
- data/task/gemgem.rb +5 -0
- data/test/test_universal.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92e289bb3e825b93385443dade7adf26959b90b8
|
4
|
+
data.tar.gz: 5861deec728b6d154f582702c5b2643ad7797b07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a33744abd434667196c62f2066c0fecfa0315d0d397239964d16d13d7726cd94d0aa98dc3581924e84912decbb6f32040106d42cdeaafd5b962d3ba75382c94
|
7
|
+
data.tar.gz: d6f3fe16efe1d82931cbb88cd9053509e2ca064e7d693365d963c5aefe154ef04e8e08d154aa3b79c4f4f3035e3795c6e14022d526a03a9624cdeff84e5e06c1
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
# CHANGES
|
2
2
|
|
3
|
+
## rest-core 3.5.7 -- 2015-09-10
|
4
|
+
|
5
|
+
### Incompatible changes
|
6
|
+
|
7
|
+
* JSON_REQUEST_METHOD was removed.
|
8
|
+
|
9
|
+
### Bugs fixed
|
10
|
+
|
11
|
+
* GET/DELETE/HEAD/OPTIONS would no longer try to attach any payload.
|
12
|
+
|
13
|
+
### Enhancements
|
14
|
+
|
15
|
+
* Introduced Middleware.has_payload? which would detect if the request
|
16
|
+
should attach a payload or not.
|
17
|
+
|
3
18
|
## rest-core 3.5.6 -- 2015-07-23
|
4
19
|
|
5
20
|
### Bugs fixed
|
data/lib/rest-core/engine.rb
CHANGED
@@ -15,7 +15,12 @@ class RestCore::Engine
|
|
15
15
|
|
16
16
|
private
|
17
17
|
def payload_and_headers env
|
18
|
-
|
18
|
+
if has_payload?(env)
|
19
|
+
Payload.generate_with_headers(env[REQUEST_PAYLOAD],
|
20
|
+
env[REQUEST_HEADERS])
|
21
|
+
else
|
22
|
+
[{}, env[REQUEST_HEADERS]]
|
23
|
+
end
|
19
24
|
end
|
20
25
|
|
21
26
|
def normalize_headers headers
|
data/lib/rest-core/middleware.rb
CHANGED
@@ -4,6 +4,7 @@ require 'rest-core'
|
|
4
4
|
|
5
5
|
module RestCore::Middleware
|
6
6
|
include RestCore
|
7
|
+
METHODS_WITH_PAYLOAD = [:post, :put, :patch]
|
7
8
|
|
8
9
|
def self.included mod
|
9
10
|
mod.send(:include, RestCore)
|
@@ -96,6 +97,11 @@ module RestCore::Middleware
|
|
96
97
|
end
|
97
98
|
public :escape
|
98
99
|
|
100
|
+
def has_payload? env
|
101
|
+
METHODS_WITH_PAYLOAD.include?(env[REQUEST_METHOD])
|
102
|
+
end
|
103
|
+
public :has_payload?
|
104
|
+
|
99
105
|
def contain_binary? payload
|
100
106
|
return false unless payload
|
101
107
|
return true if payload.respond_to?(:read)
|
@@ -7,12 +7,10 @@ class RestCore::JsonRequest
|
|
7
7
|
include RestCore::Middleware
|
8
8
|
|
9
9
|
JSON_REQUEST_HEADER = {'Content-Type' => 'application/json'}.freeze
|
10
|
-
JSON_REQUEST_METHOD = [:post, :put, :patch]
|
11
10
|
|
12
11
|
def call env, &k
|
13
12
|
return app.call(env, &k) unless json_request(env)
|
14
|
-
return app.call(env, &k) unless
|
15
|
-
JSON_REQUEST_METHOD.include?(env[REQUEST_METHOD])
|
13
|
+
return app.call(env, &k) unless has_payload?(env)
|
16
14
|
|
17
15
|
app.call(env.merge(
|
18
16
|
REQUEST_HEADERS => JSON_REQUEST_HEADER.merge(env[REQUEST_HEADERS]||{}),
|
data/lib/rest-core/version.rb
CHANGED
data/rest-core.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: rest-core 3.5.
|
2
|
+
# stub: rest-core 3.5.7 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "rest-core"
|
6
|
-
s.version = "3.5.
|
6
|
+
s.version = "3.5.7"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib"]
|
10
10
|
s.authors = ["Lin Jen-Shin (godfat)"]
|
11
|
-
s.date = "2015-
|
11
|
+
s.date = "2015-09-10"
|
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-more]: https://github.com/godfat/rest-more"
|
13
13
|
s.email = ["godfat (XD) godfat.org"]
|
14
14
|
s.files = [
|
data/task/gemgem.rb
CHANGED
data/test/test_universal.rb
CHANGED
@@ -8,6 +8,22 @@ describe RC::Universal do
|
|
8
8
|
WebMock.reset!
|
9
9
|
end
|
10
10
|
|
11
|
+
would 'only send payload for post, put, patch' do
|
12
|
+
c = RC::Universal.new(:log_method => false, :payload => '$payload')
|
13
|
+
[:get, :delete, :head, :options].each do |method|
|
14
|
+
stub_request(method, url)
|
15
|
+
c.send(method, url).tap{}
|
16
|
+
assert_requested(method, url, :body => nil)
|
17
|
+
end
|
18
|
+
|
19
|
+
[:put, :post, :patch].each do |method|
|
20
|
+
stub_request(method, url).with(:body => '$payload')
|
21
|
+
c.send(method, url).tap{}
|
22
|
+
assert_requested(method, url, :body => '$payload')
|
23
|
+
end
|
24
|
+
ok
|
25
|
+
end
|
26
|
+
|
11
27
|
would 'send Authorization header' do
|
12
28
|
u = RC::Universal.new(:log_method => false)
|
13
29
|
u.username = 'Aladdin'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.5.
|
4
|
+
version: 3.5.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lin Jen-Shin (godfat)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|