rdf-rdfxml 0.0.3 → 0.2.0

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.2.0
2
+ * Updates for RDF 0.2.0
3
+ * Use URI#intern instead of URI#new
4
+ * Change use of Graph#predicates and Graph#objects to use as enumberables
5
+
1
6
  === 0.0.3
2
7
  * Added patches for the following:
3
8
  * RDF::Graph#properties
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ begin
12
12
  gemspec.email = "gregg@kellogg-assoc.com"
13
13
  gemspec.homepage = "http://github.com/gkellogg/rdf-rdfxml"
14
14
  gemspec.authors = ["Gregg Kellogg"]
15
- gemspec.add_dependency('rdf', '>= 0.1.6')
15
+ gemspec.add_dependency('rdf', '>= 0.2.0')
16
16
  gemspec.add_dependency('nokogiri', '>= 1.3.3')
17
17
  gemspec.add_development_dependency('rspec')
18
18
  gemspec.add_development_dependency('rdf-spec')
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.2.0
@@ -3,6 +3,6 @@ class Nokogiri::XML::Node
3
3
  # URI of namespace + node_name
4
4
  def uri
5
5
  ns = self.namespace ? self.namespace.href : RDF::XML.to_s
6
- RDF::URI.new(ns + self.node_name)
6
+ RDF::URI.intern(ns + self.node_name)
7
7
  end
8
8
  end unless Nokogiri::XML::Node.method_defined?(:uri)
@@ -31,7 +31,7 @@ module RDF
31
31
  def self.[](property)
32
32
  @prop_uri ||= {}
33
33
  @prop_uri[property] ||= begin
34
- uri = RDF::URI.new([to_s, property.to_s].join(''))
34
+ uri = RDF::URI.intern([to_s, property.to_s].join(''))
35
35
  uri.vocab = self
36
36
  uri
37
37
  end
@@ -40,7 +40,7 @@ module RDF
40
40
  def [](property)
41
41
  @prop_uri ||= {}
42
42
  @prop_uri[property] ||= begin
43
- uri = RDF::URI.new([to_s, property.to_s].join(''))
43
+ uri = RDF::URI.intern([to_s, property.to_s].join(''))
44
44
  uri.vocab = self
45
45
  uri
46
46
  end
@@ -48,7 +48,7 @@ module RDF
48
48
 
49
49
  def to_uri
50
50
  @uri ||= begin
51
- uri = RDF::URI.new(to_s)
51
+ uri = RDF::URI.intern(to_s)
52
52
  uri.vocab = self
53
53
  uri
54
54
  end
@@ -35,7 +35,7 @@ module RDF::RDFXML
35
35
 
36
36
  def initialize(base, element, graph)
37
37
  # Initialize the evaluation context, [5.1]
38
- self.base = RDF::URI.new(base)
38
+ self.base = RDF::URI.intern(base)
39
39
  @uri_mappings = {}
40
40
  @language = nil
41
41
  @graph = graph
@@ -99,7 +99,7 @@ module RDF::RDFXML
99
99
 
100
100
  # Set XML base. Ignore any fragment
101
101
  def base=(b)
102
- @base = RDF::URI.new(b)
102
+ @base = RDF::URI.intern(b)
103
103
  @base.fragment = nil
104
104
  end
105
105
 
@@ -125,7 +125,7 @@ module RDF::RDFXML
125
125
  super do
126
126
  @debug = options[:debug]
127
127
  @strict = options[:strict]
128
- @base_uri = RDF::URI.new(options[:base_uri])
128
+ @base_uri = RDF::URI.intern(options[:base_uri])
129
129
 
130
130
  @id_mapping = Hash.new
131
131
 
@@ -1,7 +1,7 @@
1
1
  module RDF::RDFXML::VERSION
2
2
  MAJOR = 0
3
- MINOR = 0
4
- TINY = 2
3
+ MINOR = 2
4
+ TINY = 0
5
5
  EXTRA = nil
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
@@ -18,7 +18,7 @@ module RDF::RDFXML
18
18
  #
19
19
  # @example Serializing RDF graph into an RDF/XML file
20
20
  # RDF::RDFXML::Write.open("etc/test.rdf") do |writer|
21
- # writer.write_graph(graph)
21
+ # writer << graph
22
22
  # end
23
23
  #
24
24
  # @example Serializing RDF statements into an RDF/XML file
@@ -70,14 +70,14 @@ module RDF::RDFXML
70
70
  ##
71
71
  # @param [Graph] graph
72
72
  # @return [void]
73
- def write_graph(graph)
73
+ def insert_graph(graph)
74
74
  @graph = graph
75
75
  end
76
76
 
77
77
  ##
78
78
  # @param [Statement] statement
79
79
  # @return [void]
80
- def write_statement(statement)
80
+ def insert_statement(statement)
81
81
  @graph << statement
82
82
  end
83
83
 
@@ -89,7 +89,7 @@ module RDF::RDFXML
89
89
  # @param [RDF::Value] object
90
90
  # @return [void]
91
91
  # @see #write_epilogue
92
- def write_triple(subject, predicate, object)
92
+ def insert_triple(subject, predicate, object)
93
93
  @graph << RDF::Statement.new(subject, predicate, object)
94
94
  end
95
95
 
@@ -112,19 +112,13 @@ module RDF::RDFXML
112
112
 
113
113
  doc = Nokogiri::XML::Document.new
114
114
 
115
- add_debug "\nserialize: graph namespaces: #{@namespaces.inspect}"
116
115
  add_debug "\nserialize: graph: #{@graph.size}"
117
116
 
