quintype 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +10 -10
- data/lib/quintype/api.rb +16 -0
- data/lib/quintype/api/story.rb +17 -5
- data/quintype.gemspec +1 -1
- 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: '0287b1b423facb37184a57dba69a5d6d55ab51cf'
|
4
|
+
data.tar.gz: ecab515fafee3dd23ba15b0b24cc36acc8efbabd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17e34a6cd0641bef5cbb90ba1c8922400dcc1c0ecfed3d375daec1c050384e7c036bedd0e56610f9fcfdbb8943ad2018724c41ce42b21bde11b480e5ee53106e
|
7
|
+
data.tar.gz: be0da5cc89a320bc48cf11b2d72804a797c3370552ca289125da5bb5408f395f3dafa1dc23efb7b6da13907daf04eae04f12e175a97aabee02bf92d448f09be7
|
data/Gemfile.lock
CHANGED
@@ -1,32 +1,32 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
quintype (0.0.
|
4
|
+
quintype (0.0.10)
|
5
5
|
activesupport (~> 4.2)
|
6
6
|
faraday (~> 0.9)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activesupport (4.2.
|
11
|
+
activesupport (4.2.10)
|
12
12
|
i18n (~> 0.7)
|
13
|
-
json (~> 1.7, >= 1.7.7)
|
14
13
|
minitest (~> 5.1)
|
15
14
|
thread_safe (~> 0.3, >= 0.3.4)
|
16
15
|
tzinfo (~> 1.1)
|
17
16
|
addressable (2.4.0)
|
18
17
|
byebug (8.2.2)
|
19
18
|
coderay (1.1.1)
|
19
|
+
concurrent-ruby (1.0.5)
|
20
20
|
crack (0.4.3)
|
21
21
|
safe_yaml (~> 1.0.0)
|
22
22
|
diff-lcs (1.2.5)
|
23
|
-
faraday (0.
|
23
|
+
faraday (0.13.1)
|
24
24
|
multipart-post (>= 1.2, < 3)
|
25
25
|
hashdiff (0.3.0)
|
26
|
-
i18n (0.
|
27
|
-
|
26
|
+
i18n (0.9.0)
|
27
|
+
concurrent-ruby (~> 1.0)
|
28
28
|
method_source (0.8.2)
|
29
|
-
minitest (5.
|
29
|
+
minitest (5.10.3)
|
30
30
|
multipart-post (2.0.0)
|
31
31
|
pry (0.10.3)
|
32
32
|
coderay (~> 1.1.0)
|
@@ -47,8 +47,8 @@ GEM
|
|
47
47
|
rspec-support (3.4.1)
|
48
48
|
safe_yaml (1.0.4)
|
49
49
|
slop (3.6.0)
|
50
|
-
thread_safe (0.3.
|
51
|
-
tzinfo (1.2.
|
50
|
+
thread_safe (0.3.6)
|
51
|
+
tzinfo (1.2.4)
|
52
52
|
thread_safe (~> 0.1)
|
53
53
|
vcr (3.0.1)
|
54
54
|
webmock (1.24.2)
|
@@ -68,4 +68,4 @@ DEPENDENCIES
|
|
68
68
|
webmock
|
69
69
|
|
70
70
|
BUNDLED WITH
|
71
|
-
1.
|
71
|
+
1.15.4
|
data/lib/quintype/api.rb
CHANGED
@@ -12,6 +12,7 @@ class API
|
|
12
12
|
def establish_connection(host, conn = Faraday.new(url: host))
|
13
13
|
@@host = host
|
14
14
|
@@api_base = host + '/api/'
|
15
|
+
@@bulk_cache = ActiveSupport::Cache::MemoryStore.new
|
15
16
|
@@conn = conn
|
16
17
|
end
|
17
18
|
|
@@ -23,6 +24,21 @@ class API
|
|
23
24
|
_post("bulk", params)
|
24
25
|
end
|
25
26
|
|
27
|
+
def bulk_cached(params)
|
28
|
+
location = @@bulk_cache.fetch(params) do |params|
|
29
|
+
response = @@conn.post(@@api_base + "bulk-request", params) do |request|
|
30
|
+
request.headers['Content-Type'] = 'application/json'
|
31
|
+
request.body = params.to_json
|
32
|
+
end
|
33
|
+
if response.status == 303 && response.headers["Location"]
|
34
|
+
response.headers["Location"]
|
35
|
+
else
|
36
|
+
raise "Did not recieve a location header, status #{response.status}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
_get(location.sub(/^\/api\//, ""))
|
40
|
+
end
|
41
|
+
|
26
42
|
def config
|
27
43
|
_get("config")
|
28
44
|
end
|
data/lib/quintype/api/story.rb
CHANGED
@@ -41,13 +41,25 @@ class API
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
def prepare_bulk(params)
|
45
|
+
params.inject({}) do |hash, param|
|
46
|
+
hash[param.first] = param.last.merge(_type: param.last[:_type] || 'stories')
|
47
|
+
hash
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
44
51
|
def find_in_bulk(params)
|
45
52
|
if params.present?
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
53
|
+
response = API.bulk_post(requests: prepare_bulk(params))
|
54
|
+
response['results']
|
55
|
+
else
|
56
|
+
[]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def find_in_bulk_cached(params)
|
61
|
+
if params.present?
|
62
|
+
response = API.bulk_cached(requests: prepare_bulk(params))
|
51
63
|
response['results']
|
52
64
|
else
|
53
65
|
[]
|
data/quintype.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quintype
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
95
|
version: '0'
|
96
96
|
requirements: []
|
97
97
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.
|
98
|
+
rubygems_version: 2.6.11
|
99
99
|
signing_key:
|
100
100
|
specification_version: 4
|
101
101
|
summary: quintype!
|