traitify 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -3
- data/Gemfile.lock +25 -9
- data/README.md +44 -0
- data/lib/traitify/client/connection.rb +9 -6
- data/lib/traitify/client/request.rb +9 -2
- data/lib/traitify/configuration.rb +3 -1
- data/lib/traitify/version.rb +1 -1
- data/lib/traitify.rb +2 -2
- data/spec/spec_helper.rb +1 -0
- data/spec/support/mocks/aggregate.json +7 -0
- data/spec/traitify/client/examples/analytics_spec.rb +16 -0
- data/spec/traitify/client/examples/configuration_spec.rb +5 -5
- data/spec/traitify/client/examples/retry_spec.rb +60 -0
- data/traitify.gemspec +3 -1
- metadata +35 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9a2fc61b25125bd280cbe82b3c1c0eb5562aca678c09a1852384c221b9cd51f
|
4
|
+
data.tar.gz: 3c4f1593e2ff811e884fd82855e4076c80e720a9da3682fe098747eca200ad05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1912577c0370b0a9aa817cb13ea1c34b865a61532a3648359e58e7a1117bf87b89bc5c016b899db554d70c74a3c0b9038e1f70d586af01021ce6e916d9d043a6
|
7
|
+
data.tar.gz: 72a6ba2691c93b0acb9eb318e52e3389a8b769c4860c09b6de8cf804b9ff63f128e0ea2b8e7c65c7044628d366ccf3c5db5c9493c92bb484642f9e114c51563e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
### 2.1.0
|
2
|
+
|
3
|
+
* Features
|
4
|
+
* Added automatic retries
|
5
|
+
|
6
|
+
### 2.0.1
|
7
|
+
|
8
|
+
* Bug Fixes
|
9
|
+
* Fixed an issue with nested params
|
10
|
+
|
11
|
+
### 2.0.0
|
12
|
+
|
13
|
+
* Features
|
14
|
+
* Refactored everything
|
15
|
+
* Added dynamic system to build a request
|
16
|
+
* Added overrides for specific resources
|
17
|
+
* Added dynamic system to interact with a response
|
18
|
+
|
19
|
+
* Breaking Changes
|
20
|
+
* Removed custom methods for resources
|
21
|
+
|
1
22
|
### 1.9.0
|
2
23
|
|
3
24
|
* Features
|
@@ -81,6 +102,3 @@
|
|
81
102
|
* Get/Create Assessments
|
82
103
|
* Get/Update Slides
|
83
104
|
* Get Personality Blend, Types, and Traits
|
84
|
-
|
85
|
-
[@cpreisinger]:https://github.com/cpreisinger
|
86
|
-
[@tomprats]:https://github.com/tomprats
|
data/Gemfile.lock
CHANGED
@@ -1,40 +1,55 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
traitify (2.
|
4
|
+
traitify (2.1.0)
|
5
5
|
activesupport (>= 5.1, < 8.x)
|
6
6
|
faraday (~> 2.5)
|
7
7
|
faraday-net_http (~> 3.0)
|
8
|
+
faraday-retry (~> 2.2)
|
8
9
|
|
9
10
|
GEM
|
10
11
|
remote: https://rubygems.org/
|
11
12
|
specs:
|
12
|
-
activesupport (7.
|
13
|
+
activesupport (7.1.2)
|
14
|
+
base64
|
15
|
+
bigdecimal
|
13
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
+
connection_pool (>= 2.2.5)
|
18
|
+
drb
|
14
19
|
i18n (>= 1.6, < 2)
|
15
20
|
minitest (>= 5.1)
|
21
|
+
mutex_m
|
16
22
|
tzinfo (~> 2.0)
|
17
23
|
addressable (2.8.1)
|
18
24
|
public_suffix (>= 2.0.2, < 6.0)
|
19
25
|
ast (2.4.2)
|
26
|
+
base64 (0.2.0)
|
27
|
+
bigdecimal (3.1.5)
|
20
28
|
binding_of_caller (1.0.0)
|
21
29
|
debug_inspector (>= 0.0.1)
|
22
30
|
coderay (1.1.3)
|
23
|
-
concurrent-ruby (1.
|
31
|
+
concurrent-ruby (1.2.2)
|
32
|
+
connection_pool (2.4.1)
|
24
33
|
crack (0.4.5)
|
25
34
|
rexml
|
26
35
|
debug_inspector (1.1.0)
|
27
36
|
diff-lcs (1.5.0)
|
28
37
|
docile (1.4.0)
|
29
|
-
|
38
|
+
drb (2.2.0)
|
39
|
+
ruby2_keywords
|
40
|
+
faraday (2.8.1)
|
41
|
+
base64
|
30
42
|
faraday-net_http (>= 2.0, < 3.1)
|
31
43
|
ruby2_keywords (>= 0.0.4)
|
32
|
-
faraday-net_http (3.0.
|
44
|
+
faraday-net_http (3.0.2)
|
45
|
+
faraday-retry (2.2.0)
|
46
|
+
faraday (~> 2.0)
|
33
47
|
hashdiff (1.0.1)
|
34
|
-
i18n (1.
|
48
|
+
i18n (1.14.1)
|
35
49
|
concurrent-ruby (~> 1.0)
|
36
50
|
method_source (1.0.0)
|
37
|
-
minitest (5.
|
51
|
+
minitest (5.20.0)
|
52
|
+
mutex_m (0.2.0)
|
38
53
|
parallel (1.22.1)
|
39
54
|
parser (3.1.2.1)
|
40
55
|
ast (~> 2.4.1)
|
@@ -42,7 +57,7 @@ GEM
|
|
42
57
|
coderay (~> 1.1)
|
43
58
|
method_source (~> 1.0)
|
44
59
|
public_suffix (5.0.0)
|
45
|
-
rack (
|
60
|
+
rack (3.0.7)
|
46
61
|
rainbow (3.1.1)
|
47
62
|
rake (13.0.6)
|
48
63
|
regexp_parser (2.5.0)
|
@@ -96,7 +111,7 @@ GEM
|
|
96
111
|
simplecov_json_formatter (~> 0.1)
|
97
112
|
simplecov-html (0.12.3)
|
98
113
|
simplecov_json_formatter (0.1.4)
|
99
|
-
tzinfo (2.0.
|
114
|
+
tzinfo (2.0.6)
|
100
115
|
concurrent-ruby (~> 1.0)
|
101
116
|
unicode-display_width (1.8.0)
|
102
117
|
webmock (3.18.1)
|
@@ -107,6 +122,7 @@ GEM
|
|
107
122
|
PLATFORMS
|
108
123
|
arm64-darwin-20
|
109
124
|
arm64-darwin-21
|
125
|
+
x86_64-linux
|
110
126
|
|
111
127
|
DEPENDENCIES
|
112
128
|
binding_of_caller (~> 1.0)
|
data/README.md
CHANGED
@@ -47,6 +47,50 @@ All the configuration options can be found in `lib/traitify/configuration.rb`
|
|
47
47
|
)
|
48
48
|
traitify.assessments.create
|
49
49
|
|
50
|
+
### Auto Retry
|
51
|
+
|
52
|
+
Requests that fail can be automatically retried.
|
53
|
+
|
54
|
+
#### Retry Configuration
|
55
|
+
|
56
|
+
Retrying can be configured in multiple ways.
|
57
|
+
|
58
|
+
Through the general config:
|
59
|
+
|
60
|
+
Traitify.configure do |traitify|
|
61
|
+
traitify.auto_retry = true
|
62
|
+
traitify.retry_options = retry_options
|
63
|
+
end
|
64
|
+
|
65
|
+
traitify = Traitify.new
|
66
|
+
assessment = traitify.assessments("assessment-uuid").data
|
67
|
+
|
68
|
+
On a specific request:
|
69
|
+
|
70
|
+
traitify = Traitify.new
|
71
|
+
assessment = traitify.retriable(retry_options).assessments("assessment-uuid").data
|
72
|
+
|
73
|
+
Or with both:
|
74
|
+
|
75
|
+
Traitify.configure do |traitify|
|
76
|
+
traitify.auto_retry = false
|
77
|
+
traitify.retry_options = retry_options
|
78
|
+
end
|
79
|
+
|
80
|
+
traitify = Traitify.new
|
81
|
+
assessment = traitify.retriable.assessments("assessment-uuid").data
|
82
|
+
|
83
|
+
This allows fine tuned control when and what to retry.
|
84
|
+
|
85
|
+
#### Retry Options
|
86
|
+
|
87
|
+
The options are passed to the [Faraday Retry](https://github.com/lostisland/faraday-retry) middleware. Supported options can be found in their documentation.
|
88
|
+
|
89
|
+
retry_options = {
|
90
|
+
methods: [:get, :post],
|
91
|
+
retry_statuses: [429, 500]
|
92
|
+
}
|
93
|
+
|
50
94
|
### Decks
|
51
95
|
|
52
96
|
#### Getting all the decks:
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "faraday"
|
2
2
|
require "faraday/net_http"
|
3
|
+
require "faraday/retry"
|
3
4
|
require "traitify/middleware/formatter"
|
4
5
|
require "traitify/middleware/raise_error"
|
5
6
|
|
@@ -8,13 +9,15 @@ module Traitify
|
|
8
9
|
module Connection
|
9
10
|
def connection(options = {})
|
10
11
|
Faraday.new(options) do |faraday|
|
11
|
-
faraday.request
|
12
|
-
faraday.request
|
12
|
+
faraday.request(:authorization, :basic, secret_key || public_key, "x")
|
13
|
+
faraday.request(:json)
|
14
|
+
faraday.request(:retry, retry_options) if auto_retry
|
13
15
|
faraday.headers["Accept"] = "application/json"
|
14
|
-
faraday.
|
15
|
-
faraday.response :
|
16
|
-
faraday.response
|
17
|
-
faraday.
|
16
|
+
faraday.options.params_encoder = Faraday::FlatParamsEncoder
|
17
|
+
faraday.response(:logger, Traitify.logger, formatter: Traitify::Middleware::Formatter)
|
18
|
+
faraday.response(:raise_traitify_error)
|
19
|
+
faraday.response(:json)
|
20
|
+
faraday.adapter(:net_http)
|
18
21
|
end
|
19
22
|
end
|
20
23
|
end
|
@@ -7,13 +7,20 @@ module Traitify
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
+
def data
|
11
|
+
@data ||= request.data
|
12
|
+
end
|
13
|
+
|
10
14
|
def request
|
11
15
|
@request = Traitify::Response.new(base_request)
|
12
16
|
end
|
13
17
|
alias_method :fetch, :request
|
14
18
|
|
15
|
-
def
|
16
|
-
|
19
|
+
def retriable(**options)
|
20
|
+
copy.tap do |client|
|
21
|
+
client.auto_retry = true
|
22
|
+
client.retry_options = options unless options.blank?
|
23
|
+
end
|
17
24
|
end
|
18
25
|
|
19
26
|
private
|
data/lib/traitify/version.rb
CHANGED
data/lib/traitify.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "active_support"
|
2
|
+
require "active_support/core_ext/object/deep_dup"
|
1
3
|
require "traitify/configuration"
|
2
4
|
require "traitify/client"
|
3
5
|
require "traitify/data"
|
@@ -5,8 +7,6 @@ require "traitify/error"
|
|
5
7
|
require "traitify/response"
|
6
8
|
require "traitify/version"
|
7
9
|
require "logger"
|
8
|
-
require "active_support"
|
9
|
-
require "active_support/core_ext/object/deep_dup"
|
10
10
|
|
11
11
|
module Traitify
|
12
12
|
extend Configuration
|
data/spec/spec_helper.rb
CHANGED
@@ -14,6 +14,22 @@ describe Traitify::Client do
|
|
14
14
|
let(:client){ Traitify.new }
|
15
15
|
|
16
16
|
describe ".analytics" do
|
17
|
+
context ".aggregate" do
|
18
|
+
let(:data){
|
19
|
+
client.analytics.decks("big-five")
|
20
|
+
.aggregate(stats: [:created_count, :started_count, :completed_count]).data
|
21
|
+
}
|
22
|
+
|
23
|
+
before(:each) do
|
24
|
+
query = "locale_key=en-us&stats=created_count&stats=started_count&stats=completed_count"
|
25
|
+
stub_it(:get, "/analytics/decks/big-five/aggregate?#{query}", "aggregate")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns assessments" do
|
29
|
+
expect(data.assessments.started_count).to eq(10)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
17
33
|
context ".assessments" do
|
18
34
|
let(:assessments){ client.analytics.decks("deck-id").assessments.data }
|
19
35
|
|
@@ -14,15 +14,15 @@ describe Traitify::Client do
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
it "assigns
|
18
|
-
expect(traitify.
|
17
|
+
it "assigns host" do
|
18
|
+
expect(traitify.host).to eq("https://example.com")
|
19
19
|
end
|
20
20
|
|
21
|
-
it "assigns
|
22
|
-
expect(traitify.
|
21
|
+
it "assigns secret" do
|
22
|
+
expect(traitify.secret_key).to eq("secret")
|
23
23
|
end
|
24
24
|
|
25
|
-
it "assigns
|
25
|
+
it "assigns version" do
|
26
26
|
expect(traitify.version).to eq("v1")
|
27
27
|
end
|
28
28
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Traitify::Client do
|
4
|
+
before do
|
5
|
+
Traitify.configure do |client|
|
6
|
+
client.secret_key = "secret"
|
7
|
+
client.host = "https://example.com"
|
8
|
+
client.version = "v1"
|
9
|
+
client.deck_id = "deck-uuid"
|
10
|
+
client.logger = Logger.new("/dev/null")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:client){ Traitify.new(auto_retry: false) }
|
15
|
+
|
16
|
+
describe ".auto_retry" do
|
17
|
+
it "is set to true" do
|
18
|
+
client = Traitify.new(auto_retry: true)
|
19
|
+
|
20
|
+
expect(client.auto_retry).to eq(true)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "is set to false" do
|
24
|
+
expect(client.auto_retry).to eq(false)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe ".retriable" do
|
29
|
+
it "sets auto_retry" do
|
30
|
+
expect(client.retriable.auto_retry).to eq(true)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "sets retry_options" do
|
34
|
+
expect(client.retriable(retry_statuses: [500]).retry_options).to match(
|
35
|
+
retry_statuses: [500]
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "uses existing retry_options" do
|
40
|
+
client = Traitify.new(retry_options: {retry_statuses: [500]})
|
41
|
+
|
42
|
+
expect(client.retriable.retry_options).to match(
|
43
|
+
retry_statuses: [500]
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "is retriable when extended" do
|
48
|
+
expect(client.retriable.profiles.auto_retry).to eq(true)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "is retriable when nested" do
|
52
|
+
expect(client.profiles.retriable.auto_retry).to eq(true)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "doesn't leak" do
|
56
|
+
expect(client.retriable.auto_retry).to eq(true)
|
57
|
+
expect(client.profiles.auto_retry).to eq(false)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/traitify.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.summary = "Traitify Gem"
|
11
11
|
spec.description = "Traitify is a ruby gem wrapper for the Traitify API"
|
12
12
|
spec.authors = ["Tom Prats", "Eric Fleming", "Carson Wright"]
|
13
|
-
spec.email = "tom@
|
13
|
+
spec.email = "tom.prats@paradox.ai"
|
14
14
|
spec.homepage = "https://www.traitify.com"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
@@ -21,12 +21,14 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_runtime_dependency "activesupport", ">= 5.1", "< 8.x"
|
22
22
|
spec.add_runtime_dependency "faraday", "~> 2.5"
|
23
23
|
spec.add_runtime_dependency "faraday-net_http", "~> 3.0"
|
24
|
+
spec.add_runtime_dependency "faraday-retry", "~> 2.2"
|
24
25
|
|
25
26
|
spec.add_development_dependency "binding_of_caller", "~> 1.0"
|
26
27
|
spec.add_development_dependency "bundler", "~> 2.2"
|
27
28
|
spec.add_development_dependency "pry", "~> 0.14"
|
28
29
|
spec.add_development_dependency "rake", "~> 13.0"
|
29
30
|
spec.add_development_dependency "rspec", "~> 3.11"
|
31
|
+
spec.add_development_dependency "rubocop-traitify", "~> 1.10"
|
30
32
|
spec.add_development_dependency "simplecov", "~> 0.21.2"
|
31
33
|
spec.add_development_dependency "webmock", "~> 3.18"
|
32
34
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: traitify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Prats
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2024-01-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -60,6 +60,20 @@ dependencies:
|
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '3.0'
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: faraday-retry
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '2.2'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '2.2'
|
63
77
|
- !ruby/object:Gem::Dependency
|
64
78
|
name: binding_of_caller
|
65
79
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,6 +144,20 @@ dependencies:
|
|
130
144
|
- - "~>"
|
131
145
|
- !ruby/object:Gem::Version
|
132
146
|
version: '3.11'
|
147
|
+
- !ruby/object:Gem::Dependency
|
148
|
+
name: rubocop-traitify
|
149
|
+
requirement: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '1.10'
|
154
|
+
type: :development
|
155
|
+
prerelease: false
|
156
|
+
version_requirements: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - "~>"
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '1.10'
|
133
161
|
- !ruby/object:Gem::Dependency
|
134
162
|
name: simplecov
|
135
163
|
requirement: !ruby/object:Gem::Requirement
|
@@ -159,7 +187,7 @@ dependencies:
|
|
159
187
|
- !ruby/object:Gem::Version
|
160
188
|
version: '3.18'
|
161
189
|
description: Traitify is a ruby gem wrapper for the Traitify API
|
162
|
-
email: tom@
|
190
|
+
email: tom.prats@paradox.ai
|
163
191
|
executables: []
|
164
192
|
extensions: []
|
165
193
|
extra_rdoc_files: []
|
@@ -187,6 +215,7 @@ files:
|
|
187
215
|
- lib/traitify/version.rb
|
188
216
|
- paths.yml
|
189
217
|
- spec/spec_helper.rb
|
218
|
+
- spec/support/mocks/aggregate.json
|
190
219
|
- spec/support/mocks/assessment.json
|
191
220
|
- spec/support/mocks/assessment_analytics.json
|
192
221
|
- spec/support/mocks/assessment_with_results.json
|
@@ -216,6 +245,7 @@ files:
|
|
216
245
|
- spec/traitify/client/examples/major_spec.rb
|
217
246
|
- spec/traitify/client/examples/profiles_spec.rb
|
218
247
|
- spec/traitify/client/examples/result_spec.rb
|
248
|
+
- spec/traitify/client/examples/retry_spec.rb
|
219
249
|
- spec/traitify/client/examples/slide_spec.rb
|
220
250
|
- spec/traitify/client/model_spec.rb
|
221
251
|
- spec/traitify/client/request_spec.rb
|
@@ -251,6 +281,7 @@ specification_version: 4
|
|
251
281
|
summary: Traitify Gem
|
252
282
|
test_files:
|
253
283
|
- spec/spec_helper.rb
|
284
|
+
- spec/support/mocks/aggregate.json
|
254
285
|
- spec/support/mocks/assessment.json
|
255
286
|
- spec/support/mocks/assessment_analytics.json
|
256
287
|
- spec/support/mocks/assessment_with_results.json
|
@@ -280,6 +311,7 @@ test_files:
|
|
280
311
|
- spec/traitify/client/examples/major_spec.rb
|
281
312
|
- spec/traitify/client/examples/profiles_spec.rb
|
282
313
|
- spec/traitify/client/examples/result_spec.rb
|
314
|
+
- spec/traitify/client/examples/retry_spec.rb
|
283
315
|
- spec/traitify/client/examples/slide_spec.rb
|
284
316
|
- spec/traitify/client/model_spec.rb
|
285
317
|
- spec/traitify/client/request_spec.rb
|