Skip to content

Commit

Permalink
Feature/3.0 dev (#368)
Browse files Browse the repository at this point in the history
* Remove deprecated `#to_hash` and `#to_a`.
* Remove deprecated `grammar` option to `Node.uuid`.
* Fix emergent issue on named graph transactions to coercing triple to statement including graph name.
* Set version to 3.0.0, and soften dependencies to `>= 3.0', '< 4.0'.
* Update dependencies (webmock).
  • Loading branch information
gkellogg committed Dec 14, 2017
1 parent 371a277 commit ba78d75
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 178 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.12
3.0.0
17 changes: 0 additions & 17 deletions lib/rdf/mixin/enumerable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -747,30 +747,13 @@ def dump(*args, **options)
protected

##
# @overload #to_hash
# Returns all RDF object terms indexed by their subject and predicate
# terms.
#
# The return value is a `Hash` instance that has the structure:
# `{subject => {predicate => [*objects]}}`.
#
# @return [Hash]
# @deprecated Use {#to_h} instead.
# @overload #to_writer
# Implements #to_writer for each available instance of {RDF::Writer},
# based on the writer symbol.
#
# @return [String]
# @see {RDF::Writer.sym}
def method_missing(meth, *args)
case meth
when :to_hash
warn "[DEPRECATION] RDF::Enumerable#to_hash is deprecated, use RDF::Enumerable#to_h instead.\n" +
"This is due to the introduction of keyword arugments that attempt to turn the last argument into a hash using #to_hash.\n" +
"This can be avoided by explicitly passing an options hash as the last argument.\n" +
"Called from #{Gem.location_of_caller.join(':')}"
return self.to_h
end
writer = RDF::Writer.for(meth.to_s[3..-1].to_sym) if meth.to_s[0,3] == "to_"
if writer
writer.buffer(standard_prefixes: true) {|w| w << self}
Expand Down
34 changes: 0 additions & 34 deletions lib/rdf/mixin/enumerator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,6 @@ class Enumerator < ::Enumerator
def to_a
return super.to_a.extend(RDF::Queryable, RDF::Enumerable)
end

protected

##
# @overload #to_ary
# @see #to_a
# @deprecated use {#to_a} instead
def method_missing(name, *args)
if name == :to_ary
warn "[DEPRECATION] #{self.class}#to_ary is deprecated, use " \
"#{self.class}#to_a instead. Called from " \
"#{Gem.location_of_caller.join(':')}"
to_a
else
super
end
end
end
end

Expand All @@ -52,23 +35,6 @@ class Enumerator < ::Enumerator
def to_a
return super.to_a.extend(RDF::Queryable, RDF::Enumerable)
end

protected

##
# @overload #to_ary
# @see #to_a
# @deprecated use {#to_a} instead
def method_missing(name, *args)
if name == :to_ary
warn "[DEPRECATION] #{self.class}#to_ary is deprecated, use " \
"#{self.class}#to_a instead. Called from " \
"#{Gem.location_of_caller.join(':')}"
self.to_a
else
super
end
end
end
end
end
11 changes: 2 additions & 9 deletions lib/rdf/model/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,8 @@ def self.cache
# Some RDF storage systems (e.g. AllegroGraph) require this.
# Requires that the `uuid` gem be loadable to use `format`
# @return [RDF::Node]
def self.uuid(format: :default, grammar: nil)
case
when grammar
warn "[DEPRECATION] The grammar parameter to RDF::Node#uri is deprecated.\n" +
"Called from #{Gem.location_of_caller.join(':')}"
uuid = RDF::Util::UUID.generate(format: format) until uuid =~ grammar
else
uuid = RDF::Util::UUID.generate(format: format)
end
def self.uuid(format: :default)
uuid = RDF::Util::UUID.generate(format: format)
self.new(uuid)
end

Expand Down
28 changes: 0 additions & 28 deletions lib/rdf/model/statement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,6 @@ def to_triple
end
alias_method :to_a, :to_triple

##
# @deprecated use {#to_a} or {#to_triple} instead
# @see #to_triple
def to_ary
to_triple
end

##
# Canonicalizes each unfrozen term in the statement
#
Expand Down Expand Up @@ -414,26 +407,5 @@ def reified(subject: nil, id: nil, graph_name: nil)
graph << [subject, RDF.object, self.object]
end
end

protected
##
# @overload #to_hash
# Returns the terms of this statement as a `Hash`.
#
# @param (see #to_h)
# @return (see #to_h)
# @deprecated Use {#to_h} instead.
def method_missing(meth, *args)
case meth
when :to_hash
warn "[DEPRECATION] RDF::Statement#to_hash is deprecated, use RDF::Statement#to_h instead.\n" +
"This is due to the introduction of keyword arugments that attempt to turn the last argument into a hash using #to_hash.\n" +
"This can be avoided by explicitly passing an options hash as the last argument.\n" +
"Called from #{Gem.location_of_caller.join(':')}"
self.to_h
else
super
end
end
end
end
21 changes: 0 additions & 21 deletions lib/rdf/model/uri.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ def self.cache
# @param (see #initialize)
# @return [RDF::URI] an immutable, frozen URI object
def self.intern(str, *args)
args << {} unless args.last.is_a?(Hash) # FIXME: needed until #to_hash is removed to avoid DEPRECATION warning.
(cache[(str = str.to_s).to_sym] ||= self.new(str, *args)).freeze
end

Expand Down Expand Up @@ -1293,26 +1292,6 @@ def format_authority
""
end
end

protected
##
# @overload #to_hash
# Returns object representation of this URI, broken into components
#
# @return (see #object)
# @deprecated Use {#to_h} instead.
def method_missing(meth, *args)
case meth
when :to_hash
warn "[DEPRECATION] RDF::URI#to_hash is deprecated, use RDF::URI#to_h instead.\n" +
"This is due to the introduction of keyword arugments that attempt to turn the last argument into a hash using #to_hash.\n" +
"This can be avoided by explicitly passing an options hash as the last argument.\n" +
"Called from #{Gem.location_of_caller.join(':')}"
self.to_h
else
super
end
end
end

# RDF::IRI is a synonym for RDF::URI
Expand Down
16 changes: 2 additions & 14 deletions lib/rdf/query/solution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Solution
# @param [Hash{Symbol => RDF::Term}] bindings
# @yield [solution]
def initialize(bindings = {}, &block)
@bindings = bindings.to_hash
@bindings = bindings.to_h

if block_given?
case block.arity
Expand Down Expand Up @@ -264,25 +264,13 @@ def inspect
protected

##
# @overload #to_hash
# Returns object representation of this URI, broken into components
#
# @return (see #to_h)
# @deprecated Use {#to_h} instead.
#
# @overload binding(name)
# Return the binding for this name
#
# @param [Symbol] name
# @return [RDF::Term]
def method_missing(name, *args, &block)
if name == :to_hash
warn "[DEPRECATION] RDF::Query::Solution#to_hash is deprecated, use RDF::Query::Solution#to_h instead.\n" +
"This is due to the introduction of keyword arugments that attempt to turn the last argument into a hash using #to_hash.\n" +
"This can be avoided by explicitly passing an options hash as the last argument.\n" +
"Called from #{Gem.location_of_caller.join(':')}"
self.to_h
elsif args.empty? && @bindings.has_key?(name.to_sym)
if args.empty? && @bindings.has_key?(name.to_sym)
@bindings[name.to_sym]
else
super # raises NoMethodError
Expand Down
21 changes: 0 additions & 21 deletions lib/rdf/query/variable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,26 +219,5 @@ def to_s
prefix = distinguished? ? '?' : "??"
unbound? ? "#{prefix}#{name}" : "#{prefix}#{name}=#{value}"
end

protected
##
# @overload #to_hash
# Returns object representation of this URI, broken into components
#
# @return (see #object)
# @deprecated Use {#to_h} instead.
def method_missing(name, *args, &block)
if name == :to_hash
warn "[DEPRECATION] RDF::Query::Variable#to_hash is deprecated, use RDF::Query::Variable#to_h instead.\n" +
"This is due to the introduction of keyword arugments that attempt to turn the last argument into a hash using #to_hash.\n" +
"This can be avoided by explicitly passing an options hash as the last argument.\n" +
"Called from #{Gem.location_of_caller.join(':')}"
self.to_h
elsif args.empty? && @bindings.has_key?(name.to_sym)
@bindings[name.to_sym]
else
super # raises NoMethodError
end
end
end # Variable
end # RDF::Query
22 changes: 13 additions & 9 deletions rdf.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,21 @@ Gem::Specification.new do |gem|
gem.requirements = []
gem.add_runtime_dependency 'link_header', '~> 0.0', '>= 0.0.8'
gem.add_runtime_dependency 'hamster', '~> 3.0'
gem.add_development_dependency 'rdf-spec', '~> 2.2'
gem.add_development_dependency 'rdf-turtle', '~> 2.0'
gem.add_development_dependency 'rdf-vocab', '~> 2.0'
gem.add_development_dependency 'rdf-xsd', '~> 2.0'
#gem.add_development_dependency 'rdf-spec', '~> 3.0'
#gem.add_development_dependency 'rdf-turtle', '~> 3.0'
#gem.add_development_dependency 'rdf-vocab', '~> 3.0'
#gem.add_development_dependency 'rdf-xsd', '~> 3.0'
gem.add_development_dependency 'rdf-spec', '>= 2.2', '< 4.0'
gem.add_development_dependency 'rdf-turtle', '>= 2.0', '< 4.0'
gem.add_development_dependency 'rdf-vocab', '>= 2.0', '< 4.0'
gem.add_development_dependency 'rdf-xsd', '>= 2.0', '< 4.0'
gem.add_development_dependency 'rest-client', '~> 2.0'
gem.add_development_dependency 'rspec', '~> 3.0'
gem.add_development_dependency 'rspec-its', '~> 1.0'
gem.add_development_dependency 'webmock', '~> 2.3'
gem.add_development_dependency 'rspec', '~> 3.7'
gem.add_development_dependency 'rspec-its', '~> 1.2'
gem.add_development_dependency 'webmock', '~> 3.0'
gem.add_development_dependency 'yard', '~> 0.8'
gem.add_development_dependency 'faraday', '~> 0.9'
gem.add_development_dependency 'faraday_middleware', '~> 0.9'
gem.add_development_dependency 'faraday', '~> 0.13'
gem.add_development_dependency 'faraday_middleware', '~> 0.12'

gem.post_install_message = nil
end
2 changes: 1 addition & 1 deletion spec/model_graph_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
it 'inserts to graph' do
st = [RDF::URI('s'), RDF::URI('p'), 'o']
expect { transactable.transaction(mutable: true) { insert(st) } }
.to change { transactable.statements }.to contain_exactly(st)
.to change { transactable.statements }.to contain_exactly(RDF::Statement.from(st, graph_name: name))
end

it 'deletes from graph' do
Expand Down
7 changes: 3 additions & 4 deletions spec/model_node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@
expect(described_class.uuid(format: :compact)).to be_a_node
end

it "accepts grammar: option with deprecation" do
it "rejects grammar: option" do
expect {
expect(described_class.uuid(grammar: /\S+/)).to be_a_node
}.to write('[DEPRECATION]').to(:error)
expect(described_class.uuid(format: :compact)).to be_a_node
described_class.uuid(grammar: /\S+/)
}.to raise_error(ArgumentError)
end
end

Expand Down
12 changes: 0 additions & 12 deletions spec/model_statement_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,18 +186,6 @@
})
end

it {is_expected.not_to respond_to(:to_hash)}
its(:to_hash) do
expect {
is_expected.to eql({
subject: stmt.subject,
predicate: stmt.predicate,
object: stmt.object,
graph_name: stmt.graph_name,
})
}.to write("DEPRECATION").to(:error)
end

it {is_expected.to respond_to(:to_s)}
its(:to_s) {is_expected.to eql "<http://rubygems.org/gems/rdf> <http://purl.org/dc/terms/creator> <http://ar.to/#self> ."}

Expand Down
7 changes: 0 additions & 7 deletions spec/query_solution_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,5 @@
it "Responding to a bound variable" do
expect(solution).to respond_to :mbox
end

it "Retrieving all bindings in the solution as a Hash" do
expect(solution.to_h).to eq({title: "foo", mbox: "jrhacker@example.org"})
expect {
expect(solution.to_hash).to eq({title: "foo", mbox: "jrhacker@example.org"})
}.to write("DEPRECATION").to(:error)
end
end
end

0 comments on commit ba78d75

Please sign in to comment.