rdf 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -5,9 +5,11 @@ This is a pure-Ruby library for working with [Resource Description Framework
5
5
  (RDF)][RDF] data.
6
6
 
7
7
  * <http://github.com/bendiken/rdf>
8
+ * <http://blog.datagraph.org/2010/12/rdf-for-ruby>
8
9
  * <http://blog.datagraph.org/2010/03/rdf-for-ruby>
9
10
  * <http://blog.datagraph.org/2010/04/parsing-rdf-with-ruby>
10
11
  * <http://blog.datagraph.org/2010/04/rdf-repository-howto>
12
+ * <http://semanticweb.org/wiki/Getting_data_from_the_Semantic_Web_(Ruby)>
11
13
 
12
14
  Features
13
15
  --------
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -607,11 +607,14 @@ module RDF
607
607
  # ntriples = enumerable.dump(:ntriples)
608
608
  #
609
609
  # @param [Array<Object>] args
610
+ # if the last argument is a hash, it is passed as keyword options to
611
+ # {RDF::Writer.dump}.
610
612
  # @return [String]
611
613
  # @see RDF::Writer.dump
612
614
  # @since 0.2.0
613
615
  def dump(*args)
614
- RDF::Writer.for(*args).dump(self)
616
+ options = args.last.is_a?(Hash) ? args.pop : {}
617
+ RDF::Writer.for(*args).dump(self, nil, options)
615
618
  end
616
619
  end # Enumerable
617
620
  end # RDF
data/lib/rdf/model/uri.rb CHANGED
@@ -370,15 +370,17 @@ module RDF
370
370
  vocab_uri = local_name.empty? ? self.to_s : self.to_s[0...-(local_name.length)]
371
371
  Vocabulary.each do |vocab|
372
372
  if vocab.to_uri == vocab_uri
373
- return [vocab.__prefix__, local_name.empty? ? nil : local_name.to_sym]
373
+ prefix = vocab.equal?(RDF) ? :rdf : vocab.__prefix__
374
+ return [prefix, local_name.empty? ? nil : local_name.to_sym]
374
375
  end
375
376
  end
376
377
  else
377
378
  Vocabulary.each do |vocab|
378
379
  vocab_uri = vocab.to_uri
379
380
  if self.start_with?(vocab_uri)
381
+ prefix = vocab.equal?(RDF) ? :rdf : vocab.__prefix__
380
382
  local_name = self.to_s[vocab_uri.length..-1]
381
- return [vocab.__prefix__, local_name.empty? ? nil : local_name.to_sym]
383
+ return [prefix, local_name.empty? ? nil : local_name.to_sym]
382
384
  end
383
385
  end
384
386
  end
data/lib/rdf/reader.rb CHANGED
@@ -107,7 +107,7 @@ module RDF
107
107
  #
108
108
  # @param [String, #to_s] filename
109
109
  # @param [Hash{Symbol => Object}] options
110
- # any additional options (see {RDF::Reader#initialize})
110
+ # any additional options (see {RDF::Reader#initialize} and {RDF::Format.for})
111
111
  # @option options [Symbol] :format (:ntriples)
112
112
  # @yield [reader]
113
113
  # @yieldparam [RDF::Reader] reader
@@ -115,9 +115,10 @@ module RDF
115
115
  # @raise [RDF::FormatError] if no reader found for the specified format
116
116
  def self.open(filename, options = {}, &block)
117
117
  Util::File.open_file(filename, options) do |file|
118
- reader = self.for(options[:format]) if options[:format]
119
- content_type = file.content_type if file.respond_to?(:content_type)
120
- reader ||= self.for(options.merge(:file_name => filename, :content_type => content_type))
118
+ format_options = options.dup
119
+ format_options[:content_type] ||= file.content_type if file.respond_to?(:content_type)
120
+ format_options[:file_name] ||= filename
121
+ reader = self.for(format_options)
121
122
  if reader
122
123
  reader.new(file, options, &block)
123
124
  else
data/lib/rdf/version.rb CHANGED
@@ -2,7 +2,7 @@ module RDF
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- TINY = 0
5
+ TINY = 1
6
6
  EXTRA = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, EXTRA].compact.join('.')
data/lib/rdf/writer.rb CHANGED
@@ -102,22 +102,25 @@ module RDF
102
102
  end
103
103
 
104
104
  ##
105
- # @param [Object] data
106
- # @param [IO, File] io
105
+ # @param [RDF::Enumerable, #each] data
106
+ # the graph or repository to dump
107
+ # @param [IO, File] io
108
+ # the output stream or file to write to
107
109
  # @param [Hash{Symbol => Object}] options
110
+ # passed to {RDF::Writer.new} or {RDF::Writer.buffer}
108
111
  # @return [void]
109
112
  def self.dump(data, io = nil, options = {})
110
113
  io = File.open(io, 'w') if io.is_a?(String)
111
114
  method = data.respond_to?(:each_statement) ? :each_statement : :each
112
115
  if io
113
- new(io) do |writer|
116
+ new(io, options) do |writer|
114
117
  data.send(method) do |statement|
115
118
  writer << statement
116
119
  end
117
120
  writer.flush
118
121
  end
119
122
  else
120
- buffer do |writer|
123
+ buffer(options) do |writer|
121
124
  data.send(method) do |statement|
122
125
  writer << statement
123
126
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 0
9
- version: 0.3.0
8
+ - 1
9
+ version: 0.3.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Arto Bendiken
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-12-27 00:00:00 +01:00
19
+ date: 2011-01-13 00:00:00 +01:00
20
20
  default_executable: rdf
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -70,8 +70,8 @@ dependencies:
70
70
  segments:
71
71
  - 0
72
72
  - 3
73
- - 0
74
- version: 0.3.0
73
+ - 1
74
+ version: 0.3.1
75
75
  type: :development
76
76
  version_requirements: *id004
77
77
  description: RDF.rb is a pure-Ruby library for working with Resource Description Framework (RDF) data.