survey-gizmo-ruby 5.0.3 → 5.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9e8d3c3ad7b01fbcd010738d2a5cf49376162df8
4
- data.tar.gz: b7718a4435ea2b88abe17d460698b1104b2d6b02
3
+ metadata.gz: c2d8dfa46ed2f287166d32c156466b1ff39d84b7
4
+ data.tar.gz: c22d6cb33d3e3a57fe6d848e33011dd9c5f860ad
5
5
  SHA512:
6
- metadata.gz: 3f9484c0436ffe3d78b5a0b68e0fe208ed3144480f7e0e7aefc3a4bb346e9f783b553d99dd542c5c9d6040ff263c9469472598137c40670f6c10925bf99aed05
7
- data.tar.gz: 165082ee6af357726b193f86c6ef5c803a66fb7b77c21c43292254bcbc096403050c6b6ca7ec48611639664c7ee9fcbda570a2a3514f8ca634547c7520d64a35
6
+ metadata.gz: 89cda081f559f84fb5c19493ddb11e2f48bd0d8c4ff26d76ab6f4d8320428dc5dbfc7561cbbf929a67fb4217cae391414b269eeb6a330c2a7fb3f9549d1986eb
7
+ data.tar.gz: 06cac087f8f21a42fe5a6e2c535d0e407fac2d86fa39967778942e68ce469419dadb7e56308a47a95e48c1e87d5241788d9465792b7356d48805bf2372995f2d
data/README.md CHANGED
@@ -58,6 +58,9 @@ SurveyGizmo.configure do |config|
58
58
 
59
59
  # Optional - Defaults to 50, maximum 500. Setting too high may cause SurveyGizmo to start throwing timeouts.
60
60
  config.results_per_page = 100
61
+
62
+ # Optional - Defaults to 300 seconds
63
+ config.timeout_seconds = 600
61
64
  end
62
65
  ```
63
66
 
@@ -78,7 +81,8 @@ Pester.configure do |config|
78
81
  config.environments[:survey_gizmo_ruby][:retry_error_classes] = [MyExceptionClass, MyOtherExceptionClass]
79
82
  end
80
83
 
81
- # To set Pester to retry on ALL exception classes, do this (use with caution! Can include exceptions Rails likes to throw on SIGHUP)
84
+ # To set Pester to retry on ALL exception classes, do this:
85
+ # (use with caution! Can include exceptions Rails likes to throw on SIGHUP)
82
86
  Pester.configure do |config|
83
87
  config.environments[:survey_gizmo_ruby][:retry_error_classes] = nil
84
88
  end
@@ -121,9 +125,9 @@ questions = survey.questions
121
125
  questions = survey.actual_questions
122
126
 
123
127
  # Create a question for your survey. The returned object will be given an :id parameter by SG.
124
- question = SurveyGizmo::API::Question.create(survey_id: survey.id, title: 'Do you like ruby?', type: 'checkbox')
128
+ question = SurveyGizmo::API::Question.create(survey_id: survey.id, title: 'Do u ruby?', type: 'checkbox')
125
129
  # Update a question
126
- question.title = "Do you LOVE Ruby?"
130
+ question.title = "Do u <3 Ruby?"
127
131
  question.save
128
132
  # Destroy a question
129
133
  question.destroy
@@ -131,8 +135,8 @@ question.destroy
131
135
  # Iterate over all your Responses
132
136
  survey.responses.each { |response| do_something_with(response) }
133
137
  # Use filters to limit results - this example will iterate over page 3 of completed, non test data
134
- # SurveyResponses submitted within the past 3 days for contact 999. It demonstrates how to use some of the gem's
135
- # built in filters/generators as well as how to construct a filter.
138
+ # SurveyResponses submitted within the past 3 days for contact 999. It demonstrates how to use some of
139
+ # the gem's built in filters/generators as well as how to construct a filter.
136
140
  # See: http://apihelp.surveygizmo.com/help/article/link/filters for more info on filters
137
141
  filters = [
138
142
  SurveyGizmo::API::Response::NO_TEST_DATA,
@@ -197,7 +201,7 @@ class SomeObject
197
201
  get: '/something/:id',
198
202
  update: '/something/weird/:id',
199
203
  create: '/something',
200
- delete: /something/delete/:id'
204
+ delete: '/something/delete/:id'
201
205
  }
202
206
  end
203
207
  ```
