Skip to content

Commit bd7afc9

Browse files
committed
Release 1.99.0:
* Warn when a deprecated vocabulary constant is found that it is deprecated, and that the access pattern will change. Fixes #191. * RDF.rb 2.0 will deprecate the use of `context` in favor of `graph_name`. This affects many methods, but also :context used as an option. For issue #189. * Change `#has_blank_nodes?` to `#node?`, but keep as method alias. * Add `Term#compatible?` from SPARQL. * Add a `#valid?` implementation to Reader base. * Fix issues converting DateTime and Time objects to strings when not canonicalizing. Fixes #218. * Fix named graph support in `RDF::Transaction` * Use of `RDF::Graph` to store inserts and deletes in `RDF::Transaction` is heavy handed, and results in the destruction of graph names on statements passed in. This fix simply uses `[]` to handle the statement lists (`RDF::Enumerable` is already included by force). * This should be cheaper and insulate us from potentially unwanted behavior outside of `Enumerable`. Clients can still use `RDF::Graph` by passing it on initialization at their own risk. * Correct behaviors for open_file: * charset should be a downcased string. Fixes #199. * content_encoding reflects Content-Encoding, as an array of downcased strings. * Non-UTF input is transformed to UTF-8, so that `external_encoding` is now "utf-8" with `charset` the original character set. * With Ruby 2.2+, attempt to turn Unicode input into NFC. * Make `Transaction#execute` more atomic * Executing a transaction individually called `#delete` or `#insert` for each statement in the changeset. This prevents using the features of `Repositories` with a more efficient implementation of `#insert/delete_statements`. * Use `#clear_statements` when available * `Mutable#clear` checks whether the instance responds to `#clear_statements` and falls back on `#delete_statements`. The former clears the entire mutable, using e.g., `graph_name`, while the later has enumerative semantics (deleting the members of the set of statements). Because `#clear_statements` is protected or private, it will never be used by immutable without the `true` flag on `#respond_to?`. * Add `Statement.#complete?/#incomplete?` to check for nil elements. Update `Repository#insert_statement` to not add incomplete statements (silently); raises an ArgumentError. For #226.
2 parents 20dc5f6 + d71f8a1 commit bd7afc9

66 files changed

Lines changed: 7143 additions & 6790 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Gemfile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ gemspec
44

55
group :develop do
66
gem "rdf-spec", git: "git://github.com/ruby-rdf/rdf-spec.git", branch: "develop"
7+
gem "rdf-vocab", git: "git://github.com/ruby-rdf/rdf-vocab.git", branch: "develop"
78
gem 'linkeddata', git: "git://github.com/ruby-rdf/linkeddata.git", branch: "develop"
9+
gem 'rdf-aggregate-repo', git: "git://github.com/ruby-rdf/rdf-aggregate-repo.git", branch: "develop"
10+
gem 'rdf-isomorphic', git: "git://github.com/ruby-rdf/rdf-isomorphic.git", branch: "develop"
811
gem 'rdf-n3', git: "git://github.com/ruby-rdf/rdf-n3.git", branch: "develop"
912
gem "rdf-rdfxml", git: "git://github.com/ruby-rdf/rdf-rdfxml.git", branch: "develop"
1013
gem 'rdf-rdfa', git: "git://github.com/ruby-rdf/rdf-rdfa.git", branch: "develop"
14+
gem 'rdf-trig', git: "git://github.com/ruby-rdf/rdf-trig.git", branch: "develop"
1115
gem 'rdf-turtle', git: "git://github.com/ruby-rdf/rdf-turtle.git", branch: "develop"
1216
gem 'rdf-microdata', git: "git://github.com/ruby-rdf/rdf-microdata.git", branch: "develop"
1317
gem "rdf-xsd", git: "git://github.com/ruby-rdf/rdf-xsd.git", branch: "develop"
@@ -19,13 +23,13 @@ group :develop do
1923
end
2024

2125
group :debug do
22-
gem 'psych', :platforms => [:mri, :rbx]
26+
gem 'psych', platforms: [:mri, :rbx]
2327
gem "wirble"
24-
gem "redcarpet", :platforms => :ruby
25-
gem "debugger", :platforms => :mri_19
26-
gem "byebug", :platforms => :mri
27-
gem "ruby-debug", :platforms => :jruby
28-
gem "pry", :platforms => :rbx
28+
gem "redcarpet", platforms: :ruby
29+
gem "debugger", platforms: :mri_19
30+
gem "byebug", platforms: :mri
31+
gem "ruby-debug", platforms: :jruby
32+
gem "pry", platforms: :rbx
2933
gem 'guard-rspec'
3034
end
3135

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ operations on RDF files using available readers and writers.
9292
### Writing RDF data using the [N-Triples][] format
9393

