survey-gizmo-ruby 6.2.13 → 6.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 +4 -4
- data/CHANGELOG.md +5 -1
- data/README.md +5 -3
- data/lib/survey_gizmo/configuration.rb +35 -8
- data/lib/survey_gizmo/connection.rb +4 -22
- data/lib/survey_gizmo/logger.rb +1 -1
- data/lib/survey_gizmo/version.rb +1 -1
- data/spec/logger_spec.rb +25 -24
- data/spec/spec_helper.rb +1 -4
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e99c0f495a8bbdda92408e8392e5d5b1d5b45458
|
4
|
+
data.tar.gz: af1e998bae5ba6ec339bf5deee9c62d55bfacdab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 212d6dbff7ed1156c1ede83363ed6be79c33170eecfc5bef38437db5909d1429e6267206e2c0c2b832661ef2b2ca0773ebc05193e3d7d33c37e1609b28a4c664
|
7
|
+
data.tar.gz: 8ff36651178e6576aa23ff43ef67fa1cd01595d3b34fc6fb83b3d544fafc3df56bab1d4e0046f2afbc8657de6cfe2ae799b0f8aadee40ba79ad221187d42f410
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
# Versions
|
2
2
|
|
3
|
+
## 6.3.0
|
4
|
+
* Deprecate `retry_attempts` and `retry_interval` configuration options
|
5
|
+
* Add ability to set the entire `Retriable` hash directly by configuring `retriable_params`
|
6
|
+
|
3
7
|
## 6.2.13
|
4
|
-
* max_elapsed_time of 1 hour for
|
8
|
+
* max_elapsed_time of 1 hour for `Retriable`
|
5
9
|
|
6
10
|
## 6.2.12
|
7
11
|
* Bugfix: Don't allow option_ids of 0
|
data/README.md
CHANGED
@@ -38,12 +38,14 @@ SurveyGizmo.configure do |config|
|
|
38
38
|
# Optional - Defaults to 300 seconds
|
39
39
|
config.timeout_seconds = 600
|
40
40
|
|
41
|
-
# Optional -
|
42
|
-
config.
|
43
|
-
config.retry_interval = 60
|
41
|
+
# Optional - Configure arguments to the Retriable gem directly that will be merged into the defaults
|
42
|
+
config.retriable_params = { tries: 30, max_elapsed_time: 3600 }
|
44
43
|
end
|
45
44
|
```
|
46
45
|
|
46
|
+
Check the [Retriable](https://github.com/kamui/retriable) documentation for how to configure the `retriable_params` hash.
|
47
|
+
The default is to retry 3 times, with 60 seconds before the first retry and a slow exponential backoff after that.
|
48
|
+
|
47
49
|
`api_token` and `api_token_secret` can be read from environment variables, in which case you would set them like this:
|
48
50
|
|
49
51
|
```bash
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'survey_gizmo/faraday_middleware/parse_survey_gizmo'
|
2
|
+
|
1
3
|
module SurveyGizmo
|
2
4
|
class << self
|
3
5
|
attr_writer :configuration
|
@@ -10,6 +12,18 @@ module SurveyGizmo
|
|
10
12
|
def configure
|
11
13
|
reset!
|
12
14
|
yield(@configuration) if block_given?
|
15
|
+
|
16
|
+
if @configuration.retry_attempts
|
17
|
+
@configuration.logger.warn('Configuring retry_attempts is deprecated; pass a retriable_params hash instead.')
|
18
|
+
@configuration.retriable_params[:tries] = @configuration.retry_attempts + 1
|
19
|
+
end
|
20
|
+
|
21
|
+
if @configuration.retry_interval
|
22
|
+
@configuration.logger.warn('Configuring retry_interval is deprecated; pass a retriable_params hash instead.')
|
23
|
+
@configuration.retriable_params[:base_interval] = @configuration.retry_interval
|
24
|
+
end
|
25
|
+
|
26
|
+
@configuration.retriable_params = Configuration::DEFAULT_RETRIABLE_PARAMS.merge(@configuration.retriable_params)
|
13
27
|
end
|
14
28
|
|
15
29
|
def reset!
|
@@ -22,8 +36,6 @@ module SurveyGizmo
|
|
22
36
|
DEFAULT_API_VERSION = 'v4'
|
23
37
|
DEFAULT_RESULTS_PER_PAGE = 50
|
24
38
|
DEFAULT_TIMEOUT_SECONDS = 300
|
25
|
-
DEFAULT_RETRIES = 3
|
26
|
-
DEFAULT_RETRY_INTERVAL = 60
|
27
39
|
DEFAULT_REGION = :us
|
28
40
|
|
29
41
|
REGION_INFO = {
|
@@ -37,6 +49,23 @@ module SurveyGizmo
|
|
37
49
|
}
|
38
50
|
}
|
39
51
|
|
52
|
+
DEFAULT_RETRIABLE_PARAMS = {
|
53
|
+
base_interval: 60,
|
54
|
+
max_interval: 300,
|
55
|
+
rand_factor: 0,
|
56
|
+
tries: 4,
|
57
|
+
on: [
|
58
|
+
Errno::ETIMEDOUT,
|
59
|
+
Faraday::Error::ClientError,
|
60
|
+
Net::ReadTimeout,
|
61
|
+
SurveyGizmo::BadResponseError,
|
62
|
+
SurveyGizmo::RateLimitExceededError
|
63
|
+
],
|
64
|
+
on_retry: Proc.new do |exception, tries|
|
65
|
+
SurveyGizmo.configuration.logger.warn("Retrying after #{exception.class}: #{tries} attempts.")
|
66
|
+
end
|
67
|
+
}
|
68
|
+
|
40
69
|
attr_accessor :api_token
|
41
70
|
attr_accessor :api_token_secret
|
42
71
|
|
@@ -46,22 +75,21 @@ module SurveyGizmo
|
|
46
75
|
attr_accessor :api_version
|
47
76
|
attr_accessor :logger
|
48
77
|
attr_accessor :results_per_page
|
49
|
-
|
50
78
|
attr_accessor :timeout_seconds
|
79
|
+
attr_accessor :retriable_params
|
80
|
+
|
81
|
+
# TODO Deprecated; remove in 7.0
|
51
82
|
attr_accessor :retry_attempts
|
52
83
|
attr_accessor :retry_interval
|
53
84
|
|
54
|
-
|
55
85
|
def initialize
|
56
86
|
@api_token = ENV['SURVEYGIZMO_API_TOKEN'] || nil
|
57
87
|
@api_token_secret = ENV['SURVEYGIZMO_API_TOKEN_SECRET'] || nil
|
58
88
|
|
59
89
|
@api_version = DEFAULT_API_VERSION
|
60
90
|
@results_per_page = DEFAULT_RESULTS_PER_PAGE
|
61
|
-
|
62
91
|
@timeout_seconds = DEFAULT_TIMEOUT_SECONDS
|
63
|
-
@
|
64
|
-
@retry_interval = DEFAULT_RETRY_INTERVAL
|
92
|
+
@retriable_params = DEFAULT_RETRIABLE_PARAMS
|
65
93
|
self.region = DEFAULT_REGION
|
66
94
|
|
67
95
|
@logger = SurveyGizmo::Logger.new(STDOUT)
|
@@ -76,5 +104,4 @@ module SurveyGizmo
|
|
76
104
|
@api_time_zone = region_infos[:locale]
|
77
105
|
end
|
78
106
|
end
|
79
|
-
|
80
107
|
end
|
@@ -4,19 +4,19 @@ module SurveyGizmo
|
|
4
4
|
class Connection
|
5
5
|
class << self
|
6
6
|
def get(route)
|
7
|
-
Retriable.retriable(
|
7
|
+
Retriable.retriable(SurveyGizmo.configuration.retriable_params) { connection.get(route) }
|
8
8
|
end
|
9
9
|
|
10
10
|
def post(route, params)
|
11
|
-
Retriable.retriable(
|
11
|
+
Retriable.retriable(SurveyGizmo.configuration.retriable_params) { connection.post(route, params) }
|
12
12
|
end
|
13
13
|
|
14
14
|
def put(route, params)
|
15
|
-
Retriable.retriable(
|
15
|
+
Retriable.retriable(SurveyGizmo.configuration.retriable_params) { connection.put(route, params) }
|
16
16
|
end
|
17
17
|
|
18
18
|
def delete(route)
|
19
|
-
Retriable.retriable(
|
19
|
+
Retriable.retriable(SurveyGizmo.configuration.retriable_params) { connection.delete(route) }
|
20
20
|
end
|
21
21
|
|
22
22
|
def reset!
|
@@ -48,24 +48,6 @@ module SurveyGizmo
|
|
48
48
|
connection.adapter Faraday.default_adapter
|
49
49
|
end
|
50
50
|
end
|
51
|
-
|
52
|
-
def retriable_args
|
53
|
-
{
|
54
|
-
base_interval: SurveyGizmo.configuration.retry_interval,
|
55
|
-
tries: SurveyGizmo.configuration.retry_attempts + 1,
|
56
|
-
max_elapsed_time: 3600,
|
57
|
-
on: [
|
58
|
-
Errno::ETIMEDOUT,
|
59
|
-
Faraday::Error::ClientError,
|
60
|
-
Net::ReadTimeout,
|
61
|
-
SurveyGizmo::BadResponseError,
|
62
|
-
SurveyGizmo::RateLimitExceededError
|
63
|
-
],
|
64
|
-
on_retry: Proc.new do |exception, tries|
|
65
|
-
SurveyGizmo.configuration.logger.warn("Retrying after #{exception.class}: #{tries} attempts.")
|
66
|
-
end
|
67
|
-
}
|
68
|
-
end
|
69
51
|
end
|
70
52
|
end
|
71
53
|
end
|
data/lib/survey_gizmo/logger.rb
CHANGED
data/lib/survey_gizmo/version.rb
CHANGED
data/spec/logger_spec.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe SurveyGizmo::
|
3
|
+
describe SurveyGizmo::Logger do
|
4
|
+
let(:progname) { 'TEST' }
|
5
|
+
let(:severity) { 'INFO' }
|
6
|
+
let(:time_string) { '2015-04-15 05:46:30' }
|
7
|
+
|
4
8
|
before(:each) do
|
5
9
|
SurveyGizmo.configure do |config|
|
6
10
|
config.api_token = 'king_of_the&whirled$'
|
7
11
|
config.api_token_secret = 'dream/word'
|
8
12
|
end
|
9
|
-
@severity = 'INFO'
|
10
|
-
@time_string = '2015-04-15 05:46:30'
|
11
|
-
@progname = 'TEST'
|
12
13
|
end
|
13
14
|
|
14
15
|
after(:each) do
|
@@ -18,60 +19,60 @@ describe SurveyGizmo::Configuration do
|
|
18
19
|
it 'should mask unencoded api token' do
|
19
20
|
config = SurveyGizmo.configuration
|
20
21
|
formatted_message = config.logger.format_message(
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
severity,
|
23
|
+
time_string.to_time,
|
24
|
+
progname,
|
24
25
|
config.api_token
|
25
26
|
)
|
26
27
|
expect(
|
27
28
|
formatted_message
|
28
|
-
).to
|
29
|
-
|
29
|
+
).to match(
|
30
|
+
/\[#{time_string} #{severity} \(\d+\)\] <SG_API_KEY>/
|
30
31
|
)
|
31
32
|
end
|
32
33
|
|
33
34
|
it 'should mask percent encoded api token' do
|
34
35
|
config = SurveyGizmo.configuration
|
35
36
|
formatted_message = config.logger.format_message(
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
severity,
|
38
|
+
time_string.to_time,
|
39
|
+
progname,
|
39
40
|
CGI.escape(config.api_token)
|
40
41
|
)
|
41
42
|
expect(
|
42
43
|
formatted_message
|
43
|
-
).to
|
44
|
-
|
44
|
+
).to match(
|
45
|
+
/\[#{time_string} #{severity} \(\d+\)\] <SG_API_KEY>/
|
45
46
|
)
|
46
47
|
end
|
47
48
|
|
48
49
|
it 'should mask unencoded api token secret' do
|
49
50
|
config = SurveyGizmo.configuration
|
50
51
|
formatted_message = config.logger.format_message(
|
51
|
-
|
52
|
-
|
53
|
-
|
52
|
+
severity,
|
53
|
+
time_string.to_time,
|
54
|
+
progname,
|
54
55
|
config.api_token_secret
|
55
56
|
)
|
56
57
|
expect(
|
57
58
|
formatted_message
|
58
|
-
).to
|
59
|
-
|
59
|
+
).to match(
|
60
|
+
/\[#{time_string} #{severity} \(\d+\)\] <SG_API_SECRET>/
|
60
61
|
)
|
61
62
|
end
|
62
63
|
|
63
64
|
it 'should mask percent encoded api token secret' do
|
64
65
|
config = SurveyGizmo.configuration
|
65
66
|
formatted_message = config.logger.format_message(
|
66
|
-
|
67
|
-
|
68
|
-
|
67
|
+
severity,
|
68
|
+
time_string.to_time,
|
69
|
+
progname,
|
69
70
|
CGI.escape(config.api_token_secret)
|
70
71
|
)
|
71
72
|
expect(
|
72
73
|
formatted_message
|
73
|
-
).to
|
74
|
-
|
74
|
+
).to match(
|
75
|
+
/\[#{time_string} #{severity} \(\d+\)\] <SG_API_SECRET>/
|
75
76
|
)
|
76
77
|
end
|
77
78
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -14,10 +14,7 @@ RSpec.configure do |config|
|
|
14
14
|
SurveyGizmo.configure do |config|
|
15
15
|
config.api_token = 'king_of_the_whirled'
|
16
16
|
config.api_token_secret = 'dreamword'
|
17
|
-
|
18
|
-
config.retry_attempts = 0
|
19
|
-
config.retry_interval = 0
|
20
|
-
|
17
|
+
config.retriable_params = { tries: 1, base_interval: 0 }
|
21
18
|
config.logger.level = Logger::FATAL
|
22
19
|
end
|
23
20
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: survey-gizmo-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kabari Hendrick
|
@@ -259,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
259
259
|
version: '0'
|
260
260
|
requirements: []
|
261
261
|
rubyforge_project:
|
262
|
-
rubygems_version: 2.2.
|
262
|
+
rubygems_version: 2.2.5
|
263
263
|
signing_key:
|
264
264
|
specification_version: 4
|
265
265
|
summary: Gem to use the SurveyGizmo.com REST API, v3+
|
@@ -275,4 +275,3 @@ test_files:
|
|
275
275
|
- spec/test_json/page.json
|
276
276
|
- spec/test_json/question.json
|
277
277
|
- spec/test_json/survey.json
|
278
|
-
has_rdoc:
|