productive 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/generators/productive/productive_generator.rb +8 -10
- data/lib/json_api_paginator.rb +6 -4
- data/lib/productive/configuration.rb +2 -2
- data/lib/productive/railtie.rb +1 -1
- data/lib/productive/resources/base.rb +1 -2
- data/lib/productive/version.rb +1 -1
- data/productive.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ade904ec45d6bfd889ad1aa9e8a86d26da920710
|
4
|
+
data.tar.gz: 1a0b17811c30f76bf2f9ad43721ceb7a0c0ab0bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b479c35c2deeee84f71ce9d43abc3deac70e8d25c6607dd2650d4aaf96e7719492db4e96d7cca0aee5a4b7928ce08352b4abe6e62ec62c0e01cfa12fa3da232
|
7
|
+
data.tar.gz: e71849e848d371f765f0794d2cdafe3757ee6f5552ce91a7f5484481d46c0d9f835cde1254d150111593013d70721991b0cb48dc88acf5c063c6b68cd23077cc
|
data/README.md
CHANGED
@@ -6,26 +6,24 @@ class ProductiveGenerator < Rails::Generators::Base
|
|
6
6
|
argument :api_key, required: true, desc: 'required'
|
7
7
|
argument :account_id, required: true, desc: 'required'
|
8
8
|
|
9
|
-
gem 'productive'
|
10
|
-
|
11
9
|
desc 'Configure Productive API client'
|
12
10
|
|
13
11
|
def create_initializer_file
|
14
|
-
|
12
|
+
if /^[a-f0-9\-]{36}$/ !~ api_key
|
15
13
|
raise Thor::Error, "Invalid Productive API key #{api_key.inspect}\nYou can find the API key on the Settings -> Security page of https://productive.io"
|
16
14
|
end
|
17
15
|
|
18
|
-
|
16
|
+
if /^[0-9]*$/ !~ account_id
|
19
17
|
raise Thor::Error, "Invalid Productive Account ID #{account_id.inspect}\n"
|
20
18
|
end
|
21
19
|
|
22
20
|
initializer 'productive.rb' do
|
23
|
-
<<-
|
24
|
-
Productive.configure do |config|
|
25
|
-
|
26
|
-
|
27
|
-
end
|
28
|
-
|
21
|
+
<<-CONFIG.strip_heredoc
|
22
|
+
Productive.configure do |config|
|
23
|
+
config.api_key = #{api_key.inspect}
|
24
|
+
config.account_id = #{account_id.inspect}
|
25
|
+
end
|
26
|
+
CONFIG
|
29
27
|
end
|
30
28
|
end
|
31
29
|
end
|
data/lib/json_api_paginator.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rack'
|
2
|
+
|
1
3
|
class JsonApiPaginator
|
2
4
|
attr_reader :params, :result_set, :links, :meta
|
3
5
|
|
@@ -28,7 +30,7 @@ class JsonApiPaginator
|
|
28
30
|
if links['last']
|
29
31
|
uri = result_set.links.link_url_for('last')
|
30
32
|
last_params = params_for_uri(uri)
|
31
|
-
last_params['page[number
|
33
|
+
last_params['page']['number'].to_i
|
32
34
|
else
|
33
35
|
current_page
|
34
36
|
end
|
@@ -40,11 +42,11 @@ class JsonApiPaginator
|
|
40
42
|
alias_method :total_count, :total_entries
|
41
43
|
|
42
44
|
def per_page
|
43
|
-
params['page[size
|
45
|
+
params['page']['size'].to_i
|
44
46
|
end
|
45
47
|
|
46
48
|
def current_page
|
47
|
-
(params['page[number
|
49
|
+
(params['page']['number'] || 1).to_i
|
48
50
|
end
|
49
51
|
|
50
52
|
def previous_page
|
@@ -59,6 +61,6 @@ class JsonApiPaginator
|
|
59
61
|
def params_for_uri(uri)
|
60
62
|
return {} unless uri
|
61
63
|
uri = Addressable::URI.parse(uri)
|
62
|
-
uri.
|
64
|
+
Rack::Utils.parse_nested_query(uri.query || '')
|
63
65
|
end
|
64
66
|
end
|
@@ -8,8 +8,8 @@ module Productive
|
|
8
8
|
attr_accessor :paginator
|
9
9
|
|
10
10
|
def initialize
|
11
|
-
self.api_key = ENV
|
12
|
-
self.account_id =
|
11
|
+
self.api_key = ENV.fetch('PRODUCTIVE_API_KEY')
|
12
|
+
self.account_id = ENV.fetch('PRODUCTIVE_ACCOUNT_ID')
|
13
13
|
self.base_url = 'https://productive.io/api/v2/'
|
14
14
|
self.paginator = JsonApiPaginator
|
15
15
|
end
|
data/lib/productive/railtie.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module Productive
|
2
2
|
class Base < JsonApiClient::Resource
|
3
|
-
def self.setup
|
4
|
-
config = Productive.configuration
|
3
|
+
def self.setup(config)
|
5
4
|
self.site = File.join config.base_url, config.account_id.to_s, '/'
|
6
5
|
self.connection_options = {headers: {'X-Auth-Token' => config.api_key}}
|
7
6
|
self.paginator = config.paginator
|
data/lib/productive/version.rb
CHANGED
data/productive.gemspec
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: productive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
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: 2016-08-
|
11
|
+
date: 2016-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rack
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: json_api_client
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|