rdf 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README +1 -1
  2. data/VERSION +1 -1
  3. data/lib/rdf/format.rb +11 -0
  4. data/lib/rdf/util/file.rb +11 -2
  5. metadata +3 -3
data/README CHANGED
@@ -24,7 +24,7 @@ This is a pure-Ruby library for working with [Resource Description Framework
24
24
  not modify any of Ruby's core classes or standard library.
25
25
  * Based entirely on Ruby's autoloading, meaning that you can generally make
26
26
  use of any one part of the library without needing to load up the rest.
27
- * Compatible with Ruby 1.8.7+, Ruby 1.9.x, and JRuby 1.7+.
27
+ * Compatible with Ruby 1.8.7+, Ruby 1.9.x, Ruby 2.0, Rubinius and JRuby 1.7+.
28
28
  * Compatible with older Ruby versions with the help of the [Backports][] gem.
29
29
  * Performs auto-detection of input to select appropriate Reader class if one
30
30
  cannot be determined from file characteristics.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.2
1
+ 1.0.3
data/lib/rdf/format.rb CHANGED
@@ -387,6 +387,17 @@ module RDF
387
387
  end
388
388
  end
389
389
 
390
+ ##
391
+ # Retrieves or defines file extensions for this RDF serialization format.
392
+ #
393
+ # The return is an array where the first element is the cannonical
394
+ # file extension for the format and following elements are alias file extensions.
395
+ #
396
+ # @return [Array<String>]
397
+ def self.file_extension
398
+ @@file_extensions.map {|ext, formats| ext if formats.include?(self)}.compact
399
+ end
400
+
390
401
  protected
391
402
 
392
403
  ##
data/lib/rdf/util/file.rb CHANGED
@@ -20,6 +20,8 @@ module RDF; module Util
20
20
 
21
21
  ##
22
22
  # Open the file, returning or yielding an IO stream and mime_type.
23
+ # Adds Accept header based on available reader content types to allow
24
+ # for content negotiation based on available readers.
23
25
  #
24
26
  # @param [String] filename_or_url to open
25
27
  # @param [Hash{Symbol => Object}] options
@@ -27,12 +29,19 @@ module RDF; module Util
27
29
  # to override this implementation to provide more control over HTTP
28
30
  # headers and redirect following.
29
31
  # @option options [Array, String] :headers
30
- # HTTP Request headers.
32
+ # HTTP Request headers, passed to Kernel.open.
31
33
  # @return [IO] File stream
32
34
  # @yield [IO] File stream
35
+ # @note HTTP headers not passed to `Kernel.open` for Ruby versions < 1.9.
33
36
  def self.open_file(filename_or_url, options = {}, &block)
34
37
  filename_or_url = $1 if filename_or_url.to_s.match(/^file:(.*)$/)
35
- Kernel.open(filename_or_url.to_s, &block)
38
+ options[:headers] ||= {}
39
+ options[:headers]['Accept'] ||= RDF::Reader.map {|r| r.format.content_type}.uniq.join(", ")
40
+ if RUBY_VERSION < "1.9"
41
+ Kernel.open(filename_or_url.to_s, &block)
42
+ else
43
+ Kernel.open(filename_or_url.to_s, options[:headers], &block)
44
+ end
36
45
  end
37
46
  end # File
38
47
  end; end # RDF::Util
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: 1.0.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-02-22 00:00:00.000000000 Z
14
+ date: 2013-02-26 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: addressable
@@ -188,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
188
  version: '0'
189
189
  segments:
190
190
  - 0
191
- hash: -1665620731377728344
191
+ hash: -2150851322746438702
192
192
  requirements: []
193
193
  rubyforge_project: rdf
194
194
  rubygems_version: 1.8.25