verso 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -65,6 +65,11 @@ Search for Occupations, get back lists of "occupation data," i.e., a list of lis
65
65
  creds.first.title # => "Computer Programming (NOCTI)"
66
66
  creds.first.related_courses.last # => "Programming, Advanced"
67
67
 
68
+ ## Additional Documentation
69
+
70
+ * [http://api.cteresource.org/docs](http://api.cteresource.org/docs)
71
+ * [http://rubydoc.info/gems/verso/](http://rubydoc.info/gems/verso/)
72
+
68
73
  In general, the objects returned from the wrapper should respond to calls to
69
74
  the attributes described in the API documentation. Open an issue on GitHub or
70
75
  send an email to lcapps@cteresource.org if you have questions or concerns.
@@ -29,9 +29,10 @@ module Verso
29
29
  # courses = Verso::CourseList.new(:text => "internet", :cluster => "Marketing") # => <Verso::CourseList:0x007fa5a19b6c90 @attrs={ . . . }>
30
30
  # courses.count # => 1
31
31
  #
32
- # @example An empty search returns an empty list
32
+ # @example Calling #new with no attrs
33
33
  # courses = Verso::CourseList.new
34
- # courses.count # => 0
34
+ # courses.count # => A big number
35
+ # courses # => All the courses
35
36
  #
36
37
  # @overload initialize(attrs={})
37
38
  # @option attrs [String] :code Course code
@@ -48,7 +49,7 @@ module Verso
48
49
  private
49
50
 
50
51
  def courses
51
- @courses ||= if q_uri.query_values.values.any?
52
+ @courses ||= if attrs.empty? || q_uri.query_values.values.any?
52
53
  get_attr(:courses).collect { |c| Course.new(c) }
53
54
  else
54
55
  []
@@ -66,7 +67,7 @@ module Verso
66
67
  end
67
68
 
68
69
  def path
69
- q_uri.request_uri
70
+ attrs.empty? ? '/courses/' : q_uri.request_uri
70
71
  end
71
72
  end
72
73
  end
data/lib/verso/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Verso
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -1,85 +1,13 @@
1
1
  require 'spec_helper'
2
+ require 'shared_verso_list_examples'
2
3
 
3
4
  describe Verso::ClusterList do
4
5
  use_vcr_cassette :record => :new_episodes
5
6
 
6
7
  before(:each) do
7
8
  @list = Verso::ClusterList.new
9
+ @kontained = Verso::Cluster
8
10
  end
9
11
 
10
- describe '#[]' do
11
- it 'responds' do
12
- @list.should respond_to(:[])
13
- end
14
-
15
- it 'is a Verso::Cluster object' do
16
- @list[3].should be_a(Verso::Cluster)
17
- end
18
- end
19
-
20
- describe '#each' do
21
- it 'responds' do
22
- @list.should respond_to(:each)
23
- end
24
-
25
- it 'yields' do
26
- expect { |b| @list.each("foo", &b).to yield_control }
27
- end
28
-
29
- it 'yields Verso::Cluster objects' do
30
- @list.each do |c|
31
- c.should be_a(Verso::Cluster)
32
- end
33
- end
34
- end
35
-
36
- describe '#empty?' do
37
- it 'responds' do
38
- @list.should respond_to(:empty?)
39
- end
40
-
41
- it 'is not empty' do
42
- @list.should_not be_empty
43
- end
44
- end
45
-
46
- describe '#last' do
47
- it 'responds' do
48
- @list.should respond_to(:last)
49
- end
50
-
51
- it 'is a Verso::Cluster object' do
52
- @list.last.should be_a(Verso::Cluster)
53
- end
54
- end
55
-
56
- describe '#length' do
57
- it 'responds' do
58
- @list.should respond_to(:length)
59
- end
60
-
61
- it 'is 16' do
62
- @list.length.should == 16
63
- end
64
- end
65
-
66
- describe '#first' do
67
- it 'responds' do
68
- @list.should respond_to(:first)
69
- end
70
-
71
- it 'is a Verso::Cluster object' do
72
- @list.first.should be_a(Verso::Cluster)
73
- end
74
- end
75
-
76
- describe '#count' do
77
- it 'responds' do
78
- @list.should respond_to(:count)
79
- end
80
-
81
- it 'is 16' do
82
- @list.count.should == 16
83
- end
84
- end
12
+ it_behaves_like "any Verso list"
85
13
  end
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'shared_verso_list_examples'
2
3
 
3
4
  describe Verso::CorrelationList do
4
5
  use_vcr_cassette :record => :new_episodes
@@ -9,6 +10,7 @@ describe Verso::CorrelationList do
9
10
  :edition => Verso::EditionList.new.last.year,
10
11
  :name => "english"
11
12
  )
13
+ @kontained = Verso::Task
12
14
  end
13
15
 
14
16
  describe '#code' do
@@ -27,87 +29,5 @@ describe Verso::CorrelationList do
27
29
  it { @list.title.should == 'English' }
28
30
  end
29
31
 
30
- describe '#[]' do
31
- it 'responds' do
32
- @list.should respond_to(:[])
33
- end
34
-
35
- it 'is a Verso::Task' do
36
- @list[@list.count / 2].should be_a(Verso::Task)
37
- end
38
- end
39
-
40
- describe '#each' do
41
- it 'responds' do
42
- @list.should respond_to(:each)
43
- end
44
-
45
- it 'yields' do
46
- expect { |b| @list.each("foo", &b).to yield_control }
47
- end
48
-
49
- it 'yields a Verso::Task' do
50
- @list.each do |t|
51
- t.should be_a(Verso::Task)
52
- end
53
- end
54
- end
55
-
56
- describe '#empty?' do
57
- it 'responds' do
58
- @list.should respond_to(:empty?)
59
- end
60
-
61
- it 'is not empty' do
62
- @list.should_not be_empty
63
- end
64
- end
65
-
66
- describe '#last' do
67
- it 'responds' do
68
- @list.should respond_to(:last)
69
- end
70
-
71
- it 'is a Verso::Task' do
72
- @list.last.should be_a(Verso::Task)
73
- end
74
- end
75
-
76
- describe '#length' do
77
- it 'responds' do
78
- @list.should respond_to(:length)
79
- end
80
-
81
- it 'is a Fixnum' do
82
- @list.length.should be_a(Fixnum)
83
- end
84
-
85
- it 'is not zero' do
86
- @list.length.should_not == 0
87
- end
88
- end
89
-
90
- describe '#first' do
91
- it 'responds' do
92
- @list.should respond_to(:first)
93
- end
94
-
95
- it 'is a Verso::Task' do
96
- @list.first.should be_a(Verso::Task)
97
- end
98
- end
99
-
100
- describe '#count' do
101
- it 'responds' do
102
- @list.should respond_to(:count)
103
- end
104
-
105
- it 'is a Fixnum' do
106
- @list.count.should be_a(Fixnum)
107
- end
108
-
109
- it 'is not zero' do
110
- @list.count.should_not == 0
111
- end
112
- end
32
+ it_behaves_like 'any Verso list'
113
33
  end
@@ -1,9 +1,10 @@
1
1
  require 'spec_helper'
2
+ require 'shared_verso_list_examples'
2
3
 
3
4
  describe Verso::CourseList do
4
5
  use_vcr_cassette :record => :new_episodes
5
6
 
6
- describe 'searches' do
7
+ describe 'search' do
7
8
  it "searches by code" do
8
9
  results = Verso::CourseList.new(:code => "6320")
9
10
  results.each { |c| c.code.should == "6320" }
@@ -27,13 +28,12 @@ describe Verso::CourseList do
27
28
  should eq("Equine Management Production")
28
29
  end
29
30
 
30
- it "can find courses by program area too" do
31
+ it "finds courses by program area too" do
31
32
  results = Verso::CourseList.new(:program_area => "across the board")
32
33
  results.first.title.strip.should eq("Work-Based Learning through Service")
33
34
  end
34
35
 
35
- it "should return empty results when queries are empty" do
36
- Verso::CourseList.new({}).count.should == 0
36
+ it "returns empty results when queries are empty" do
37
37
  [:text, :program_area, :cluster].each do |k|
38
38
  Verso::CourseList.new(k => nil).count.should == 0
39
39
  Verso::CourseList.new(k => '').count.should == 0
@@ -41,85 +41,18 @@ describe Verso::CourseList do
41
41
  Verso::CourseList.new(:text => '', :program_area => '', :cluster => '').
42
42
  count.should == 0
43
43
  end
44
+
45
+ it 'return everything when #new is called without attrs' do
46
+ Verso::CourseList.new.count.should_not == 0
47
+ end
44
48
  end
45
49
 
46
50
  describe 'array-like behavior' do
47
51
  before(:each) do
48
- @courses = Verso::CourseList.new(:cluster => "Information Technology")
49
- end
50
-
51
- describe '#[]' do
52
- it 'responds' do
53
- @courses.should respond_to(:[])
54
- end
55
-
56
- it 'gets a Verso::Course object' do
57
- @courses[10].should be_a(Verso::Course)
58
- end
59
- end
60
-
61
- describe '#each' do
62
- it 'responds' do
63
- @courses.should respond_to(:each)
64
- end
65
-
66
- it 'yields' do
67
- expect { |b| @courses.each("foo", &b).to yield_control }
68
- end
69
-
70
- it 'yields Verso::Course objects' do
71
- @courses.each { |c| c.should be_a(Verso::Course) }
72
- end
73
- end
74
-
75
- describe '#empty?' do
76
- it 'responds' do
77
- @courses.should respond_to(:empty?)
78
- end
79
-
80
- it 'is not empty' do
81
- @courses.should_not be_empty
82
- end
52
+ @list = Verso::CourseList.new(:cluster => "Information Technology")
53
+ @kontained = Verso::Course
83
54
  end
84
55
 
85
- describe '#last' do
86
- it 'responds' do
87
- @courses.should respond_to(:last)
88
- end
89
-
90
- it 'is a Verso::Course object' do
91
- @courses.last.should be_a(Verso::Course)
92
- end
93
- end
94
-
95
- describe '#length' do
96
- it 'responds' do
97
- @courses.should respond_to(:length)
98
- end
99
-
100
- it 'is a Fixnum' do
101
- @courses.length.should be_a(Fixnum)
102
- end
103
- end
104
-
105
- describe '#first' do
106
- it 'responds' do
107
- @courses.should respond_to(:first)
108
- end
109
-
110
- it 'is a Verso::Course object' do
111
- @courses.first.should be_a(Verso::Course)
112
- end
113
- end
114
-
115
- describe '#count' do
116
- it 'responds' do
117
- @courses.should respond_to(:count)
118
- end
119
-
120
- it 'is a Fixnum' do
121
- @courses.count.should be_a(Fixnum)
122
- end
123
- end
56
+ it_behaves_like "any Verso list"
124
57
  end
125
58
  end
@@ -1,98 +1,29 @@
1
1
  require 'spec_helper'
2
+ require 'shared_verso_list_examples'
2
3
 
3
4
  describe Verso::CredentialList do
4
5
  use_vcr_cassette :record => :new_episodes
5
6
  describe 'array-like behavior' do
6
7
  before(:each) do
7
- @credentials = Verso::CredentialList.new
8
+ @list = Verso::CredentialList.new
9
+ @kontained = Verso::Credential
8
10
  end
9
11
 
10
- describe '#[]' do
11
- it 'responds' do
12
- @credentials.should respond_to(:[])
13
- end
12
+ it_behaves_like 'any Verso list'
14
13
 
15
- it 'gets a Verso::Credential object' do
16
- @credentials[10].should be_a(Verso::Credential)
17
- end
18
- end
19
-
20
- describe '#each' do
21
- it 'responds' do
22
- @credentials.should respond_to(:each)
23
- end
24
-
25
- it 'yields' do
26
- expect { |b| @credentials.each("foo", &b).to yield_control }
27
- end
28
-
29
- it 'yields Verso::Credential objects' do
30
- @credentials.each { |c| c.should be_a(Verso::Credential) }
31
- end
32
- end
33
-
34
- describe '#empty?' do
35
- it 'responds' do
36
- @credentials.should respond_to(:empty?)
37
- end
38
-
39
- it 'is not empty' do
40
- @credentials.should_not be_empty
41
- end
42
- end
43
-
44
- describe '#last' do
45
- it 'responds' do
46
- @credentials.should respond_to(:last)
47
- end
48
-
49
- it 'is a Verso::Credential object' do
50
- @credentials.last.should be_a(Verso::Credential)
51
- end
52
- end
53
-
54
- describe '#length' do
55
- it 'responds' do
56
- @credentials.should respond_to(:length)
57
- end
58
-
59
- it 'is a Fixnum' do
60
- @credentials.length.should be_a(Fixnum)
61
- end
62
- end
63
-
64
- describe '#first' do
65
- it 'responds' do
66
- @credentials.should respond_to(:first)
67
- end
68
-
69
- it 'is a Verso::Credential object' do
70
- @credentials.first.should be_a(Verso::Credential)
71
- end
72
- end
73
-
74
- describe '#count' do
75
- it 'responds' do
76
- @credentials.should respond_to(:count)
77
- end
78
-
79
- it 'is a Fixnum' do
80
- @credentials.count.should be_a(Fixnum)
81
- end
82
- end
83
14
  end
84
15
 
85
16
  describe 'search' do
86
17
  before(:each) do
87
- @credentials = Verso::CredentialList.new(:text => 'nocti')
18
+ @list = Verso::CredentialList.new(:text => 'nocti')
88
19
  end
89
20
 
90
21
  it 'is a collection of Verso::Credential objects' do
91
- @credentials.first.should be_a(Verso::Credential)
22
+ @list.first.should be_a(Verso::Credential)
92
23
  end
93
24
 
94
25
  it 'is related to the search term' do
95
- @credentials.first.source.title.should match (/NOCTI/)
26
+ @list.first.source.title.should match (/NOCTI/)
96
27
  end
97
28
  end
98
29
 
@@ -1,96 +1,24 @@
1
1
  require 'spec_helper'
2
+ require 'shared_verso_list_examples'
2
3
 
3
4
  describe Verso::EditionList do
4
5
  use_vcr_cassette :record => :new_episodes
5
6
 
6
7
  before(:each) do
7
- @editions = Verso::EditionList.new
8
+ @list = Verso::EditionList.new
9
+ @kontained = OpenStruct
8
10
  end
9
11
 
10
- describe 'array-like behavior' do
11
- describe '#[]' do
12
- it 'responds' do
13
- @editions.should respond_to(:[])
14
- end
15
-
16
- it 'gets a OpenStruct object' do
17
- @editions[0].should be_a(OpenStruct)
18
- end
19
- end
20
-
21
- describe '#each' do
22
- it 'responds' do
23
- @editions.should respond_to(:each)
24
- end
25
-
26
- it 'yields' do
27
- expect { |b| @editions.each("foo", &b).to yield_control }
28
- end
29
-
30
- it 'yields OpenStruct objects' do
31
- @editions.each { |c| c.should be_a(OpenStruct) }
32
- end
33
- end
34
-
35
- describe '#empty?' do
36
- it 'responds' do
37
- @editions.should respond_to(:empty?)
38
- end
39
-
40
- it 'is not empty' do
41
- @editions.should_not be_empty
42
- end
43
- end
44
-
45
- describe '#last' do
46
- it 'responds' do
47
- @editions.should respond_to(:last)
48
- end
49
-
50
- it 'is a OpenStruct object' do
51
- @editions.last.should be_a(OpenStruct)
52
- end
53
- end
54
-
55
- describe '#length' do
56
- it 'responds' do
57
- @editions.should respond_to(:length)
58
- end
59
-
60
- it 'is a Fixnum' do
61
- @editions.length.should be_a(Fixnum)
62
- end
63
- end
64
-
65
- describe '#first' do
66
- it 'responds' do
67
- @editions.should respond_to(:first)
68
- end
69
-
70
- it 'is a OpenStruct object' do
71
- @editions.first.should be_a(OpenStruct)
72
- end
73
- end
74
-
75
- describe '#count' do
76
- it 'responds' do
77
- @editions.should respond_to(:count)
78
- end
79
-
80
- it 'is a Fixnum' do
81
- @editions.count.should be_a(Fixnum)
82
- end
83
- end
84
- end
12
+ it_behaves_like 'any Verso list'
85
13
 
86
14
  describe 'OpenStruct edition proxy' do
87
15
  describe '#year' do
88
16
  it 'responds' do
89
- @editions.last.should respond_to(:year)
17
+ @list.last.should respond_to(:year)
90
18
  end
91
19
 
92
20
  it 'looks like a year' do
93
- @editions.first.year.should match(/2\d{3}/)
21
+ @list.first.year.should match(/2\d{3}/)
94
22
  end
95
23
  end
96
24
  end
@@ -1,85 +1,13 @@
1
1
  require 'spec_helper'
2
+ require 'shared_verso_list_examples'
2
3
 
3
4
  describe Verso::EmphasisList do
4
5
  use_vcr_cassette :record => :new_episodes
5
6
 
6
7
  before do
7
- @emphases = Verso::EmphasisList.new
8
+ @list = Verso::EmphasisList.new
9
+ @kontained = Verso::Emphasis
8
10
  end
9
11
 
10
- describe 'array-like behavior' do
11
- describe '#[]' do
12
- it 'responds' do
13
- @emphases.should respond_to(:[])
14
- end
15
-
16
- it 'gets a Verso::Emphasis object' do
17
- @emphases[10].should be_a(Verso::Emphasis)
18
- end
19
- end
20
-
21
- describe '#each' do
22
- it 'responds' do
23
- @emphases.should respond_to(:each)
24
- end
25
-
26
- it 'yields' do
27
- expect { |b| @emphases.each("foo", &b).to yield_control }
28
- end
29
-
30
- it 'yields Verso::Emphasis objects' do
31
- @emphases.each { |c| c.should be_a(Verso::Emphasis) }
32
- end
33
- end
34
-
35
- describe '#empty?' do
36
- it 'responds' do
37
- @emphases.should respond_to(:empty?)
38
- end
39
-
40
- it 'is not empty' do
41
- @emphases.should_not be_empty
42
- end
43
- end
44
-
45
- describe '#last' do
46
- it 'responds' do
47
- @emphases.should respond_to(:last)
48
- end
49
-
50
- it 'is a Verso::Emphasis object' do
51
- @emphases.last.should be_a(Verso::Emphasis)
52
- end
53
- end
54
-
55
- describe '#length' do
56
- it 'responds' do
57
- @emphases.should respond_to(:length)
58
- end
59
-
60
- it 'is a Fixnum' do
61
- @emphases.length.should be_a(Fixnum)
62
- end
63
- end
64
-
65
- describe '#first' do
66
- it 'responds' do
67
- @emphases.should respond_to(:first)
68
- end
69
-
70
- it 'is a Verso::Emphasis object' do
71
- @emphases.first.should be_a(Verso::Emphasis)
72
- end
73
- end
74
-
75
- describe '#count' do
76
- it 'responds' do
77
- @emphases.should respond_to(:count)
78
- end
79
-
80
- it 'is a Fixnum' do
81
- @emphases.count.should be_a(Fixnum)
82
- end
83
- end
84
- end
12
+ it_behaves_like 'any Verso list'
85
13
  end