118
117
  preprocess
119
118
 
120
- predicates = @graph.predicates.uniq
121
- add_debug "\nserialize: predicates #{predicates.inspect}"
122
- possible = predicates + @graph.objects.uniq
123
- namespaces = {}
124
- required_namespaces = {}
125
- possible.each do |res|
126
- get_qname(res)
127
- end
119
+ # Get QNames and necessary namespaces from predicates and objects
120
+ @graph.predicates.each {|pred| add_debug("serialize pred: #{pred.inspect}"); get_qname(pred)}
121
+ @graph.objects.each {|obj| add_debug("serialize obj: #{obj.inspect}"); get_qname(obj)}
128
122
  add_namespace(:rdf, RDF_NS)
129
123
  add_namespace(:xml, RDF::XML) if @base_uri || @lang
130
124
 
@@ -134,6 +128,8 @@ module RDF::RDFXML
134
128
  add_debug("def_namespace: #{@default_namespace}, prefix: #{@default_namespace_prefix}")
135
129
  end
136
130
 
131
+ add_debug "\nserialize: graph namespaces: #{@namespaces.inspect}"
132
+
137
133
  doc.root = Nokogiri::XML::Element.new("rdf:RDF", doc)
138
134
  @namespaces.each_pair do |p, uri|
139
135
  if p.to_s.empty?
@@ -188,7 +184,7 @@ module RDF::RDFXML
188
184
  end
189
185
 
190
186
  prop_list.each do |prop|
191
- prop_ref = RDF::URI.new(prop)
187
+ prop_ref = RDF::URI.intern(prop)
192
188
 
193
189
  properties[prop].each do |object|
194
190
  @depth += 1
@@ -211,7 +207,7 @@ module RDF::RDFXML
211
207
  # If _is_unique_ is true, this predicate may be able to be serialized as an attribute
212
208
  def predicate(prop, object, node, is_unique)
213
209
  qname = get_qname(prop)
214
- raise RdfException, "No qname generated for <#{prop}>" unless qname
210
+ raise RDF::WriterError, "No qname generated for <#{prop}>" unless qname
215
211
 
216
212
  # See if we can serialize as attribute.
217
213
  # * untyped attributes that aren't duplicated where xml:lang == @lang
@@ -422,6 +418,7 @@ module RDF::RDFXML
422
418
  end
423
419
 
424
420
  def add_namespace(prefix, ns)
421
+ add_debug "add_namespace: '#{prefix}', <#{ns}>"
425
422
  @namespaces[prefix.to_sym] = ns.to_s
426
423
  end
427
424
 
data/rdf-rdfxml.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rdf-rdfxml}
8
- s.version = "0.0.3"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Gregg Kellogg"]
12
- s.date = %q{2010-06-12}
12
+ s.date = %q{2010-06-17}
13
13
  s.description = %q{ RDF::RDFXML is an RDF/XML reader and writer for Ruby using the RDF.rb library suite.
14
14
  }
15
15
  s.email = %q{gregg@kellogg-assoc.com}
@@ -438,20 +438,20 @@ Gem::Specification.new do |s|
438
438
  s.specification_version = 3
439
439
 
440
440
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
441
- s.add_runtime_dependency(%q<rdf>, [">= 0.1.6"])
441
+ s.add_runtime_dependency(%q<rdf>, [">= 0.2.0"])
442
442
  s.add_runtime_dependency(%q<nokogiri>, [">= 1.3.3"])
443
443
  s.add_development_dependency(%q<rspec>, [">= 0"])
444
444
  s.add_development_dependency(%q<rdf-spec>, [">= 0"])
445
445
  s.add_development_dependency(%q<activesupport>, [">= 2.3.0"])
446
446
  else
447
- s.add_dependency(%q<rdf>, [">= 0.1.6"])
447
+ s.add_dependency(%q<rdf>, [">= 0.2.0"])
448
448
  s.add_dependency(%q<nokogiri>, [">= 1.3.3"])
449
449
  s.add_dependency(%q<rspec>, [">= 0"])
450
450
  s.add_dependency(%q<rdf-spec>, [">= 0"])
451
451
  s.add_dependency(%q<activesupport>, [">= 2.3.0"])
452
452
  end
453
453
  else
454
- s.add_dependency(%q<rdf>, [">= 0.1.6"])
454
+ s.add_dependency(%q<rdf>, [">= 0.2.0"])
455
455
  s.add_dependency(%q<nokogiri>, [">= 1.3.3"])
456
456
  s.add_dependency(%q<rspec>, [">= 0"])
457
457
  s.add_dependency(%q<rdf-spec>, [">= 0"])
data/spec/writer_spec.rb CHANGED
@@ -382,7 +382,7 @@ describe "RDF::RDFXML::Writer" do
382
382
  def serialize(options = {})
383
383
  @debug = []
384
384
  result = RDF::RDFXML::Writer.buffer(options.merge(:debug => @debug)) do |writer|
385
- writer.write_graph(@graph)
385
+ writer << @graph
386
386
  end
387
387
  puts @debug.join("\n") if $DEBUG
388
388
  result
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf-rdfxml
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
+ - 2
8
9
  - 0
9
- - 3
10
- version: 0.0.3
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gregg Kellogg
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-12 00:00:00 -04:00
18
+ date: 2010-06-17 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -29,9 +29,9 @@ dependencies:
29
29
  hash: 23
30
30
  segments:
31
31
  - 0
32
- - 1
33
- - 6
34
- version: 0.1.6
32
+ - 2
33
+ - 0
34
+ version: 0.2.0
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency