Skip to content

Commit

Permalink
Finish 2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Apr 29, 2016
2 parents 50f2a64 + 28128f7 commit 78b2de6
Show file tree
Hide file tree
Showing 13 changed files with 172 additions and 157 deletions.
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@ rvm:
- 2.0
- 2.1
- 2.2.4
- 2.3.0
- 2.3.1
- jruby-9.0.4.0
- rbx-2
cache: bundler
sudo: false
matrix:
allow_failures:
- rvm: rbx-2
addons:
code_climate:
repo_token: 5806cc8a21c03f4e2f9d3b9d98d5d9fe084b66243b1dbb27b467dbc795acdcac
repo_token: 5806cc8a21c03f4e2f9d3b9d98d5d9fe084b66243b1dbb27b467dbc795acdcac
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ group :debug do
gem "wirble"
gem "redcarpet", platforms: :ruby
gem "byebug", platforms: :mri
gem 'rubinius-debugger', platform: :rbx
gem 'guard-rspec'
end

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0
2.0.1
3 changes: 2 additions & 1 deletion bin/rdf
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ end

abort options.banner if ARGV.empty? && !options.options[:evaluate]

RDF::CLI.exec(ARGV, options.options)
# Add option_parser to parsed options to enable help
RDF::CLI.exec(ARGV, options.options.merge(option_parser: options))
8 changes: 4 additions & 4 deletions lib/rdf/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
require 'linkeddata'
rescue LoadError
# Silently load without linkeddata, but try some others
%w(reasoner rdfa rdfxml turtle json/ld ld/patch).each do |ser|
%w(reasoner rdfa rdfxml turtle vocab json/ld ld/patch).each do |ser|
begin
require ser.include?('/') ? ser : "rdf/#{ser}"
rescue LoadError
Expand Down Expand Up @@ -345,16 +345,16 @@ def self.exec(args, options = {})
cmds, args = args.partition {|e| commands.include?(e.to_s)}

if cmds.empty?
usage(options)
usage(options.fetch(:option_parser, self.options))
abort "No command given"
end

if cmds.first == 'help'
on_cmd = cmds[1]
if on_cmd && COMMANDS.fetch(on_cmd.to_sym, {})[:help]
usage(self.options, banner: "Usage: #{self.basename.split('/').last} #{COMMANDS[on_cmd.to_sym][:help]}")
usage(options.fetch(:option_parser, self.options), banner: "Usage: #{self.basename.split('/').last} #{COMMANDS[on_cmd.to_sym][:help]}")
else
usage(self.options)
usage(options.fetch(:option_parser, self.options))
end
return
end
Expand Down
44 changes: 24 additions & 20 deletions lib/rdf/model/list.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# coding: utf-8
module RDF
##
# An RDF list.
Expand Down Expand Up @@ -344,12 +345,7 @@ def []=(*args)
# @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-unshift
#
def unshift(value)
value = case value
when nil then RDF.nil
when RDF::Term then value
when Array then RDF::List.new(subject: nil, graph: graph, values: value)
else value
end
value = normalize_value(value)

new_subject, old_subject = RDF::Node.new, subject

Expand Down Expand Up @@ -407,12 +403,7 @@ def clear
# @return [RDF::List]
# @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-3C-3C
def <<(value)
value = case value
when nil then RDF.nil
when RDF::Value then value
when Array then RDF::List.new(subject: nil, graph: graph, values: value)
else value
end
value = normalize_value(value)

if empty?
@subject = new_subject = RDF::Node.new
Expand Down Expand Up @@ -547,12 +538,11 @@ def slice_with_range(range)
# RDF::List[1, 2, 3].fetch(4, nil) #=> nil
# RDF::List[1, 2, 3].fetch(4) { |n| n*n } #=> 16
#
# @return [RDF::Term]
# @return [RDF::Term, nil]
# @see http://ruby-doc.org/core-1.9/classes/Array.html#M000420
def fetch(index, default = UNSET)
each.with_index do |v, i|
return v if i == index
end
val = at(index)
return val unless val.nil?

case
when block_given? then yield index
Expand All @@ -568,12 +558,10 @@ def fetch(index, default = UNSET)
# RDF::List[1, 2, 3].at(0) #=> 1
# RDF::List[1, 2, 3].at(4) #=> nil
#
# @return [RDF::Term]
# @return [RDF::Term, nil]
# @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-at
def at(index)
each.with_index do |v, i|
return v if i == index
end
each.with_index { |v, i| return v if i == index }
return nil
end

Expand Down Expand Up @@ -943,5 +931,21 @@ def inspect
sprintf("#<%s:%#0x(%s)>", self.class.name, __id__, join(', '))
end
end

private

