workable 2.0.0rc1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -3
- data/CHANGELOG.md +6 -0
- data/Gemfile +0 -4
- data/README.md +1 -1
- data/lib/workable/client.rb +10 -8
- data/lib/workable/collection.rb +4 -4
- data/lib/workable/errors.rb +6 -6
- data/lib/workable/version.rb +1 -1
- data/spec/lib/workable/collection_spec.rb +13 -2
- data/workable.gemspec +2 -2
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1918a3c5a23e3c42973eed949f0b0cc3ba83c613
|
4
|
+
data.tar.gz: 307220a59d69533df3446a11c216f72a8748be8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fd937d0071f53b9c2df9735cd376d774abe397d2565ee0a12e13cb89c2b0fbeb77e7d2f802e83be0aa69d25bcc775ca964df002982f697b2e538ed99f8288f6
|
7
|
+
data.tar.gz: 80671b951b7f0a01bb0c00fd5bff54fa2e209358c4dbeb2b6ea06ea0946829ba63cdebc3319d56a1bf2daa2016133befdfc53b1d58d6caaae936e5dd0dad12e7
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
[![Gem Version](https://badge.fury.io/rb/workable.svg)](http://badge.fury.io/rb/workable)
|
7
7
|
[![Dependency Status](https://gemnasium.com/emq/workable.svg)](https://gemnasium.com/emq/workable)
|
8
8
|
|
9
|
-
Dead-simple Ruby API client for [workable.com][1]. No extra runtime dependencies.
|
9
|
+
Dead-simple Ruby API client for [workable.com][1]. No extra runtime dependencies.
|
10
10
|
|
11
11
|
Uses v3 API provided by workable.
|
12
12
|
|
data/lib/workable/client.rb
CHANGED
@@ -133,7 +133,7 @@ module Workable
|
|
133
133
|
|
134
134
|
# build the url to api
|
135
135
|
def api_url
|
136
|
-
'https://www.workable.com/spi/v%s/accounts/%s' % [Workable::API_VERSION, subdomain]
|
136
|
+
@_api_url ||= 'https://www.workable.com/spi/v%s/accounts/%s' % [Workable::API_VERSION, subdomain]
|
137
137
|
end
|
138
138
|
|
139
139
|
# do the get request to api
|
@@ -157,7 +157,9 @@ module Workable
|
|
157
157
|
http.use_ssl = true
|
158
158
|
|
159
159
|
request = type.new(uri.request_uri, headers)
|
160
|
+
|
160
161
|
yield request if block_given?
|
162
|
+
|
161
163
|
response = http.request(request)
|
162
164
|
|
163
165
|
parse!(response)
|
@@ -166,9 +168,9 @@ module Workable
|
|
166
168
|
# parse the api response
|
167
169
|
def parse!(response)
|
168
170
|
case response.code.to_i
|
169
|
-
when 204, 205
|
171
|
+
when 204, 205
|
170
172
|
nil
|
171
|
-
when 200...300
|
173
|
+
when 200...300
|
172
174
|
JSON.parse(response.body)
|
173
175
|
when 401
|
174
176
|
fail Errors::NotAuthorized, JSON.parse(response.body)['error']
|
@@ -217,11 +219,11 @@ module Workable
|
|
217
219
|
response = get_request(url, params)
|
218
220
|
|
219
221
|
Collection.new(
|
220
|
-
@transform_to.apply(transform_mapping, response[root_key]),
|
221
|
-
method(__callee__),
|
222
|
-
transform_mapping,
|
223
|
-
root_key,
|
224
|
-
response['paging'])
|
222
|
+
data: @transform_to.apply(transform_mapping, response[root_key]),
|
223
|
+
next_page_method: method(__callee__),
|
224
|
+
transform_mapping: transform_mapping,
|
225
|
+
root_key: root_key,
|
226
|
+
paging: response['paging'])
|
225
227
|
end
|
226
228
|
|
227
229
|
def configuration_error(message)
|
data/lib/workable/collection.rb
CHANGED
@@ -5,14 +5,14 @@ module Workable
|
|
5
5
|
|
6
6
|
attr_reader :data
|
7
7
|
|
8
|
-
def initialize(data
|
8
|
+
def initialize(data:, next_page_method:, transform_mapping:, root_key:, paging: nil)
|
9
9
|
@data = data
|
10
10
|
|
11
11
|
if paging
|
12
|
-
@next_page
|
13
|
-
@next_page_method
|
12
|
+
@next_page = paging['next']
|
13
|
+
@next_page_method = next_page_method
|
14
14
|
@transform_mapping = transform_mapping
|
15
|
-
@root_key
|
15
|
+
@root_key = root_key
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
data/lib/workable/errors.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module Workable
|
2
2
|
module Errors
|
3
|
-
class WorkableError
|
3
|
+
class WorkableError < StandardError; end
|
4
4
|
class InvalidConfiguration < WorkableError; end
|
5
|
-
class NotAuthorized
|
6
|
-
class InvalidResponse
|
7
|
-
class NotFound
|
8
|
-
class AlreadyExists
|
9
|
-
class RequestToLong
|
5
|
+
class NotAuthorized < WorkableError; end
|
6
|
+
class InvalidResponse < WorkableError; end
|
7
|
+
class NotFound < WorkableError; end
|
8
|
+
class AlreadyExists < WorkableError; end
|
9
|
+
class RequestToLong < WorkableError; end
|
10
10
|
end
|
11
11
|
end
|
data/lib/workable/version.rb
CHANGED
@@ -2,7 +2,12 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Workable::Collection do
|
4
4
|
describe 'delegation' do
|
5
|
-
let(:collection){ described_class.new(
|
5
|
+
let(:collection){ described_class.new(
|
6
|
+
data: [1, 2, 3],
|
7
|
+
next_page_method: double,
|
8
|
+
transform_mapping: :job,
|
9
|
+
root_key: 'jobs')
|
10
|
+
}
|
6
11
|
|
7
12
|
it 'delegates size to `data`' do
|
8
13
|
expect(collection.size).to eq(3)
|
@@ -27,7 +32,13 @@ describe Workable::Collection do
|
|
27
32
|
|
28
33
|
describe '#fetch_next_page' do
|
29
34
|
let(:next_method){ double }
|
30
|
-
let(:collection){ described_class.new(
|
35
|
+
let(:collection){ described_class.new(
|
36
|
+
data: [],
|
37
|
+
next_page_method: next_method,
|
38
|
+
transform_mapping: :job,
|
39
|
+
root_key: 'jobs',
|
40
|
+
paging: paging)
|
41
|
+
}
|
31
42
|
|
32
43
|
context 'when next page is available' do
|
33
44
|
let(:paging){ { 'next' => 'http://example.com?limit=2&since_id=3' } }
|
data/workable.gemspec
CHANGED
@@ -17,12 +17,12 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ['lib']
|
19
19
|
|
20
|
-
spec.required_ruby_version = '>= 1.
|
20
|
+
spec.required_ruby_version = '>= 2.1.0'
|
21
21
|
|
22
22
|
spec.add_development_dependency 'rake', '~> 10.0'
|
23
23
|
spec.add_development_dependency 'rspec', '~> 3.1.0'
|
24
24
|
spec.add_development_dependency 'webmock', '~> 1.20.4'
|
25
|
-
spec.add_development_dependency 'coveralls', '~> 0.
|
25
|
+
spec.add_development_dependency 'coveralls', '~> 0.8.9'
|
26
26
|
spec.add_development_dependency 'guard', '~> 2.12'
|
27
27
|
spec.add_development_dependency 'guard-rspec', '~> 4.5'
|
28
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: workable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafał Wojsznis
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-11-
|
12
|
+
date: 2015-11-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -59,14 +59,14 @@ dependencies:
|
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: 0.
|
62
|
+
version: 0.8.9
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0.
|
69
|
+
version: 0.8.9
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: guard
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -147,12 +147,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
147
147
|
requirements:
|
148
148
|
- - ">="
|
149
149
|
- !ruby/object:Gem::Version
|
150
|
-
version: 1.
|
150
|
+
version: 2.1.0
|
151
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
152
|
requirements:
|
153
|
-
- - "
|
153
|
+
- - ">="
|
154
154
|
- !ruby/object:Gem::Version
|
155
|
-
version:
|
155
|
+
version: '0'
|
156
156
|
requirements: []
|
157
157
|
rubyforge_project:
|
158
158
|
rubygems_version: 2.4.6
|