productive 0.6.12 → 0.6.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f81064343d92daff334e6e911c4cbf7e98a9fd84
4
- data.tar.gz: ca2a00d084fa22ddf13d009a2a491dffa3c1f7bb
3
+ metadata.gz: 7870e1199efedbcd44e8e4d006cae81d38896617
4
+ data.tar.gz: 7bc9d3c1ba970f5122c909ea2b89d5df66acfa4c
5
5
  SHA512:
6
- metadata.gz: ce9d7bb602bde8f85b5f2af219e484f7acfcbbbe0527c46deb22583bf752a2083a603d14a27e40d37b9f2edbeb2b6dd52dec4509cb2fbddf1b66a8d0d2cfea32
7
- data.tar.gz: 89d981fb1075221f9a661966a99d231f039bcccdfd1fdb94d6e0035328e4eb38f614b17fd9efe06027cdec19871a2a8191b32ba2934723f543998a72f301678f
6
+ metadata.gz: 06d73d9ce29a16a171e1465b5772dd1d8015c1e5302f716d86bb9e2c91b3856e4016b28d6d238e56c1127f14d6439b41380602e09b65f4abad22ceb6279c02dd
7
+ data.tar.gz: 8ca21e2c83da1836b5ce2c06721d95dbdb98e6792048abdcc0ff833a26d0cd5fe08d6e6f6d20ad1f7cfc0137aee80e3763f6632ba58c491031699b7947072d3e
@@ -0,0 +1,15 @@
1
+ class JsonApiQueryBuilder < JsonApiClient::Query::Builder
2
+ def all
3
+ @all ||= begin
4
+ results = page = find
5
+
6
+ loop do
7
+ page = page.pages.next
8
+ break if page.nil?
9
+ results += page
10
+ end
11
+
12
+ results
13
+ end
14
+ end
15
+ end
@@ -1,14 +1,16 @@
1
1
  require 'json_api_paginator'
2
+ require 'json_api_query_builder'
2
3
 
3
4
  module Productive
4
5
  class Configuration
5
- attr_accessor :api_key, :account_id, :base_url, :paginator, :connection_options
6
+ attr_accessor :api_key, :account_id, :base_url, :paginator, :query_builder, :connection_options
6
7
 
7
8
  def initialize
8
9
  self.api_key = ENV['PRODUCTIVE_API_KEY']
9
10
  self.account_id = ENV['PRODUCTIVE_ACCOUNT_ID']
10
11
  self.base_url = 'https://api.productive.io/api/v2/'
11
12
  self.paginator = JsonApiPaginator
13
+ self.query_builder = JsonApiQueryBuilder
12
14
  self.connection_options = {}
13
15
  end
14
16
  end
@@ -30,6 +30,7 @@ module Productive
30
30
  site_setup config
31
31
  connection_options_setup config
32
32
  paginator_setup config
33
+ query_builder_setup config
33
34
  reset_connection
34
35
  end
35
36
 
@@ -51,49 +52,12 @@ module Productive
51
52
  self.paginator = config.paginator
52
53
  end
53
54
 
54
- def self.reset_connection
55
- connection(rebuild: true)
56
- end
57
-
58
- def self.all(args = {})
59
- depaginate(BaseItems.new([]), args).items
60
- end
61
-
62
- def self.lazy_all(args = {})
63
- Enumerator.new do |yielder|
64
- depaginate(LazyItems.new(yielder), args)
65
- end.lazy
66
- end
67
-
68
- def self.depaginate(items, args)
69
- page = paginate(per_page: PER_PAGE).find(args)
70
- items.append(page)
71
-
72
- loop do
73
- page = page.pages.next
74
- raise StopIteration if page.nil?
75
- items.append(page)
76
- end
77
-
78
- items
79
- end
80
-
81
- class BaseItems
82
- attr_reader :items
83
-
84
- def initialize(items)
85
- @items = items
86
- end
87
-
88
- def append(results)
89
- @items += results
90
- end
55
+ def self.query_builder_setup(config)
56
+ self.query_builder = config.query_builder
91
57
  end
92
58
 
93
- class LazyItems < BaseItems
94
- def append(results)
95
- results.each { |item| @items << item }
96
- end
59
+ def self.reset_connection
60
+ connection(rebuild: true)
97
61
  end
98
62
  end
99
63
  end
@@ -1,3 +1,3 @@
1
1
  module Productive
2
- VERSION = '0.6.12'.freeze
2
+ VERSION = '0.6.13'.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.6.12
4
+ version: 0.6.13
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: 2018-06-28 00:00:00.000000000 Z
11
+ date: 2018-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -65,6 +65,7 @@ files:
65
65
  - README.md
66
66
  - lib/generators/productive/productive_generator.rb
67
67
  - lib/json_api_paginator.rb
68
+ - lib/json_api_query_builder.rb
68
69
  - lib/productive.rb
69
70
  - lib/productive/configuration.rb
70
71
  - lib/productive/railtie.rb