@@ -1,19 +1,17 @@
1
1
  # This REST endpoint is only available to accounts with admin privileges
2
2
  # This code is untested.
3
3
 
4
- module SurveyGizmo
5
- module API
6
- class AccountTeams
7
- include SurveyGizmo::Resource
4
+ module SurveyGizmo::API
5
+ class AccountTeams
6
+ include SurveyGizmo::Resource
8
7
 
9
- attribute :id, Integer
10
- attribute :teamid, Integer
11
- attribute :teamname, String
12
- attribute :color, String
13
- attribute :default_role, String
14
- attribute :status, String
8
+ attribute :id, Integer
9
+ attribute :teamid, Integer
10
+ attribute :teamname, String
11
+ attribute :color, String
12
+ attribute :default_role, String
13
+ attribute :status, String
15
14
 
16
- @route = '/accountteams'
17
- end
15
+ @route = '/accountteams'
18
16
  end
19
17
  end
@@ -1,59 +1,56 @@
1
- module SurveyGizmo
2
- module API
3
- class Answer
4
- include Virtus.model
1
+ module SurveyGizmo::API
2
+ class Answer
3
+ include Virtus.model
5
4
 
6
- attribute :key, String
7
- attribute :value, String
8
- attribute :survey_id, Integer
9
- attribute :response_id, Integer
10
- attribute :question_id, Integer
11
- attribute :option_id, Integer
12
- attribute :submitted_at, DateTime
13
- attribute :answer_text, String
14
- attribute :other_text, String
15
- attribute :question_pipe, String
5
+ attribute :key, String
6
+ attribute :value, String
7
+ attribute :survey_id, Integer
8
+ attribute :response_id, Integer
9
+ attribute :question_id, Integer
10
+ attribute :option_id, Integer
11
+ attribute :submitted_at, DateTime
12
+ attribute :answer_text, String
13
+ attribute :other_text, String
14
+ attribute :question_pipe, String
16
15
 
17
- def initialize(attrs = {})
18
- self.attributes = attrs
16
+ def initialize(attrs = {})
17
+ self.attributes = attrs
19
18
 
20
- case key
21
- when /\[question\((\d+)\),\s*option\((\d+|"\d+-other")\)\]/
22
- @question_id, @option_id = $1, $2
19
+ case key
20
+ when /\[question\((\d+)\),\s*option\((\d+|"\d+-other")\)\]/
21
+ self.question_id, self.option_id = $1, $2
23
22
 
24
- if @option_id =~ /other/
25
- @option_id.delete!('-other"')
26
- self.other_text = value
27
- end
28
- when /\[question\((\d+)\),\s*question_pipe\("(.*)"\)\]/
29
- @question_id = $1
30
- @question_pipe = $2
31
- when /\[question\((\d+)\)\]/
32
- @question_id = $1
33
- else
34
- fail "Can't recognize pattern for #{attrs[:key]} => #{attrs[:value]} - you may have to parse your answers manually."
35
- end
36
-
37
- self.question_id = @question_id.to_i
38
- if @option_id
39
- fail "Bad option_id #{option_id}!" if option_id.to_i == 0 && option_id != '0'
40
- self.option_id = @option_id.to_i
23
+ if option_id =~ /-other/
24
+ option_id.delete!('-other"')
25
+ self.other_text = value
41
26
  end
27
+ when /\[question\((\d+)\),\s*question_pipe\("(.*)"\)\]/
28
+ self.question_id, self.question_pipe = $1, $2
29
+ when /\[question\((\d+)\)\]/
30
+ self.question_id = $1
31
+ else
32
+ fail "Can't recognize pattern for #{attrs[:key]} => #{attrs[:value]} - you may have to parse your answers manually."
42
33
  end
43
34
 
44
- # Strips out the answer_text when there is a valid option_id
45
- def to_hash
46
- {
47
- response_id: response_id,
48
- question_id: question_id,
49
- option_id: option_id,
50
- question_pipe: question_pipe,
51
- submitted_at: submitted_at,
52
- survey_id: survey_id,
53
- other_text: other_text,
54
- answer_text: option_id || other_text ? nil : answer_text
55
- }.reject { |k,v| v.nil? }
35
+ self.question_id = question_id.to_i
36
+ if option_id
37
+ fail "Bad option_id #{option_id} (class: #{option_id.class}) for #{attrs}!" if option_id.to_i == 0 && option_id != '0' && option_id != 0
38
+ self.option_id = option_id.to_i
56
39
  end
