productive 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02cce79d5592e3ef152ee93b73422d112ea59fb5
4
- data.tar.gz: e8eb6762f85ba240464b5feb01902479d322a86b
3
+ metadata.gz: 77f29b8aec3d5246bfa8c47324367f71a8d89fe1
4
+ data.tar.gz: 164de5a9592b69346d43d62afd5810722f7e2275
5
5
  SHA512:
6
- metadata.gz: 3388af949c859dac0ed94ae3154efefc7adf8b9d7d7262705a020ef18e3f61d896583b0a52f6ace7c9bae24cbbda4a1f9494ae87c64bfb1667c21fc790ba3fff
7
- data.tar.gz: 6732c9513119cc831a6aaae8783823d5b38fc1d7f79fa3155df38f8b6a4fe4d9ccb2b6156103df04aff14c93db2445737d5ed485c2200cb4c11e7642685b7abd
6
+ metadata.gz: 1cfbcdea8b7ed820c83c954b23b482fc9c9fbfc4909fc4818c8c505af790c826b34c9f1f13d6f9ae56b903dba771163bae7c8592ff821dcfadd44bda626b5b10
7
+ data.tar.gz: 7cff7c8493628f0d22f9919e9448328a33d0d9c9e25ac4125352e534e2acd048da64d6e7e9a7750090785522551a80392dcb48ef8abcfa25d1ae89f6f6e3cde1
@@ -1,5 +1,7 @@
1
1
  module Productive
2
2
  class Base < JsonApiClient::Resource
3
+ PER_PAGE = 1000
4
+
3
5
  def self.setup(config)
4
6
  site_setup config
5
7
  connection_options_setup config
@@ -17,5 +19,32 @@ module Productive
17
19
  def self.paginator_setup(config)
18
20
  self.paginator = config.paginator
19
21
  end
22
+
23
+ def self.all(args = {})
24
+ arr = []
25
+ page = 1
26
+
27
+ loop do
28
+ results = paginate(per_page: PER_PAGE, page: page).find(args)
29
+ raise StopIteration if results.empty?
30
+ arr += results
31
+ page += 1
32
+ end
33
+
34
+ arr
35
+ end
36
+
37
+ def self.lazy_all
38
+ Enumerator.new do |yielder|
39
+ page = 1
40
+
41
+ loop do
42
+ results = paginate(per_page: PER_PAGE, page: page).find(args)
43
+ raise StopIteration if results.empty?
44
+ results.each { |item| yielder << item }
45
+ page += 1
46
+ end
47
+ end.lazy
48
+ end
20
49
  end
21
50
  end
@@ -1,3 +1,3 @@
1
1
  module Productive
2
- VERSION = '0.5.2'.freeze
2
+ VERSION = '0.5.3'.freeze
3
3
  end
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.2
4
+ version: 0.5.3
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-04-14 00:00:00.000000000 Z
11
+ date: 2017-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  version: '0'
109
109
  requirements: []
110
110
  rubyforge_project:
111
- rubygems_version: 2.5.1
111
+ rubygems_version: 2.6.7
112
112
  signing_key:
113
113
  specification_version: 4
114
114
  summary: A JSONAPI-based client to consume Productive API