survey-gizmo-ruby 5.0.2 → 5.0.3

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: 49463d6fa875d93712a1da0951dac1e0053747ee
4
- data.tar.gz: 339404fe4dae766bd04abc675cd7fbd34f244488
3
+ metadata.gz: 9e8d3c3ad7b01fbcd010738d2a5cf49376162df8
4
+ data.tar.gz: b7718a4435ea2b88abe17d460698b1104b2d6b02
5
5
  SHA512:
6
- metadata.gz: 38c186f0d5e12964b5b559aeb0c674c2291d1ade6f0518c7ed681e806cb3a56cb05d791b5f9374655cc81fe491853406c74d5dab72ba126aa668195963d4ca08
7
- data.tar.gz: ea37139f7d8fdad647d2b38db73cef15a065b6b6098a05efbbd911e8dda70404b8979bb42e6fad9f1b9eeaa41f1df49e8ddb8e0f7f34708569255f1823ebd388
6
+ metadata.gz: 3f9484c0436ffe3d78b5a0b68e0fe208ed3144480f7e0e7aefc3a4bb346e9f783b553d99dd542c5c9d6040ff263c9469472598137c40670f6c10925bf99aed05
7
+ data.tar.gz: 165082ee6af357726b193f86c6ef5c803a66fb7b77c21c43292254bcbc096403050c6b6ca7ec48611639664c7ee9fcbda570a2a3514f8ca634547c7520d64a35
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.1.8
5
+ - 2.2.4
6
+ - 2.3.0
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Survey Gizmo (ruby)
2
2
 
3
+ [![Build Status](https://travis-ci.org/jarthod/survey-gizmo-ruby.svg?branch=master)](https://travis-ci.org/jarthod/survey-gizmo-ruby)
4
+
3
5
  Integrate with the [Survey Gizmo API](http://apisurveygizmo.helpgizmo.com/help) using an ActiveModel style interface.
4
6
 
5
7
  Currently supports SurveyGizmo API **v4** (default) and **v3**.
@@ -20,14 +20,17 @@ module SurveyGizmo; module API
20
20
  end
21
21
 
22
22
  def questions
23
- # See note about broken subquestions in resource.rb
24
- @questions.flat_map { |q| q.sub_question_skus }.each do |sku|
25
- sku = sku[1] if sku.is_a?(Array)
26
- next if @questions.find { |q| q.id == sku }
27
- @questions << Question.first(children_params.merge(id: sku))
23
+ @questions.each { |q| q.attributes = children_params }
24
+ return @questions if @questions.all? { |q| q.sub_question_skus.all? { |sku| @questions.find { |q| q.id == sku } } }
25
+
26
+ # See note on broken subquestions in resource.rb.
27
+ with_subquestions = @questions
28
+ @questions.each do |q|
29
+ with_subquestions.reject! { |q| q.sub_question_skus.include?(q.id) }
30
+ with_subquestions += q.sub_questions
28
31
  end
29
32
 
30
- @questions.each { |q| q.attributes = children_params }
33
+ @questions = with_subquestions.each { |q| q.attributes = children_params }
31
34
  end
32
35
  end
33
36
  end; end
@@ -43,12 +43,16 @@ module SurveyGizmo; module API
43
43
  @parent_question ||= Question.first(survey_id: survey_id, id: parent_question_id)
44
44
  end
45
45
 
46
+ def sub_question_skus
47
+ # As of 2015-12-23, the sub_question_skus attribute can either contain an array of integers if no shortname (alias)
48
+ # was set for any question, or an array of [String, Integer] with the String corresponding to the subquestion
49
+ # shortname and the integer corresponding to the subquestion id if at least one shortname was set.
50
+ @sub_question_skus.map { |sku| sku.is_a?(Array) ? sku[1] : sku }
51
+ end
52
+
46
53
  def sub_questions
47
54
  @sub_questions ||= sub_question_skus.map do |sku|
48
- # As of 2015-12-23, the sub_question_skus attribute can either contain an array of integers if no shortname (alias)
49
- # was set for any question, or an array of [String, Integer] with the String corresponding to the subquestion
50
- # shortname and the integer corresponding to the subquestion id if at least one shortname was set.
51
- sku = sku[1] if sku.is_a?(Array)
55
+ SurveyGizmo.configuration.logger.warn("Have to do individual load of sub question #{sku}...")
52
56
  subquestion = Question.first(survey_id: survey_id, id: sku)
53
57
  subquestion.parent_question_id = id
54
58
  subquestion
@@ -72,7 +72,7 @@ module SurveyGizmo
72
72
  @api_url = DEFAULT_REST_API_URL
73
73
  @api_version = DEFAULT_API_VERSION
74
74
  @results_per_page = DEFAULT_RESULTS_PER_PAGE
75
- @logger = ::Logger.new(STDOUT)
75
+ @logger = SurveyGizmo::Logger.new(STDOUT)
76
76
  @api_debug = ENV['GIZMO_DEBUG'].to_s =~ /^(true|t|yes|y|1)$/i
77
77
  end
78
78
  end
@@ -0,0 +1,9 @@
1
+ require 'logger'
2
+
3
+ module SurveyGizmo
4
+ class Logger < ::Logger
5
+ def format_message(severity, timestamp, progname, msg)
6
+ "#{timestamp.strftime('%Y-%m-%d %H:%M:%S')} #{severity} #{msg}\n"
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module SurveyGizmo
2
- VERSION = '5.0.2'
2
+ VERSION = '5.0.3'
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -14,7 +14,7 @@ RSpec.configure do |config|
14
14
  SurveyGizmo.configure do |config|
15
15
  config.user = 'test@test.com'
16
16
  config.password = 'password'
17
- config.logger.level = Logger::WARN
17
+ config.logger.level = Logger::FATAL
18
18
  end
19
19
 
20
20
  Pester.configure do |config|
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.2
4
+ version: 5.0.3
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: 2015-12-30 00:00:00.000000000 Z
14
+ date: 2016-01-24 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
@@ -191,6 +191,7 @@ files:
191
191
  - ".document"
192
192
  - ".gitignore"
193
193
  - ".rspec"
194
+ - ".travis.yml"
194
195
  - Gemfile
195
196
  - LICENSE.txt
196
197
  - README.md
@@ -210,6 +211,7 @@ files:
210
211
  - lib/survey_gizmo/connection.rb
211
212
  - lib/survey_gizmo/faraday_middleware/parse_survey_gizmo.rb
212
213
  - lib/survey_gizmo/faraday_middleware/pester_survey_gizmo.rb
214
+ - lib/survey_gizmo/logger.rb
213
215
  - lib/survey_gizmo/multilingual_title.rb
214
216
  - lib/survey_gizmo/resource.rb
215
217
  - lib/survey_gizmo/version.rb
@@ -259,4 +261,3 @@ test_files:
259
261
  - spec/test_json/page.json
260
262
  - spec/test_json/question.json
261
263
  - spec/test_json/survey.json
262
- has_rdoc: