verso 0.0.2 → 0.0.3

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 +2 -0
  2. data/README.md +10 -22
  3. data/lib/verso.rb +10 -2
  4. data/lib/verso/base.rb +50 -0
  5. data/lib/verso/cluster.rb +55 -25
  6. data/lib/verso/cluster_list.rb +15 -10
  7. data/lib/verso/correlation_list.rb +30 -40
  8. data/lib/verso/course.rb +106 -43
  9. data/lib/verso/course_list.rb +57 -21
  10. data/lib/verso/credential.rb +94 -20
  11. data/lib/verso/credential_list.rb +30 -15
  12. data/lib/verso/duty_area.rb +23 -10
  13. data/lib/verso/edition_list.rb +18 -10
  14. data/lib/verso/emphasis.rb +26 -12
  15. data/lib/verso/emphasis_list.rb +18 -10
  16. data/lib/verso/examination_list.rb +28 -12
  17. data/lib/verso/extra.rb +34 -32
  18. data/lib/verso/extras_list.rb +28 -12
  19. data/lib/verso/frontmatter.rb +43 -11
  20. data/lib/verso/hash.rb +19 -0
  21. data/lib/verso/http_gettable.rb +31 -0
  22. data/lib/verso/occupation.rb +36 -14
  23. data/lib/verso/occupation_data.rb +35 -14
  24. data/lib/verso/occupation_list.rb +23 -20
  25. data/lib/verso/pathway.rb +32 -14
  26. data/lib/verso/program_area.rb +42 -21
  27. data/lib/verso/program_area_list.rb +15 -11
  28. data/lib/verso/standard.rb +45 -23
  29. data/lib/verso/standards_list.rb +41 -30
  30. data/lib/verso/task.rb +52 -17
  31. data/lib/verso/task_list.rb +40 -17
  32. data/lib/verso/version.rb +1 -1
  33. data/spec/cluster_list_spec.rb +78 -5
  34. data/spec/cluster_spec.rb +106 -9
  35. data/spec/correlation_list_spec.rb +108 -50
  36. data/spec/course_list_spec.rb +112 -23
  37. data/spec/course_spec.rb +321 -127
  38. data/spec/credential_list_spec.rb +83 -52
  39. data/spec/credential_spec.rb +358 -19
  40. data/spec/duty_area_spec.rb +47 -17
  41. data/spec/edition_list_spec.rb +90 -4
  42. data/spec/emphasis_list_spec.rb +75 -11
  43. data/spec/emphasis_spec.rb +37 -21
  44. data/spec/examination_list_spec.rb +146 -20
  45. data/spec/extra_spec.rb +61 -22
  46. data/spec/extras_list_spec.rb +80 -17
  47. data/spec/frontmatter_spec.rb +141 -6
  48. data/spec/hash_spec.rb +49 -0
  49. data/spec/occupation_data_spec.rb +31 -13
  50. data/spec/occupation_list_spec.rb +88 -15
  51. data/spec/occupation_spec.rb +72 -28
  52. data/spec/pathway_spec.rb +47 -27
  53. data/spec/program_area_list_spec.rb +78 -4
  54. data/spec/program_area_spec.rb +70 -22
  55. data/spec/standard_spec.rb +94 -36
  56. data/spec/standards_list_spec.rb +130 -36
  57. data/spec/task_list_spec.rb +160 -51
  58. data/spec/task_spec.rb +120 -33
  59. data/verso.gemspec +3 -1
  60. metadata +41 -17
  61. data/lib/verso/http_get.rb +0 -9
  62. data/lib/verso/sol_correlation_list.rb +0 -53
  63. data/spec/sol_correlation_list_spec.rb +0 -74
@@ -1,55 +1,142 @@
1
1
  require 'spec_helper'
2
2
 
