lightrdf 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ === 0.3.3 2011-03-22
2
+
3
+ * Parsing of ntriples with literals with language annotations.
4
+ * RDFa parsing support with URI as parsing parameter
5
+
1
6
  === 0.3.2 2011-03-22
2
7
 
3
8
  * Added RDF::Graph#== and RDF::Graph#contains methods that disambiguate bnodes
@@ -51,13 +51,13 @@ module RDF
51
51
  end
52
52
  end
53
53
 
54
- def self.parse format, text
54
+ def self.parse format, text, uri=nil
55
55
  case format
56
56
  when :ntriples
57
57
  graph = RDF::Graph.new
58
58
  graph.triples = text.split("\n").select{|l| l.strip!=''}.map do |l|
59
- s, p, o = l.strip.match(/\A(<\S+>|".*"|_:\w+)\s+(<\S+>|".*"|_:\w+)\s+(<\S+>|".*"|_:\w+)\s+\.\Z/).captures
60
- [parse_chunk_ntriples(s), parse_chunk_ntriples(p), parse_chunk_ntriples(o)]
59
+ s, lang1, p, lang2, o, lang3 = l.strip.match(/\A(<\S+>|".*"(@\w+)?|_:\w+)\s+(<\S+>|".*"(@\w+)?|_:\w+)\s+(<\S+>|".*"(@\w+)?|_:\w+)\s+\.\Z/).captures
60
+ [parse_chunk_ntriples(s,uri), parse_chunk_ntriples(p,uri), parse_chunk_ntriples(o,uri)]
61
61
  end
62
62
  graph
63
63
  when :yarf
@@ -83,7 +83,7 @@ module RDF
83
83
  else
84
84
  tempfile = new_tempfile
85
85
  File.open(tempfile, 'w') { |f| f.write text }
86
- parse :ntriples, %x[rapper -q -i #{format} -o ntriples #{tempfile} 2> /dev/null]
86
+ parse :ntriples, %x[rapper -q -i #{format} -o ntriples #{tempfile} 2> /dev/null], uri
87
87
  end
88
88
  end
89
89
 
@@ -215,12 +215,17 @@ module RDF
215
215
  end
216
216
  end
217
217
 
218
- def self.parse_chunk_ntriples c
218
+ def self.parse_chunk_ntriples c, uri=nil
219
219
  case c[0..0]
220
- when '<' then Node c[1..-2]
220
+ when '<' then
221
+ if uri
222
+ Node(URI::parse(uri).merge(c[1..-2]).to_s)
223
+ else
224
+ Node c[1..-2]
225
+ end
221
226
  when '_' then Node c
222
227
  when '"' then
223
- ActiveSupport::JSON.decode(c)
228
+ ActiveSupport::JSON.decode(c.match(/\A(\".*\")(@\w+)?\Z/).captures.first)
224
229
  else
225
230
  raise Exception, "Parsing error: #{c}"
226
231
  end
data/lib/lightrdf.rb CHANGED
@@ -2,7 +2,7 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
4
  module RDF
5
- VERSION = '0.3.2'
5
+ VERSION = '0.3.3'
6
6
  end
7
7
 
8
8
  require 'rubygems'
data/lightrdf.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{lightrdf}
5
- s.version = "0.3.2"
5
+ s.version = "0.3.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Jose Ignacio"]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 2
9
- version: 0.3.2
8
+ - 3
9
+ version: 0.3.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jose Ignacio