dato 0.3.3 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dato/local/items_repo.rb +6 -3
- data/lib/dato/local/json_api_entity.rb +1 -1
- data/lib/dato/local/loader.rb +1 -17
- data/lib/dato/site/repo/item.rb +27 -2
- data/lib/dato/version.rb +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: ad3ec619bb80a4704d54452bc49ec677e1b6f498
|
4
|
+
data.tar.gz: 1c4f832a125be15cd51fa8923d7d431707c6c618
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c69a434cbbfed50009a013c9e23b7d2b1e9fbd62a370f2c90976739958a94c9c31031ef2c04536348042a37a9c173a432473dd2042bb4bde1f1f06c6aa2afd32
|
7
|
+
data.tar.gz: f1e25a2b11be0c93f2e8a7c7577a114bc712a5538c2770231c8a8992043e4d619f757703e4c63d8d043c555386a4182d581e92b41b8d571049277cb4c2b9491d
|
@@ -127,9 +127,12 @@ module Dato
|
|
127
127
|
item_types.each do |item_type|
|
128
128
|
method = item_type_methods[item_type]
|
129
129
|
next unless item_type.singleton
|
130
|
-
|
131
|
-
|
132
|
-
|
130
|
+
|
131
|
+
item = if item_type.singleton_item
|
132
|
+
@items_by_id[item_type.singleton_item.id]
|
133
|
+
end
|
134
|
+
|
135
|
+
@collections_by_type[method] = item
|
133
136
|
end
|
134
137
|
end
|
135
138
|
|
data/lib/dato/local/loader.rb
CHANGED
@@ -31,23 +31,7 @@ module Dato
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def all_items
|
34
|
-
|
35
|
-
base_response = client.request(:get, '/items', 'page[limit]' => 500)
|
36
|
-
|
37
|
-
extra_pages = (
|
38
|
-
base_response[:meta][:total_count] / items_per_page.to_f
|
39
|
-
).ceil - 1
|
40
|
-
|
41
|
-
extra_pages.times do |page|
|
42
|
-
base_response[:data] += client.request(
|
43
|
-
:get,
|
44
|
-
'/items',
|
45
|
-
'page[offset]' => items_per_page * (page + 1),
|
46
|
-
'page[limit]' => items_per_page
|
47
|
-
)[:data]
|
48
|
-
end
|
49
|
-
|
50
|
-
base_response
|
34
|
+
client.items.all({}, false)
|
51
35
|
end
|
52
36
|
end
|
53
37
|
end
|
data/lib/dato/site/repo/item.rb
CHANGED
@@ -35,8 +35,33 @@ module Dato
|
|
35
35
|
put_request "/items/#{item_id}", body
|
36
36
|
end
|
37
37
|
|
38
|
-
def all(filters = {})
|
39
|
-
|
38
|
+
def all(filters = {}, deserialize_response = true)
|
39
|
+
items_per_page = 500
|
40
|
+
|
41
|
+
base_response = client.request(
|
42
|
+
:get, '/items', filters.dup.merge('page[limit]' => items_per_page)
|
43
|
+
)
|
44
|
+
|
45
|
+
extra_pages = (
|
46
|
+
base_response[:meta][:total_count] / items_per_page.to_f
|
47
|
+
).ceil - 1
|
48
|
+
|
49
|
+
extra_pages.times do |page|
|
50
|
+
base_response[:data] += client.request(
|
51
|
+
:get,
|
52
|
+
'/items',
|
53
|
+
filters.dup.merge(
|
54
|
+
'page[offset]' => items_per_page * (page + 1),
|
55
|
+
'page[limit]' => items_per_page
|
56
|
+
)
|
57
|
+
)[:data]
|
58
|
+
end
|
59
|
+
|
60
|
+
if deserialize_response
|
61
|
+
JsonApiDeserializer.new.deserialize(base_response)
|
62
|
+
else
|
63
|
+
base_response
|
64
|
+
end
|
40
65
|
end
|
41
66
|
|
42
67
|
def find(item_id)
|
data/lib/dato/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dato
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefano Verna
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|