9494
require 'rdf/ntriples'
95-
graph = RDF::Graph.new << [:hello, RDF::DC.title, "Hello, world!"]
95+
graph = RDF::Graph.new << [:hello, RDF::RDFS.label, "Hello, world!"]
9696
graph.dump(:ntriples)
9797

9898
or
@@ -114,13 +114,13 @@ or
114114

115115
### Reading RDF data in other formats
116116
{RDF::Reader.open} and {RDF::Repository.load} use a number of mechanisms to determine the appropriate reader
117-
to use when loading a file. The specific format to use can be forced using, e.g. `:format => :ntriples`
117+
to use when loading a file. The specific format to use can be forced using, e.g. `format: :ntriples`
118118
option where the specific format symbol is determined by the available readers. Both also use
119119
MimeType or file extension, where available.
120120

121121
require 'rdf/nquads'
122122

123-
graph = RDF::Graph.load("http://ruby-rdf.github.com/rdf/etc/doap.nq", :format => :nquads)
123+
graph = RDF::Graph.load("http://ruby-rdf.github.com/rdf/etc/doap.nq", format: :nquads)
124124

125125
A specific sub-type of Reader can also be invoked directly:
126126

@@ -144,24 +144,24 @@ appropriate writer to use.
144144

145145
require 'linkeddata'
146146

147-
RDF::Writer.open("hello.nq", :format => :nquads) do |writer|
147+
RDF::Writer.open("hello.nq", format: :nquads) do |writer|
148148
writer << RDF::Repository.new do |repo|
149-
repo << RDF::Statement.new(:hello, RDF::DC.title, "Hello, world!", :context => RDF::URI("context"))
149+
repo << RDF::Statement.new(:hello, RDF::RDFS.label, "Hello, world!", context: RDF::URI("context"))
150150
end
151151
end
152152

153153
A specific sub-type of Writer can also be invoked directly:
154154

155155
require 'rdf/nquads'
156156

157-
repo = RDF::Repository.new << RDF::Statement.new(:hello, RDF::DC.title, "Hello, world!", :context => RDF::URI("context"))
157+
repo = RDF::Repository.new << RDF::Statement.new(:hello, RDF::RDFS.label, "Hello, world!", context: RDF::URI("context"))
158158
File.open("hello.nq", "w") {|f| f << repo.dump(:nquads)}
159159

160160
## Reader/Writer convenience methods
161161
{RDF::Enumerable} implements `to_{format}` for each available instance of {RDF::Reader}.
162162
For example, if `rdf/turtle` is loaded, this allows the following:
163163

164-
graph = RDF::Graph.new << [:hello, RDF::DC.title, "Hello, world!"]
164+
graph = RDF::Graph.new << [:hello, RDF::RDFS.label, "Hello, world!"]
165165
graph.to_ttl
166166

167167
Similarly, {RDF::Mutable} implements `from_{format}` for each available instance
@@ -172,15 +172,15 @@ of {RDF::Writer}. For example:
172172

173173
Note that no prefixes are loaded automatically, however they can be provided as arguments:
174174

175-
graph.from_ttl("[ a rdf:Resource]", :prefixes => {:rdf => RDF.to_uri})
175+
graph.from_ttl("[ a rdf:Resource]", prefixes: {rdf: RDF.to_uri})
176176

177177
### Querying RDF data using basic graph patterns (BGPs)
178178

179179
require 'rdf/ntriples'
180180

