redlander 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +5 -0
- data/Gemfile.lock +1 -1
- data/README.rdoc +1 -1
- data/lib/redland.rb +1 -0
- data/lib/redlander/node.rb +4 -1
- data/lib/redlander/version.rb +1 -1
- data/spec/lib/redlander/model_spec.rb +1 -1
- data/spec/lib/redlander/node_spec.rb +80 -63
- metadata +9 -30
data/ChangeLog
CHANGED
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
data/lib/redland.rb
CHANGED
@@ -60,6 +60,7 @@ module Redland
|
|
60
60
|
attach_function :librdf_node_equals, [:pointer, :pointer], :int
|
61
61
|
attach_function :librdf_node_to_string, [:pointer], :string
|
62
62
|
attach_function :librdf_node_get_uri, [:pointer], :pointer
|
63
|
+
attach_function :librdf_node_get_blank_identifier, [:pointer], :string
|
63
64
|
|
64
65
|
# Stream
|
65
66
|
attach_function :librdf_free_stream, [:pointer], :void
|
data/lib/redlander/node.rb
CHANGED
@@ -105,8 +105,11 @@ module Redlander
|
|
105
105
|
def value
|
106
106
|
if resource?
|
107
107
|
uri
|
108
|
+
elsif blank?
|
109
|
+
Redland.librdf_node_get_blank_identifier(@rdf_node).force_encoding("UTF-8")
|
108
110
|
else
|
109
|
-
|
111
|
+
v = Redland.librdf_node_get_literal_value(@rdf_node).force_encoding("UTF-8")
|
112
|
+
XmlSchema.instantiate(v, @datatype)
|
110
113
|
end
|
111
114
|
end
|
112
115
|
|
data/lib/redlander/version.rb
CHANGED
@@ -54,7 +54,7 @@ describe Model do
|
|
54
54
|
|
55
55
|
it "should yield multiple bindings" do
|
56
56
|
# TODO: librdf screws up the input UTF-8 encoding
|
57
|
-
helpers = ["
|
57
|
+
helpers = ["Călin Ardelean", "Danny Gagne", "Joey Geiger", "Fumihiro Kato", "Naoki Kawamukai", "Hellekin O. Wolf", "John Fieber", "Keita Urashima", "Pius Uzamere"]
|
58
58
|
|
59
59
|
expect(subject.size).to eql helpers.size
|
60
60
|
subject.each do |binding|
|
@@ -10,87 +10,104 @@ describe Node do
|
|
10
10
|
it { should be_blank }
|
11
11
|
|
12
12
|
it "should have a blank identifier for a blank node" do
|
13
|
-
subject.
|
13
|
+
subject.to_s.should eql "_:#{subject.value}"
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
describe "value" do
|
17
|
+
subject { described_class.new(nil, @options).value }
|
18
18
|
|
19
|
-
it "should
|
20
|
-
expect(subject.
|
19
|
+
it "should be UTF-8 encoded" do
|
20
|
+
expect(subject.encoding).to eql Encoding::UTF_8
|
21
|
+
end
|
22
|
+
|
23
|
+
it { should match(/^r\d+/) }
|
24
|
+
|
25
|
+
context "when given :blank_id" do
|
26
|
+
before { @options = {:blank_id => "blank0"} }
|
27
|
+
|
28
|
+
it { should eql "blank0" }
|
21
29
|
end
|
22
30
|
end
|
23
31
|
end
|
24
32
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
33
|
+
describe "resource" do
|
34
|
+
it "should create a resource node" do
|
35
|
+
resource_uri = URI.parse('http://example.com/nodes#node_1')
|
36
|
+
Node.new(resource_uri).should be_resource
|
37
|
+
end
|
29
38
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
node2.datatype.should eql node1.datatype
|
39
|
+
it "should have an instance of URI for a resource node" do
|
40
|
+
resource_uri = URI('http://example.com/nodes#node_1')
|
41
|
+
Node.new(resource_uri).value.should be_an_instance_of(URI::HTTP)
|
42
|
+
end
|
35
43
|
end
|
36
44
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
45
|
+
describe "literal" do
|
46
|
+
it "should be created from a literal rdf_node" do
|
47
|
+
node1 = Node.new("hello, world")
|
48
|
+
node2 = Node.new(node1.rdf_node)
|
49
|
+
node2.datatype.should_not be_nil
|
50
|
+
node2.datatype.should eql node1.datatype
|
51
|
+
end
|
42
52
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
53
|
+
it "should be created from a string" do
|
54
|
+
node = Node.new("hello, world")
|
55
|
+
node.should be_literal
|
56
|
+
node.datatype.should eql URI("http://www.w3.org/2001/XMLSchema#string")
|
57
|
+
end
|
48
58
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
59
|
+
it "should be created from a boolean value" do
|
60
|
+
node = Node.new(true)
|
61
|
+
node.should be_literal
|
62
|
+
node.datatype.should eql URI("http://www.w3.org/2001/XMLSchema#boolean")
|
63
|
+
end
|
54
64
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
65
|
+
it "should be created from an integer value" do
|
66
|
+
node = Node.new(10)
|
67
|
+
node.should be_literal
|
68
|
+
node.datatype.should eql URI("http://www.w3.org/2001/XMLSchema#integer")
|
69
|
+
end
|
60
70
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
71
|
+
it "should be created from a floating-point value" do
|
72
|
+
node = Node.new(3.1416)
|
73
|
+
node.should be_literal
|
74
|
+
node.datatype.should eql URI("http://www.w3.org/2001/XMLSchema#float")
|
75
|
+
end
|
66
76
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
77
|
+
it "should be created from a time value" do
|
78
|
+
node = Node.new(Time.now)
|
79
|
+
node.should be_literal
|
80
|
+
node.datatype.should eql URI("http://www.w3.org/2001/XMLSchema#time")
|
81
|
+
end
|
72
82
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
83
|
+
it "should be created from a date value" do
|
84
|
+
node = Node.new(Date.today)
|
85
|
+
node.should be_literal
|
86
|
+
node.datatype.should eql URI("http://www.w3.org/2001/XMLSchema#date")
|
87
|
+
end
|
78
88
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
89
|
+
it "should be created from a datetime value" do
|
90
|
+
node = Node.new(DateTime.now)
|
91
|
+
node.should be_literal
|
92
|
+
node.datatype.should eql URI("http://www.w3.org/2001/XMLSchema#dateTime")
|
93
|
+
end
|
83
94
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
# surprisingly, two instances of the same time do not compare
|
89
|
-
node.value.xmlschema.should eql(t.xmlschema)
|
90
|
-
end
|
95
|
+
it "should have proper string representation" do
|
96
|
+
node = Node.new("Bye-bye, cruel world...")
|
97
|
+
node.to_s.should eql('"Bye-bye, cruel world..."^^<http://www.w3.org/2001/XMLSchema#string>')
|
98
|
+
end
|
91
99
|
|
92
|
-
|
93
|
-
|
94
|
-
|
100
|
+
it "should have a properly instantiated value" do
|
101
|
+
t = Time.now
|
102
|
+
node = Node.new(t)
|
103
|
+
node.value.should be_an_instance_of(Time)
|
104
|
+
# surprisingly, two instances of the same time do not compare
|
105
|
+
node.value.xmlschema.should eql(t.xmlschema)
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should have UTF-9 encoded value" do
|
109
|
+
node = Node.new("test")
|
110
|
+
expect(node.value.encoding).to eql Encoding::UTF_8
|
111
|
+
end
|
95
112
|
end
|
96
113
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redlander
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
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-
|
12
|
+
date: 2012-09-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: xml_schema
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirement: &20744320 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,15 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.1.3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 0.1.3
|
24
|
+
version_requirements: *20744320
|
30
25
|
- !ruby/object:Gem::Dependency
|
31
26
|
name: ffi
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
27
|
+
requirement: &21431040 !ruby/object:Gem::Requirement
|
33
28
|
none: false
|
34
29
|
requirements:
|
35
30
|
- - ~>
|
@@ -37,15 +32,10 @@ dependencies:
|
|
37
32
|
version: '1.1'
|
38
33
|
type: :runtime
|
39
34
|
prerelease: false
|
40
|
-
version_requirements:
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '1.1'
|
35
|
+
version_requirements: *21431040
|
46
36
|
- !ruby/object:Gem::Dependency
|
47
37
|
name: rspec
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirement: &21430560 !ruby/object:Gem::Requirement
|
49
39
|
none: false
|
50
40
|
requirements:
|
51
41
|
- - ~>
|
@@ -53,12 +43,7 @@ dependencies:
|
|
53
43
|
version: '2'
|
54
44
|
type: :development
|
55
45
|
prerelease: false
|
56
|
-
version_requirements:
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '2'
|
46
|
+
version_requirements: *21430560
|
62
47
|
description: ! 'Redlander is Ruby bindings to Redland library (see http://librdf.org)
|
63
48
|
written in C, which is used to manipulate RDF graphs. This is an alternative implementation
|
64
49
|
of Ruby bindings (as opposed to the official bindings), aiming to be more intuitive,
|
@@ -115,21 +100,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
115
100
|
- - ! '>='
|
116
101
|
- !ruby/object:Gem::Version
|
117
102
|
version: '0'
|
118
|
-
segments:
|
119
|
-
- 0
|
120
|
-
hash: 302731036018920791
|
121
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
104
|
none: false
|
123
105
|
requirements:
|
124
106
|
- - ! '>='
|
125
107
|
- !ruby/object:Gem::Version
|
126
108
|
version: '0'
|
127
|
-
segments:
|
128
|
-
- 0
|
129
|
-
hash: 302731036018920791
|
130
109
|
requirements: []
|
131
110
|
rubyforge_project:
|
132
|
-
rubygems_version: 1.8.
|
111
|
+
rubygems_version: 1.8.11
|
133
112
|
signing_key:
|
134
113
|
specification_version: 3
|
135
114
|
summary: Advanced Ruby bindings for Redland runtime library (librdf).
|