rdf-spec 0.1.10 → 0.2.0

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.
@@ -11,41 +11,52 @@ share_as :RDF_Repository do
11
11
  @enumerable = @repository
12
12
  end
13
13
 
14
- context "when updating" do
15
- require 'rdf/spec/mutable'
14
+ context "when counting statements" do
15
+ require 'rdf/spec/countable'
16
16
 
17
17
  before :each do
18
- @subject = RDF::URI.new("http://rubygems.org/gems/rdf")
19
- @context = RDF::URI.new("http://example.org/context")
18
+ @countable = @repository
19
+ @countable.insert(*@statements)
20
20
  end
21
21
 
22
- it_should_behave_like RDF_Mutable
23
-
22
+ it_should_behave_like RDF_Countable
24
23
  end
25
24
 
26
25
  context "when enumerating statements" do
27
26
  require 'rdf/spec/enumerable'
28
27
 
29
28
  before :each do
30
- @repository.insert(*@statements)
31
29
  @enumerable = @repository
30
+ @enumerable.insert(*@statements)
32
31
  end
33
32
 
34
33
  it_should_behave_like RDF_Enumerable
35
34
  end
36
35
 
37
- context "when querying statements, " do
36
+ context "when querying statements" do
38
37
  require 'rdf/spec/queryable'
39
38
 
40
39
  before :each do
41
- @subject = RDF::URI.new("http://rubygems.org/gems/rdf")
42
40
  @queryable = @repository
41
+ @subject = RDF::URI.new('http://rubygems.org/gems/rdf')
43
42
  end
44
43
 
45
44
  it_should_behave_like RDF_Queryable
46
45
  end
47
46
 
48
- context "as a durable repository, " do
47
+ context "when updating" do
48
+ require 'rdf/spec/mutable'
49
+
50
+ before :each do
51
+ @mutable = @repository
52
+ @subject = RDF::URI.new('http://rubygems.org/gems/rdf')
53
+ @context = RDF::URI.new('http://example.org/context')
54
+ end
55
+
56
+ it_should_behave_like RDF_Mutable
57
+ end
58
+
59
+ context "as a durable repository" do
49
60
  require 'rdf/spec/durable'
50
61
 
51
62
  before :each do
@@ -101,21 +101,60 @@ share_as :RDF_Statement do
101
101
  end
102
102
 
103
103
  context "when used like an Array" do
104
- it "should support #to_a" do
104
+ it "should respond to #to_a" do
105
105
  @stmt.should respond_to(:to_a)
106
- @stmt.to_a.should eql([@stmt.subject, @stmt.predicate, @stmt.object])
107
106
  end
108
107
 
109
- it "should support #[]" do
108
+ it "should respond to #[]" do
110
109
  @stmt.should respond_to(:[])
110
+ end
111
+
112
+ it "should respond to #[]=" do
113
+ @stmt.should respond_to(:[]=)
114
+ end
115
+
116
+ it "should support #to_a" do
117
+ @stmt.to_a.should eql([@stmt.subject, @stmt.predicate, @stmt.object])
118
+ end
119
+
120
+ it "should support #[] for the subject" do
111
121
  @stmt[0].should equal(@stmt.subject)
122
+ end
123
+
124
+ it "should support #[] for the predicate" do
112
125
  @stmt[1].should equal(@stmt.predicate)
126
+ end
127
+
128
+ it "should support #[] for the object" do
113
129
  @stmt[2].should equal(@stmt.object)
114
130
  end
115
131
 
116
- it "should support #[]=" do
117
- @stmt.should respond_to(:[]=)
118
- # TODO
132
+ it "should support #[] for the context" do
133
+ @stmt[3].should equal(@stmt.context)
134
+ end
135
+
136
+ it "should support #[]= for the subject" do
137
+ stmt = @stmt.dup
138
+ stmt[0] = s = RDF::URI("http://example.org/subject")
139
+ stmt.subject.should == s
140
+ end
141
+
142
+ it "should support #[]= for the predicate" do
143
+ stmt = @stmt.dup
144
+ stmt[1] = p = RDF::URI("http://example.org/predicate")
145
+ stmt.predicate.should == p
146
+ end
147
+
148
+ it "should support #[]= for the object" do
149
+ stmt = @stmt.dup
150
+ stmt[2] = o = RDF::URI("http://example.org/object")
151
+ stmt.object.should == o
152
+ end
153
+
154
+ it "should support #[]= for the context" do
155
+ stmt = @stmt.dup
156
+ stmt[3] = c = RDF::URI("http://example.org/context")
157
+ stmt.context.should == c
119
158
  end
120
159
  end
121
160
 
