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 CHANGED
@@ -1,3 +1,8 @@
1
+ redlander (0.5.2)
2
+
3
+ * UTF-8 output for Node#value
4
+ * value of the blank node is its identifier without "_:" prefix
5
+
1
6
  redlander (0.5.1)
2
7
 
3
8
  * fixed a memory leak in Model#query
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- redlander (0.5.1)
4
+ redlander (0.5.2)
5
5
  ffi (~> 1.1)
6
6
  xml_schema (~> 0.1.3)
7
7
 
@@ -144,7 +144,7 @@ If anything unexpected happens, Redlander raises RedlandError.
144
144
 
145
145
  = Authors and Contributors
146
146
 
147
- Slava Kravchenko <slava.kravchenko@gmail.com>
147
+ Slava Kravchenko <https://github.com/cordawyn>
148
148
 
149
149
  = Thanks
150
150
 
@@ -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
@@ -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
- XmlSchema.instantiate(to_s)
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
 
@@ -1,4 +1,4 @@
1
1
  module Redlander
2
2
  # Redlander version number
3
- VERSION = "0.5.1"
3
+ VERSION = "0.5.2"
4
4
  end
@@ -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 = ["C\\u0103lin Ardelean", "Danny Gagne", "Joey Geiger", "Fumihiro Kato", "Naoki Kawamukai", "Hellekin O. Wolf", "John Fieber", "Keita Urashima", "Pius Uzamere"]
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.value.should match(/^_:\w+$/)
13
+ subject.to_s.should eql "_:#{subject.value}"
14
14
  end
15
15
 
16
- context "when given :blank_id" do
17
- before { @options = {:blank_id => "blank0"} }
16
+ describe "value" do
17
+ subject { described_class.new(nil, @options).value }
18
18
 
19
- it "should create a node with the given identifier" do
20
- expect(subject.value).to eql "_:blank0"
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
- it "should create a resource node" do
26
- resource_uri = URI.parse('http://example.com/nodes#node_1')
27
- Node.new(resource_uri).should be_resource
28
- end
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
- it "should create a literal node from a literal rdf_node" do
31
- node1 = Node.new("hello, world")
32
- node2 = Node.new(node1.rdf_node)
33
- node2.datatype.should_not be_nil
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
- it "should create a string literal" do
38
- node = Node.new("hello, world")
39
- node.should be_literal
40
- node.datatype.should eql URI("http://www.w3.org/2001/XMLSchema#string")
41
- end
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
- it "should create a boolean literal" do
44
- node = Node.new(true)
45
- node.should be_literal
46
- node.datatype.should eql URI("http://www.w3.org/2001/XMLSchema#boolean")
47
- end
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
- it "should create an integer number literal" do
50
- node = Node.new(10)
51
- node.should be_literal
52
- node.datatype.should eql URI("http://www.w3.org/2001/XMLSchema#integer")
53
- end
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
- it "should create a floating-point number literal" do
56
- node = Node.new(3.1416)
57
- node.should be_literal
58
- node.datatype.should eql URI("http://www.w3.org/2001/XMLSchema#float")
59
- end
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
- it "should create a time literal" do
62
- node = Node.new(Time.now)
63
- node.should be_literal
64
- node.datatype.should eql URI("http://www.w3.org/2001/XMLSchema#time")
65
- end
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
- it "should create a date literal" do
68
- node = Node.new(Date.today)
69
- node.should be_literal
70
- node.datatype.should eql URI("http://www.w3.org/2001/XMLSchema#date")
71
- end
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
- it "should create a datetime literal" do
74
- node = Node.new(DateTime.now)
75
- node.should be_literal
76
- node.datatype.should eql URI("http://www.w3.org/2001/XMLSchema#dateTime")
77
- end
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
- it "should have proper string representation" do
80
- node = Node.new("Bye-bye, cruel world...")
81
- node.to_s.should eql('"Bye-bye, cruel world..."^^<http://www.w3.org/2001/XMLSchema#string>')
82
- end
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
- it "should have a proper value for a literal node" do
85
- t = Time.now
86
- node = Node.new(t)
87
- node.value.should be_an_instance_of(Time)
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
- it "should have an instance of URI for a resource node" do
93
- resource_uri = URI('http://example.com/nodes#node_1')
94
- Node.new(resource_uri).value.should be_an_instance_of(URI::HTTP)
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.1
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-07-31 00:00:00.000000000 Z
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: !ruby/object:Gem::Requirement
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: !ruby/object:Gem::Requirement
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: !ruby/object:Gem::Requirement
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.24
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).