rest-core 3.5.5 → 3.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +7 -0
- data/lib/rest-core/middleware/json_response.rb +4 -9
- data/lib/rest-core/util/json.rb +0 -1
- data/lib/rest-core/version.rb +1 -1
- data/rest-core.gemspec +3 -3
- data/test/test_thread_pool.rb +4 -28
- 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: 22b1bd4e98e62b8b87bbe2021020e0fc3897d429
|
4
|
+
data.tar.gz: 15f1a45e675881ad5a2de3c10fd56ffd2d0837e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecf7a1ec80da7bc369bd49985f5c43eac6c298050f7b2777790c170e2f80cf0062725320a41efe268605faaab212f34c84b662bd563195c561dfd900d25f92d4
|
7
|
+
data.tar.gz: d4203a3a72e2c511d4e0b0312942e9155dc5ef440c8e4de76ef45a8ee1e16660a69aad3c0b8e4d38cb5688d9926db466b193932b27999365b1d74138d3f30d2f
|
data/CHANGES.md
CHANGED
@@ -28,16 +28,11 @@ class RestCore::JsonResponse
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def process response
|
31
|
+
# StackExchange returns the problematic BOM! in UTF-8, so we need to
|
32
|
+
# strip it or it would break JSON parsers (i.e. yajl-ruby and json)
|
31
33
|
body = response[RESPONSE_BODY].to_s.sub(/\A\xEF\xBB\xBF/, '')
|
32
|
-
|
33
|
-
|
34
|
-
RESPONSE_SOCKET => Json.decode_from_io(response[RESPONSE_SOCKET]))
|
35
|
-
else
|
36
|
-
# StackExchange returns the problematic BOM! in UTF-8, so we need to
|
37
|
-
# strip it or it would break JSON parsers (i.e. yajl-ruby and json)
|
38
|
-
response.merge(RESPONSE_BODY => Json.decode("[#{body}]").first)
|
39
|
-
# [this].first is not needed for yajl-ruby
|
40
|
-
end
|
34
|
+
response.merge(RESPONSE_BODY => Json.decode("[#{body}]").first)
|
35
|
+
# [this].first is not needed for yajl-ruby
|
41
36
|
rescue Json.const_get(:ParseError) => error
|
42
37
|
fail(response, ParseError.new(error, body))
|
43
38
|
end
|
data/lib/rest-core/util/json.rb
CHANGED
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.6 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.6"
|
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-07-
|
11
|
+
s.date = "2015-07-23"
|
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_thread_pool.rb
CHANGED
@@ -2,33 +2,9 @@
|
|
2
2
|
require 'rest-core/test'
|
3
3
|
|
4
4
|
describe RC::ThreadPool do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
# end
|
10
|
-
|
11
|
-
would 'not waiting forever' do
|
12
|
-
mutex = Mutex.new
|
13
|
-
condv = ConditionVariable.new
|
14
|
-
klass = Struct.new(:pool_size, :pool_idle_time).new(2, 10)
|
15
|
-
pool = RC::ThreadPool[klass]
|
16
|
-
pool.defer(mutex){mutex.synchronize{ condv.signal }} # populate one worker
|
17
|
-
mutex.synchronize{ condv.wait(mutex) }
|
18
|
-
called = []
|
19
|
-
pool.defer(mutex) do
|
20
|
-
sleep 1
|
21
|
-
called << 0
|
22
|
-
end
|
23
|
-
pool.defer(mutex) do
|
24
|
-
sleep 1
|
25
|
-
called << 0
|
26
|
-
pool.defer(mutex) do
|
27
|
-
called << 1
|
28
|
-
end
|
29
|
-
end
|
30
|
-
sleep 5
|
31
|
-
p called
|
32
|
-
ok
|
5
|
+
would 'have the same pool for the same client' do
|
6
|
+
client = RC::Builder.client
|
7
|
+
pool = RC::ThreadPool[client]
|
8
|
+
RC::ThreadPool[client].object_id.should.eq pool.object_id
|
33
9
|
end
|
34
10
|
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.6
|
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-07-
|
11
|
+
date: 2015-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|