productive 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/productive/resources/base.rb +32 -18
- data/lib/productive/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: 135076a9825c5ba98a32ae6adcf847bee2613d14
|
4
|
+
data.tar.gz: 2926f11187cd278ca1d6b6c481e8df905ca44988
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69c10baf363ebb19915aaac3b81bce0f3404bb7e30092c552ed1f61587205e3e35098d887c09f64fc64145a1486c43ab8de9ce27a2493c94e32a7678adcd46ed
|
7
|
+
data.tar.gz: 1281601acbc2c4648ca60a7330435855561dccdf9da4092adcc9e728ecf0408aa5d0e3d6d340712f43a96f9f7957dd752e46e001a8a066e3a5cfc4e0e1bb5d44
|
@@ -21,30 +21,44 @@ module Productive
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.all(args = {})
|
24
|
-
|
25
|
-
|
24
|
+
depaginate(BaseItems.new([]), args).items
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.lazy_all(args = {})
|
28
|
+
Enumerator.new do |yielder|
|
29
|
+
depaginate(LazyItems.new(yielder), args)
|
30
|
+
end.lazy
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.depaginate(items, args)
|
34
|
+
page = paginate(per_page: PER_PAGE).find(args)
|
35
|
+
items.append(page)
|
26
36
|
|
27
37
|
loop do
|
28
|
-
|
29
|
-
raise StopIteration if
|
30
|
-
|
31
|
-
page += 1
|
38
|
+
page = page.pages.next
|
39
|
+
raise StopIteration if page.nil?
|
40
|
+
items.append(page)
|
32
41
|
end
|
33
42
|
|
34
|
-
|
43
|
+
items
|
35
44
|
end
|
36
45
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
class BaseItems
|
47
|
+
attr_reader :items
|
48
|
+
|
49
|
+
def initialize(items)
|
50
|
+
@items = items
|
51
|
+
end
|
52
|
+
|
53
|
+
def append(results)
|
54
|
+
@items += results
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
class LazyItems < BaseItems
|
59
|
+
def append(results)
|
60
|
+
results.each { |item| @items << item }
|
61
|
+
end
|
48
62
|
end
|
49
63
|
end
|
50
64
|
end
|
data/lib/productive/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: productive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josip Bišćan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|