productive 0.2.0 → 0.3.0

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: d6bbda2ba26520dea3d18c61ee5dad955d1cff23
4
- data.tar.gz: c548d9825ab20b7b2c4add3abc57a697a418841b
3
+ metadata.gz: ade904ec45d6bfd889ad1aa9e8a86d26da920710
4
+ data.tar.gz: 1a0b17811c30f76bf2f9ad43721ceb7a0c0ab0bc
5
5
  SHA512:
6
- metadata.gz: c92f9cad758a6f5d0287edd37b72515ec8d7dfd0b127ada6f5193b0ae4d31772aa38c3d23507c9a99084b68a94f6393a1cab985101ebfd83c5ec8de04acf852e
7
- data.tar.gz: 8e61f057da799703f68bd46c4f9074f6158f9482b1e07d8b4aa6f28efef8f77b0ba0eebaf7d881d2c7e0b4969c4edff6b8f139cad85eda940f1e08415fb54c38
6
+ metadata.gz: 3b479c35c2deeee84f71ce9d43abc3deac70e8d25c6607dd2650d4aaf96e7719492db4e96d7cca0aee5a4b7928ce08352b4abe6e62ec62c0e01cfa12fa3da232
7
+ data.tar.gz: e71849e848d371f765f0794d2cdafe3757ee6f5552ce91a7f5484481d46c0d9f835cde1254d150111593013d70721991b0cb48dc88acf5c063c6b68cd23077cc
data/README.md CHANGED
@@ -29,7 +29,7 @@ Productive.configure do |config|
29
29
  config.account_id = ACCOUNT_ID
30
30
  end
31
31
 
32
- Productive::Base.setup
32
+ Productive::Base.setup(Productive.configuration)
33
33
  ```
34
34
 
35
35
  ## Usage
@@ -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
- unless /^[a-f0-9\-]{36}$/ =~ api_key
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
- unless /^[0-9]*$/ =~ account_id
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
- <<-EOF
24
- Productive.configure do |config|
25
- config.api_key = #{api_key.inspect}
26
- config.account_id = #{account_id.inspect}
27
- end
28
- EOF
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
@@ -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]'].to_i
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]'].to_i
45
+ params['page']['size'].to_i
44
46
  end
45
47
 
46
48
  def current_page
47
- (params['page[number]'] || 1).to_i
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.query_values || {}
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['PRODUCTIVE_API_KEY']
12
- self.account_id = nil
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
@@ -3,7 +3,7 @@ require 'rails'
3
3
  module Productive
4
4
  class Railtie < Rails::Railtie
5
5
  config.after_initialize do
6
- Productive::Base.setup
6
+ Productive::Base.setup(Productive.configuration)
7
7
  end
8
8
  end
9
9
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Productive
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
data/productive.gemspec CHANGED
@@ -13,5 +13,6 @@ Gem::Specification.new do |s|
13
13
  s.license = 'MIT'
14
14
  s.files = `git ls-files`.split("\n")
15
15
 
16
+ s.add_dependency 'rack'
16
17
  s.add_dependency 'json_api_client'
17
18
  end
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.2.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-03 00:00:00.000000000 Z
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