3
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")
4
+ use_vcr_cassette :record => :new_episodes
5
+
6
+ before(:each) do
7
+ @task = Verso::CourseList.new(:code => "6320").
8
+ last.
9
+ duty_areas.
10
+ last.
11
+ tasks.
12
+ first
13
+ end
14
+
15
+ describe '#code' do
16
+ it 'responds' do
17
+ @task.should respond_to(:code)
18
+ end
19
+
20
+ it 'is a String' do
21
+ @task.code.should be_a(String)
22
+ end
23
+ end
24
+
25
+ describe '#definition' do
26
+ it 'responds' do
27
+ @task.should respond_to(:definition)
28
+ end
29
+
30
+ it 'is a Sring' do
31
+ @task.definition.should be_a(String)
32
+ end
33
+
34
+ it 'looks like HTML' do
35
+ @task.definition.should match(/<\/.+>/)
36
+ end
37
+ end
38
+
39
+ describe '#edition' do
40
+ it 'responds' do
41
+ @task.should respond_to(:edition)
42
+ end
43
+
44
+ it 'is a String' do
45
+ @task.edition.should be_a(String)
46
+ end
47
+ end
48
+
49
+ describe '#essential' do
50
+ it 'responds' do
51
+ @task.should respond_to(:essential)
52
+ end
53
+
54
+ it 'is a Boolean' do
55
+ @task.essential.to_s.should match(/true|false/)
56
+ end
57
+ end
58
+
59
+ describe '#essential?' do
60
+ it 'responds' do
61
+ @task.should respond_to(:essential?)
62
+ end
63
+
64
+ it 'is a Boolean' do
65
+ @task.essential?.to_s.should match(/true|false/)
66
+ end
67
+ end
68
+
69
+ describe '#goals' do
70
+ it 'responds' do
71
+ @task.should respond_to(:goals)
72
+ end
73
+
74
+ it 'is a Verso::StandardsList' do
75
+ @task.goals.should be_a(Verso::StandardsList)
76
+ end
77
+ end
78
+
79
+ describe '#id' do
80
+ it 'responds' do
81
+ @task.should respond_to(:id)
82
+ end
83
+
84
+ it 'is a Fixnum' do
85
+ @task.id.should be_a(String)
86
+ end
87
+
88
+ it 'is not the same as #object_id' do
89
+ @task.id.should_not == @task.object_id
90
+ end
91
+ end
92
+
93
+ describe '#questions' do
94
+ it 'responds' do
95
+ @task.should respond_to(:questions)
7
96
  end
8
97
 
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")
98
+ it 'is a String' do
99
+ @task.questions.should be_a(String)
100
+ end
101
+ end
102
+
103
+ describe '#sensitive' do
104
+ it 'responds' do
105
+ @task.should respond_to(:sensitive)
14
106
  end
15
107
 
16
- it "responds to standards" do
17
- @task.should_receive(:goals).and_return({})
18
- Verso::StandardsList.should_receive(:new)
19
- @task.standards
108
+ it 'is a Boolean' do
109
+ @task.sensitive.to_s.should match(/true|false/)
20
110
  end
21
111
  end
22
112
 
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)
113
+ describe '#sensitive?' do
114
+ it 'responds' do
115
+ @task.should respond_to(:sensitive?)
32
116
  end
33
117
 
34
- it "responds to #statement" do
35
- @task.statement.should eq("Do this.")
118
+ it 'is a Boolean' do
119
+ @task.sensitive?.to_s.should match(/true|false/)
36
120
  end
121
+ end
37
122
 
38
- it "responds to #id" do
39
- @task.id.should eq("12345")
123
+ describe '#standards' do
124
+ it 'responds' do
125
+ @task.should respond_to(:standards)
40
126
  end
41
- it "responds to #sensitive" do
42
- @task.sensitive.should eq(false)
127
+
128
+ it 'is a Verso::StandardsList' do
129
+ @task.standards.should be_a(Verso::StandardsList)
43
130
  end
131
+ end
44
132
 
45
- it "responds to #essential" do
46
- @task.essential.should eq(true)
133
+ describe '#statement' do
134
+ it 'responds' do
135
+ @task.should respond_to(:statement)
47
136
  end
48
137
 
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")
138
+ it 'is a String' do
139
+ @task.statement.should be_a(String)
53
140
  end
54
141
  end
55
142
  end
@@ -20,8 +20,10 @@ Gem::Specification.new do |s|
20
20
  s.add_runtime_dependency 'json'
21
21
  s.add_runtime_dependency 'addressable'
22
22
  s.add_development_dependency "fakeweb"
23
+ s.add_development_dependency "redcarpet"
23
24
  s.add_development_dependency "rspec"
24
25
  s.add_development_dependency "vcr"
26
+ s.add_development_dependency "yard"
25
27
 
26
- s.required_ruby_version = '>= 1.9.3'
28
+ s.required_ruby_version = '>= 1.8.7'
27
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: verso
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-12 00:00:00.000000000 Z
12
+ date: 2012-07-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &70358296940660 !ruby/object:Gem::Requirement
16
+ requirement: &70112552508440 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70358296940660
24
+ version_requirements: *70112552508440
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: addressable
27
- requirement: &70358296939920 !ruby/object:Gem::Requirement
27
+ requirement: &70112552507920 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70358296939920
35
+ version_requirements: *70112552507920
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: fakeweb
38
- requirement: &70358296938880 !ruby/object:Gem::Requirement
38
+ requirement: &70112552507480 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,21 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70358296938880
46
+ version_requirements: *70112552507480
47
+ - !ruby/object:Gem::Dependency
48
+ name: redcarpet
49
+ requirement: &70112552506920 !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: *70112552506920
47
58
  - !ruby/object:Gem::Dependency
