rdf 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,50 @@
1
+ module RDF class Writer
2
+ ##
3
+ # An N-Triples serializer.
4
+ #
5
+ # @see <http://www.w3.org/TR/rdf-testcases/#ntriples>
6
+ class NTriples < Writer
7
+ content_type 'text/plain', :extension => :nt
8
+ content_encoding 'ascii'
9
+
10
+ ##
11
+ # @param [String] text
12
+ # @return [void]
13
+ def write_comment(text)
14
+ puts "# #{text}"
15
+ end
16
+
17
+ ##
18
+ # @param [Resource] subject
19
+ # @param [URI] predicate
20
+ # @param [Value] object
21
+ # @return [void]
22
+ def write_triple(subject, predicate, object)
23
+ s = format_uri(subject)
24
+ p = format_uri(predicate)
25
+ o = object.kind_of?(RDF::URI) ? format_uri(object) : format_literal(object)
26
+ puts "%s %s %s ." % [s, p, o]
27
+ end
28
+
29
+ ##
30
+ # @param [node] Resource
31
+ # @return [void]
32
+ def format_uri(node)
33
+ "<%s>" % uri_for(node)
34
+ end
35
+
36
+ ##
37
+ # @param [String, Literal] literal
38
+ # @return [void]
39
+ def format_literal(literal) # TODO
40
+ #if literal.kind_of?(RDF::Literal)
41
+ # text = quoted(escaped(literal.value))
42
+ # text << "@#{literal.language}" if literal.language
43
+ # text << "^^<#{uri_for(literal.type)}>" if literal.type
44
+ # text
45
+ #else
46
+ quoted(escaped(literal.to_s))
47
+ #end
48
+ end
49
+ end
50
+ end end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arto Bendiken
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-22 00:00:00 +01:00
12
+ date: 2009-12-23 00:00:00 +01:00
13
13
  default_executable: rdf
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -36,6 +36,7 @@ description: RDF.rb is a pure-Ruby library for working with Resource Description
36
36
  email: arto.bendiken@gmail.com
37
37
  executables:
38
38
  - rdf
39
+ - rdf-count
39
40
  extensions: []
40
41
 
41
42
  extra_rdoc_files: []
@@ -47,10 +48,22 @@ files:
47
48
  - UNLICENSE
48
49
  - VERSION
49
50
  - bin/rdf
51
+ - bin/rdf-count
52
+ - bin/rdf-lengths
53
+ - bin/rdf-objects
54
+ - bin/rdf-predicates
55
+ - bin/rdf-subjects
56
+ - lib/df.rb
57
+ - lib/rdf/cli.rb
58
+ - lib/rdf/graph.rb
59
+ - lib/rdf/literal.rb
60
+ - lib/rdf/node.rb
50
61
  - lib/rdf/reader/ntriples.rb
51
62
  - lib/rdf/reader.rb
63
+ - lib/rdf/resource.rb
52
64
  - lib/rdf/statement.rb
53
65
  - lib/rdf/uri.rb
66
+ - lib/rdf/value.rb
54
67
  - lib/rdf/version.rb
55
68
  - lib/rdf/vocabulary/cc.rb
56
69
  - lib/rdf/vocabulary/dc.rb
@@ -68,6 +81,8 @@ files:
68
81
  - lib/rdf/vocabulary/xhtml.rb
69
82
  - lib/rdf/vocabulary/xsd.rb
70
83
  - lib/rdf/vocabulary.rb
84
+ - lib/rdf/writer/ntriples.rb
85
+ - lib/rdf/writer.rb
71
86
  - lib/rdf.rb
72
87
  has_rdoc: false
73
88
  homepage: http://rdf.rubyforge.org/