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.
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,23 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require 'verso'
3
+ require 'vcr'
4
+
5
+ VCR.configure do |c|
6
+ c.hook_into :fakeweb
7
+ c.ignore_localhost = true
8
+ c.cassette_library_dir = 'tmp/cassettes'
9
+ end
10
+
11
+ RSpec.configure do |config|
12
+ # == Mock Framework
13
+ #
14
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate
15
+ # line:
16
+ #
17
+ # config.mock_with :mocha
18
+ # config.mock_with :flexmock
19
+ # config.mock_with :rr
20
+ config.mock_with :rspec
21
+
22
+ config.extend VCR::RSpec::Macros
23
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe Verso::Standard do
4
+ before do
5
+ @goal = { "title" => "goal title",
6
+ "description" => "goal description" }
7
+ @nested_goal = { "title" => "nested goal title",
8
+ "description" => "nested goal description" }
9
+ @section = { "title" => "section title",
10
+ "description" => "section description",
11
+ "goals" => [@nested_goal], "sections" => [] }
12
+ @raw_standard = { :aname => { "title" => "standard title",
13
+ "description" => "standard description",
14
+ "goals" => [@goal],
15
+ "sections" => [@section] } }
16
+ @standard = Verso::Standard.new(@raw_standard.values.first)
17
+ end
18
+
19
+ it "should respond to title" do
20
+ @standard.title.should eq("standard title")
21
+ end
22
+
23
+ it "should respond to description" do
24
+ @standard.description.should eq("standard description")
25
+ end
26
+
27
+ it "should respond to sections" do
28
+ @standard.sections.first.title.should eq(@section["title"])
29
+ end
30
+
31
+ it "should respond to goals" do
32
+ @standard.goals.first.title.should eq("goal title")
33
+ end
34
+
35
+ it "should respond to nested goals" do
36
+ @standard.sections.first.goals.first.title.should eq("nested goal title")
37
+ end
38
+
39
+ it "should fetch standard as necessary" do
40
+ course = OpenStruct.new(:code => "6320", :edition => "2011")
41
+ std = { "name" => "science" }
42
+ std = Verso::Standard.new(std, course)
43
+ std.name.should eq("science")
44
+ std.code.should eq("6320")
45
+
46
+ raw_std = { "standard" => { "title" => "Science", "sections" => [],
47
+ "goals" => [] } }
48
+ Net::HTTP.stub(:get).and_return(nil)
49
+ JSON.stub(:parse).and_return(raw_std)
50
+ std.title.should eq("Science")
51
+ std.name.should eq("science")
52
+ end
53
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ describe Verso::StandardsList do
4
+ before do
5
+ @goal = OpenStruct.new({ "title" => "goal title",
6
+ "description" => "goal description" })
7
+ @nested_goal = OpenStruct.new(
8
+ { "title" => "nested goal title",
9
+ "description" => "nested goal description" }
10
+ )
11
+ @section = OpenStruct.new(
12
+ { "title" => "section title", "description" => "section description",
13
+ "goals" => [@nested_goal], "sections" => [] }
14
+ )
15
+ @raw_standard = { :aname => { "title" => "standard title",
16
+ "description" => "standard description",
17
+ "goals" => [@goal],
18
+ "sections" => [@section] } }
19
+ sol = { :science => { "title" => "Science",
20
+ "description" => "standard description",
21
+ "name" => "science",
22
+ "goals" => [@goal],
23
+ "sections" => [@section] } }
24
+ @raw_standard.merge!(sol)
25
+ @standards_list = Verso::StandardsList.new(@raw_standard)
26
+ end
27
+
28
+ it "responds as Enumerable" do
29
+ @standards_list.last.title.should eq("standard title")
30
+ @standards_list.first.title.should eq("Science")
31
+ end
32
+
33
+ it "should respond to sols" do
34
+ @standards_list.sols.first.title.should eq('Science')
35
+ end
36
+
37
+ it "should respond to non_sols" do
38
+ @standards_list.non_sols.first.title.should eq("standard title")
39
+ end
40
+
41
+ it "should create a list from a course" do
42
+ course = double("Course", :code => "6320", :edition => "2011")
43
+ Net::HTTP.stub(:get).and_return(nil)
44
+ raw = { "standards" => @raw_standard.values }
45
+ JSON.stub(:parse).and_return(raw)
46
+ sl = Verso::StandardsList.new(raw["standards"], course)
47
+ Verso::StandardsList.should_receive(:new).with(raw["standards"], course).
48
+ and_return(sl)
49
+ Verso::StandardsList.from_course(course).last.title.should eq("standard title")
50
+ end
51
+ end
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+
3
+ describe Verso::TaskList do
4
+ use_vcr_cassette :record => :new_episodes
5
+
6
+ before do
7
+ @tl = Verso::TaskList.new(:code => "6320", :edition => "2011")
8
+ end
9
+
10
+ it "responds to #first" do
11
+ @duty_area = double("Verso::DutyArea", :title => "A Verso::Duty Area")
12
+ Verso::DutyArea.should_receive(:new).and_return(@duty_area)
13
+ @tl.first.title.should eq("A Verso::Duty Area")
14
+ end
15
+
16
+ it "responds to #code, #edition" do
17
+ @tl.code.should eq("6320")
18
+ @tl.edition.should eq("2011")
19
+ end
20
+
21
+ it "responds to #has_optional_task? when true" do
22
+ @tl.stub(:duty_areas).and_return(
23
+ [{"title" => "DA Title",
24
+ "tasks" => [
25
+ { "statement" => "one",
26
+ "sensitive" => false,
27
+ "essential" => true }
28
+ ]}]
29
+ )
30
+ @tl.has_optional_task?.should eq(false)
31
+ end
32
+
33
+ it "responds to #has_optional_task? when false" do
34
+ @tl.stub(:duty_areas).and_return(
35
+ [{"title" => "DA Title",
36
+ "tasks" => [
37
+ { "statement" => "one",
38
+ "sensitive" => false,
39
+ "essential" => false }
40
+ ]}]
41
+ )
42
+ @tl.has_optional_task?.should eq(true)
43
+ end
44
+
45
+ it "responds to #has_sensitive_task? when true" do
46
+ @tl.stub(:duty_areas).and_return(
47
+ [{"title" => "DA Title",
48
+ "tasks" => [
49
+ { "statement" => "one",
50
+ "sensitive" => true }
51
+ ]}]
52
+ )
53
+ @tl.has_sensitive_task?.should eq(true)
54
+ end
55
+
56
+ it "responds to #has_sensitive_task? when false" do
57
+ @tl.stub(:duty_areas).and_return(
58
+ [{"title" => "DA Title",
59
+ "tasks" => [
60
+ { "statement" => "one",
61
+ "sensitive" => false }
62
+ ]}]
63
+ )
64
+ @tl.has_sensitive_task?.should eq(false)
65
+ end
66
+
67
+ it "should return an empty task list if none is published" do
68
+ @tl = Verso::TaskList.new(:code => "1234", :edition => "1929")
69
+ JSON.stub(:parse).and_return({ "errors" => "Not Found" })
70
+ @tl.duty_areas.should eq([])
71
+ end
72
+ end
data/spec/task_spec.rb ADDED
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe Verso::Task do
4
+ context "when you are fetching full task" do
5
+ before do
6
+ @task = Verso::Task.new("code" => "6320", "edition" => "2011", "id" => "1")
7
+ end
8
+
9
+ it "fetches the full task" do
10
+ @task.should_receive(:http_get).and_return(
11
+ JSON.pretty_generate(:statement => "a statement")
12
+ )
13
+ @task.statement.should eq("a statement")
14
+ end
15
+
16
+ it "responds to standards" do
17
+ @task.should_receive(:goals).and_return({})
18
+ Verso::StandardsList.should_receive(:new)
19
+ @task.standards
20
+ end
21
+ end
22
+
23
+ context "when you are working from a short task" do
24
+ before do
25
+ @goals = { "a_body" => { "title" => "A Body",
26
+ "description" => "A Description",
27
+ "goals" => [],
28
+ "sections" => [] } }
29
+ @task = Verso::Task.new("statement" => "Do this.", "id" => "12345",
30
+ "sensitive" => false, "essential" => true,
31
+ "goals" => @goals)
32
+ end
33
+
34
+ it "responds to #statement" do
35
+ @task.statement.should eq("Do this.")
36
+ end
37
+
38
+ it "responds to #id" do
39
+ @task.id.should eq("12345")
40
+ end
41
+ it "responds to #sensitive" do
42
+ @task.sensitive.should eq(false)
43
+ end
44
+
45
+ it "responds to #essential" do
46
+ @task.essential.should eq(true)
47
+ end
48
+
49
+ it "responds to #standards" do
50
+ @standard = double("Verso::Standard", :title => "A Body")
51
+ Verso::StandardsList.should_receive(:new).with(@goals).and_return([@standard])
52
+ @task.standards.first.title.should eq("A Body")
53
+ end
54
+ end
55
+ end
data/verso.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "verso/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "verso"
7
+ s.version = Verso::VERSION
8
+ s.authors = ["Lee Capps"]
9
+ s.email = ["himself@leecapps.com"]
10
+ s.homepage = "https://github.com/jlcapps/verso"
11
+ s.summary = %q{Verso API wrapper}
12
+ s.description = %q{A Ruby wrapper for the Virginia CTE Resource Center's Web API}
13
+
14
+ s.rubyforge_project = "verso"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+ s.add_runtime_dependency 'json'
21
+ s.add_runtime_dependency 'addressable'
22
+ s.add_development_dependency "fakeweb"
23
+ s.add_development_dependency "rspec"
24
+ s.add_development_dependency "vcr"
25
+ end
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: verso
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Lee Capps
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: json
16
+ requirement: &70179451528380 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70179451528380
25
+ - !ruby/object:Gem::Dependency
26
+ name: addressable
27
+ requirement: &70179451527920 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70179451527920
36
+ - !ruby/object:Gem::Dependency
37
+ name: fakeweb
38
+ requirement: &70179451527460 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70179451527460
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: &70179451527040 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70179451527040
58
+ - !ruby/object:Gem::Dependency
59
+ name: vcr
60
+ requirement: &70179451526580 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70179451526580
69
+ description: A Ruby wrapper for the Virginia CTE Resource Center's Web API
70
+ email:
71
+ - himself@leecapps.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - Gemfile
78
+ - LICENSE.md
79
+ - README.md
80
+ - Rakefile
81
+ - lib/verso.rb
82
+ - lib/verso/cluster.rb
83
+ - lib/verso/cluster_list.rb
84
+ - lib/verso/correlation_list.rb
85
+ - lib/verso/course.rb
86
+ - lib/verso/course_list.rb
87
+ - lib/verso/credential.rb
88
+ - lib/verso/credential_list.rb
89
+ - lib/verso/duty_area.rb
90
+ - lib/verso/edition_list.rb
91
+ - lib/verso/emphasis.rb
92
+ - lib/verso/emphasis_list.rb
93
+ - lib/verso/examination_list.rb
94
+ - lib/verso/extra.rb
95
+ - lib/verso/extras_list.rb
96
+ - lib/verso/frontmatter.rb
97
+ - lib/verso/http_get.rb
98
+ - lib/verso/occupation.rb
99
+ - lib/verso/occupation_data.rb
100
+ - lib/verso/occupation_list.rb
101
+ - lib/verso/pathway.rb
102
+ - lib/verso/program_area.rb
103
+ - lib/verso/program_area_list.rb
104
+ - lib/verso/sol_correlation_list.rb
105
+ - lib/verso/standard.rb
106
+ - lib/verso/standards_list.rb
107
+ - lib/verso/task.rb
108
+ - lib/verso/task_list.rb
109
+ - lib/verso/version.rb
110
+ - spec/cluster_list_spec.rb
111
+ - spec/cluster_spec.rb
112
+ - spec/correlation_list_spec.rb
113
+ - spec/course_list_spec.rb
114
+ - spec/course_spec.rb
115
+ - spec/credential_list_spec.rb
116
+ - spec/credential_spec.rb
117
+ - spec/duty_area_spec.rb
118
+ - spec/edition_list_spec.rb
119
+ - spec/emphasis_list_spec.rb
120
+ - spec/emphasis_spec.rb
121
+ - spec/examination_list_spec.rb
122
+ - spec/extra_spec.rb
123
+ - spec/extras_list_spec.rb
124
+ - spec/frontmatter_spec.rb
125
+ - spec/occupation_data_spec.rb
126
+ - spec/occupation_list_spec.rb
127
+ - spec/occupation_spec.rb
128
+ - spec/pathway_spec.rb
129
+ - spec/program_area_list_spec.rb
130
+ - spec/program_area_spec.rb
131
+ - spec/sol_correlation_list_spec.rb
132
+ - spec/spec_helper.rb
133
+ - spec/standard_spec.rb
134
+ - spec/standards_list_spec.rb
135
+ - spec/task_list_spec.rb
136
+ - spec/task_spec.rb
137
+ - verso.gemspec
138
+ homepage: https://github.com/jlcapps/verso
139
+ licenses: []
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ none: false
152
+ requirements:
153
+ - - ! '>='
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubyforge_project: verso
158
+ rubygems_version: 1.8.10
159
+ signing_key:
160
+ specification_version: 3
161
+ summary: Verso API wrapper
162
+ test_files:
163
+ - spec/cluster_list_spec.rb
164
+ - spec/cluster_spec.rb
165
+ - spec/correlation_list_spec.rb
166
+ - spec/course_list_spec.rb
167
+ - spec/course_spec.rb
168
+ - spec/credential_list_spec.rb
169
+ - spec/credential_spec.rb
170
+ - spec/duty_area_spec.rb
171
+ - spec/edition_list_spec.rb
172
+ - spec/emphasis_list_spec.rb
173
+ - spec/emphasis_spec.rb
174
+ - spec/examination_list_spec.rb
175
+ - spec/extra_spec.rb
176
+ - spec/extras_list_spec.rb
177
+ - spec/frontmatter_spec.rb
178
+ - spec/occupation_data_spec.rb
179
+ - spec/occupation_list_spec.rb
180
+ - spec/occupation_spec.rb
181
+ - spec/pathway_spec.rb
182
+ - spec/program_area_list_spec.rb
183
+ - spec/program_area_spec.rb
184
+ - spec/sol_correlation_list_spec.rb
185
+ - spec/spec_helper.rb
186
+ - spec/standard_spec.rb
187
+ - spec/standards_list_spec.rb
188
+ - spec/task_list_spec.rb
189
+ - spec/task_spec.rb