verso 0.0.1
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.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/LICENSE.md +20 -0
- data/README.md +75 -0
- data/Rakefile +1 -0
- data/lib/verso.rb +33 -0
- data/lib/verso/cluster.rb +43 -0
- data/lib/verso/cluster_list.rb +19 -0
- data/lib/verso/correlation_list.rb +53 -0
- data/lib/verso/course.rb +84 -0
- data/lib/verso/course_list.rb +36 -0
- data/lib/verso/credential.rb +34 -0
- data/lib/verso/credential_list.rb +28 -0
- data/lib/verso/duty_area.rb +17 -0
- data/lib/verso/edition_list.rb +19 -0
- data/lib/verso/emphasis.rb +21 -0
- data/lib/verso/emphasis_list.rb +19 -0
- data/lib/verso/examination_list.rb +21 -0
- data/lib/verso/extra.rb +38 -0
- data/lib/verso/extras_list.rb +22 -0
- data/lib/verso/frontmatter.rb +18 -0
- data/lib/verso/http_get.rb +9 -0
- data/lib/verso/occupation.rb +25 -0
- data/lib/verso/occupation_data.rb +31 -0
- data/lib/verso/occupation_list.rb +32 -0
- data/lib/verso/pathway.rb +25 -0
- data/lib/verso/program_area.rb +39 -0
- data/lib/verso/program_area_list.rb +20 -0
- data/lib/verso/sol_correlation_list.rb +53 -0
- data/lib/verso/standard.rb +37 -0
- data/lib/verso/standards_list.rb +49 -0
- data/lib/verso/task.rb +30 -0
- data/lib/verso/task_list.rb +31 -0
- data/lib/verso/version.rb +3 -0
- data/spec/cluster_list_spec.rb +12 -0
- data/spec/cluster_spec.rb +18 -0
- data/spec/correlation_list_spec.rb +55 -0
- data/spec/course_list_spec.rb +36 -0
- data/spec/course_spec.rb +193 -0
- data/spec/credential_list_spec.rb +75 -0
- data/spec/credential_spec.rb +34 -0
- data/spec/duty_area_spec.rb +27 -0
- data/spec/edition_list_spec.rb +11 -0
- data/spec/emphasis_list_spec.rb +21 -0
- data/spec/emphasis_spec.rb +31 -0
- data/spec/examination_list_spec.rb +29 -0
- data/spec/extra_spec.rb +36 -0
- data/spec/extras_list_spec.rb +25 -0
- data/spec/frontmatter_spec.rb +11 -0
- data/spec/occupation_data_spec.rb +24 -0
- data/spec/occupation_list_spec.rb +21 -0
- data/spec/occupation_spec.rb +41 -0
- data/spec/pathway_spec.rb +41 -0
- data/spec/program_area_list_spec.rb +11 -0
- data/spec/program_area_spec.rb +39 -0
- data/spec/sol_correlation_list_spec.rb +74 -0
- data/spec/spec_helper.rb +23 -0
- data/spec/standard_spec.rb +53 -0
- data/spec/standards_list_spec.rb +51 -0
- data/spec/task_list_spec.rb +72 -0
- data/spec/task_spec.rb +55 -0
- data/verso.gemspec +25 -0
- metadata +189 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
module Verso
|
2
|
+
class DutyArea
|
3
|
+
attr_reader :title, :context
|
4
|
+
|
5
|
+
def initialize(raw_da, context)
|
6
|
+
@context = context
|
7
|
+
@title = raw_da["title"]
|
8
|
+
@raw_tasks = raw_da["tasks"]
|
9
|
+
end
|
10
|
+
|
11
|
+
def tasks
|
12
|
+
@tasks ||= @raw_tasks.collect do |t|
|
13
|
+
Task.new(t.merge("code" => context.code, "edition" => context.edition))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Verso
|
2
|
+
class EditionList
|
3
|
+
include Enumerable
|
4
|
+
include HTTPGet
|
5
|
+
|
6
|
+
def editions
|
7
|
+
@editions ||= JSON.parse(http_get('/editions/'))["editions"].
|
8
|
+
collect { |e| OpenStruct.new(e) }
|
9
|
+
end
|
10
|
+
|
11
|
+
def each &block
|
12
|
+
editions.each &block
|
13
|
+
end
|
14
|
+
|
15
|
+
def last
|
16
|
+
editions[-1]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Verso
|
2
|
+
class Emphasis
|
3
|
+
include HTTPGet
|
4
|
+
|
5
|
+
def initialize(raw_emphasis)
|
6
|
+
@raw_emphasis = raw_emphasis
|
7
|
+
end
|
8
|
+
|
9
|
+
def method_missing(mname)
|
10
|
+
if !@raw_emphasis.has_key?(mname.to_s)
|
11
|
+
@raw_emphasis = JSON.parse(http_get("/academics/#{id}"))["emphasis"]
|
12
|
+
end
|
13
|
+
@raw_emphasis[mname.to_s]
|
14
|
+
end
|
15
|
+
|
16
|
+
def occupation_data
|
17
|
+
@occupation_data ||= method_missing(:occupation_data).
|
18
|
+
collect { |od| OccupationData.new(od) }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Verso
|
2
|
+
class EmphasisList
|
3
|
+
include Enumerable
|
4
|
+
include HTTPGet
|
5
|
+
|
6
|
+
def emphases
|
7
|
+
@emphases ||= JSON.parse(http_get('/academics/'))["emphases"].
|
8
|
+
collect { |em| Emphasis.new(em) }
|
9
|
+
end
|
10
|
+
|
11
|
+
def each &block
|
12
|
+
emphases.each &block
|
13
|
+
end
|
14
|
+
|
15
|
+
def last
|
16
|
+
emphases[-1]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Verso
|
2
|
+
class ExaminationList
|
3
|
+
include Enumerable
|
4
|
+
include HTTPGet
|
5
|
+
|
6
|
+
attr_reader :examinations
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@examinations = JSON.parse(http_get("/examinations/"))["examinations"].
|
10
|
+
collect { |e| OpenStruct.new(e) }
|
11
|
+
end
|
12
|
+
|
13
|
+
def each &block
|
14
|
+
examinations.each &block
|
15
|
+
end
|
16
|
+
|
17
|
+
def last
|
18
|
+
examinations[-1]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/verso/extra.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
module Verso
|
2
|
+
class Extra
|
3
|
+
include HTTPGet
|
4
|
+
|
5
|
+
def initialize(raw_extra)
|
6
|
+
@raw_extra = raw_extra
|
7
|
+
end
|
8
|
+
|
9
|
+
def code
|
10
|
+
@raw_extra["code"]
|
11
|
+
end
|
12
|
+
|
13
|
+
def edition
|
14
|
+
@raw_extra["edition"]
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
def name
|
19
|
+
@raw_extra["name"]
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def title
|
24
|
+
@raw_extra["title"]
|
25
|
+
end
|
26
|
+
|
27
|
+
def description
|
28
|
+
if @raw_extra["description"].nil?
|
29
|
+
@raw_extra.merge!(
|
30
|
+
JSON.parse(
|
31
|
+
http_get("/courses/#{code},#{edition}/extras/#{name}")
|
32
|
+
)["extra"]
|
33
|
+
)
|
34
|
+
end
|
35
|
+
@raw_extra["description"]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Verso
|
2
|
+
class ExtrasList
|
3
|
+
attr_reader :code, :edition
|
4
|
+
include Enumerable
|
5
|
+
include HTTPGet
|
6
|
+
|
7
|
+
def initialize(opts)
|
8
|
+
@code, @edition = opts[:code], opts[:edition]
|
9
|
+
end
|
10
|
+
|
11
|
+
def extras
|
12
|
+
@extras ||= JSON.parse(
|
13
|
+
http_get("/courses/#{code},#{edition}/extras/")
|
14
|
+
)["extras"].
|
15
|
+
collect { |e| Extra.new(e.merge("code" => code, "edition" => edition)) }
|
16
|
+
end
|
17
|
+
|
18
|
+
def each &block
|
19
|
+
extras.each &block
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Verso
|
2
|
+
class Frontmatter
|
3
|
+
include HTTPGet
|
4
|
+
|
5
|
+
def initialize(opts)
|
6
|
+
@raw_frontmatter = opts
|
7
|
+
end
|
8
|
+
|
9
|
+
def method_missing(mname)
|
10
|
+
if !@raw_frontmatter.has_key?(mname.to_s)
|
11
|
+
@raw_frontmatter = JSON.parse(
|
12
|
+
http_get("/courses/#{@raw_frontmatter['code']},#{@raw_frontmatter['edition']}/frontmatter")
|
13
|
+
)["frontmatter"]
|
14
|
+
end
|
15
|
+
@raw_frontmatter[mname.to_s]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Verso
|
2
|
+
class Occupation
|
3
|
+
include HTTPGet
|
4
|
+
|
5
|
+
def initialize(raw_occupation)
|
6
|
+
@raw_occupation = raw_occupation
|
7
|
+
end
|
8
|
+
|
9
|
+
def method_missing(mname)
|
10
|
+
if @raw_occupation[mname.to_s].nil?
|
11
|
+
@raw_occupation = JSON.parse(http_get("/occupations/#{id}"))["occupation"]
|
12
|
+
end
|
13
|
+
@raw_occupation[mname.to_s]
|
14
|
+
end
|
15
|
+
|
16
|
+
def related_courses
|
17
|
+
@related_courses ||= method_missing(:related_courses).
|
18
|
+
collect { |c| Course.new(c) }
|
19
|
+
end
|
20
|
+
|
21
|
+
def pathway
|
22
|
+
@pathway ||= Pathway.new(method_missing(:pathway))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Verso
|
2
|
+
class OccupationData
|
3
|
+
def initialize(od)
|
4
|
+
@raw_od = od
|
5
|
+
end
|
6
|
+
|
7
|
+
def cluster
|
8
|
+
@cluster ||= Cluster.new(@raw_od["cluster"])
|
9
|
+
end
|
10
|
+
|
11
|
+
def pathway
|
12
|
+
@pathway ||= Pathway.new(@raw_od["pathway"])
|
13
|
+
end
|
14
|
+
|
15
|
+
def occupations
|
16
|
+
@occupations ||= @raw_od["occupations"].
|
17
|
+
collect { |o| Occupation.new(o) }
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.find_by_slugs(cslug, pslug, slug)
|
21
|
+
cluster = ClusterList.new.find { |c| c.title.parameterize == cslug }
|
22
|
+
pathway = cluster.pathways.find { |p| p.title.parameterize == pslug }
|
23
|
+
occupation = pathway.occupations.find { |o| o.title.parameterize == slug }
|
24
|
+
OccupationData.new(
|
25
|
+
{ "cluster" => { "title" => cluster.title },
|
26
|
+
"pathway" => { "title" => pathway.title },
|
27
|
+
"occupations" => [{ "title" => occupation.title }] }
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Verso
|
2
|
+
class OccupationList
|
3
|
+
include Enumerable
|
4
|
+
include HTTPGet
|
5
|
+
|
6
|
+
def initialize(raw_query={})
|
7
|
+
@q_uri = Addressable::URI.new(
|
8
|
+
:path => '/occupations',
|
9
|
+
:query_values => raw_query
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
def occupations
|
14
|
+
@occupations ||= JSON.
|
15
|
+
parse(http_get(@q_uri.request_uri))["occupation_data"].
|
16
|
+
collect { |o| OccupationData.new(o) }.
|
17
|
+
sort_by { |o| [o.cluster.title, o.pathway.title] }
|
18
|
+
end
|
19
|
+
|
20
|
+
def each &block
|
21
|
+
occupations.each &block
|
22
|
+
end
|
23
|
+
|
24
|
+
def last
|
25
|
+
occupations[-1]
|
26
|
+
end
|
27
|
+
|
28
|
+
def empty?
|
29
|
+
occupations.empty?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Verso
|
2
|
+
class Pathway
|
3
|
+
include HTTPGet
|
4
|
+
|
5
|
+
def initialize(raw_pathway)
|
6
|
+
@raw_pathway = raw_pathway
|
7
|
+
end
|
8
|
+
|
9
|
+
def method_missing(mname)
|
10
|
+
if @raw_pathway[mname.to_s].nil?
|
11
|
+
@raw_pathway = JSON.parse(http_get("/pathways/#{id}"))["pathway"]
|
12
|
+
end
|
13
|
+
@raw_pathway[mname.to_s]
|
14
|
+
end
|
15
|
+
|
16
|
+
def occupations
|
17
|
+
@occupations ||= method_missing(:occupations).
|
18
|
+
collect { |o| Occupation.new(o) }
|
19
|
+
end
|
20
|
+
|
21
|
+
def cluster
|
22
|
+
@cluster ||= Cluster.new(method_missing(:cluster))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Verso
|
2
|
+
class ProgramArea
|
3
|
+
include HTTPGet
|
4
|
+
|
5
|
+
def initialize(raw_category)
|
6
|
+
@raw_program_area = raw_category
|
7
|
+
end
|
8
|
+
|
9
|
+
def method_missing(mname)
|
10
|
+
if @raw_program_area[mname.to_s].nil?
|
11
|
+
@raw_program_area.merge!(
|
12
|
+
JSON.parse(http_get("/program_areas/"))["program_areas"].
|
13
|
+
find { |c| c["title"] == @raw_program_area["title"] }
|
14
|
+
)
|
15
|
+
end
|
16
|
+
@raw_program_area[mname.to_s]
|
17
|
+
end
|
18
|
+
|
19
|
+
def description
|
20
|
+
""
|
21
|
+
end
|
22
|
+
|
23
|
+
def courses
|
24
|
+
@courses ||= CourseList.new(:program_area => slug.gsub('-', ' ')).
|
25
|
+
sort_by { |c| c.title + c.edition }.
|
26
|
+
uniq { |c| c.code + c.edition }
|
27
|
+
end
|
28
|
+
|
29
|
+
def slug
|
30
|
+
# swiped from ActiveSupport::Inflector
|
31
|
+
parameterized_string = @raw_program_area["title"].dup
|
32
|
+
parameterized_string.gsub!(/[^a-z0-9\-_]+/i, '-')
|
33
|
+
re_sep = Regexp.escape('-')
|
34
|
+
parameterized_string.gsub!(/#{re_sep}{2,}/, '-')
|
35
|
+
parameterized_string.gsub!(/^#{re_sep}|#{re_sep}$/i, '')
|
36
|
+
parameterized_string.downcase
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Verso
|
2
|
+
class ProgramAreaList
|
3
|
+
include Enumerable
|
4
|
+
include HTTPGet
|
5
|
+
|
6
|
+
def program_areas
|
7
|
+
@program_areas ||= JSON.parse(
|
8
|
+
http_get('/program_areas/')
|
9
|
+
)["program_areas"].collect { |pa| ProgramArea.new(pa) }
|
10
|
+
end
|
11
|
+
|
12
|
+
def each &block
|
13
|
+
program_areas.each &block
|
14
|
+
end
|
15
|
+
|
16
|
+
def last
|
17
|
+
program_areas[-1]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Verso
|
2
|
+
class SOLCorrelationList
|
3
|
+
include Enumerable
|
4
|
+
include HTTPGet
|
5
|
+
|
6
|
+
def initialize(context)
|
7
|
+
@context = context
|
8
|
+
end
|
9
|
+
|
10
|
+
def code
|
11
|
+
@context.code
|
12
|
+
end
|
13
|
+
|
14
|
+
def edition
|
15
|
+
@context.edition
|
16
|
+
end
|
17
|
+
|
18
|
+
def tasklist
|
19
|
+
@context.duty_areas
|
20
|
+
end
|
21
|
+
|
22
|
+
def sol_names
|
23
|
+
@sol_names ||= @context.standards.sols.collect { |s| s.name }
|
24
|
+
end
|
25
|
+
|
26
|
+
def correlations
|
27
|
+
@correlations ||= sol_names.collect do |name|
|
28
|
+
JSON.parse(
|
29
|
+
http_get("/courses/#{code},#{edition}/standards/#{name}/correlations")
|
30
|
+
)["correlations"]
|
31
|
+
end.flatten
|
32
|
+
end
|
33
|
+
|
34
|
+
def each &block
|
35
|
+
count = 0
|
36
|
+
tasklist.each do |da|
|
37
|
+
da.tasks.each do |task|
|
38
|
+
count += 1
|
39
|
+
related = correlations.find_all { |c| c["id"] == task.id }
|
40
|
+
if related.empty?
|
41
|
+
next
|
42
|
+
else
|
43
|
+
related[1,related.count].each do |c|
|
44
|
+
related.first["goals"].merge!(c["goals"])
|
45
|
+
end
|
46
|
+
related.first["number"] = count
|
47
|
+
yield Task.new(related.first)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Verso
|
2
|
+
class Standard
|
3
|
+
include HTTPGet
|
4
|
+
|
5
|
+
def initialize(raw_standard, context=nil)
|
6
|
+
@raw_standard = raw_standard
|
7
|
+
@context = context
|
8
|
+
end
|
9
|
+
|
10
|
+
def method_missing(mname)
|
11
|
+
if !@raw_standard.has_key?(mname.to_s)
|
12
|
+
@raw_standard.merge!(JSON.parse(
|
13
|
+
http_get("/courses/#{code},#{edition}/standards/#{name}")
|
14
|
+
)["standard"])
|
15
|
+
end
|
16
|
+
@raw_standard[mname.to_s]
|
17
|
+
end
|
18
|
+
|
19
|
+
def code
|
20
|
+
@context && @context.code
|
21
|
+
end
|
22
|
+
|
23
|
+
def edition
|
24
|
+
@context && @context.edition
|
25
|
+
end
|
26
|
+
|
27
|
+
def sections
|
28
|
+
@sections ||= method_missing(:sections).
|
29
|
+
collect { |raw_section| Standard.new(raw_section, @context) }
|
30
|
+
end
|
31
|
+
|
32
|
+
def goals
|
33
|
+
@goals ||= method_missing(:goals).
|
34
|
+
collect { |raw_standard| OpenStruct.new(raw_standard) }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|