dmtd_vbmapp_data 1.0.4 → 1.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 +4 -4
- data/CHANGELOG.md +8 -1
- data/lib/dmtd_vbmapp_data/assessment_report.rb +7 -13
- data/lib/dmtd_vbmapp_data/client.rb +32 -29
- data/lib/dmtd_vbmapp_data/guide.rb +17 -28
- data/lib/dmtd_vbmapp_data/guide_chapter.rb +9 -9
- data/lib/dmtd_vbmapp_data/guide_chapter_section.rb +11 -9
- data/lib/dmtd_vbmapp_data/guide_section_sub_section.rb +9 -9
- data/lib/dmtd_vbmapp_data/vbmapp.rb +32 -23
- data/lib/dmtd_vbmapp_data/vbmapp_area.rb +6 -40
- data/lib/dmtd_vbmapp_data/vbmapp_area_group.rb +17 -22
- data/lib/dmtd_vbmapp_data/vbmapp_area_question.rb +9 -13
- data/lib/dmtd_vbmapp_data/vbmapp_area_response.rb +5 -4
- data/lib/dmtd_vbmapp_data/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 122b6604eb2c2c904d99f0f07a3906eabda7ee7f
|
4
|
+
data.tar.gz: 602691f8db6c4739446f01dc8e6ca1b6a4795092
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27ba06d0568758a013914f72ad4ecfdfa23a1230811dd95dd5812d8b30a3c42e123652d37732df78f0a26dea0711ad193d163d6ee89fb243ab3142125c5999af
|
7
|
+
data.tar.gz: 3e927cd10c3bf0aa66d2fde5b5a399384da10ae9337c712a857cf6b336f81f8cb740bb517c73ce693d3198adb1a395aa588fe8b74cbc0feda0075a2cad499b68
|
data/CHANGELOG.md
CHANGED
@@ -16,4 +16,11 @@
|
|
16
16
|
|
17
17
|
## 1.0.4
|
18
18
|
|
19
|
-
* Implemented the Guide's caching support
|
19
|
+
* Implemented the Guide's caching support
|
20
|
+
|
21
|
+
## 1.1.0
|
22
|
+
|
23
|
+
* Implemented the VB-Mapp controller's caching support
|
24
|
+
* Completely reworked the documentation to be 'yard'-style format
|
25
|
+
* Privatized the 'index' methods on guide & vbmapp as they really aren't needed publicly
|
26
|
+
* Minor bug fixes
|
@@ -20,24 +20,18 @@ module DmtdVbmappData
|
|
20
20
|
# The client for which the report will be generated
|
21
21
|
attr_reader :client
|
22
22
|
|
23
|
-
# The language in which the report will be generated
|
24
|
-
attr_reader :language
|
25
|
-
|
26
23
|
# Initializes the receiver with the given options:
|
27
24
|
#
|
28
25
|
# This method does *not* block, simply creates an accessor and returns
|
29
26
|
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
# +resolver+:: See +resolver+ above
|
33
|
-
# +language+:: the language to use (i.e. 'en', 'es' or may be nil)
|
27
|
+
# @option opts [Client] :client The client for which to run the report
|
28
|
+
# @param [method] :resolver @see #resolver
|
34
29
|
def initialize(opts, &resolver)
|
35
30
|
@client = opts.fetch(:client)
|
36
31
|
@resolver = resolver
|
37
|
-
@language = opts.fetch(:language, nil)
|
38
32
|
end
|
39
33
|
|
40
|
-
# Returns the JSON for the IEP report
|
34
|
+
# Returns the JSON for the IEP report. See {https://datamtd.atlassian.net/wiki/pages/viewpage.action?pageId=19267590 /1/assessment_report/iep - GET} for the
|
41
35
|
# full format.
|
42
36
|
#
|
43
37
|
# The following transformations are made to the server JSON:
|
@@ -49,10 +43,10 @@ module DmtdVbmappData
|
|
49
43
|
# * All Condition nodes are stripped
|
50
44
|
# * All Condition_Comment nodes are stripped
|
51
45
|
#
|
52
|
-
# This method *will* block on the first access to retrieve the
|
53
|
-
#
|
46
|
+
# @note This method *will* block on the first access to retrieve the
|
47
|
+
# data from the server.
|
54
48
|
#
|
55
|
-
#
|
49
|
+
# @note The keys in the JSON hash will be symbols and *not* strings.
|
56
50
|
def iep
|
57
51
|
result = retrieve_responses_json
|
58
52
|
|
@@ -100,7 +94,7 @@ module DmtdVbmappData
|
|
100
94
|
end
|
101
95
|
|
102
96
|
def retrieve_responses_json
|
103
|
-
response = RequestHelpers::get_authorized(end_point: AssessmentReport::end_point, params: nil, client_id: @client.id, client_code: @client.code, language: language)
|
97
|
+
response = RequestHelpers::get_authorized(end_point: AssessmentReport::end_point, params: nil, client_id: @client.id, client_code: @client.code, language: client.language)
|
104
98
|
proc_response = RequestHelpers::process_json_response(response)
|
105
99
|
json = proc_response[:json]
|
106
100
|
server_response_code = proc_response[:code]
|
@@ -22,29 +22,28 @@ module DmtdVbmappData
|
|
22
22
|
|
23
23
|
# Creates a new client on the VB-MAPP Data Server
|
24
24
|
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
25
|
+
# @note The {code} may be specified as a key of the corresponding record in your database.
|
26
|
+
# This allows the client to be referred to later on via this key as opposed to the id
|
27
|
+
# generated by our system. Using this option means that your application data is not required
|
28
|
+
# to store a new id for the client, but can use your existing id (primary key).
|
29
29
|
#
|
30
|
-
# This operation blocks until it receives a response from the VB-MAPP Data Server.
|
30
|
+
# @note This operation blocks until it receives a response from the VB-MAPP Data Server.
|
31
31
|
#
|
32
|
-
# If
|
33
|
-
#
|
32
|
+
# @note If {is_valid_for_create?} returns false, then the instance will *not* be sent to the server, it is assumed to already be there.
|
33
|
+
# Otherwise it will be sent to the server.
|
34
34
|
#
|
35
|
-
#
|
36
|
-
#
|
35
|
+
# @note Language is *not* stored on the server along with the client information and thus, it must be
|
36
|
+
# specified each time the instance is created if a language other than the default is needed.
|
37
37
|
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
# +language+:: the language to use (i.e. 'en', 'es' or may be nil)
|
38
|
+
# @option opts [Date] :date_of_birth The date of birth of the client as a ruby Date object (may be nil)
|
39
|
+
# @option opts [Integer] :gender The gender of the client, either {GENDER_MALE} or {GENDER_FEMALE} (may be nil if {is_valid_for_create?})
|
40
|
+
# @option opts [String] :id The vbmapp_data server's identifier for this client (may be nil)
|
41
|
+
# @option opts [String] :organization_id The organization identifier (may be nil, if so {DmtdVbmappData.config}['organization_id'] will be used)
|
42
|
+
# @option opts [String] :code A code that can be used to refer to the client; possibly a key in the customer's database (may be nil)
|
43
|
+
# @option opts [String] :first_name The first name of the client (may be nil)
|
44
|
+
# @option opts [String] :last_name The last name of the client (may be nil)
|
45
|
+
# @option opts [String] :settings A string value that can be associated with the client (may be nil)
|
46
|
+
# @option opts [String] :language The language to use (i.e. 'en', 'es' or may be nil) @see #DmtdVbmappData.AVAILABLE_LANGUAGES
|
48
47
|
def initialize(opts)
|
49
48
|
@date_of_birth = opts.fetch(:date_of_birth, nil)
|
50
49
|
@gender = opts.fetch(:gender, nil)
|
@@ -66,34 +65,38 @@ module DmtdVbmappData
|
|
66
65
|
|
67
66
|
# Retrieves all existing clients from the VB-MAPP Data Server
|
68
67
|
#
|
69
|
-
# This operation blocks until it receives a response from the VB-MAPP Data Server.
|
68
|
+
# @note This operation *blocks* until it receives a response from the VB-MAPP Data Server.
|
70
69
|
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
# +language+:: the language to use (i.e. 'en', 'es' or may be nil)
|
70
|
+
# @option opts [String] :organization_id The organization identifier (may be nil, if so {DmtdVbmappData.config}['organization_id'] will be used)
|
71
|
+
# @option opts [String] :language The language to use (i.e. 'en', 'es' or may be nil) @see #DmtdVbmappData.AVAILABLE_LANGUAGES
|
74
72
|
#
|
75
|
-
#
|
76
|
-
# Array of DmtdVbmappData::Client instances or server http response code (integer) if an error was received
|
73
|
+
# @return [Array<Client> | Integer] http response code (integer) if an error was received
|
77
74
|
def self.retrieve_clients(opts = {})
|
78
75
|
retrieve_server_clients(opts)
|
79
76
|
end
|
80
77
|
|
81
|
-
#
|
78
|
+
# @note This method does *not* block
|
79
|
+
#
|
80
|
+
# @return [Guide]
|
82
81
|
def guide
|
83
82
|
Guide.new(client: self, language: language)
|
84
83
|
end
|
85
84
|
|
86
|
-
#
|
85
|
+
# @note This method does *not* block
|
86
|
+
#
|
87
|
+
# @return [Vbmapp]
|
87
88
|
def vbmapp
|
88
89
|
Vbmapp.new(client: self, language: language)
|
89
90
|
end
|
90
91
|
|
91
|
-
#
|
92
|
+
# @note This method does *not* block
|
93
|
+
#
|
94
|
+
# @return [AssessmentReport]
|
92
95
|
def iep_report(&resolver)
|
93
96
|
AssessmentReport.new(client: self, language: language, &resolver).iep
|
94
97
|
end
|
95
98
|
|
96
|
-
#
|
99
|
+
# @return [true | false] true if the receiver is parametrized correctly for creation on the server
|
97
100
|
def is_valid_for_create?
|
98
101
|
@id.nil? && !@date_of_birth.nil? && !@gender.nil? && !@organization_id.nil?
|
99
102
|
end
|
@@ -11,27 +11,30 @@ module DmtdVbmappData
|
|
11
11
|
#
|
12
12
|
# This method does *not* block, simply creates an accessor and returns
|
13
13
|
#
|
14
|
-
#
|
15
|
-
# +client+:: a client instance
|
14
|
+
# @option opts [Client] :client A client instance
|
16
15
|
def initialize(opts)
|
17
16
|
@client = opts.fetch(:client)
|
18
17
|
end
|
19
18
|
|
20
|
-
#
|
19
|
+
# @note The first call to this method with an expired cache will
|
20
|
+
# block until the cache is populated. All subsequent calls
|
21
|
+
# will load from the cache.
|
21
22
|
#
|
22
|
-
#
|
23
|
+
# @note The cache is an in-memory cache (not on-disc). Thus, if the process is restarted,
|
24
|
+
# the cache will be dropped. Additionally this cache expires once a day at midnight UTC.
|
23
25
|
#
|
24
|
-
#
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
26
|
+
# @return [Array<GuideChapter>] The entire set of {GuideChapter} instances
|
27
|
+
def chapters
|
28
|
+
@chapters = index.map.with_index do |chapter_json, chapter_num|
|
29
|
+
GuideChapter.new(client: client, chapter_num: chapter_num, chapter_index_json: chapter_json)
|
30
|
+
end if @chapters.nil?
|
31
|
+
|
32
|
+
@chapters
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
34
36
|
|
37
|
+
def index
|
35
38
|
expire_cache
|
36
39
|
if defined?(@@guide_cache).nil?
|
37
40
|
@@guide_cache = {
|
@@ -43,20 +46,6 @@ module DmtdVbmappData
|
|
43
46
|
@@guide_cache[:guide_index]
|
44
47
|
end
|
45
48
|
|
46
|
-
# Returns the VB-MAPP Guide chapters
|
47
|
-
#
|
48
|
-
# Note that this method calls +index+. See that method for
|
49
|
-
# its blocking characteristics.
|
50
|
-
def chapters
|
51
|
-
@chapters = index.map.with_index do |chapter_json, chapter_num|
|
52
|
-
GuideChapter.new(client: client, chapter_num: chapter_num, chapter_index_json: chapter_json)
|
53
|
-
end if @chapters.nil?
|
54
|
-
|
55
|
-
@chapters
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
49
|
def expire_cache
|
61
50
|
if defined?(@@guide_cache)
|
62
51
|
today = DateTime.now.new_offset(0).to_date
|
@@ -12,12 +12,12 @@ module DmtdVbmappData
|
|
12
12
|
|
13
13
|
# Creates an accessor for the VB-MAPP Guide Chapter on the VB-MAPP Data Server
|
14
14
|
#
|
15
|
-
# This method does *not* block, simply creates an accessor and returns
|
15
|
+
# @note This method does *not* block, simply creates an accessor and returns
|
16
16
|
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
17
|
+
# @option opts [Client] :client A client instance
|
18
|
+
# @option opts [Integer] :chapter_num The number (index 0..n) of the chapter in the Guide's index array
|
19
|
+
# @option opts [Hash] :chapter_index_json The guide index json for the chapter in the format described at
|
20
|
+
# {https://datamtd.atlassian.net/wiki/pages/viewpage.action?pageId=18710558 1/guide/index REST api - Chapter Fields}
|
21
21
|
def initialize(opts)
|
22
22
|
@client = opts.fetch(:client)
|
23
23
|
@chapter_num = opts.fetch(:chapter_num)
|
@@ -29,18 +29,18 @@ module DmtdVbmappData
|
|
29
29
|
@sections_index = index_json[:sections]
|
30
30
|
end
|
31
31
|
|
32
|
-
#
|
32
|
+
# @note This method *does* block as the content is retrieved
|
33
33
|
#
|
34
|
-
#
|
34
|
+
# @return [String] The preamble of the Guide's chapter
|
35
35
|
def chapter_preamble
|
36
36
|
@chapter_preamble = retrieve_guide_chapter[:chapterPreamble] if @chapter_preamble.nil?
|
37
37
|
|
38
38
|
@chapter_preamble
|
39
39
|
end
|
40
40
|
|
41
|
-
#
|
41
|
+
# @note This method does *not* block
|
42
42
|
#
|
43
|
-
#
|
43
|
+
# @return [Array<GuideChapterSection>] all of the the VB-MAPP Guide's {GuideChapterSection} instances
|
44
44
|
def sections
|
45
45
|
@sections = @sections_index.map.with_index { |section_index_json, section_num|
|
46
46
|
GuideChapterSection.new(client: client, chapter_num: chapter_num, section_num: section_num, section_index_json: section_index_json)
|
@@ -13,13 +13,13 @@ module DmtdVbmappData
|
|
13
13
|
|
14
14
|
# Creates an accessor for the VB-MAPP Guide Chapter Section on the VB-MAPP Data Server
|
15
15
|
#
|
16
|
-
# This method does *not* block, simply creates an accessor and returns
|
16
|
+
# @note This method does *not* block, simply creates an accessor and returns
|
17
17
|
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
18
|
+
# @option opts [Client] :client A client instance
|
19
|
+
# @option opts [Integer] :chapter_num The number (index 0..n) of the chapter in the Guide's index array
|
20
|
+
# @option opts [Integer] :section_num The number (index 0..n) of the section in the chapter's sections array
|
21
|
+
# @option opts [Hash] :section_index_json The guide index json for the chapter section in the format described at
|
22
|
+
# {https://datamtd.atlassian.net/wiki/pages/viewpage.action?pageId=18710558 1/guide/index REST api - Section Fields}
|
23
23
|
def initialize(opts)
|
24
24
|
@client = opts.fetch(:client)
|
25
25
|
@chapter_num = opts.fetch(:chapter_num)
|
@@ -31,16 +31,18 @@ module DmtdVbmappData
|
|
31
31
|
@sub_sections_index = index_json[:subSections]
|
32
32
|
end
|
33
33
|
|
34
|
-
#
|
34
|
+
# @note This method *does* block as the content is retrieved
|
35
35
|
#
|
36
|
-
#
|
36
|
+
# @return [String] The content of the Guide's chapter section
|
37
37
|
def section_content
|
38
38
|
@section_content = retrieve_guide_section[:sectionContent] if @section_content.nil?
|
39
39
|
|
40
40
|
@section_content
|
41
41
|
end
|
42
42
|
|
43
|
-
#
|
43
|
+
# @note This method does *not* block
|
44
|
+
#
|
45
|
+
# @return [Array<GuideSectionSubSection>] The VB-MAPP Guide section's sub_sections
|
44
46
|
def sub_sections
|
45
47
|
@sub_sections = @sub_sections_index.map.with_index do |sub_section_index_json, sub_section_num|
|
46
48
|
GuideSectionSubSection.new(client: client, chapter_num: chapter_num, section_num: section_num, sub_section_num: sub_section_num, sub_section_index_json: sub_section_index_json)
|
@@ -14,14 +14,14 @@ module DmtdVbmappData
|
|
14
14
|
|
15
15
|
# Creates an accessor for the VB-MAPP Guide Chapter Section on the VB-MAPP Data Server
|
16
16
|
#
|
17
|
-
# This method does *not* block, simply creates an accessor and returns
|
17
|
+
# @note This method does *not* block, simply creates an accessor and returns
|
18
18
|
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
19
|
+
# @option opts [Client] :client A client instance
|
20
|
+
# @option opts [Integer] :chapter_num The number (index 0..n) of the chapter in the Guide's index array
|
21
|
+
# @option opts [Integer] :section_num The number (index 0..n) of the section in the chapter's sections array
|
22
|
+
# @option opts [Integer] :sub_section_num The number (index 0..n) of the subSection in section's subSections array
|
23
|
+
# @option opts [Hash] :sub_section_index_json The guide index json for the subSection in the format described at
|
24
|
+
# {https://datamtd.atlassian.net/wiki/pages/viewpage.action?pageId=18710558 1/guide/index REST api - SubSection Fields}
|
25
25
|
def initialize(opts)
|
26
26
|
@client = opts.fetch(:client)
|
27
27
|
@chapter_num = opts.fetch(:chapter_num)
|
@@ -33,9 +33,9 @@ module DmtdVbmappData
|
|
33
33
|
@section_short_title = sub_section_index_json[:sectionShortTitle]
|
34
34
|
end
|
35
35
|
|
36
|
-
#
|
36
|
+
# @note This method *does* block as the content is retrieved
|
37
37
|
#
|
38
|
-
#
|
38
|
+
# @return [String] The content of the Guide's sub section
|
39
39
|
def section_content
|
40
40
|
retrieve_guide_sub_section[:sectionContent]
|
41
41
|
end
|
@@ -9,44 +9,53 @@ module DmtdVbmappData
|
|
9
9
|
|
10
10
|
# Creates an accessor for the VB-MAPP content on the VB-MAPP Data Server
|
11
11
|
#
|
12
|
-
# This method does *not* block, simply creates an accessor and returns
|
12
|
+
# @note This method does *not* block, simply creates an accessor and returns
|
13
13
|
#
|
14
|
-
#
|
15
|
-
# +client+:: a client instance
|
14
|
+
# @option opts [Client] :client A client instance
|
16
15
|
def initialize(opts)
|
17
16
|
@client = opts.fetch(:client)
|
18
17
|
end
|
19
18
|
|
20
|
-
#
|
19
|
+
# @note The first call to this method with an expired cache will
|
20
|
+
# block until the cache is populated. All subsequent calls
|
21
|
+
# will load from the cache.
|
21
22
|
#
|
22
|
-
#
|
23
|
+
# @note The cache is an in-memory cache (not on-disc). Thus, if the process is restarted,
|
24
|
+
# the cache will be dropped. Additionally this cache expires once a day at midnight UTC.
|
23
25
|
#
|
24
|
-
#
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
# @return [Array<VbmappArea>] The entire set of {VbmappArea} instances
|
27
|
+
def areas
|
28
|
+
@areas = index.map do |area_index_json|
|
29
|
+
VbmappArea.new(client: client, area_index_json: area_index_json)
|
30
|
+
end if @areas.nil?
|
31
|
+
|
32
|
+
@areas
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
30
37
|
def index
|
31
|
-
|
32
|
-
|
38
|
+
|
39
|
+
expire_cache
|
40
|
+
if defined?(@@vbmapp_index_cache).nil?
|
41
|
+
@@vbmapp_index_cache = {
|
42
|
+
datestamp: DateTime.now.new_offset(0).to_date,
|
43
|
+
vbmapp_index: retrieve_vbmapp_index
|
44
|
+
}
|
33
45
|
end
|
34
46
|
|
35
|
-
|
47
|
+
@@vbmapp_index_cache[:vbmapp_index]
|
36
48
|
end
|
37
49
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
def areas
|
43
|
-
@areas = index.map {|area_index_json| VbmappArea.new(client: client, area_index_json: area_index_json)} if @areas.nil?
|
50
|
+
def expire_cache
|
51
|
+
if defined?(@@vbmapp_index_cache)
|
52
|
+
today = DateTime.now.new_offset(0).to_date
|
53
|
+
cache_day = @@vbmapp_index_cache[:datestamp]
|
44
54
|
|
45
|
-
|
55
|
+
@@vbmapp_index_cache = nil unless cache_day == today
|
56
|
+
end
|
46
57
|
end
|
47
58
|
|
48
|
-
private
|
49
|
-
|
50
59
|
def self.end_point
|
51
60
|
'1/vbmapp/index'
|
52
61
|
end
|
@@ -10,11 +10,11 @@ module DmtdVbmappData
|
|
10
10
|
|
11
11
|
# Creates an accessor for the VB-MAPP Guide Chapter on the VB-MAPP Data Server
|
12
12
|
#
|
13
|
-
# This method does *not* block, simply creates an accessor and returns
|
13
|
+
# @note This method does *not* block, simply creates an accessor and returns
|
14
14
|
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
15
|
+
# @option opts [Client] :client A client instance
|
16
|
+
# @option opts [Hash] :area_index_json The vbmapp area index json for the VB-Mapp Area in the format described at
|
17
|
+
# {https://datamtd.atlassian.net/wiki/pages/viewpage.action?pageId=18710543 /1/vbmapp/index - GET REST api - Area Fields}
|
18
18
|
def initialize(opts)
|
19
19
|
@client = opts.fetch(:client)
|
20
20
|
|
@@ -23,9 +23,9 @@ module DmtdVbmappData
|
|
23
23
|
@groups_index = index_json[:groups]
|
24
24
|
end
|
25
25
|
|
26
|
-
#
|
26
|
+
# @note This method does *not* block on server access
|
27
27
|
#
|
28
|
-
#
|
28
|
+
# @return [Array<VbmappAreaGroup>] all of the VB-Mapp's {VbmappAreaGroup} instances
|
29
29
|
def groups
|
30
30
|
@groups = @groups_index.map.with_index { |group_index_json, group_num|
|
31
31
|
VbmappAreaGroup.new(client: client, area: area, group_index_json: group_index_json)
|
@@ -34,40 +34,6 @@ module DmtdVbmappData
|
|
34
34
|
@groups
|
35
35
|
end
|
36
36
|
|
37
|
-
# Returns the possible responses for all questions of this area
|
38
|
-
#
|
39
|
-
# This method *will* block on the first access to retrieve the
|
40
|
-
# data from the server
|
41
|
-
def responses
|
42
|
-
if @responses.nil?
|
43
|
-
responses_json = retrieve_responses_json || []
|
44
|
-
@responses = responses_json.map { |response_json| VbmappAreaResponse.new(area: area, response_json: response_json) }
|
45
|
-
end
|
46
|
-
|
47
|
-
@responses
|
48
|
-
end
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
def self.end_point
|
53
|
-
'1/vbmapp/area_responses'
|
54
|
-
end
|
55
|
-
|
56
|
-
def retrieve_responses_json
|
57
|
-
params = {
|
58
|
-
area: area
|
59
|
-
}
|
60
|
-
response = RequestHelpers::get_authorized(end_point: VbmappArea::end_point, params: params, client_id: @client.id, client_code: @client.code, language: client.language)
|
61
|
-
proc_response = RequestHelpers::process_json_response(response)
|
62
|
-
json = proc_response[:json]
|
63
|
-
server_response_code = proc_response[:code]
|
64
|
-
|
65
|
-
result = json
|
66
|
-
result = server_response_code if json.nil?
|
67
|
-
|
68
|
-
result
|
69
|
-
end
|
70
|
-
|
71
37
|
end
|
72
38
|
|
73
39
|
end
|
@@ -11,12 +11,12 @@ module DmtdVbmappData
|
|
11
11
|
|
12
12
|
# Creates an accessor for the VB-MAPP Area Group on the VB-MAPP Data Server
|
13
13
|
#
|
14
|
-
# This method does *not* block, simply creates an accessor and returns
|
14
|
+
# @note This method does *not* block, simply creates an accessor and returns
|
15
15
|
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
16
|
+
# @option opts [Client] :client A client instance
|
17
|
+
# @option opts [String] :area The vbmapp area of the group ('milestones', 'barriers', 'transitions', 'eesa')
|
18
|
+
# @option opts [Hash] :group_index_json The vbmapp index json for the group in the format described at
|
19
|
+
# {https://datamtd.atlassian.net/wiki/pages/viewpage.action?pageId=18710543 /1/vbmapp/index - GET REST api - Group Fields}
|
20
20
|
def initialize(opts)
|
21
21
|
@client = opts.fetch(:client)
|
22
22
|
@area = opts.fetch(:area)
|
@@ -27,26 +27,23 @@ module DmtdVbmappData
|
|
27
27
|
@levels = index_json[:levels]
|
28
28
|
end
|
29
29
|
|
30
|
-
#
|
30
|
+
# @note This method *does* block as the content is retrieved
|
31
31
|
#
|
32
|
-
#
|
32
|
+
# @option opts [String | Symbol] :level Filters the questions to the given level (may be null)
|
33
33
|
#
|
34
|
-
#
|
34
|
+
# @return [Array<VbmappAreaQuestion>] all of the area group's {VbmappAreaQuestion} instances
|
35
35
|
def questions(opts = {})
|
36
36
|
level_name = opts.fetch(:level, nil)
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
@questions = questions_json.map {|question_json|
|
42
|
-
VbmappAreaQuestion.new(client: client, area: area, group: group, question_json: question_json)
|
43
|
-
}
|
44
|
-
end
|
38
|
+
@questions = retrieve_questions_json.map do |question_json|
|
39
|
+
VbmappAreaQuestion.new(client: client, area: area, group: group, question_json: question_json)
|
40
|
+
end if @questions.nil?
|
45
41
|
|
46
42
|
if level_name.nil?
|
47
43
|
result = @questions
|
48
44
|
else
|
49
|
-
|
45
|
+
level_str = level_name.to_s
|
46
|
+
level_desc = @levels.select {|level| level[:level].to_s == level_str}[0]
|
50
47
|
start_num = level_desc[:start_question_num] + 1 # question_number is 1-based
|
51
48
|
end_num = start_num + level_desc[:question_count]
|
52
49
|
|
@@ -56,13 +53,11 @@ module DmtdVbmappData
|
|
56
53
|
result
|
57
54
|
end
|
58
55
|
|
59
|
-
#
|
56
|
+
# @note This method does *not* block
|
57
|
+
#
|
58
|
+
# @return [Symbol] all of the area group's levels
|
60
59
|
def levels
|
61
|
-
@levels
|
62
|
-
VbmappAreaLevel.new(client: client, area: area, group: section_num, sub_section_num: sub_section_num)
|
63
|
-
} if @levels.nil?
|
64
|
-
|
65
|
-
@levels
|
60
|
+
@levels.map {|level_json| level_json[:level].to_sym }
|
66
61
|
end
|
67
62
|
|
68
63
|
private
|
@@ -15,13 +15,13 @@ module DmtdVbmappData
|
|
15
15
|
|
16
16
|
# Creates an accessor for the VB-MAPP Area Question on the VB-MAPP Data Server
|
17
17
|
#
|
18
|
-
# This method does *not* block, simply creates an accessor and returns
|
18
|
+
# @note This method does *not* block, simply creates an accessor and returns
|
19
19
|
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
20
|
+
# @option opts [Client] :client A client instance
|
21
|
+
# @option opts [String] :area The vbmapp area of the group ('milestones', 'barriers', 'transitions', 'eesa')
|
22
|
+
# @option opts [String] :group The vbmapp area group name (i.e. 'mand', 'tact', 'group1', etc.)
|
23
|
+
# @option opts [Hash] :question_json The vbmapp question json for the question in the format described at
|
24
|
+
# {https://datamtd.atlassian.net/wiki/pages/viewpage.action?pageId=18710549 /1/vbmapp/area_question - GET REST api - Fields}
|
25
25
|
def initialize(opts)
|
26
26
|
@client = opts.fetch(:client)
|
27
27
|
@area = opts.fetch(:area)
|
@@ -36,7 +36,9 @@ module DmtdVbmappData
|
|
36
36
|
@responses_json_array = question_json[:responses]
|
37
37
|
end
|
38
38
|
|
39
|
-
#
|
39
|
+
# @note This method does *not* block.
|
40
|
+
#
|
41
|
+
# @return [Array<VbmappAreaResponse>] all of the VB-MAPP question's possible responses
|
40
42
|
def responses
|
41
43
|
if @responses.nil?
|
42
44
|
|
@@ -48,12 +50,6 @@ module DmtdVbmappData
|
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
51
|
-
# @levels = @levels.map { |sub_section_num|
|
52
|
-
# GuideSectionSubSection.new(client: client, chapter_num: chapter_num, section_num: section_num, sub_section_num: sub_section_num)
|
53
|
-
# } if @levels.nil?
|
54
|
-
#
|
55
|
-
# @levels
|
56
|
-
|
57
53
|
@responses
|
58
54
|
end
|
59
55
|
|
@@ -12,11 +12,12 @@ module DmtdVbmappData
|
|
12
12
|
|
13
13
|
# Creates an accessor for the VB-MAPP Area Question on the VB-MAPP Data Server
|
14
14
|
#
|
15
|
-
# This method does *not* block, simply creates an accessor and returns
|
15
|
+
# @note This method does *not* block, simply creates an accessor and returns
|
16
16
|
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
17
|
+
# @option opts [Client] :client A client instance
|
18
|
+
# @option opts [String] :area The vbmapp area of the group ('milestones', 'barriers', 'transitions', 'eesa')
|
19
|
+
# @option opts [Hash] :response_json The vbmapp question json for the question in the format described at
|
20
|
+
# {https://datamtd.atlassian.net/wiki/pages/viewpage.action?pageId=18710549 /1/vbmapp/area_question - GET REST api - response}
|
20
21
|
def initialize(opts)
|
21
22
|
@area = opts.fetch(:area)
|
22
23
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dmtd_vbmapp_data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Hunt
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: psych
|
@@ -152,3 +152,4 @@ signing_key:
|
|
152
152
|
specification_version: 4
|
153
153
|
summary: Ruby gem to simplify access to DMTD's VB-MAPP REST service
|
154
154
|
test_files: []
|
155
|
+
has_rdoc:
|