48
59
  name: rspec
49
- requirement: &70358296938440 !ruby/object:Gem::Requirement
60
+ requirement: &70112552506320 !ruby/object:Gem::Requirement
50
61
  none: false
51
62
  requirements:
52
63
  - - ! '>='
@@ -54,10 +65,21 @@ dependencies:
54
65
  version: '0'
55
66
  type: :development
56
67
  prerelease: false
57
- version_requirements: *70358296938440
68
+ version_requirements: *70112552506320
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: vcr
60
- requirement: &70358296937940 !ruby/object:Gem::Requirement
71
+ requirement: &70112552505820 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70112552505820
80
+ - !ruby/object:Gem::Dependency
81
+ name: yard
82
+ requirement: &70112552505220 !ruby/object:Gem::Requirement
61
83
  none: false
62
84
  requirements:
63
85
  - - ! '>='
@@ -65,7 +87,7 @@ dependencies:
65
87
  version: '0'
66
88
  type: :development
67
89
  prerelease: false
68
- version_requirements: *70358296937940
90
+ version_requirements: *70112552505220
69
91
  description: A Ruby wrapper for the Virginia CTE Resource Center's Web API
70
92
  email:
71
93
  - himself@leecapps.com
@@ -79,6 +101,7 @@ files:
79
101
  - README.md
80
102
  - Rakefile
81
103
  - lib/verso.rb
104
+ - lib/verso/base.rb
82
105
  - lib/verso/cluster.rb
83
106
  - lib/verso/cluster_list.rb
84
107
  - lib/verso/correlation_list.rb
@@ -94,14 +117,14 @@ files:
94
117
  - lib/verso/extra.rb
95
118
  - lib/verso/extras_list.rb
96
119
  - lib/verso/frontmatter.rb
97
- - lib/verso/http_get.rb
120
+ - lib/verso/hash.rb
121
+ - lib/verso/http_gettable.rb
98
122
  - lib/verso/occupation.rb
99
123
  - lib/verso/occupation_data.rb
100
124
  - lib/verso/occupation_list.rb
101
125
  - lib/verso/pathway.rb
102
126
  - lib/verso/program_area.rb
103
127
  - lib/verso/program_area_list.rb
104
- - lib/verso/sol_correlation_list.rb
105
128
  - lib/verso/standard.rb
106
129
  - lib/verso/standards_list.rb
107
130
  - lib/verso/task.rb
@@ -122,13 +145,13 @@ files:
122
145
  - spec/extra_spec.rb
123
146
  - spec/extras_list_spec.rb
124
147
  - spec/frontmatter_spec.rb
148
+ - spec/hash_spec.rb
125
149
  - spec/occupation_data_spec.rb
126
150
  - spec/occupation_list_spec.rb
127
151
  - spec/occupation_spec.rb
128
152
  - spec/pathway_spec.rb
129
153
  - spec/program_area_list_spec.rb
130
154
  - spec/program_area_spec.rb
131
- - spec/sol_correlation_list_spec.rb
132
155
  - spec/spec_helper.rb
133
156
  - spec/standard_spec.rb
134
157
  - spec/standards_list_spec.rb
@@ -146,7 +169,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
169
  requirements:
147
170
  - - ! '>='
148
171
  - !ruby/object:Gem::Version
149
- version: 1.9.3
172
+ version: 1.8.7
150
173
  required_rubygems_version: !ruby/object:Gem::Requirement
151
174
  none: false
152
175
  requirements:
@@ -175,15 +198,16 @@ test_files:
175
198
  - spec/extra_spec.rb
176
199
  - spec/extras_list_spec.rb
177
200
  - spec/frontmatter_spec.rb
201
+ - spec/hash_spec.rb
178
202
  - spec/occupation_data_spec.rb
179
203
  - spec/occupation_list_spec.rb
180
204
  - spec/occupation_spec.rb
181
205
  - spec/pathway_spec.rb
182
206
  - spec/program_area_list_spec.rb
183
207
  - spec/program_area_spec.rb
184
- - spec/sol_correlation_list_spec.rb
185
208
  - spec/spec_helper.rb
186
209
  - spec/standard_spec.rb
187
210
  - spec/standards_list_spec.rb
188
211
  - spec/task_list_spec.rb
189
212
  - spec/task_spec.rb
213
+ has_rdoc:
@@ -1,9 +0,0 @@
1
- module Verso
2
- module HTTPGet
3
- protected
4
-
5
- def http_get(path)
6
- Net::HTTP.get('api.cteresource.org', path, 80)
7
- end
8
- end
9
- end
@@ -1,53 +0,0 @@
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
@@ -1,74 +0,0 @@
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