57
40
  end
41
+
42
+ # Strips out the answer_text when there is a valid option_id
43
+ def to_hash
44
+ {
45
+ response_id: response_id,
46
+ question_id: question_id,
47
+ option_id: option_id,
48
+ question_pipe: question_pipe,
49
+ submitted_at: submitted_at,
50
+ survey_id: survey_id,
51
+ other_text: other_text,
52
+ answer_text: option_id || other_text ? nil : answer_text
53
+ }.reject { |k, v| v.nil? }
54
+ end
58
55
  end
59
56
  end
@@ -1,5 +1,4 @@
1
- module SurveyGizmo; module API
2
- # @see SurveyGizmo::Resource::ClassMethods
1
+ module SurveyGizmo::API
3
2
  class Campaign
4
3
  include SurveyGizmo::Resource
5
4
 
@@ -29,4 +28,4 @@ module SurveyGizmo; module API
29
28
  Contact.all(conditions.merge(children_params).merge(all_pages: !conditions[:page]))
30
29
  end
31
30
  end
32
- end; end
31
+ end
@@ -1,5 +1,4 @@
1
- module SurveyGizmo; module API
2
- # @see SurveyGizmo::Resource::ClassMethods
1
+ module SurveyGizmo::API
3
2
  class Contact
4
3
  include SurveyGizmo::Resource
5
4
 
@@ -38,4 +37,4 @@ module SurveyGizmo; module API
38
37
 
39
38
  @route = '/survey/:survey_id/surveycampaign/:campaign_id/contact'
40
39
  end
41
- end; end
40
+ end
@@ -1,5 +1,4 @@
1
- module SurveyGizmo; module API
2
- # @see SurveyGizmo::Resource::ClassMethods
1
+ module SurveyGizmo::API
3
2
  class EmailMessage
4
3
  include SurveyGizmo::Resource
5
4
 
@@ -22,4 +21,4 @@ module SurveyGizmo; module API
22
21
 
23
22
  @route = '/survey/:survey_id/surveycampaign/:campaign_id/emailmessage'
24
23
  end
25
- end; end
24
+ end
@@ -1,5 +1,4 @@
1
- module SurveyGizmo; module API
2
- # @see SurveyGizmo::Resource::ClassMethods
1
+ module SurveyGizmo::API
3
2
  class Option
4
3
  include SurveyGizmo::Resource
5
4
  include SurveyGizmo::MultilingualTitle
@@ -13,4 +12,4 @@ module SurveyGizmo; module API
13
12
 
14
13
  @route = '/survey/:survey_id/surveypage/:page_id/surveyquestion/:question_id/surveyoption'
15
14
  end
16
- end; end
15
+ end
@@ -1,7 +1,6 @@
1
1
  require 'survey_gizmo/api/question'
2
2
 
3
- module SurveyGizmo; module API
4
- # @see SurveyGizmo::Resource::ClassMethods
3
+ module SurveyGizmo::API
5
4
  class Page
6
5
  include SurveyGizmo::Resource
7
6
  include SurveyGizmo::MultilingualTitle
@@ -33,4 +32,4 @@ module SurveyGizmo; module API
33
32
  @questions = with_subquestions.each { |q| q.attributes = children_params }
34
33
  end
35
34
  end
36
- end; end
35
+ end
@@ -1,7 +1,6 @@
1
1
  require 'survey_gizmo/api/option'
2
2
 
3
- module SurveyGizmo; module API
4
- # @see SurveyGizmo::Resource::ClassMethods
3
+ module SurveyGizmo::API
5
4
  class Question
6
5
  include SurveyGizmo::Resource
7
6
  include SurveyGizmo::MultilingualTitle
@@ -59,4 +58,4 @@ module SurveyGizmo; module API
59
58
  end
60
59
  end
61
60
  end
62
- end; end
61
+ end
@@ -1,5 +1,4 @@
1
- module SurveyGizmo; module API
2
- # @see SurveyGizmo::Resource::ClassMethods
1
+ module SurveyGizmo::API
3
2
  class Response
