rest-core 3.5.0 → 3.5.1
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.
- checksums.yaml +4 -4
- data/.travis.yml +4 -2
- data/CHANGES.md +4 -0
- data/lib/rest-core/client.rb +10 -10
- data/lib/rest-core/middleware.rb +4 -4
- data/lib/rest-core/version.rb +1 -1
- data/rest-core.gemspec +3 -3
- data/test/test_client.rb +1 -1
- data/test/test_error_handler.rb +1 -1
- data/test/test_promise.rb +2 -2
- data/test/test_universal.rb +3 -3
- 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: 0deea3c56ae01f19f5d7f7d6b32a6ea35259846b
|
4
|
+
data.tar.gz: ce45a4ddcadda96dfecec4ad2ad24079f5fedcb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b1f3bd1b3b254cd7c922dddebe618f134c4cf2d328b018584b0390410adc1218b8bf6333f163ddd9698a54d88347ef5d3fdb850e7b50c3cc7ba63b7a0797457
|
7
|
+
data.tar.gz: 0314d2a3658e30486a13d7e9ffbb9fd8d63d8fd1f5711fb38cd5c99b26576bb9af4698b337e1f97320b9ab35c51c0bffe556da73f6837483518971cfc414a9b8
|
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
data/lib/rest-core/client.rb
CHANGED
@@ -20,13 +20,13 @@ module RestCore::Client
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
def default_#{name}
|
23
|
+
def default_#{name} a=app
|
24
24
|
if self.class.respond_to?("default_#{name}")
|
25
25
|
self.class.default_#{name} # old class default style
|
26
|
-
elsif
|
27
|
-
|
28
|
-
elsif
|
29
|
-
default_#{name}(
|
26
|
+
elsif a.respond_to?(:#{name})
|
27
|
+
a.#{name}({}) # middleware instance value
|
28
|
+
elsif a.respond_to?(:app)
|
29
|
+
default_#{name}(a.app) # walk into next app
|
30
30
|
else
|
31
31
|
nil
|
32
32
|
end
|
@@ -154,16 +154,16 @@ module RestCore::Client
|
|
154
154
|
self.class.event_source_class.new(self, path, query, opts)
|
155
155
|
end
|
156
156
|
|
157
|
-
def request env,
|
157
|
+
def request env, a=app
|
158
158
|
if block_given?
|
159
|
-
request_full(env,
|
159
|
+
request_full(env, a){ |response| yield(response[response_key(env)]) }
|
160
160
|
else
|
161
|
-
request_full(env,
|
161
|
+
request_full(env, a)[response_key(env)]
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
165
|
-
def request_full env,
|
166
|
-
response =
|
165
|
+
def request_full env, a=app, &k
|
166
|
+
response = a.call(build_env({ASYNC => !!k}.merge(env))) do |res|
|
167
167
|
(k || RC.id).call(request_complete(res))
|
168
168
|
end
|
169
169
|
|
data/lib/rest-core/middleware.rb
CHANGED
@@ -50,11 +50,11 @@ module RestCore::Middleware
|
|
50
50
|
env
|
51
51
|
end
|
52
52
|
end
|
53
|
-
def run
|
54
|
-
if
|
55
|
-
run(
|
53
|
+
def run a=app
|
54
|
+
if a.respond_to?(:app) && a.app
|
55
|
+
run(a.app)
|
56
56
|
else
|
57
|
-
|
57
|
+
a
|
58
58
|
end
|
59
59
|
end
|
60
60
|
def error_callback res, err
|
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.1 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.1"
|
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 = "2014-12-
|
11
|
+
s.date = "2014-12-27"
|
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/test/test_client.rb
CHANGED
@@ -170,7 +170,7 @@ describe RC::Simple do
|
|
170
170
|
error_callback = lambda{ |e| error = e }
|
171
171
|
should.raise(Errno::ECONNREFUSED) do
|
172
172
|
RC::Simple.new(:error_callback => error_callback).
|
173
|
-
get('http://localhost
|
173
|
+
get('http://localhost:1').tap{}
|
174
174
|
end
|
175
175
|
error.should.kind_of?(Errno::ECONNREFUSED)
|
176
176
|
end
|
data/test/test_error_handler.rb
CHANGED
@@ -61,7 +61,7 @@ describe RC::ErrorHandler do
|
|
61
61
|
called = false
|
62
62
|
RC::Builder.client do
|
63
63
|
use RC::ErrorHandler, lambda{ |_| called = true }
|
64
|
-
end.new.get('http://localhost') do |error|
|
64
|
+
end.new.get('http://localhost:1') do |error|
|
65
65
|
error.should.kind_of?(SystemCallError)
|
66
66
|
end.wait
|
67
67
|
called.should.eq false
|
data/test/test_promise.rb
CHANGED
@@ -50,7 +50,7 @@ describe RC::Promise do
|
|
50
50
|
msg.should.eq 'boom'
|
51
51
|
end
|
52
52
|
|
53
|
-
@client.new.get('http://localhost
|
53
|
+
@client.new.get('http://localhost:1') do |err|
|
54
54
|
err.should.kind_of?(Errno::ECONNREFUSED)
|
55
55
|
raise 'boom'
|
56
56
|
end.wait
|
@@ -59,7 +59,7 @@ describe RC::Promise do
|
|
59
59
|
would 'call error_callback on errors' do
|
60
60
|
errors = []
|
61
61
|
@client.new(:error_callback => lambda{ |e| errors << e }).
|
62
|
-
get('http://localhost
|
62
|
+
get('http://localhost:1') do |err|
|
63
63
|
err.should.kind_of?(Errno::ECONNREFUSED)
|
64
64
|
raise 'boom'
|
65
65
|
end.wait
|
data/test/test_universal.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
require 'rest-core/test'
|
3
3
|
|
4
4
|
describe RC::Universal do
|
5
|
-
url = 'http://localhost
|
5
|
+
url = 'http://localhost:1'
|
6
6
|
|
7
7
|
after do
|
8
8
|
WebMock.reset!
|
@@ -34,8 +34,8 @@ describe RC::Universal do
|
|
34
34
|
would 'follow redirect regardless response body' do
|
35
35
|
called = []
|
36
36
|
stub_request(:get, url).to_return(:body => 'bad json!',
|
37
|
-
:status => 302, :headers => {'Location' => "#{url}a"})
|
38
|
-
stub_request(:get, "#{url}a").to_return do
|
37
|
+
:status => 302, :headers => {'Location' => "#{url}/a"})
|
38
|
+
stub_request(:get, "#{url}/a").to_return do
|
39
39
|
Thread.pass
|
40
40
|
{:body => '{"good":"json!"}'}
|
41
41
|
end
|
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.1
|
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: 2014-12-
|
11
|
+
date: 2014-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|