Skip to content

Commit

Permalink
Finish 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Apr 11, 2016
2 parents b4cb770 + b402cf3 commit 50f2a64
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 71 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0.beta2
2.0.0
6 changes: 1 addition & 5 deletions lib/rdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,7 @@ def self.Literal(*args, &block)
#
# @param (see RDF::Graph#initialize)
# @return [RDF::Graph]
def self.Graph(*args, **options, &block)
unless args.empty?
warn "[DEPRECATION] Graph#initialize now uses keyword arguments. Called from #{Gem.location_of_caller.join(':')}"
options[:graph_name] ||= args.first
end
def self.Graph(**options, &block)
Graph.new(options, &block)
end

Expand Down
33 changes: 8 additions & 25 deletions lib/rdf/model/graph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,25 +87,13 @@ def self.load(url, graph_name: nil, **options, &block)
end

##
# @overload initialize(graph_name, options)
# @param [RDF::Resource] graph_name
# The graph_name from the associated {RDF::Queryable} associated
# with this graph as provided with the `:data` option
# (only for {RDF::Queryable} instances supporting
# named graphs).
# @param [Hash{Symbol => Object}] options
# @option options [RDF::Queryable] :data (RDF::Repository.new)
# Storage behind this graph.
# @deprecated This form is deprecated in version 2.0.
#
# @overload initialize(graph_name: nil, data: nil)
# @param [RDF::Resource] graph_name
# The graph_name from the associated {RDF::Queryable} associated
# with this graph as provided with the `:data` option
# (only for {RDF::Queryable} instances supporting
# named graphs).
# @param [RDF::Queryable] :data (RDF::Repository.new)
# Storage behind this graph.
# @param [RDF::Resource] graph_name
# The graph_name from the associated {RDF::Queryable} associated
# with this graph as provided with the `:data` option
# (only for {RDF::Queryable} instances supporting
# named graphs).
# @param [RDF::Queryable] :data (RDF::Repository.new)
# Storage behind this graph.
#
# @raise [ArgumentError] if a `data` does not support named graphs.
# @note
Expand All @@ -115,12 +103,7 @@ def self.load(url, graph_name: nil, **options, &block)
# graphs which are named, but the name is not a property of the graph.
# @yield [graph]
# @yieldparam [Graph]
def initialize(*args, graph_name: nil, data: nil, **options, &block)
unless args.empty?
warn "[DEPRECATION] Graph#initialize now uses keyword arguments. Called from #{Gem.location_of_caller.join(':')}"
graph_name ||= args.first
end

def initialize(graph_name: nil, data: nil, **options, &block)
@graph_name = case graph_name
when nil then nil
when RDF::Resource then graph_name
Expand Down
31 changes: 8 additions & 23 deletions lib/rdf/model/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,29 +48,14 @@ def self.[](*values)
# g = RDF::Graph.new << l
# g.count # => l.count
#
# @overload initialize(subject = nil, graph = nil, values = nil, &block)
# @param [RDF::Resource] subject
# Subject should be an {RDF::Node}, not a {RDF::URI}. A list with an IRI head will not validate, but is commonly used to detect if a list is valid.
# @param [RDF::Graph] graph
# @param [Array<RDF::Term>] values
# Any values which are not terms are coerced to `RDF::Literal`.
# @yield [list]
# @yieldparam [RDF::List] list
# @deprecated This form is deprecated in version 2.0
#
# @overload initialize(subject: nil, graph: nil, values: nil, &block)
# @param [RDF::Resource] subject (RDF.nil)
# Subject should be an {RDF::Node}, not a {RDF::URI}. A list with an IRI head will not validate, but is commonly used to detect if a list is valid.
# @param [RDF::Graph] graph (RDF::Graph.new)
# @param [Array<RDF::Term>] values
# Any values which are not terms are coerced to `RDF::Literal`.
# @yield [list]
# @yieldparam [RDF::List] list
#
def initialize(*args, subject: nil, graph: nil, values: nil, &block)
unless args.empty?
raise ArgumentError, "[FATAL DEPRECATION] List#initialize now uses keyword arguments. Called from #{Gem.location_of_caller.join(':')}"
end
# @param [RDF::Resource] subject (RDF.nil)
# Subject should be an {RDF::Node}, not a {RDF::URI}. A list with an IRI head will not validate, but is commonly used to detect if a list is valid.
# @param [RDF::Graph] graph (RDF::Graph.new)
# @param [Array<RDF::Term>] values
# Any values which are not terms are coerced to `RDF::Literal`.
# @yield [list]
# @yieldparam [RDF::List] list
def initialize(subject: nil, graph: nil, values: nil, &block)
@subject = subject || RDF.nil
@graph = graph || RDF::Graph.new
is_empty = @graph.query(subject: subject, predicate: RDF.first).empty?
Expand Down
4 changes: 2 additions & 2 deletions lib/rdf/transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ def self.begin(repository, mutable: false, **options, &block)
#
# @deprecated
# @return [RDF::Enumerable]
attr_reader :deletes
def deletes
warn "[DEPRECATION] Transaction#deletes now uses keyword arguments. Called from #{Gem.location_of_caller.join(':')}"
self.changes.deletes
end

