productive 0.6.12 → 0.6.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/json_api_query_builder.rb +15 -0
- data/lib/productive/configuration.rb +3 -1
- data/lib/productive/resources/base.rb +5 -41
- data/lib/productive/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7870e1199efedbcd44e8e4d006cae81d38896617
|
4
|
+
data.tar.gz: 7bc9d3c1ba970f5122c909ea2b89d5df66acfa4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06d73d9ce29a16a171e1465b5772dd1d8015c1e5302f716d86bb9e2c91b3856e4016b28d6d238e56c1127f14d6439b41380602e09b65f4abad22ceb6279c02dd
|
7
|
+
data.tar.gz: 8ca21e2c83da1836b5ce2c06721d95dbdb98e6792048abdcc0ff833a26d0cd5fe08d6e6f6d20ad1f7cfc0137aee80e3763f6632ba58c491031699b7947072d3e
|
@@ -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.
|
55
|
-
|
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
|
-
|
94
|
-
|
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
|
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.6.
|
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-
|
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
|