verso 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/.gitignore +5 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.md +20 -0
  4. data/README.md +75 -0
  5. data/Rakefile +1 -0
  6. data/lib/verso.rb +33 -0
  7. data/lib/verso/cluster.rb +43 -0
  8. data/lib/verso/cluster_list.rb +19 -0
  9. data/lib/verso/correlation_list.rb +53 -0
  10. data/lib/verso/course.rb +84 -0
  11. data/lib/verso/course_list.rb +36 -0
  12. data/lib/verso/credential.rb +34 -0
  13. data/lib/verso/credential_list.rb +28 -0
  14. data/lib/verso/duty_area.rb +17 -0
  15. data/lib/verso/edition_list.rb +19 -0
  16. data/lib/verso/emphasis.rb +21 -0
  17. data/lib/verso/emphasis_list.rb +19 -0
  18. data/lib/verso/examination_list.rb +21 -0
  19. data/lib/verso/extra.rb +38 -0
  20. data/lib/verso/extras_list.rb +22 -0
  21. data/lib/verso/frontmatter.rb +18 -0
  22. data/lib/verso/http_get.rb +9 -0
  23. data/lib/verso/occupation.rb +25 -0
  24. data/lib/verso/occupation_data.rb +31 -0
  25. data/lib/verso/occupation_list.rb +32 -0
  26. data/lib/verso/pathway.rb +25 -0
  27. data/lib/verso/program_area.rb +39 -0
  28. data/lib/verso/program_area_list.rb +20 -0
  29. data/lib/verso/sol_correlation_list.rb +53 -0
  30. data/lib/verso/standard.rb +37 -0
  31. data/lib/verso/standards_list.rb +49 -0
  32. data/lib/verso/task.rb +30 -0
  33. data/lib/verso/task_list.rb +31 -0
  34. data/lib/verso/version.rb +3 -0
  35. data/spec/cluster_list_spec.rb +12 -0
  36. data/spec/cluster_spec.rb +18 -0
  37. data/spec/correlation_list_spec.rb +55 -0
  38. data/spec/course_list_spec.rb +36 -0
  39. data/spec/course_spec.rb +193 -0
  40. data/spec/credential_list_spec.rb +75 -0
  41. data/spec/credential_spec.rb +34 -0
  42. data/spec/duty_area_spec.rb +27 -0
  43. data/spec/edition_list_spec.rb +11 -0
  44. data/spec/emphasis_list_spec.rb +21 -0
  45. data/spec/emphasis_spec.rb +31 -0
  46. data/spec/examination_list_spec.rb +29 -0
  47. data/spec/extra_spec.rb +36 -0
  48. data/spec/extras_list_spec.rb +25 -0
  49. data/spec/frontmatter_spec.rb +11 -0
  50. data/spec/occupation_data_spec.rb +24 -0
  51. data/spec/occupation_list_spec.rb +21 -0
  52. data/spec/occupation_spec.rb +41 -0
  53. data/spec/pathway_spec.rb +41 -0
  54. data/spec/program_area_list_spec.rb +11 -0
  55. data/spec/program_area_spec.rb +39 -0
  56. data/spec/sol_correlation_list_spec.rb +74 -0
  57. data/spec/spec_helper.rb +23 -0
  58. data/spec/standard_spec.rb +53 -0
  59. data/spec/standards_list_spec.rb +51 -0
  60. data/spec/task_list_spec.rb +72 -0
  61. data/spec/task_spec.rb +55 -0
  62. data/verso.gemspec +25 -0
  63. metadata +189 -0
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe Verso::Credential do
4
+ before do
5
+ @credential = Verso::Credential.new("id" => 880)
6
+ Net::HTTP.stub(:get).and_return(
7
+ JSON.pretty_generate(
8
+ :credential => { :id => 880, :title => "Computer Programming (NOCTI)",
9
+ :source => { :title => "National Occupational" },
10
+ :details => nil,
11
+ :related_courses => [{ :code => '6641' }] }
12
+ )
13
+ )
14
+ end
15
+ it 'responds to #id' do
16
+ @credential.id.should eq(880)
17
+ end
18
+
19
+ it 'responds to #title' do
20
+ @credential.title.should eq("Computer Programming (NOCTI)")
21
+ end
22
+
23
+ it 'responds to #source' do
24
+ @credential.source.title.should eq("National Occupational")
25
+ end
26
+
27
+ it 'responds to #details' do
28
+ @credential.details.should eq('')
29
+ end
30
+
31
+ it 'responds to #related_courses' do
32
+ @credential.related_courses.first.code.should eq('6641')
33
+ end
34
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe Verso::DutyArea do
4
+ before do
5
+ context = double("context", :code => "6320", :edition => "2012")
6
+ @duty_area = Verso::DutyArea.new({
7
+ "title" => "A Duty Area",
8
+ "tasks" => [{ "statement" => "Do this.",
9
+ "id" => "12345",
10
+ "sensitive" => false,
11
+ "essential" => true } ]},
12
+ context
13
+ )
14
+ @task = double("Task", :statement => "Do this.", :id => "12345",
15
+ :sensitive => false, :essential => true,
16
+ :code => "6320", :edition => "2012")
17
+ end
18
+
19
+ it "responds to #title" do
20
+ @duty_area.title.should eq("A Duty Area")
21
+ end
22
+
23
+ it "responds to #tasks" do
24
+ Verso::Task.should_receive(:new).and_return(@task)
25
+ @duty_area.tasks.first.statement.should eq("Do this.")
26
+ end
27
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Verso::EditionList do
4
+ use_vcr_cassette :record => :new_episodes
5
+
6
+ it "responds to #first, #last" do
7
+ list = Verso::EditionList.new
8
+ list.first.year.should match(/20\d\d/)
9
+ list.last.year.should match(/20\d\d/)
10
+ end
11
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe Verso::EmphasisList do
4
+ before do
5
+ @raw_edition_list = {
6
+ "emphases" => [ { "title" => "Earth Science", "id" => 7 } ]
7
+ }
8
+ Net::HTTP.
9
+ should_receive(:get).
10
+ and_return(JSON.pretty_generate(@raw_edition_list))
11
+ @emphases = Verso::EmphasisList.new
12
+ end
13
+
14
+ it 'should respond to #first' do
15
+ @emphases.first.title.should eq("Earth Science")
16
+ end
17
+
18
+ it 'should responds to #last' do
19
+ @emphases.last.title.should eq("Earth Science")
20
+ end
21
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe Verso::Emphasis do
4
+ before do
5
+ @emphasis = Verso::Emphasis.new("id" => 7, "title" => "Earth Science")
6
+ end
7
+
8
+ it 'responds to #title' do
9
+ @emphasis.title.should eq("Earth Science")
10
+ end
11
+
12
+ it 'responds to #occupation_data' do
13
+ occupation_data = [{
14
+ "cluster" => { "title" => "Information Technology", "id" => 1 },
15
+ "pathway" => { "title" => "Information and Support Services", "id" => 2 },
16
+ "occupations" => [{ "title" => "Database Analyst", "id" => 3 }]
17
+ }]
18
+ Net::HTTP.should_receive(:get).
19
+ with('api.cteresource.org', "/academics/7", 80).
20
+ and_return(
21
+ JSON.pretty_generate(
22
+ :emphasis => {
23
+ :id => 7, :title => "Earth Science",
24
+ :occupation_data => occupation_data }
25
+ )
26
+ )
27
+ @emphasis.occupation_data.first.cluster.title.should eq(
28
+ "Information Technology"
29
+ )
30
+ end
31
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe Verso::ExaminationList do
4
+ before do
5
+ Net::HTTP.
6
+ should_receive(:get).
7
+ with('api.cteresource.org', "/examinations/", 80).
8
+ and_return(
9
+ JSON.pretty_generate(
10
+ :examinations => [ { :passing_score => "3",
11
+ :source => "NOCTI",
12
+ :title => "AP Computer Science",
13
+ :retired => false,
14
+ :amt_seal => true } ]
15
+ )
16
+ )
17
+ @examinations = Verso::ExaminationList.new
18
+ end
19
+
20
+ it 'responds to #first' do
21
+ exam = @examinations.first
22
+ exam.title.should eq("AP Computer Science")
23
+ end
24
+
25
+ it 'responds to #last' do
26
+ exam = @examinations.last
27
+ exam.title.should eq("AP Computer Science")
28
+ end
29
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe Verso::Extra do
4
+ before do
5
+ Net::HTTP.stub(:get).
6
+ with('api.cteresource.org',
7
+ "/courses/6320,2011/extras/untitled~6320",
8
+ 80).
9
+ and_return(JSON.pretty_generate(
10
+ :extra => { :title => "Instructional Scenario",
11
+ :description => "extra description" }
12
+ ))
13
+ @extra = Verso::Extra.new("code" => "6320", "edition" => "2011",
14
+ "name" => "untitled~6320",
15
+ "title" => "Instructional Scenarios")
16
+ end
17
+
18
+ it "responds to #title" do
19
+ @extra.title.should eq("Instructional Scenarios")
20
+ end
21
+
22
+ it "responds to #description" do
23
+ @extra.description.should eq("extra description")
24
+ end
25
+ it "responds to #code" do
26
+ @extra.code.should eq("6320")
27
+ end
28
+
29
+ it "resonds to #name" do
30
+ @extra.name.should eq("untitled~6320")
31
+ end
32
+
33
+ it "responds to #edition" do
34
+ @extra.edition.should eq("2011")
35
+ end
36
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Verso::ExtrasList do
4
+ before do
5
+ @extra = double("Verso::Extra", :code => "6320", :edition => "2011",
6
+ :name => "untitled~6320",
7
+ :title => "Instructional Scenarios")
8
+ @extras_list = Verso::ExtrasList.new(:code => "6320", :edition => "2011")
9
+ Net::HTTP.stub(:get).and_return(
10
+ JSON.pretty_generate(
11
+ :extras => [
12
+ { :title => "Instructional Scenarios", :name => "untitled~6320" }
13
+ ]
14
+ )
15
+ )
16
+ end
17
+
18
+ it "responds as Enumerable" do
19
+ Verso::Extra.should_receive(:new).
20
+ with("code" => "6320", "edition" => "2011", "name" => "untitled~6320",
21
+ "title" => "Instructional Scenarios").
22
+ and_return(@extra)
23
+ @extras_list.first.title.should eq("Instructional Scenarios")
24
+ end
25
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Verso::Frontmatter do
4
+ it 'fetches the remote resource' do
5
+ @frontmatter = Verso::Frontmatter.new("code" => "6320", "edition" => "2011")
6
+ @frontmatter.should_receive(:http_get).and_return(
7
+ JSON.pretty_generate(:frontmatter => { :notice_block => "foobar" })
8
+ )
9
+ @frontmatter.notice_block
10
+ end
11
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe Verso::OccupationData do
4
+ before do
5
+ @occupation_data = [{
6
+ "cluster" => { "title" => "Information Technology" },
7
+ "pathway" => { "title" => "Information and Support Services" },
8
+ "occupations" => [{ "title" => "Database Analyst" }]
9
+ }]
10
+ @occdata = Verso::OccupationData.new(@occupation_data.first)
11
+ end
12
+
13
+ it 'should respond to title' do
14
+ @occdata.cluster.title.should eq("Information Technology")
15
+ end
16
+
17
+ it 'should respond to pathway' do
18
+ @occdata.pathway.title.should eq("Information and Support Services")
19
+ end
20
+
21
+ it 'should respond to occupations' do
22
+ @occdata.occupations.first.title.should eq("Database Analyst")
23
+ end
24
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe Verso::OccupationList do
4
+ it "searches by text" do
5
+ Net::HTTP.should_receive(:get).
6
+ with('api.cteresource.org', '/occupations?text=teacher', 80).
7
+ and_return(
8
+ JSON.pretty_generate(
9
+ { :occupation_data => [{
10
+ :cluster => { :title => "Education and Training" },
11
+ :pathway => { :title => "Teaching and Training" },
12
+ :occupations => [
13
+ { :title => "Elementary School Teacher" }
14
+ ]
15
+ }] }
16
+ )
17
+ )
18
+ results = Verso::OccupationList.new(:text => "teacher")
19
+ results.first.occupations.first.title.should eq("Elementary School Teacher")
20
+ end
21
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe Verso::Occupation do
4
+ before do
5
+ @raw_occupation = { "id" => 2966,
6
+ "title" => "Agricultural Commodity Broker",
7
+ "pathway" => { "title" => "Agriculture" } }
8
+ @occupation = Verso::Occupation.new(@raw_occupation)
9
+ end
10
+
11
+ it 'should respond to #title' do
12
+ @occupation.title.should eq("Agricultural Commodity Broker")
13
+ end
14
+
15
+ it 'should respond to #id' do
16
+ @occupation.id.should eq(2966)
17
+ end
18
+
19
+ it 'should respond to #pathway' do
20
+ @occupation.pathway.title.should eq("Agriculture")
21
+ end
22
+
23
+ it 'should respond to #related_courses' do
24
+ Net::HTTP.
25
+ should_receive(:get).
26
+ with('api.cteresource.org', "/occupations/2966", 80).
27
+ and_return(
28
+ JSON.pretty_generate(
29
+ :occupation => {
30
+ :id => 2966,
31
+ :title => "Agricultural Commodity Broker",
32
+ :related_courses => [
33
+ { :code => "8050",
34
+ :title => "Agricultural Education--Preparation" }
35
+ ]
36
+ }
37
+ )
38
+ )
39
+ @occupation.related_courses.first.code.should eq("8050")
40
+ end
41
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe Verso::Pathway do
4
+ before do
5
+ @raw_cluster = { "title" => "Agriculture, Food, and Natural Resources",
6
+ "id" => 49 }
7
+ @raw_pathway = { "title" => "Agribusiness Systems", "id" => 306 ,
8
+ "cluster" => @raw_cluster }
9
+ @pathway = Verso::Pathway.new(@raw_pathway)
10
+ end
11
+
12
+ it 'should respond to #title' do
13
+ @pathway.title.should eq('Agribusiness Systems')
14
+ end
15
+
16
+ it 'should respond to #cluster' do
17
+ @pathway.cluster.id.should eq(49)
18
+ end
19
+
20
+ it 'should respond to #id' do
21
+ @pathway.id.should eq(306)
22
+ end
23
+
24
+ it 'should respond to #occupations' do
25
+ Net::HTTP.
26
+ should_receive(:get).
27
+ with('api.cteresource.org', "/pathways/306", 80).
28
+ and_return(
29
+ JSON.pretty_generate(
30
+ :pathway => {
31
+ :id => 306,
32
+ :title => "Agribusiness Systems",
33
+ :occupations => [
34
+ { :id => 2966, :title => "Agricultural Commodity Broker" }
35
+ ]
36
+ }
37
+ )
38
+ )
39
+ @pathway.occupations.first.title.should eq('Agricultural Commodity Broker')
40
+ end
41
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Verso::ProgramAreaList do
4
+ use_vcr_cassette :record => :new_episodes
5
+
6
+ it 'responds to #first, #last' do
7
+ list = Verso::ProgramAreaList.new
8
+ list.first.title.should eq("Academic")
9
+ list.last.title.should eq("Trade and Industrial Education")
10
+ end
11
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe Verso::ProgramArea do
4
+ before do
5
+ @pa = Verso::ProgramArea.new("title" => "Career Connections")
6
+ end
7
+
8
+ it 'should respond to description' do
9
+ @pa.description.should eq("")
10
+ end
11
+
12
+ it 'should respond to title' do
13
+ @pa.title.should eq("Career Connections")
14
+ end
15
+
16
+ it 'should respond to slug' do
17
+ @pa.slug.should eq('career-connections')
18
+ end
19
+
20
+ it 'should respond to courses' do
21
+ @course = double("Course", :title => "a course", :edition => "1998",
22
+ :code => "9999")
23
+ Verso::CourseList.should_receive(:new).
24
+ with(:program_area => "career connections").
25
+ and_return([@course])
26
+ @pa.courses.should eq([@course])
27
+ end
28
+
29
+ it 'should respond to deprecated' do
30
+ @pa.stub(:http_get).
31
+ and_return(
32
+ { "program_areas" => [ {
33
+ "title" => "Career Connections",
34
+ "deprecated" => false
35
+ } ] }.to_json
36
+ )
37
+ @pa.deprecated.should eq(false)
38
+ end
39
+ end
@@ -0,0 +1,74 @@
1
+ require 'spec_helper'
2
+
3
+ describe Verso::SOLCorrelationList do
4
+ before do
5
+ @goal = OpenStruct.new({ "title" => "goal title",
6
+ "description" => "goal description" })
7
+ @standard = double("Standard", :title => "standard title",
8
+ :description => "standard description",
9
+ :goals => [@goal], :sections => [])
10
+ @standards_list = [@standard]
11
+ @standards_list.stub(:sols).
12
+ and_return([OpenStruct.new(:name => "english"),
13
+ OpenStruct.new(:name => "science")])
14
+ @task = double("Task", :statement => "task statement", :id => "111",
15
+ :standards => @standards_list)
16
+ @tasks = [@task]
17
+ @duty_areas = [OpenStruct.new(:tasks => @tasks)]
18
+ @course = double("Course", :title => "course title", :edition => "1929",
19
+ :code => "0000", :duration => 36, :hours => nil,
20
+ :co_op => true, :related_resources => ["tasks"],
21
+ :standards => @standards_list,
22
+ :duty_areas => @duty_areas, :certifications => [])
23
+ correlations1 = { "correlations" => [
24
+ {"id" => "111", "statement" => "task statement",
25
+ "goals" => {
26
+ "english" => { "title" => "English", "description" => "",
27
+ "sections" => [],
28
+ "goals" => [
29
+ { "title" => "english goal title",
30
+ "description" => "english goal description" }
31
+ ] }
32
+ }
33
+ }
34
+ ]}.to_json
35
+ correlations2 = { "correlations" => [
36
+ {"id" => "111", "statement" => "task statement",
37
+ "goals" => {
38
+ "science" => { "title" => "Science", "description" => "",
39
+ "sections" => [],
40
+ "goals" => [
41
+ { "title" => "science goal title",
42
+ "description" => "science goal description" }
43
+ ] }
44
+ }
45
+ }
46
+ ]}.to_json
47
+ @correlations = Verso::SOLCorrelationList.new(@course)
48
+ Net::HTTP.should_receive(:get).
49
+ with('api.cteresource.org',
50
+ "/courses/#{@course.code},#{@course.edition}/standards/english/correlations",
51
+ 80).
52
+ and_return(correlations1)
53
+ Net::HTTP.should_receive(:get).
54
+ with('api.cteresource.org',
55
+ "/courses/#{@course.code},#{@course.edition}/standards/science/correlations",
56
+ 80).
57
+ and_return(correlations2)
58
+ end
59
+
60
+ it 'is enumerable' do
61
+ @correlations.first.statement.should eq('task statement')
62
+ end
63
+
64
+ it 'numbers the correlations' do
65
+ @correlations.first.number.should eq(1)
66
+ end
67
+
68
+ it 'compiles the goals' do
69
+ @correlations.first.standards.count.should eq(2)
70
+ titles = @correlations.first.standards.collect { |s| s.title }
71
+ titles.first.should eq('English')
72
+ titles.last.should eq('Science')
73
+ end
74
+ end