##
# Normalizes `Array` to `RDF::List` and `nil` to `RDF.nil`.
#
# @param value [Object]
# @return [RDF::Value, Object] normalized value
def normalize_value(value)
case value
when nil then RDF.nil
when RDF::Value then value
when Array then RDF::List.new(subject: nil, graph: graph, values: value)
else value
end
end
end
end
2 changes: 1 addition & 1 deletion lib/rdf/model/literal/double.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module RDF; class Literal
# @since 0.2.1
class Double < Numeric
DATATYPE = RDF::XSD.double
GRAMMAR = /^NaN|(?:[\+\-]?(?:INF|(?:\d+(\.\d*)?([eE][\+\-]?\d+)?)))$/.freeze
GRAMMAR = /^(?:NaN|(?:[\+\-]?(?:INF|(?:\d+(\.\d*)?([eE][\+\-]?\d+)?))))$/.freeze

##
# @param [Float, #to_f] value
Expand Down
17 changes: 1 addition & 16 deletions lib/rdf/model/uri.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,7 @@ def query_values=(value)

value = value.to_hash if value.respond_to?(:to_hash)
self.query = case value
when Array
when Array, Hash
value.map do |(k,v)|
k = normalize_segment(k.to_s, UNRESERVED)
if v.nil?
Expand All @@ -1250,21 +1250,6 @@ def query_values=(value)
end.join("&")
end
end
when Hash
value.map do |k, v|
k = normalize_segment(k.to_s, UNRESERVED)
if v.nil?
k
else
Array(v).map do |vv|
if vv === TrueClass
k
else
"#{k}=#{normalize_segment(vv.to_s, UNRESERVED)}"
end
end.join("&")
end
end
else
raise TypeError,
"Can't convert #{value.class} into Hash."
Expand Down
20 changes: 0 additions & 20 deletions lib/rdf/transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,26 +113,6 @@ def self.begin(repository, mutable: false, **options, &block)
# @since 2.0.0
attr_reader :changes

##
# RDF statements to delete when executed.
#
# @deprecated
# @return [RDF::Enumerable]
def deletes
warn "[DEPRECATION] Transaction#deletes now uses keyword arguments. Called from #{Gem.location_of_caller.join(':')}"
self.changes.deletes
end

##
# RDF statements to insert when executed.
#
# @deprecated
# @return [RDF::Enumerable]
def inserts
warn "[DEPRECATION] Transaction#inserts now uses keyword arguments. Called from #{Gem.location_of_caller.join(':')}"
self.changes.inserts
end

##
# Any additional options for this transaction.
#
Expand Down
46 changes: 23 additions & 23 deletions lib/rdf/vocab/rdfv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,37 @@ def name; "RDF"; end
term :Alt,
comment: %(The class of containers of alternatives.).freeze,
label: "Alt".freeze,
"rdfs:isDefinedBy" => %(rdf:).freeze,
:"rdfs:isDefinedBy" => %(rdf:).freeze,
subClassOf: "rdfs:Container".freeze,
type: "rdfs:Class".freeze
term :Bag,
comment: %(The class of unordered containers.).freeze,
label: "Bag".freeze,
"rdfs:isDefinedBy" => %(rdf:).freeze,
:"rdfs:isDefinedBy" => %(rdf:).freeze,
subClassOf: "rdfs:Container".freeze,
type: "rdfs:Class".freeze
term :List,
comment: %(The class of RDF Lists.).freeze,
label: "List".freeze,
"rdfs:isDefinedBy" => %(rdf:).freeze,
:"rdfs:isDefinedBy" => %(rdf:).freeze,
subClassOf: "rdfs:Resource".freeze,
type: "rdfs:Class".freeze
term :Property,
comment: %(The class of RDF properties.).freeze,
label: "Property".freeze,
"rdfs:isDefinedBy" => %(rdf:).freeze,
:"rdfs:isDefinedBy" => %(rdf:).freeze,
subClassOf: "rdfs:Resource".freeze,
type: "rdfs:Class".freeze
term :Seq,
comment: %(The class of ordered containers.).freeze,
label: "Seq".freeze,
"rdfs:isDefinedBy" => %(rdf:).freeze,
:"rdfs:isDefinedBy" => %(rdf:).freeze,
subClassOf: "rdfs:Container".freeze,
type: "rdfs:Class".freeze
term :Statement,
comment: %(The class of RDF statements.).freeze,
label: "Statement".freeze,
"rdfs:isDefinedBy" => %(rdf:).freeze,
:"rdfs:isDefinedBy" => %(rdf:).freeze,
subClassOf: "rdfs:Resource".freeze,
type: "rdfs:Class".freeze