4
3
  include SurveyGizmo::Resource
5
4
 
@@ -40,7 +39,8 @@ module SurveyGizmo; module API
40
39
  answers.select do |k,v|
41
40
  next false unless v.is_a?(FalseClass) || v.present?
42
41
 
43
- # Strip out "Other" answers that don't actually have the "other" text.
42
+ # Strip out "Other" answers that don't actually have the "other" text (they come back as two responses - one
43
+ # for the "Other" option_id, and then a whole separate response for the text given as an "Other" response.
44
44
  if k =~ /\[question\((\d+)\),\s*option\((\d+)\)\]/
45
45
  !answers.keys.any? { |key| key =~ /\[question\((#{$1})\),\s*option\("(#{$2})-other"\)\]/ }
46
46
  else
@@ -49,4 +49,4 @@ module SurveyGizmo; module API
49
49
  end.map { |k,v| Answer.new(children_params.merge(key: k, value: v, answer_text: v, submitted_at: submitted_at)) }
50
50
  end
51
51
  end
52
- end; end
52
+ end
@@ -1,7 +1,6 @@
1
1
  require 'survey_gizmo/api/page'
2
2
 
3
- module SurveyGizmo; module API
4
- # @see SurveyGizmo::Resource::ClassMethods
3
+ module SurveyGizmo::API
5
4
  class Survey
6
5
  include SurveyGizmo::Resource
7
6
 
@@ -22,16 +21,15 @@ module SurveyGizmo; module API
22
21
  attribute :created_on, DateTime
23
22
  attribute :modified_on, DateTime
24
23
  attribute :copy, Boolean
25
- # Unfortunately if pages is an attribute, then save and update requests will collide with the differing response
26
- # types to Survey.all and Survey.first and cause an incorrect reload
24
+ # See comment in the #pages method for why this :pages can't be an attribute
27
25
  # attribute :pages, Array[Page]
28
26
 
29
27
  @route = '/survey'
30
28
 
31
29
  def pages
32
- # SurveyGizmo sends down the page info to .first requests but NOT to .all requests, so we must load pages manually
33
- # We should be able to just .reload this Survey BUT we can't make :pages a Virtus attribute without requiring a
34
- # call to this method during Survey.save
30
+ # SurveyGizmo sends down the page info to .first requests but NOT to .all requests, so we must load pages
31
+ # manually. We should be able to just .reload this Survey BUT we can't make :pages a Virtus attribute without
32
+ # requiring a call to this method during Survey.save
35
33
  @pages ||= Page.all(children_params.merge(all_pages: true)).to_a
36
34
  @pages.each { |p| p.attributes = children_params }
37
35
  end
@@ -84,4 +82,4 @@ module SurveyGizmo; module API
84
82
  @campaigns ||= Campaign.all(children_params.merge(all_pages: true)).to_a
85
83
  end
86
84
  end
87
- end; end
85
+ end
@@ -58,6 +58,7 @@ module SurveyGizmo
58
58
  DEFAULT_REST_API_URL = 'https://restapi.surveygizmo.com'
59
59
  DEFAULT_API_VERSION = 'v4'
60
60
  DEFAULT_RESULTS_PER_PAGE = 50
61
+ DEFAULT_TIMEOUT_SECONDS = 300
61
62
 
62
63
  attr_accessor :user
63
64
  attr_accessor :password
@@ -67,11 +68,13 @@ module SurveyGizmo
67
68
  attr_accessor :api_version
68
69
  attr_accessor :logger
69
70
  attr_accessor :results_per_page
71
+ attr_accessor :timeout_seconds
70
72
 
71
73
  def initialize
72
74
  @api_url = DEFAULT_REST_API_URL
73
75
  @api_version = DEFAULT_API_VERSION
74
76
  @results_per_page = DEFAULT_RESULTS_PER_PAGE
77
+ @timeout_seconds = DEFAULT_TIMEOUT_SECONDS
75
78
  @logger = SurveyGizmo::Logger.new(STDOUT)
76
79
  @api_debug = ENV['GIZMO_DEBUG'].to_s =~ /^(true|t|yes|y|1)$/i
77
80
  end
@@ -2,8 +2,6 @@ require 'active_support/core_ext/module/delegation'
2
2
 
3
3
  module SurveyGizmo
4
4
  class Connection
5
- TIMEOUT_SECONDS = 300
6
-
7
5
  class << self
8
6
  delegate :put, :get, :delete, :post, to: :connection
9
7
 
@@ -18,8 +16,8 @@ module SurveyGizmo
18
16
  url: SurveyGizmo.configuration.api_url,
19
17
  params: { 'user:md5' => "#{SurveyGizmo.configuration.user}:#{Digest::MD5.hexdigest(SurveyGizmo.configuration.password)}" },
20
18
  request: {
21
- timeout: TIMEOUT_SECONDS,
22
- open_timeout: TIMEOUT_SECONDS
19
+ timeout: SurveyGizmo.configuration.timeout_seconds,
20
+ open_timeout: SurveyGizmo.configuration.timeout_seconds
23
21
  }
24
22
  }
25
23
 
@@ -1,3 +1,3 @@
1
1
  module SurveyGizmo
2
- VERSION = '5.0.3'
2
+ VERSION = '5.0.4'
3
3
  end
@@ -11,15 +11,15 @@ Gem::Specification.new do |gem|
11
11
  gem.email = ['adrien.jarthon@dimelo.com']
12
12
  gem.description = 'Gem to use the SurveyGizmo.com REST API, v3+'
13
13
  gem.summary = 'Gem to use the SurveyGizmo.com REST API, v3+'
14
- gem.homepage = 'http://github.com/RipTheJacker/survey-gizmo-ruby'
14
+ gem.homepage = 'http://github.com/jarthod/survey-gizmo-ruby'
15
15
  gem.licenses = ['MIT']
16
16
  gem.required_ruby_version = '>= 1.9'
17
17
 
18
18
  gem.add_dependency 'activesupport', '>= 3.0'
19
19
  gem.add_dependency 'addressable', '~> 2'
20
20
  gem.add_dependency 'awesome_print', '~> 1'
21
- gem.add_dependency 'faraday', '~> 0.9'
22
- gem.add_dependency 'faraday_middleware'
21
+ gem.add_dependency 'faraday', '>= 0.9.1', '~> 0.9'
22
+ gem.add_dependency 'faraday_middleware', '~> 0.10'
23
23
  gem.add_dependency 'i18n'
24
24
  gem.add_dependency 'pester', '>= 1.0.0'
25
25
  gem.add_dependency 'virtus', '>= 1.0.0'
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: 5.0.3
4
+ version: 5.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kabari Hendrick
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-01-24 00:00:00.000000000 Z
14
+ date: 2016-01-26 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
@@ -59,6 +59,9 @@ dependencies:
59
59
  name: faraday
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 0.9.1
62
65
  - - "~>"
63
66
  - !ruby/object:Gem::Version
64
67
  version: '0.9'
@@ -66,6 +69,9 @@ dependencies:
66
69
  prerelease: false
67
70
  version_requirements: !ruby/object:Gem::Requirement
68
71
  requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 0.9.1
69
75
  - - "~>"
70
76
  - !ruby/object:Gem::Version
71
77
  version: '0.9'
@@ -73,16 +79,16 @@ dependencies:
73
79
  name: faraday_middleware
74
80
  requirement: !ruby/object:Gem::Requirement
75
81
  requirements:
76
- - - ">="
82
+ - - "~>"
77
83
  - !ruby/object:Gem::Version
78
- version: '0'
84
+ version: '0.10'
79
85
  type: :runtime
80
86
  prerelease: false
81
87
  version_requirements: !ruby/object:Gem::Requirement
82
88
  requirements:
83
- - - ">="
89
+ - - "~>"
84
90
  - !ruby/object:Gem::Version
85
- version: '0'
91
+ version: '0.10'
86
92
  - !ruby/object:Gem::Dependency
87
93
  name: i18n
88
94
  requirement: !ruby/object:Gem::Requirement
@@ -226,7 +232,7 @@ files:
226
232
  - spec/test_json/question.json
227
233
  - spec/test_json/survey.json
228
234
  - survey-gizmo-ruby.gemspec
229
- homepage: http://github.com/RipTheJacker/survey-gizmo-ruby
235
+ homepage: http://github.com/jarthod/survey-gizmo-ruby
230
236
  licenses:
231
237
  - MIT
232
238
  metadata: {}