181181
graph = RDF::Graph.load("http://ruby-rdf.github.com/rdf/etc/doap.nt")
182182
query = RDF::Query.new({
183-
:person => {
183+
person: {
184184
RDF.type => FOAF.Person,
185185
FOAF.name => :name,
186186
FOAF.mbox => :email,

Rakefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ namespace :gem do
1616
end
1717

1818
desc 'Default: run specs.'
19-
task :default => :spec
20-
task :specs => :spec
19+
task default: :spec
20+
task specs: :spec
2121

2222
require 'rspec/core/rake_task'
2323
desc 'Run specifications'
@@ -99,7 +99,7 @@ vocab_sources = {
9999
strict: false},
100100
}
101101

102-
task :gen_vocabs => vocab_sources.keys.map {|v| "lib/rdf/vocab/#{v}.rb"}
102+
task gen_vocabs: vocab_sources.keys.map {|v| "lib/rdf/vocab/#{v}.rb"}
103103

104104
vocab_sources.each do |id, v|
105105
file "lib/rdf/vocab/#{id}.rb" => :do_build do

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.17.1
1+
1.99.0

etc/Gemfile

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
source 'http://rubygems.org'
22

3-
gem 'rdf', :git => 'git://github.com/ruby-rdf/rdf.git'
4-
gem 'rdf-do', :git => 'git://github.com/ruby-rdf/rdf-do.git'
5-
gem 'rdf-isomorphic', :git => 'git://github.com/ruby-rdf/rdf-isomorphic.git'
6-
gem 'rdf-json', :git => 'git://github.com/ruby-rdf/rdf-json.git'
7-
gem 'rdf-mongo', :git => 'git://github.com/ruby-rdf/rdf-mongo.git'
8-
gem 'rdf-n3', :git => 'git://github.com/ruby-rdf/rdf-n3.git'
9-
gem 'rdf-n3', :git => 'git://github.com/ruby-rdf/rdf-trig.git'
10-
gem 'rdf-n3', :git => 'git://github.com/ruby-rdf/rdf-turtle.git'
11-
gem 'rdf-rdfa', :git => 'git://github.com/ruby-rdf/rdf-rdfa.git'
12-
gem 'rdf-rdfxml', :git => 'git://github.com/ruby-rdf/rdf-rdfxml.git'
13-
gem 'rdf-spec', :git => 'git://github.com/ruby-rdf/rdf-spec.git'
14-
gem 'rdf-trix', :git => 'git://github.com/ruby-rdf/rdf-trix.git'
3+
gem 'rdf', git: 'git://github.com/ruby-rdf/rdf.git'
4+
gem 'rdf-do', git: 'git://github.com/ruby-rdf/rdf-do.git'
5+
gem 'rdf-isomorphic', git: 'git://github.com/ruby-rdf/rdf-isomorphic.git'
6+
gem 'rdf-json', git: 'git://github.com/ruby-rdf/rdf-json.git'
7+
gem 'rdf-mongo', git: 'git://github.com/ruby-rdf/rdf-mongo.git'
8+
gem 'rdf-n3', git: 'git://github.com/ruby-rdf/rdf-n3.git'
9+
gem 'rdf-n3', git: 'git://github.com/ruby-rdf/rdf-trig.git'
10+
gem 'rdf-n3', git: 'git://github.com/ruby-rdf/rdf-turtle.git'
11+
gem 'rdf-rdfa', git: 'git://github.com/ruby-rdf/rdf-rdfa.git'
12+
gem 'rdf-rdfxml', git: 'git://github.com/ruby-rdf/rdf-rdfxml.git'
13+
gem 'rdf-spec', git: 'git://github.com/ruby-rdf/rdf-spec.git'
14+
gem 'rdf-trix', git: 'git://github.com/ruby-rdf/rdf-trix.git'
1515

16-
gem 'rdf-arq', :git => 'git://github.com/bendiken/rdf-arq.git'
17-
gem 'rdf-bert', :git => 'git://github.com/bendiken/rdf-bert.git'
18-
gem 'rdf-cassandra', :git => 'git://github.com/bendiken/rdf-cassandra.git'
19-
gem 'rdf-raptor', :git => 'git://github.com/bendiken/rdf-raptor.git'
20-
gem 'rdf-rasqal', :git => 'git://github.com/bendiken/rdf-rasqal.git'
21-
gem 'rdf-sesame', :git => 'git://github.com/bendiken/rdf-sesame.git'
16+
gem 'rdf-arq', git: 'git://github.com/bendiken/rdf-arq.git'
17+
gem 'rdf-bert', git: 'git://github.com/bendiken/rdf-bert.git'
18+
gem 'rdf-cassandra', git: 'git://github.com/bendiken/rdf-cassandra.git'
19+
gem 'rdf-raptor', git: 'git://github.com/bendiken/rdf-raptor.git'
20+
gem 'rdf-rasqal', git: 'git://github.com/bendiken/rdf-rasqal.git'
21+
gem 'rdf-sesame', git: 'git://github.com/bendiken/rdf-sesame.git'
2222

23-
gem 'rdf-talis', :git => 'git://github.com/bhuga/rdf-talis.git'
23+
gem 'rdf-talis', git: 'git://github.com/bhuga/rdf-talis.git'
2424

25-
gem 'rdf-n3', :git => 'git://github.com/gkellogg/json-ld.git'
25+
gem 'rdf-n3', git: 'git://github.com/gkellogg/json-ld.git'
2626

27-
gem 'rdf-4store', :git => 'git://github.com/fumi/rdf-4store.git'
28-
gem 'rdf-redstore', :git => 'git://github.com/njh/rdf-redstore.git'
27+
gem 'rdf-4store', git: 'git://github.com/fumi/rdf-4store.git'
28+
gem 'rdf-redstore', git: 'git://github.com/njh/rdf-redstore.git'

examples/query_bench.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
require 'benchmark'
44
require 'rdf'
5+
require 'rdf/vocab'
56
require 'rdf/ntriples'
67
graph = RDF::Graph.load("etc/doap.nt")
78

8-
puts graph.query(:predicate => RDF::FOAF.name).is_a?(RDF::Queryable)
9+
puts graph.query(predicate: RDF::Vocab::FOAF.name).is_a?(RDF::Queryable)
910

1011
Benchmark.bmbm do |bench|
1112
bench.report("query_pattern") do
1213
100_000.times do
13-
graph.query(:predicate => RDF::FOAF.name) {}
14+
graph.query(predicate: RDF::Vocab::FOAF.name) {}
1415
end
1516
end
1617
end

lib/rdf.rb

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,20 @@ module RDF
5555
autoload :Vocabulary, 'rdf/vocabulary'
5656
autoload :StrictVocabulary, 'rdf/vocabulary'
5757
VOCABS = Dir.glob(File.join(File.dirname(__FILE__), 'rdf', 'vocab', '*.rb')).map { |f| File.basename(f)[0...-(File.extname(f).size)].to_sym } rescue []
58-
VOCABS.each { |v| autoload v.to_s.upcase.to_sym, "rdf/vocab/#{v}" unless v == :rdf }
58+
59+
# Use const_missing instead of autoload to load most vocabularies so we can provide deprecation messages
60+
def self.const_missing(constant)
61+
if VOCABS.include?(constant.to_s.downcase.to_sym)
62+
warn %([DEPRECATION] the #{constant} vocabulary will be moved to the rdf-vocab gem
63+
for the RDF.rb 2.0 release. Use as RDF::Vocab::#{constant}, or include RDF::Vocab in the RDF module.
64+
Called from #{Gem.location_of_caller.join(':')}
65+
).gsub(/^\s+/, '') unless [:OWL, :RDFS, :RDFV, :XSD].include?(constant)
66+
require "rdf/vocab/#{constant.to_s.downcase}"
67+
const_get(constant)
68+
else
69+
super
70+
end
71+
end
5972

6073
# Utilities
6174
autoload :Util, 'rdf/util'
@@ -152,15 +165,17 @@ def self.List(*args)
152165
# @option options [RDF::URI] :predicate (nil)
153166
# @option options [RDF::Term] :object (nil)
154167
# @option options [RDF::Resource] :context (nil)
155-
# Note, in RDF 1.1, a context MUST be an IRI.
168+
# Alias for :graph_name, :context is deprecated in RDF.rb.
169+
# @option options [RDF::Resource] :graph_name (nil)
170+
# Note, a graph_name MUST be an IRI or BNode.
156171
# @return [RDF::Statement]
157172
#
158173
# @overload Statement(subject, predicate, object, options = {})
159174
# @param [RDF::Resource] subject
160175
# @param [RDF::URI] predicate
161176
# @param [RDF::Term] object
162177
# @param [Hash{Symbol => Object}] options
163-
# @option options [RDF::Resource] :context (nil)
178+
# @option options [RDF::Resource] :graph_name (nil)
164179
# @return [RDF::Statement]
165180
#
166181
def self.Statement(*args)
@@ -203,7 +218,7 @@ def self.respond_to?(method, include_all = false)
203218
end
204219

205220
##
206-
# Delegate other methods to RDF::RDF
221+
# Delegate other methods to RDF::RDFV
207222
def self.method_missing(property, *args, &block)
208223
if args.empty?
209224
# Special-case rdf:_n for all integers

lib/rdf/cli.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ class CLI
6262
writer_class = RDF::Writer.for(opts[:output_format]) || RDF::NTriples::Writer
6363
out = opts[:output] || $stdout
6464
out.set_encoding(Encoding::UTF_8) if out.respond_to?(:set_encoding) && RUBY_PLATFORM == "java"
65-
opts = opts.merge(:prefixes => {})
66-
writer_opts = opts.merge(:standard_prefixes => true)
65+
opts = opts.merge(prefixes: {})
66+
writer_opts = opts.merge(standard_prefixes: true)
6767
self.parse(argv, opts) do |reader|
6868
writer_class.new(out, writer_opts) do |writer|
6969
writer << reader
@@ -91,14 +91,14 @@ def self.basename() File.basename($0) end
9191
def self.options(&block)
9292
options = OptionParser.new
9393
opts = options.options = {
94-
:base_uri => nil,
95-
:canonicalize => false,
96-
:debug => false,
97-
:evaluate => nil,
98-
:format => nil,
99-
:output => $stdout,
100-
:output_format => :ntriples,
101-
:validate => false,
94+
base_uri: nil,
95+
canonicalize: false,
96+
debug: false,
97+
evaluate: nil,
98+
format: nil,
99+
output: $stdout,
100+
output_format: :ntriples,
101+
validate: false,
102102
}
103103

104104
# Command-specific options

lib/rdf/format.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ module RDF
1111
# @example Getting a serialization format class
1212
# RDF::Format.for(:ntriples) #=> RDF::NTriples::Format
1313
# RDF::Format.for("etc/doap.nt")
14-
# RDF::Format.for(:file_name => "etc/doap.nt")
15-
# RDF::Format.for(:file_extension => "nt")
16-
# RDF::Format.for(:content_type => "application/n-triples")
14+
# RDF::Format.for(file_name: "etc/doap.nt")
15+
# RDF::Format.for(file_extension: "nt")
16+
# RDF::Format.for(content_type: "application/n-triples")
1717
#
1818
# @example Obtaining serialization format MIME types
1919
# RDF::Format.content_types #=> {"application/n-triples" => [RDF::NTriples::Format]}
2020
#
2121
# @example Obtaining serialization format file extension mappings
22-
# RDF::Format.file_extensions #=> {:nt => [RDF::NTriples::Format]}
22+
# RDF::Format.file_extensions #=> {nt: [RDF::NTriples::Format]}
2323
#
2424
# @example Defining a new RDF serialization format class
2525
# class RDF::NTriples::Format < RDF::Format
26-
# content_type 'application/n-triples', :extension => :nt
26+
# content_type 'application/n-triples', extension: :nt
2727
# content_encoding 'utf-8'
2828
#
2929
# reader RDF::NTriples::Reader
@@ -95,7 +95,7 @@ def self.for(options = {})
9595
format = case options
9696
when String
9797
# Find a format based on the file name
98-
self.for(:file_name => options) { yield if block_given? }
98+
self.for(file_name: options) { yield if block_given? }
9999

100100
when Hash
101101
case
@@ -112,7 +112,7 @@ def self.for(options = {})
112112
content_types[mime_type] unless mime_type == 'text/plain' && (options[:sample] || block_given?)
113113
# Find a format based on the file name:
114114
when file_name = options[:file_name]
115-
self.for(:file_extension => File.extname(file_name.to_s)[1..-1]) { yield if block_given? }
115+
self.for(file_extension: File.extname(file_name.to_s)[1..-1]) { yield if block_given? }
116116
# Find a format based on the file extension:
117117
when file_ext = options[:file_extension]
118118
file_extensions[file_ext.to_sym]
@@ -201,7 +201,7 @@ def self.reader_symbols
201201
# @example
202202
#
203203
# content_types = RDF::Format.reader_types
204-
# format = RDF::Format.for(:content_type => content_types.first)
204+
# format = RDF::Format.for(content_type: content_types.first)
205205
#
206206
# @return [Array<String>]
207207
def self.reader_types
@@ -227,7 +227,7 @@ def self.writer_symbols
227227
# @example
228228
#
229229
# content_types = RDF::Format.writer_types
230-
# format = RDF::Format.for(:content_type => content_types.first)
230+
# format = RDF::Format.for(content_type: content_types.first)
231231
#
232232
# @return [Array<String>]
233233
def self.writer_types

0 commit comments

Comments
 (0)