Expand All @@ -128,8 +128,8 @@ def deletes
#
# @deprecated
# @return [RDF::Enumerable]
attr_reader :inserts
def inserts
warn "[DEPRECATION] Transaction#inserts now uses keyword arguments. Called from #{Gem.location_of_caller.join(':')}"
self.changes.inserts
end

Expand Down
6 changes: 3 additions & 3 deletions lib/rdf/vocab/writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ def write_epilogue

@output.print %(# -*- encoding: utf-8 -*-
# frozen_string_literal: true
# This file generated automatically using vocab-fetch from #{source}
# This file generated automatically using rdf vocabulary format from #{source}
require 'rdf'
module #{module_name}
# @!parse
# # Vocabulary for <#{base_uri}>
# class #{vocab.name} < RDF::#{"Strict" if strict}Vocabulary
# class #{class_name} < RDF::#{"Strict" if strict}Vocabulary
# end
class #{vocab.name} < RDF::#{"Strict" if strict}Vocabulary("#{base_uri}")
class #{class_name} < RDF::#{"Strict" if strict}Vocabulary("#{base_uri}")
).gsub(/^ /, '')

# Split nodes into Class/Property/Datatype/Other
Expand Down
6 changes: 3 additions & 3 deletions rdf.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ 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.0.0.beta', '< 3'
gem.add_development_dependency 'rdf-vocab', '>= 2.0.0.beta', '< 3'
gem.add_development_dependency 'rdf-xsd', '>= 2.0.0.beta', '< 3'
gem.add_development_dependency 'rdf-spec', '~> 2.0'
gem.add_development_dependency 'rdf-vocab', '~> 2.0'
gem.add_development_dependency 'rdf-xsd', '~> 2.0'
gem.add_development_dependency 'rest-client', '~> 1.7'
gem.add_development_dependency 'rspec', '~> 3.0'
gem.add_development_dependency 'rspec-its', '~> 1.0'
Expand Down
13 changes: 5 additions & 8 deletions spec/model_graph_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,13 @@
context "as method" do
it "with keyword arg" do
expect(described_class).to receive(:new).with(graph_name: "http://ruby-rdf.github.com/rdf/etc/doap.nt")
expect {
RDF::Graph(graph_name: "http://ruby-rdf.github.com/rdf/etc/doap.nt")
}.not_to write('[DEPRECATION]').to(:error)
RDF::Graph(graph_name: "http://ruby-rdf.github.com/rdf/etc/doap.nt")
end

it "with positional arg (DEPRECATED)" do
expect(described_class).to receive(:new).with(graph_name: "http://ruby-rdf.github.com/rdf/etc/doap.nt")
it "with positional arg (removed)" do
expect {
RDF::Graph("http://ruby-rdf.github.com/rdf/etc/doap.nt")
}.to write('[DEPRECATION]').to(:error)
}.to raise_error(ArgumentError)
end
end

Expand Down Expand Up @@ -56,10 +53,10 @@
expect { subject }.to_not raise_error
end

it "should be instantiable with positional arg (DEPRECATED)" do
it "should not be instantiable with positional arg" do
expect {
described_class.new("http://ruby-rdf.github.com/rdf/etc/doap.nt", data: RDF::Repository.new)
}.to write('[DEPRECATION]').to(:error)
}.to raise_error(ArgumentError)
end

it "should not be instantiable by default" do
Expand Down
2 changes: 1 addition & 1 deletion spec/model_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
expect(l.subject).to eq(n)
end

it "should be instantiable with positional args (DEPRECATED)" do
it "should not be instantiable with positional args" do
expect {
described_class.new(RDF::Node.new, graph)
}.to raise_error ArgumentError
Expand Down

0 comments on commit 50f2a64

Please sign in to comment.