isurvey 0.0.10 → 0.1.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 +8 -8
- data/README.md +18 -15
- data/lib/isurvey/answer.rb +5 -0
- data/lib/isurvey/api.rb +10 -24
- data/lib/isurvey/collector.rb +19 -1
- data/lib/isurvey/question.rb +10 -0
- data/lib/isurvey/version.rb +1 -1
- data/lib/isurvey.rb +7 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWRjNmIxOTRhMTViNDk1NWQyMDRjZmE0OWFlMWYxYzM4YzIxYWI3ZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjFjZDRhMmU1MmZjOTM4NDI3ODdmZGE5N2RjNzhlYWY3MTMwOTAwMQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OGEyM2VkOGFjNTdmYWViOTZkMDk3MzFmOGMzYzNmM2MyYTViOGZmOTVhYzRh
|
10
|
+
MDMxMDQ5NDExYTk5NWZlMWYzOTE3NDc2OGI3Njc4YTNmYzllMTdmNGZmN2Fj
|
11
|
+
OTY0OGRhNjk1OTIyNTkxMjFjNDAzNmE2YTRjYjFjMDcyN2VjZGI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MzI1NDk3MzY1YjYxMDZmNzEzYWVjNjMwNWM1YWQ3N2VjYzhjNzY4ODE2NDc0
|
14
|
+
MmY4MWE1NjgzYTI1MDlmYTFmNDZlZGUwMmRiNzM3N2FkOGVlNTZhYjNiY2Q2
|
15
|
+
MDIyNzNmZGNjZDFlYTI2YTU0MWJiNGZhYjE4ZGExODQ1NTk5MjY=
|
data/README.md
CHANGED
@@ -21,6 +21,10 @@ You must set up your company identifier and survey password. Perhaps in config/
|
|
21
21
|
Isurvey::Credentials.company_identifier = [cp]
|
22
22
|
Isurvey::Credentials.survey_password = [sp]
|
23
23
|
|
24
|
+
Before being used, the API must be loaded. This can be done in your initialzer or in any other place you see fit.
|
25
|
+
|
26
|
+
Isurvey::API.load
|
27
|
+
|
24
28
|
## Usage
|
25
29
|
|
26
30
|
There are questions and answers. Questions are available through Isurvey::Question and answers are available through Isurvey::Answer.
|
@@ -43,31 +47,30 @@ For answers, the available properties are:
|
|
43
47
|
|
44
48
|
:screen_id, :question_id, :answer_id, :result_answer, :response_date
|
45
49
|
|
46
|
-
|
47
|
-
|
48
|
-
Get a list of the questions:
|
49
|
-
|
50
|
-
Isurvey::API.questions
|
50
|
+
Any property can also be used to find on either questions or answers. For example:
|
51
51
|
|
52
|
-
|
52
|
+
Isurvey::Question.find_by_screen_id(:id)
|
53
|
+
Isurvey::Answer.find_by_question_id(:id)
|
53
54
|
|
54
|
-
|
55
|
+
You can query a question for its answers, or an answer for its questions.
|
55
56
|
|
56
|
-
|
57
|
+
Isurvey::Question.answers
|
58
|
+
Isurvey::Answer.questions
|
57
59
|
|
58
|
-
|
60
|
+
You can also find answers by result id to a question.
|
59
61
|
|
60
|
-
|
62
|
+
Isurvey::Question.answers_by_result_id(:id)
|
61
63
|
|
62
|
-
|
64
|
+
Questions and Answers have shortcut methods that allow you to query for the first or some index:
|
63
65
|
|
64
|
-
|
66
|
+
Isurvey::Question.first
|
67
|
+
Isurvey::Answer[10]
|
65
68
|
|
66
|
-
|
69
|
+
You can also get direct access to the API.
|
67
70
|
|
68
|
-
Get a list of the
|
71
|
+
Get a list of the result ids:
|
69
72
|
|
70
|
-
Isurvey::API.
|
73
|
+
Isurvey::API.result_ids
|
71
74
|
|
72
75
|
## Contributing
|
73
76
|
|
data/lib/isurvey/answer.rb
CHANGED
data/lib/isurvey/api.rb
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
module Isurvey
|
2
2
|
class API
|
3
|
+
def self.load
|
4
|
+
questions
|
5
|
+
answers
|
6
|
+
end
|
7
|
+
|
3
8
|
def self.questions
|
4
9
|
unless @questions
|
5
10
|
@questions = []
|
@@ -20,32 +25,13 @@ module Isurvey
|
|
20
25
|
@result_ids
|
21
26
|
end
|
22
27
|
|
23
|
-
|
24
|
-
def self.question_by_screen_id(id)
|
25
|
-
self.screens.each do |question|
|
26
|
-
if question[:screen_id] == id
|
27
|
-
return question[:screen_text]
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.answer_by_screen_and_result_id(options)
|
33
|
-
answers_by_result_id(options[:result_id]) & answers_by_screen_id(options[:screen_id])
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.answers_by_result_id(id)
|
37
|
-
survey_results.each do |result|
|
38
|
-
if result[:result_id] == id
|
39
|
-
return result[:screen_results][:result]
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def self.answers_by_screen_id(id)
|
28
|
+
def self.answers
|
45
29
|
@answers = []
|
46
30
|
survey_results.each do |result|
|
47
|
-
result[:screen_results][:result].each do |
|
48
|
-
|
31
|
+
result[:screen_results][:result].each do |answer|
|
32
|
+
answer = Answer.new(hash: answer)
|
33
|
+
answer.result_id = result[:result_id]
|
34
|
+
@answers << answer
|
49
35
|
end
|
50
36
|
end
|
51
37
|
@answers
|
data/lib/isurvey/collector.rb
CHANGED
@@ -1,7 +1,25 @@
|
|
1
1
|
module Isurvey
|
2
2
|
module Collector
|
3
|
+
|
4
|
+
def method_missing(method, *args, &block)
|
5
|
+
if method.to_s =~ /^find_by_(.+)$/
|
6
|
+
to_find = method.to_s.sub(/find_by_/, '')
|
7
|
+
all.select { |obj| obj.send(to_find.to_sym) == args.first }
|
8
|
+
else
|
9
|
+
super
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
3
13
|
def all
|
4
|
-
ObjectSpace.each_object(self).entries
|
14
|
+
ObjectSpace.each_object(self).entries
|
15
|
+
end
|
16
|
+
|
17
|
+
def first
|
18
|
+
all.first
|
19
|
+
end
|
20
|
+
|
21
|
+
def [](ind)
|
22
|
+
all[ind]
|
5
23
|
end
|
6
24
|
end
|
7
25
|
end
|
data/lib/isurvey/question.rb
CHANGED
data/lib/isurvey/version.rb
CHANGED
data/lib/isurvey.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require 'isurvey/version'
|
2
1
|
require 'savon'
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
require_relative './isurvey/version'
|
3
|
+
require_relative './isurvey/soap_client'
|
4
|
+
require_relative './isurvey/base'
|
5
|
+
require_relative './isurvey/collector'
|
6
|
+
require_relative './isurvey/api'
|
7
|
+
require_relative './isurvey/question'
|
8
|
+
require_relative './isurvey/answer'
|
9
9
|
|
10
10
|
module Isurvey
|
11
11
|
class Credentials
|