rest-core 2.0.3 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -6
- data/CHANGES.md +4 -0
- data/lib/rest-core/engine/em-http-request.rb +23 -10
- data/lib/rest-core/version.rb +1 -1
- data/rest-core.gemspec +2 -2
- metadata +9 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
5
|
-
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 13edab18f56e62ce573dc6cff597226d8d5ade6c
|
4
|
+
data.tar.gz: e41513b602d15644f9f4000cfc85a14bd93b71f2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 70583190f10ad4f2a90075eb894a9f12da622c585353b20a77152de34ea573f5cc1d5c9512ca9d6b19722c13baba87bc829a10a9eb77162bf95c94bdc88b1cc7
|
7
|
+
data.tar.gz: c583d03d2448e7d202a506661aea8a67be6f127f1b2ec3bf97176939585437d78fc28c5bb708f4f9fdcf2501d9e2806f2eb6a75f102949f32f5d238f34665826
|
data/CHANGES.md
CHANGED
@@ -8,7 +8,25 @@ require 'rest-core/middleware'
|
|
8
8
|
class RestCore::EmHttpRequest
|
9
9
|
include RestCore::Middleware
|
10
10
|
def call env, &k
|
11
|
-
future
|
11
|
+
future = Future.create(env, k, env[ASYNC])
|
12
|
+
|
13
|
+
# eventmachine is not thread-safe, so...
|
14
|
+
# https://github.com/igrigorik/em-http-request/issues/190#issuecomment-16995528
|
15
|
+
::EventMachine.schedule{ request(future, env) }
|
16
|
+
|
17
|
+
env.merge(RESPONSE_BODY => future.proxy_body,
|
18
|
+
RESPONSE_STATUS => future.proxy_status,
|
19
|
+
RESPONSE_HEADERS => future.proxy_headers,
|
20
|
+
FUTURE => future)
|
21
|
+
end
|
22
|
+
|
23
|
+
def close client
|
24
|
+
(client.instance_variable_get(:@callbacks)||[]).clear
|
25
|
+
(client.instance_variable_get(:@errbacks )||[]).clear
|
26
|
+
client.close
|
27
|
+
end
|
28
|
+
|
29
|
+
def request future, env
|
12
30
|
payload = ::RestClient::Payload.generate(env[REQUEST_PAYLOAD])
|
13
31
|
client = ::EventMachine::HttpRequest.new(request_uri(env)).send(
|
14
32
|
env[REQUEST_METHOD],
|
@@ -21,18 +39,13 @@ class RestCore::EmHttpRequest
|
|
21
39
|
client.response_header.status,
|
22
40
|
client.response_header)}
|
23
41
|
|
24
|
-
client.errback{
|
42
|
+
client.errback{
|
43
|
+
close(client)
|
44
|
+
future.on_error(client.error)}
|
25
45
|
|
26
46
|
env[TIMER].on_timeout{
|
27
|
-
(client
|
28
|
-
(client.instance_variable_get(:@errbacks )||[]).clear
|
29
|
-
client.close
|
47
|
+
close(client)
|
30
48
|
future.on_error(env[TIMER].error)
|
31
49
|
} if env[TIMER]
|
32
|
-
|
33
|
-
env.merge(RESPONSE_BODY => future.proxy_body,
|
34
|
-
RESPONSE_STATUS => future.proxy_status,
|
35
|
-
RESPONSE_HEADERS => future.proxy_headers,
|
36
|
-
FUTURE => future)
|
37
50
|
end
|
38
51
|
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 = "2.0.
|
5
|
+
s.version = "2.0.4"
|
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 = "2013-04-
|
11
|
+
s.date = "2013-04-30"
|
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/cardinalblue/rest-more"
|
13
13
|
s.email = ["dev (XD) cardinalblue.com"]
|
14
14
|
s.files = [
|
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: 2.0.
|
4
|
+
version: 2.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cardinal Blue
|
@@ -9,39 +9,33 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - '>='
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - '>='
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
|
-
description:
|
29
|
-
|
28
|
+
description: |-
|
29
|
+
Modular Ruby clients interface for REST APIs
|
30
30
|
|
31
31
|
There has been an explosion in the number of REST APIs available today.
|
32
|
-
|
33
32
|
To address the need for a way to access these APIs easily and elegantly,
|
34
|
-
|
35
33
|
we have developed rest-core, which consists of composable middleware
|
36
|
-
|
37
34
|
that allows you to build a REST client for any REST API. Or in the case of
|
38
|
-
|
39
35
|
common APIs such as Facebook, Github, and Twitter, you can simply use the
|
40
|
-
|
41
36
|
dedicated clients provided by [rest-more][].
|
42
37
|
|
43
|
-
|
44
|
-
[rest-more]: https://github.com/cardinalblue/rest-more'
|
38
|
+
[rest-more]: https://github.com/cardinalblue/rest-more
|
45
39
|
email:
|
46
40
|
- dev (XD) cardinalblue.com
|
47
41
|
executables: []
|
@@ -137,12 +131,12 @@ require_paths:
|
|
137
131
|
- lib
|
138
132
|
required_ruby_version: !ruby/object:Gem::Requirement
|
139
133
|
requirements:
|
140
|
-
- -
|
134
|
+
- - '>='
|
141
135
|
- !ruby/object:Gem::Version
|
142
136
|
version: '0'
|
143
137
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
138
|
requirements:
|
145
|
-
- -
|
139
|
+
- - '>='
|
146
140
|
- !ruby/object:Gem::Version
|
147
141
|
version: '0'
|
148
142
|
requirements: []
|