Expand All @@ -53,84 +53,84 @@ def name; "RDF"; end
domain: "rdf:List".freeze,
label: "first".freeze,
range: "rdfs:Resource".freeze,
"rdfs:isDefinedBy" => %(rdf:).freeze,
:"rdfs:isDefinedBy" => %(rdf:).freeze,
type: "rdf:Property".freeze
property :object,
comment: %(The object of the subject RDF statement.).freeze,
domain: "rdf:Statement".freeze,
label: "object".freeze,
range: "rdfs:Resource".freeze,
"rdfs:isDefinedBy" => %(rdf:).freeze,
:"rdfs:isDefinedBy" => %(rdf:).freeze,
type: "rdf:Property".freeze
property :predicate,
comment: %(The predicate of the subject RDF statement.).freeze,
domain: "rdf:Statement".freeze,
label: "predicate".freeze,
range: "rdfs:Resource".freeze,
"rdfs:isDefinedBy" => %(rdf:).freeze,
:"rdfs:isDefinedBy" => %(rdf:).freeze,
type: "rdf:Property".freeze
property :rest,
comment: %(The rest of the subject RDF list after the first item.).freeze,
domain: "rdf:List".freeze,
label: "rest".freeze,
range: "rdf:List".freeze,
"rdfs:isDefinedBy" => %(rdf:).freeze,
:"rdfs:isDefinedBy" => %(rdf:).freeze,
type: "rdf:Property".freeze
property :subject,
comment: %(The subject of the subject RDF statement.).freeze,
domain: "rdf:Statement".freeze,
label: "subject".freeze,
range: "rdfs:Resource".freeze,
"rdfs:isDefinedBy" => %(rdf:).freeze,
:"rdfs:isDefinedBy" => %(rdf:).freeze,
type: "rdf:Property".freeze
property :type,
comment: %(The subject is an instance of a class.).freeze,
domain: "rdfs:Resource".freeze,
label: "type".freeze,
range: "rdfs:Class".freeze,
"rdfs:isDefinedBy" => %(rdf:).freeze,
:"rdfs:isDefinedBy" => %(rdf:).freeze,
type: "rdf:Property".freeze
property :value,
comment: %(Idiomatic property used for structured values.).freeze,
domain: "rdfs:Resource".freeze,
label: "value".freeze,
range: "rdfs:Resource".freeze,
"rdfs:isDefinedBy" => %(rdf:).freeze,
:"rdfs:isDefinedBy" => %(rdf:).freeze,
type: "rdf:Property".freeze

# Datatype definitions
term :HTML,
comment: %(The datatype of RDF literals storing fragments of HTML content).freeze,
label: "HTML".freeze,
"rdfs:isDefinedBy" => %(rdf:).freeze,
"rdfs:seeAlso" => %(http://www.w3.org/TR/rdf11-concepts/#section-html).freeze,
:"rdfs:isDefinedBy" => %(rdf:).freeze,
:"rdfs:seeAlso" => %(http://www.w3.org/TR/rdf11-concepts/#section-html).freeze,
subClassOf: "rdfs:Literal".freeze,
type: "rdfs:Datatype".freeze
term :PlainLiteral,
comment: %(The class of plain \(i.e. untyped\) literal values, as used in RIF and OWL 2).freeze,
label: "PlainLiteral".freeze,
"rdfs:isDefinedBy" => %(rdf:).freeze,
"rdfs:seeAlso" => %(http://www.w3.org/TR/rdf-plain-literal/).freeze,
:"rdfs:isDefinedBy" => %(rdf:).freeze,
:"rdfs:seeAlso" => %(http://www.w3.org/TR/rdf-plain-literal/).freeze,
subClassOf: "rdfs:Literal".freeze,
type: "rdfs:Datatype".freeze
term :XMLLiteral,
comment: %(The datatype of XML literal values.).freeze,
label: "XMLLiteral".freeze,
"rdfs:isDefinedBy" => %(rdf:).freeze,
:"rdfs:isDefinedBy" => %(rdf:).freeze,
subClassOf: "rdfs:Literal".freeze,
type: "rdfs:Datatype".freeze
term :langString,
comment: %(The datatype of language-tagged string values).freeze,
label: "langString".freeze,
"rdfs:isDefinedBy" => %(rdf:).freeze,
"rdfs:seeAlso" => %(http://www.w3.org/TR/rdf11-concepts/#section-Graph-Literal).freeze,
:"rdfs:isDefinedBy" => %(rdf:).freeze,
:"rdfs:seeAlso" => %(http://www.w3.org/TR/rdf11-concepts/#section-Graph-Literal).freeze,
subClassOf: "rdfs:Literal".freeze,
type: "rdfs:Datatype".freeze

# Extra definitions
term :"",
"dc11:description" => %(This is the RDF Schema for the RDF vocabulary terms in the RDF Namespace, defined in RDF 1.1 Concepts.).freeze,
"dc11:title" => %(The RDF Concepts Vocabulary \(RDF\)).freeze,
:"dc11:description" => %(This is the RDF Schema for the RDF vocabulary terms in the RDF Namespace, defined in RDF 1.1 Concepts.).freeze,
:"dc11:title" => %(The RDF Concepts Vocabulary \(RDF\)).freeze,
type: "owl:Ontology".freeze
term :Description,
comment: %(RDF/XML node element).freeze,
Expand All @@ -150,7 +150,7 @@ def name; "RDF"; end
term :nil,
comment: %(The empty list, with no items in it. If the rest of a list is nil then the list has no more items in it.).freeze,
label: "nil".freeze,
"rdfs:isDefinedBy" => %(rdf:).freeze,
:"rdfs:isDefinedBy" => %(rdf:).freeze,
type: "rdf:List".freeze
term :nodeID,
comment: %(RDF/XML Blank Node identifier).freeze,
Expand Down

0 comments on commit 78b2de6

Please sign in to comment.