@@ -126,6 +165,7 @@ share_as :RDF_Statement do
126
165
  :subject => @stmt.subject,
127
166
  :predicate => @stmt.predicate,
128
167
  :object => @stmt.object,
168
+ :context => @stmt.context,
129
169
  })
130
170
  end
131
171
  end
data/lib/rdf/spec/uri.rb CHANGED
@@ -2,39 +2,60 @@ require 'rdf'
2
2
  require 'rdf/spec'
3
3
 
4
4
  share_as :RDF_URI do
5
-
6
5
  before :each do
7
6
  raise '+@new+ must be defined in a before(:each) block' unless instance_variable_get('@new')
8
7
  end
9
8
 
10
9
  it "should be instantiable" do
11
- lambda { @new.call("http://rdf.rubyforge.org/") }.should_not raise_error
10
+ lambda { @new.call('http://rdf.rubyforge.org/') }.should_not raise_error
11
+ end
12
+
13
+ it "should recognize URNs" do
14
+ urns = %w(urn:isbn:0451450523 urn:isan:0000-0000-9E59-0000-O-0000-0000-2 urn:issn:0167-6423 urn:ietf:rfc:2648 urn:mpeg:mpeg7:schema:2001 urn:oid:2.16.840 urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66 urn:uci:I001+SBSi-B10000083052)
15
+ urns.each do |urn|
16
+ uri = @new.call(urn)
17
+ uri.should be_a_uri
18
+ uri.should respond_to(:urn?)
19
+ uri.should be_a_urn
20
+ uri.should_not be_a_url
21
+ end
22
+ end
23
+
24
+ it "should recognize URLs" do
25
+ urls = %w(mailto:jhacker@example.org http://example.org/ ftp://example.org/)
26
+ urls.each do |url|
27
+ uri = @new.call(url)
28
+ uri.should be_a_uri
29
+ uri.should respond_to(:url?)
30
+ uri.should be_a_url
31
+ uri.should_not be_a_urn
32
+ end
12
33
  end
13
34
 
14
35
  it "should return the root URI" do
15
- uri = @new.call("http://rdf.rubyforge.org/RDF/URI.html")
36
+ uri = @new.call('http://rdf.rubyforge.org/RDF/URI.html')
16
37
  uri.should respond_to(:root)
17
38
  uri.root.should be_a_uri
18
- uri.root.should == @new.call("http://rdf.rubyforge.org/")
39
+ uri.root.should == @new.call('http://rdf.rubyforge.org/')
19
40
  end
20
41
 
21
42
  it "should find the parent URI" do
22
- uri = @new.call("http://rdf.rubyforge.org/RDF/URI.html")
43
+ uri = @new.call('http://rdf.rubyforge.org/RDF/URI.html')
23
44
  uri.should respond_to(:parent)
24
45
  uri.parent.should be_a_uri
25
- uri.parent.should == @new.call("http://rdf.rubyforge.org/RDF/")
26
- uri.parent.parent.should == @new.call("http://rdf.rubyforge.org/")
46
+ uri.parent.should == @new.call('http://rdf.rubyforge.org/RDF/')
47
+ uri.parent.parent.should == @new.call('http://rdf.rubyforge.org/')
27
48
  uri.parent.parent.parent.should be_nil
28
49
  end
29
50
 
30
- it "should return a consistent hash code" do
31
- hash1 = @new.call("http://rdf.rubyforge.org/").hash
32
- hash2 = @new.call("http://rdf.rubyforge.org/").hash
51
+ it "should have a consistent hash code" do
52
+ hash1 = @new.call('http://rdf.rubyforge.org/').hash
53
+ hash2 = @new.call('http://rdf.rubyforge.org/').hash
33
54
  hash1.should == hash2
34
55
  end
35
56
 
36
57
  it "should be duplicable" do
37
- url = Addressable::URI.parse("http://rdf.rubyforge.org/")
58
+ url = Addressable::URI.parse('http://rdf.rubyforge.org/')
38
59
  uri2 = (uri1 = @new.call(url)).dup
39
60
 
40
61
  uri1.should_not be_equal(uri2)
@@ -46,4 +67,8 @@ share_as :RDF_URI do
46
67
  uri1.should_not be_eql(uri2)
47
68
  uri1.should_not == uri2
48
69
  end
70
+
71
+ it "should not be #anonymous?" do
72
+ @new.call('http://example.org').should_not be_anonymous
73
+ end
49
74
  end
@@ -1,12 +1,11 @@
1
1
  module RDF; module Spec
2
2
  module VERSION
3
3
  MAJOR = 0
4
- MINOR = 1
5
- TINY = 10
4
+ MINOR = 2
5
+ TINY = 0
6
6
  EXTRA = nil
7
7
 
8
- STRING = [MAJOR, MINOR, TINY].join('.')
9
- STRING << ".#{EXTRA}" if EXTRA
8
+ STRING = [MAJOR, MINOR, TINY, EXTRA].compact.join('.')
10
9
 
11
10
  ##
12
11
  # @return [String]
@@ -0,0 +1,12 @@
1
+ require File.join(File.dirname(__FILE__), 'spec_helper')
2
+ require 'rdf/spec/countable'
3
+
4
+ describe RDF::Countable do
5
+ before :each do
6
+ @statements = RDF::NTriples::Reader.new(File.open('etc/doap.nt')).to_a
7
+ @countable = @statements.dup.extend(RDF::Countable)
8
+ end
9
+
10
+ # @see lib/rdf/spec/countable.rb
11
+ it_should_behave_like RDF_Countable
12
+ end
@@ -3,7 +3,7 @@ require 'rdf/spec/enumerable'
3
3
 
4
4
  describe RDF::Enumerable do
5
5
  before :each do
6
- @statements = RDF::NTriples::Reader.new(File.open("etc/doap.nt")).to_a
6
+ @statements = RDF::NTriples::Reader.new(File.open('etc/doap.nt')).to_a
7
7
  @enumerable = @statements.dup.extend(RDF::Enumerable)
8
8
  end
9
9
 
@@ -3,11 +3,11 @@ require 'rdf/spec/queryable'
3
3
 
4
4
  describe RDF::Queryable do
5
5
  before :each do
6
- @file = "etc/doap.nt"
7
- @statements = RDF::NTriples::Reader.new(File.open(@file)).to_a
8
- @queryable = @statements.extend(RDF::Queryable)
9
- @subject = RDF::URI.new("http://rubygems.org/gems/rdf")
6
+ @statements = RDF::NTriples::Reader.new(File.open(@file = 'etc/doap.nt')).to_a
7
+ @queryable = @statements.dup.extend(RDF::Queryable)
8
+ @subject = RDF::URI('http://rubygems.org/gems/rdf')
10
9
  end
11
10
 
11
+ # @see lib/rdf/spec/queryable.rb
12
12
  it_should_behave_like RDF_Queryable
13
13
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
- - 10
9
- version: 0.1.10
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Arto Bendiken
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-05-20 00:00:00 +02:00
18
+ date: 2010-06-17 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -23,13 +23,13 @@ dependencies:
23
23
  prerelease: false
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - ">="
26
+ - - ~>
27
27
  - !ruby/object:Gem::Version
28
28
  segments:
29
29
  - 0
30
- - 1
31
- - 10
32
- version: 0.1.10
30
+ - 2
31
+ - 0
32
+ version: 0.2.0
33
33
  type: :development
34
34
  version_requirements: *id001
35
35
  - !ruby/object:Gem::Dependency
@@ -56,8 +56,8 @@ dependencies:
56
56
  segments:
57
57
  - 0
58
58
  - 5
59
- - 4
60
- version: 0.5.4
59
+ - 6
60
+ version: 0.5.6
61
61
  type: :development
62
62
  version_requirements: *id003
63
63
  - !ruby/object:Gem::Dependency
@@ -65,7 +65,7 @@ dependencies:
65
65
  prerelease: false
66
66
  requirement: &id004 !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - ">="
68
+ - - ~>
69
69
  - !ruby/object:Gem::Version
70
70
  segments:
71
71
  - 1
@@ -88,6 +88,7 @@ files:
88
88
  - UNLICENSE
89
89
  - VERSION
90
90
  - etc/doap.nt
91
+ - lib/rdf/spec/countable.rb
91
92
  - lib/rdf/spec/durable.rb
92
93
  - lib/rdf/spec/enumerable.rb
93
94
  - lib/rdf/spec/graph.rb
@@ -102,6 +103,7 @@ files:
102
103
  - lib/rdf/spec/value.rb
103
104
  - lib/rdf/spec/version.rb
104
105
  - lib/rdf/spec.rb
106
+ - spec/countable_spec.rb
105
107
  - spec/enumerable_spec.rb
106
108
  - spec/queryable_spec.rb
107
109
  - spec/repository_spec.rb
@@ -122,8 +124,8 @@ required_ruby_version: !ruby/object:Gem::Requirement
122
124
  segments:
123
125
  - 1
124
126
  - 8
125
- - 2
126
- version: 1.8.2
127
+ - 1
128
+ version: 1.8.1
127
129
  required_rubygems_version: !ruby/object:Gem::Requirement
128
130
  requirements:
129
131
  - - ">="