From b2394b1e0321173bfa5eac691e15efb1d2ee33cc Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Wed, 20 May 2020 17:28:44 -0700 Subject: [PATCH 01/12] Update URLs to use HTTPS, where possible. --- CONTRIBUTING.md | 8 ++-- README.md | 89 ++++++++++++++++++------------------- Rakefile | 2 +- UNLICENSE | 2 +- lib/sparql/client.rb | 50 ++++++++++----------- lib/sparql/client/query.rb | 60 ++++++++++++------------- lib/sparql/client/update.rb | 20 ++++----- sparql-client.gemspec | 2 +- spec/fixtures/triples.ru | 54 +++++++++++----------- 9 files changed, 142 insertions(+), 145 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index af29af12..645d8275 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,7 +6,7 @@ Community contributions are essential for keeping Ruby RDF great. We want to kee This repository uses [Git Flow](https://github.com/nvie/gitflow) to manage development and release activity. All submissions _must_ be on a feature branch based on the _develop_ branch to ease staging and integration. -* create or respond to an issue on the [Github Repository](http://github.com/ruby-rdf/sparql-client/issues) +* create or respond to an issue on the [Github Repository](https://github.com/ruby-rdf/sparql-client/issues) * Fork and clone the repo: `git clone git@github.com:your-username/sparql-client.git` * Install bundle: @@ -30,7 +30,7 @@ This repository uses [Git Flow](https://github.com/nvie/gitflow) to manage devel of thumb, additions larger than about 15 lines of code), we need an explicit [public domain dedication][PDD] on record from you. -[YARD]: http://yardoc.org/ -[YARD-GS]: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md -[PDD]: http://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html +[YARD]: https://yardoc.org/ +[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md +[PDD]: https://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html [pr]: https://github.com/ruby-rdf/sparql-client/compare/ diff --git a/README.md b/README.md index 2650f5b8..016574a9 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,10 @@ This is a [Ruby][] implementation of a [SPARQL][] client for [RDF.rb][]. -* +* -[![Gem Version](https://badge.fury.io/rb/sparql-client.png)](http://badge.fury.io/rb/sparql-client) -[![Build Status](https://travis-ci.org/ruby-rdf/sparql-client.png?branch=master)](http://travis-ci.org/ruby-rdf/sparql-client) +[![Gem Version](https://badge.fury.io/rb/sparql-client.png)](https://badge.fury.io/rb/sparql-client) +[![Build Status](https://travis-ci.org/ruby-rdf/sparql-client.png?branch=master)](https://travis-ci.org/ruby-rdf/sparql-client) [![Coverage Status](https://coveralls.io/repos/ruby-rdf/sparql-client/badge.svg?branch=master&service=github)](https://coveralls.io/github/ruby-rdf/sparql-client?branch=master) ## Features @@ -18,7 +18,7 @@ This is a [Ruby][] implementation of a [SPARQL][] client for [RDF.rb][]. * Supports tuple result sets in both XML, JSON, CSV and TSV formats, with JSON being the preferred default for content-negotiation purposes. * Supports graph results in any RDF serialization format understood by RDF.rb. -* Returns results using the [RDF.rb object model][RDF.rb model]. +* Returns results using the RDF.rb object model. * Supports accessing endpoints as read/write [`RDF::Repository`][RDF::Repository] instances {SPARQL::Client::Repository}. @@ -123,15 +123,15 @@ sparql.delete_data(data) ## Dependencies -* [Ruby](http://ruby-lang.org/) (>= 2.4) -* [RDF.rb](http://rubygems.org/gems/rdf) (~> 3.1) -* [Net::HTTP::Persistent](http://rubygems.org/gems/net-http-persistent) (~> 3.1) -* Soft dependency on [SPARQL](http://rubygems.org/gems/sparql) (~> 3.1) -* Soft dependency on [Nokogiri](http://rubygems.org/gems/nokogiri) (>= 1.10) +* [Ruby](https://ruby-lang.org/) (>= 2.4) +* [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.1) +* [Net::HTTP::Persistent](https://rubygems.org/gems/net-http-persistent) (~> 3.1) +* Soft dependency on [SPARQL](https://rubygems.org/gems/sparql) (~> 3.1) +* Soft dependency on [Nokogiri](https://rubygems.org/gems/nokogiri) (>= 1.10) ## Installation -The recommended installation method is via [RubyGems](http://rubygems.org/). +The recommended installation method is via [RubyGems](https://rubygems.org/). To install the latest official release of the `SPARQL::Client` gem, do: % [sudo] gem install sparql-client @@ -145,31 +145,31 @@ To get a local working copy of the development repository, do: Alternatively, download the latest development version as a tarball as follows: - % wget http://github.com/ruby-rdf/sparql-client/tarball/master + % wget https://github.com/ruby-rdf/sparql-client/tarball/master ## Mailing List -* +* ## Authors -* [Arto Bendiken](http://github.com/bendiken) - -* [Ben Lavender](http://github.com/bhuga) - -* [Gregg Kellogg](http://github.com/gkellogg) - +* [Arto Bendiken](https://github.com/artob) - +* [Ben Lavender](https://github.com/bhuga) - +* [Gregg Kellogg](https://github.com/gkellogg) - ## Contributors -* [Christoph Badura](http://github.com/bad) - -* [James Hetherington](http://github.com/jamespjh) - -* [Gabriel Horner](http://github.com/cldwalker) - -* [Nicholas Humfrey](http://github.com/njh) - -* [Fumihiro Kato](http://github.com/fumi) - -* [David Nielsen](http://github.com/drankard) - -* [Thamaraiselvan Poomalai](http://github.com/selvan) - -* [Michael Sokol](http://github.com/mikaa123) - -* [Yves Raimond](http://github.com/moustaki) - -* [Thomas Feron](http://github.com/thoferon) - -* [Nick Gottlieb](http://github.com/ngottlieb) - +* [Christoph Badura](https://github.com/bad) - +* [James Hetherington](https://github.com/jamespjh) - +* [Gabriel Horner](https://github.com/cldwalker) - +* [Nicholas Humfrey](https://github.com/njh) - +* [Fumihiro Kato](https://github.com/fumi) - +* [David Nielsen](https://github.com/drankard) - +* [Thamaraiselvan Poomalai](https://github.com/selvan) - +* [Michael Sokol](https://github.com/mikaa123) - +* [Yves Raimond](https://github.com/moustaki) - +* [Thomas Feron](https://github.com/thoferon) - +* [Nick Gottlieb](https://github.com/ngottlieb) - ## Contributing This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange development and release activity. All submissions _must_ be on a feature branch based on the _develop_ branch to ease staging and integration. @@ -188,27 +188,26 @@ This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange develo ## Resources -* -* -* -* -* +* +* +* +* +* ## License This is free and unencumbered public domain software. For more information, -see or the accompanying {file:UNLICENSE} file. - -[Ruby]: http://ruby-lang.org/ -[RDF]: http://www.w3.org/RDF/ -[SPARQL]: http://en.wikipedia.org/wiki/SPARQL -[SPARQL JSON]: http://www.w3.org/TR/rdf-sparql-json-res/ -[RDF.rb]: http://rubygems.org/gems/rdf -[RDF.rb model]: http://blog.datagraph.org/2010/03/rdf-for-ruby -[RDF::Repository]: http://rubydoc.info/github/ruby-rdf/rdf/RDF/Repository -[DSL]: http://en.wikipedia.org/wiki/Domain-specific_language +see or the accompanying {file:UNLICENSE} file. + +[Ruby]: https://ruby-lang.org/ +[RDF]: https://www.w3.org/RDF/ +[SPARQL]: https://en.wikipedia.org/wiki/SPARQL +[SPARQL JSON]: https://www.w3.org/TR/rdf-sparql-json-res/ +[RDF.rb]: https://rubygems.org/gems/rdf +[RDF::Repository]: https://rubydoc.info/github/ruby-rdf/rdf/RDF/Repository +[DSL]: https://en.wikipedia.org/wiki/Domain-specific_language "domain-specific language" -[YARD]: http://yardoc.org/ -[YARD-GS]: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md -[PDD]: http://unlicense.org/#unlicensing-contributions -[Backports]: http://rubygems.org/gems/backports +[YARD]: https://yardoc.org/ +[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md +[PDD]: https://unlicense.org/#unlicensing-contributions +[Backports]: https://rubygems.org/gems/backports diff --git a/Rakefile b/Rakefile index dfb74f45..5c67c917 100755 --- a/Rakefile +++ b/Rakefile @@ -2,7 +2,7 @@ $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), 'lib'))) require 'rubygems' begin - require 'rakefile' # @see http://github.com/bendiken/rakefile + require 'rakefile' # @see https://github.com/artob/rakefile rescue LoadError => e end diff --git a/UNLICENSE b/UNLICENSE index 68a49daa..efb98088 100644 --- a/UNLICENSE +++ b/UNLICENSE @@ -21,4 +21,4 @@ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -For more information, please refer to +For more information, please refer to diff --git a/lib/sparql/client.rb b/lib/sparql/client.rb index c2423de0..3e556356 100644 --- a/lib/sparql/client.rb +++ b/lib/sparql/client.rb @@ -1,6 +1,6 @@ -require 'net/http/persistent' # @see http://rubygems.org/gems/net-http-persistent -require 'rdf' # @see http://rubygems.org/gems/rdf -require 'rdf/ntriples' # @see http://rubygems.org/gems/rdf +require 'net/http/persistent' # @see https://rubygems.org/gems/net-http-persistent +require 'rdf' # @see https://rubygems.org/gems/rdf +require 'rdf/ntriples' # @see https://rubygems.org/gems/rdf begin require 'nokogiri' rescue LoadError @@ -11,10 +11,10 @@ module SPARQL ## # A SPARQL 1.0/1.1 client for RDF.rb. # - # @see http://www.w3.org/TR/sparql11-query/ - # @see http://www.w3.org/TR/sparql11-protocol/ - # @see http://www.w3.org/TR/sparql11-results-json/ - # @see http://www.w3.org/TR/sparql11-results-csv-tsv/ + # @see https://www.w3.org/TR/sparql11-query/ + # @see https://www.w3.org/TR/sparql11-protocol/ + # @see https://www.w3.org/TR/sparql11-results-json/ + # @see https://www.w3.org/TR/sparql11-results-csv-tsv/ class Client autoload :Query, 'sparql/client/query' autoload :Repository, 'sparql/client/repository' @@ -185,7 +185,7 @@ def construct(*args, **options) # @param [Hash{Symbol => Object}] options # @option options [RDF::URI, String] :graph # @return [void] `self` - # @see http://www.w3.org/TR/sparql11-update/#insertData + # @see https://www.w3.org/TR/sparql11-update/#insertData def insert_data(data, **options) self.update(Update::InsertData.new(data, **options)) end @@ -206,7 +206,7 @@ def insert_data(data, **options) # @param [Hash{Symbol => Object}] options # @option options [RDF::URI, String] :graph # @return [void] `self` - # @see http://www.w3.org/TR/sparql11-update/#deleteData + # @see https://www.w3.org/TR/sparql11-update/#deleteData def delete_data(data, **options) self.update(Update::DeleteData.new(data, **options)) end @@ -222,7 +222,7 @@ def delete_data(data, **options) # @param [Hash{Symbol => Object}] options # @option options [RDF::URI, String] :graph # @return [void] `self` - # @see http://www.w3.org/TR/sparql11-update/#deleteInsert + # @see https://www.w3.org/TR/sparql11-update/#deleteInsert def delete_insert(delete_graph, insert_graph = nil, where_graph = nil, **options) self.update(Update::DeleteInsert.new(delete_graph, insert_graph, where_graph, **options)) end @@ -239,7 +239,7 @@ def delete_insert(delete_graph, insert_graph = nil, where_graph = nil, **options # @param [Hash{Symbol => Object}] options # @option options [Boolean] :silent # @return [void] `self` - # @see http://www.w3.org/TR/sparql11-update/#clear + # @see https://www.w3.org/TR/sparql11-update/#clear def clear_graph(graph_uri, **options) self.clear(:graph, graph_uri, **options) end @@ -274,7 +274,7 @@ def clear_graph(graph_uri, **options) # @option options [Boolean] :silent # @return [void] `self` # - # @see http://www.w3.org/TR/sparql11-update/#clear + # @see https://www.w3.org/TR/sparql11-update/#clear def clear(what, *arguments) self.update(Update::Clear.new(what, *arguments)) end @@ -307,7 +307,7 @@ def nodes # @option options [Hash] :headers # @return [Array] # @raise [IOError] if connection is closed - # @see http://www.w3.org/TR/sparql11-protocol/#query-operation + # @see https://www.w3.org/TR/sparql11-protocol/#query-operation def query(query, **options) @op = :query @alt_endpoint = options[:endpoint] @@ -335,7 +335,7 @@ def query(query, **options) # @option options [Hash] :headers # @return [void] `self` # @raise [IOError] if connection is closed - # @see http://www.w3.org/TR/sparql11-protocol/#update-operation + # @see https://www.w3.org/TR/sparql11-protocol/#update-operation def update(query, **options) @op = :update @alt_endpoint = options[:endpoint] @@ -402,7 +402,7 @@ def parse_response(response, **options) ## # @param [String, Hash] json # @return [] - # @see http://www.w3.org/TR/rdf-sparql-json-res/#results + # @see https://www.w3.org/TR/rdf-sparql-json-res/#results def self.parse_json_bindings(json, nodes = {}) require 'json' unless defined?(::JSON) json = JSON.parse(json.to_s) unless json.is_a?(Hash) @@ -423,8 +423,8 @@ def self.parse_json_bindings(json, nodes = {}) ## # @param [Hash{String => String}] value # @return [RDF::Value] - # @see http://www.w3.org/TR/sparql11-results-json/#select-encode-terms - # @see http://www.w3.org/TR/rdf-sparql-json-res/#variable-binding-results + # @see https://www.w3.org/TR/sparql11-results-json/#select-encode-terms + # @see https://www.w3.org/TR/rdf-sparql-json-res/#variable-binding-results def self.parse_json_value(value, nodes = {}) case value['type'].to_sym when :bnode @@ -442,7 +442,7 @@ def self.parse_json_value(value, nodes = {}) ## # @param [String, Array>] csv # @return [] - # @see http://www.w3.org/TR/sparql11-results-csv-tsv/ + # @see https://www.w3.org/TR/sparql11-results-csv-tsv/ def self.parse_csv_bindings(csv, nodes = {}) require 'csv' unless defined?(::CSV) csv = CSV.parse(csv.to_s) unless csv.is_a?(Array) @@ -466,7 +466,7 @@ def self.parse_csv_bindings(csv, nodes = {}) ## # @param [String, Array>] tsv # @return [] - # @see http://www.w3.org/TR/sparql11-results-csv-tsv/ + # @see https://www.w3.org/TR/sparql11-results-csv-tsv/ def self.parse_tsv_bindings(tsv, nodes = {}) tsv = tsv.lines.map {|l| l.chomp.split("\t")} unless tsv.is_a?(Array) vars = tsv.shift.map {|h| h.sub(/^\?/, '')} @@ -495,7 +495,7 @@ def self.parse_tsv_bindings(tsv, nodes = {}) ## # @param [String, IO, Nokogiri::XML::Node, REXML::Element] xml # @return [] - # @see http://www.w3.org/TR/rdf-sparql-json-res/#results + # @see https://www.w3.org/TR/rdf-sparql-json-res/#results def self.parse_xml_bindings(xml, nodes = {}) xml.force_encoding(::Encoding::UTF_8) if xml.respond_to?(:force_encoding) @@ -540,7 +540,7 @@ def self.parse_xml_bindings(xml, nodes = {}) ## # @param [Nokogiri::XML::Element, REXML::Element] value # @return [RDF::Value] - # @see http://www.w3.org/TR/rdf-sparql-json-res/#variable-binding-results + # @see https://www.w3.org/TR/rdf-sparql-json-res/#variable-binding-results def self.parse_xml_value(value, nodes = {}) case value.name.to_sym when :bnode @@ -699,7 +699,7 @@ def http_klass(scheme) # @yieldparam [Net::HTTPResponse] response # @return [Net::HTTPResponse] # @raise [IOError] if connection is closed - # @see http://www.w3.org/TR/sparql11-protocol/#query-operation + # @see https://www.w3.org/TR/sparql11-protocol/#query-operation def request(query, headers = {}, &block) # Make sure an appropriate Accept header is present headers['Accept'] ||= if (query.respond_to?(:expects_statements?) ? @@ -747,7 +747,7 @@ def request_method(query) # @param [String, #to_s] query # @param [Hash{String => String}] headers # @return [Net::HTTPRequest] - # @see http://www.w3.org/TR/sparql11-protocol/#query-via-get + # @see https://www.w3.org/TR/sparql11-protocol/#query-via-get def make_get_request(query, headers = {}) url = self.url.dup url.query_values = (url.query_values || {}).merge(query: query.to_s) @@ -762,8 +762,8 @@ def make_get_request(query, headers = {}) # @param [String, #to_s] query # @param [Hash{String => String}] headers # @return [Net::HTTPRequest] - # @see http://www.w3.org/TR/sparql11-protocol/#query-via-post-direct - # @see http://www.w3.org/TR/sparql11-protocol/#query-via-post-urlencoded + # @see https://www.w3.org/TR/sparql11-protocol/#query-via-post-direct + # @see https://www.w3.org/TR/sparql11-protocol/#query-via-post-urlencoded def make_post_request(query, headers = {}) if @alt_endpoint.nil? url = self.url.dup diff --git a/lib/sparql/client/query.rb b/lib/sparql/client/query.rb index d55c782c..ef59a351 100644 --- a/lib/sparql/client/query.rb +++ b/lib/sparql/client/query.rb @@ -10,7 +10,7 @@ class Query < RDF::Query # The form of the query. # # @return [:select, :ask, :construct, :describe] - # @see http://www.w3.org/TR/sparql11-query/#QueryForms + # @see https://www.w3.org/TR/sparql11-query/#QueryForms attr_reader :form ## @@ -25,7 +25,7 @@ class Query < RDF::Query # # @param [Hash{Symbol => Object}] options (see {#initialize}) # @return [Query] - # @see http://www.w3.org/TR/sparql11-query/#ask + # @see https://www.w3.org/TR/sparql11-query/#ask def self.ask(**options) self.new(:ask, **options) end @@ -33,13 +33,13 @@ def self.ask(**options) ## # Creates a tuple `SELECT` query. # - # @example SELECT * WHERE { ?s ?p ?o . } + # @example `SELECT * WHERE { ?s ?p ?o . }` # Query.select.where([:s, :p, :o]) # - # @example SELECT ?s WHERE {?s ?p ?o .} + # @example `SELECT ?s WHERE {?s ?p ?o .}` # Query.select(:s).where([:s, :p, :o]) # - # @example SELECT COUNT(?uri as ?c) WHERE {?uri a owl:Class} + # @example `SELECT COUNT(?uri as ?c) WHERE {?uri a owl:Class}` # Query.select(count: {uri: :c}).where([:uri, RDF.type, RDF::OWL.Class]) # # @param [Array] variables @@ -49,7 +49,7 @@ def self.ask(**options) # @param [Array] variables # @param [Hash{Symbol => Object}] options (see {#initialize}) # @return [Query] - # @see http://www.w3.org/TR/sparql11-query/#select + # @see https://www.w3.org/TR/sparql11-query/#select def self.select(*variables, **options) self.new(:select, **options).select(*variables) end @@ -67,7 +67,7 @@ def self.select(*variables, **options) # @param [Array] variables # @param [Hash{Symbol => Object}] options (see {#initialize}) # @return [Query] - # @see http://www.w3.org/TR/sparql11-query/#describe + # @see https://www.w3.org/TR/sparql11-query/#describe def self.describe(*variables, **options) self.new(:describe, **options).describe(*variables) end @@ -85,7 +85,7 @@ def self.describe(*variables, **options) # @param [Array] patterns # @param [Hash{Symbol => Object}] options (see {#initialize}) # @return [Query] - # @see http://www.w3.org/TR/sparql11-query/#construct + # @see https://www.w3.org/TR/sparql11-query/#construct def self.construct(*patterns, **options) self.new(:construct, **options).construct(*patterns) # FIXME end @@ -112,25 +112,25 @@ def initialize(form = :ask, **options, &block) # query.ask.where([:s, :p, :o]) # # @return [Query] - # @see http://www.w3.org/TR/sparql11-query/#ask + # @see https://www.w3.org/TR/sparql11-query/#ask def ask @form = :ask self end ## - # @example SELECT * WHERE { ?s ?p ?o . } + # @example `SELECT * WHERE { ?s ?p ?o . }` # query.select.where([:s, :p, :o]) # - # @example SELECT ?s WHERE {?s ?p ?o .} + # @example `SELECT ?s WHERE {?s ?p ?o .}` # query.select(:s).where([:s, :p, :o]) # - # @example SELECT COUNT(?uri as ?c) WHERE {?uri a owl:Class} + # @example `SELECT COUNT(?uri as ?c) WHERE {?uri a owl:Class}` # query.select(count: {uri: :c}).where([:uri, RDF.type, RDF::OWL.Class]) # # @param [Array, Hash{Symbol => RDF::Query::Variable}] variables # @return [Query] - # @see http://www.w3.org/TR/sparql11-query/#select + # @see https://www.w3.org/TR/sparql11-query/#select def select(*variables) @values = if variables.length == 1 && variables.first.is_a?(Hash) variables.to_a @@ -146,7 +146,7 @@ def select(*variables) # # @param [Array] variables # @return [Query] - # @see http://www.w3.org/TR/sparql11-query/#describe + # @see https://www.w3.org/TR/sparql11-query/#describe def describe(*variables) @values = variables.map { |var| [var, var.is_a?(RDF::URI) ? var : RDF::Query::Variable.new(var)] @@ -160,7 +160,7 @@ def describe(*variables) # # @param [Array] patterns # @return [Query] - # @see http://www.w3.org/TR/sparql11-query/#construct + # @see https://www.w3.org/TR/sparql11-query/#construct def construct(*patterns) options[:template] = build_patterns(patterns) self @@ -172,7 +172,7 @@ def construct(*patterns) # # @param [RDF::URI] uri # @return [Query] - # @see http://www.w3.org/TR/sparql11-query/#specifyingDataset + # @see https://www.w3.org/TR/sparql11-query/#specifyingDataset def from(uri) options[:from] = uri self @@ -205,7 +205,7 @@ def from(uri) # Yield form with or without argument; without an argument, evaluates within the query. # @yieldparam [SPARQL::Client::Query] query Actually a delegator to query. Methods other than `#select` are evaluated against `self`. For `#select`, a new Query is created, and the result added as a subquery. # @return [Query] - # @see http://www.w3.org/TR/sparql11-query/#GraphPattern + # @see https://www.w3.org/TR/sparql11-query/#GraphPattern def where(*patterns_queries, &block) subqueries, patterns = patterns_queries.partition {|pq| pq.is_a? SPARQL::Client::Query} @patterns += build_patterns(patterns) @@ -245,7 +245,7 @@ def select(*variables) # # @param [Array] variables # @return [Query] - # @see http://www.w3.org/TR/sparql11-query/#modOrderBy + # @see https://www.w3.org/TR/sparql11-query/#modOrderBy def order(*variables) options[:order_by] = variables self @@ -260,7 +260,7 @@ def order(*variables) # # @param [Array] var # @return [Query] - # @see http://www.w3.org/TR/sparql11-query/#modOrderBy + # @see https://www.w3.org/TR/sparql11-query/#modOrderBy def asc(var) (options[:order_by] ||= []) << {var => :asc} self @@ -273,7 +273,7 @@ def asc(var) # # @param [Array] var # @return [Query] - # @see http://www.w3.org/TR/sparql11-query/#modOrderBy + # @see https://www.w3.org/TR/sparql11-query/#modOrderBy def desc(var) (options[:order_by] ||= []) << {var => :desc} self @@ -285,7 +285,7 @@ def desc(var) # # @param [Array] variables # @return [Query] - # @see http://www.w3.org/TR/sparql11-query/#groupby + # @see https://www.w3.org/TR/sparql11-query/#groupby def group(*variables) options[:group_by] = variables self @@ -298,7 +298,7 @@ def group(*variables) # query.select(:s).distinct.where([:s, :p, :o]) # # @return [Query] - # @see http://www.w3.org/TR/sparql11-query/#modDuplicates + # @see https://www.w3.org/TR/sparql11-query/#modDuplicates def distinct(state = true) options[:distinct] = state self @@ -309,7 +309,7 @@ def distinct(state = true) # query.select(:s).reduced.where([:s, :p, :o]) # # @return [Query] - # @see http://www.w3.org/TR/sparql11-query/#modDuplicates + # @see https://www.w3.org/TR/sparql11-query/#modDuplicates def reduced(state = true) options[:reduced] = state self @@ -320,7 +320,7 @@ def reduced(state = true) # query.select.graph(:g).where([:s, :p, :o]) # @param [RDF::Value] graph_uri_or_var # @return [Query] - # @see http://www.w3.org/TR/sparql11-query/#queryDataset + # @see https://www.w3.org/TR/sparql11-query/#queryDataset def graph(graph_uri_or_var) options[:graph] = case graph_uri_or_var when Symbol then RDF::Query::Variable.new(graph_uri_or_var) @@ -337,7 +337,7 @@ def graph(graph_uri_or_var) # # @param [Integer, #to_i] start # @return [Query] - # @see http://www.w3.org/TR/sparql11-query/#modOffset + # @see https://www.w3.org/TR/sparql11-query/#modOffset def offset(start) slice(start, nil) end @@ -348,7 +348,7 @@ def offset(start) # # @param [Integer, #to_i] length # @return [Query] - # @see http://www.w3.org/TR/sparql11-query/#modResultLimit + # @see https://www.w3.org/TR/sparql11-query/#modResultLimit def limit(length) slice(nil, length) end @@ -387,7 +387,7 @@ def slice(start, length) # # @param [string] string # @return [Query] - # @see http://www.w3.org/TR/sparql11-query/#prefNames + # @see https://www.w3.org/TR/sparql11-query/#prefNames def prefix(val) options[:prefixes] ||= [] if val.kind_of? String @@ -420,7 +420,7 @@ def prefix(val) # Yield form with or without argument; without an argument, evaluates within the query. # @yieldparam [SPARQL::Client::Query] query used for creating filters on the optional patterns. # @return [Query] - # @see http://www.w3.org/TR/sparql11-query/#optionals + # @see https://www.w3.org/TR/sparql11-query/#optionals def optional(*patterns, &block) (options[:optionals] ||= []) << build_patterns(patterns) @@ -466,7 +466,7 @@ def optional(*patterns, &block) # Yield form with or without argument; without an argument, evaluates within the query. # @yieldparam [SPARQL::Client::Query] query used for adding select clauses. # @return [Query] - # @see http://www.w3.org/TR/sparql11-query/#optionals + # @see https://www.w3.org/TR/sparql11-query/#optionals def union(*patterns, &block) options[:unions] ||= [] @@ -519,7 +519,7 @@ def union(*patterns, &block) # Yield form with or without argument; without an argument, evaluates within the query. # @yieldparam [SPARQL::Client::Query] query used for adding select clauses. # @return [Query] - # @see http://www.w3.org/TR/sparql11-query/#optionals + # @see https://www.w3.org/TR/sparql11-query/#optionals def minus(*patterns, &block) options[:minuses] ||= [] diff --git a/lib/sparql/client/update.rb b/lib/sparql/client/update.rb index fa014b18..22e6b848 100644 --- a/lib/sparql/client/update.rb +++ b/lib/sparql/client/update.rb @@ -155,7 +155,7 @@ def silent end ## - # @see http://www.w3.org/TR/sparql11-update/#insertData + # @see https://www.w3.org/TR/sparql11-update/#insertData class InsertData < Operation # @return [RDF::Enumerable] attr_reader :data @@ -205,7 +205,7 @@ def to_s end ## - # @see http://www.w3.org/TR/sparql11-update/#deleteData + # @see https://www.w3.org/TR/sparql11-update/#deleteData class DeleteData < Operation # @return [RDF::Enumerable] attr_reader :data @@ -247,7 +247,7 @@ def to_s end ## - # @see http://www.w3.org/TR/sparql11-update/#deleteInsert + # @see https://www.w3.org/TR/sparql11-update/#deleteInsert class DeleteInsert < Operation attr_reader :insert_graph attr_reader :delete_graph @@ -301,7 +301,7 @@ def to_s end ## - # @see http://www.w3.org/TR/sparql11-update/#load + # @see https://www.w3.org/TR/sparql11-update/#load class Load < Operation attr_reader :from attr_reader :into @@ -350,7 +350,7 @@ def to_s end ## - # @see http://www.w3.org/TR/sparql11-update/#clear + # @see https://www.w3.org/TR/sparql11-update/#clear class Clear < Operation attr_reader :uri @@ -414,7 +414,7 @@ def to_s end ## - # @see http://www.w3.org/TR/sparql11-update/#create + # @see https://www.w3.org/TR/sparql11-update/#create class Create < Operation attr_reader :uri @@ -433,7 +433,7 @@ def to_s end ## - # @see http://www.w3.org/TR/sparql11-update/#drop + # @see https://www.w3.org/TR/sparql11-update/#drop class Drop < Clear def to_s query_text = 'DROP ' @@ -450,7 +450,7 @@ def to_s end ## - # @see http://www.w3.org/TR/sparql11-update/#copy + # @see https://www.w3.org/TR/sparql11-update/#copy class Copy < Operation def to_s # TODO @@ -458,7 +458,7 @@ def to_s end ## - # @see http://www.w3.org/TR/sparql11-update/#move + # @see https://www.w3.org/TR/sparql11-update/#move class Move < Operation def to_s # TODO @@ -466,7 +466,7 @@ def to_s end ## - # @see http://www.w3.org/TR/sparql11-update/#add + # @see https://www.w3.org/TR/sparql11-update/#add class Add < Operation def to_s # TODO diff --git a/sparql-client.gemspec b/sparql-client.gemspec index 1baa1ff1..d94db85d 100755 --- a/sparql-client.gemspec +++ b/sparql-client.gemspec @@ -6,7 +6,7 @@ Gem::Specification.new do |gem| gem.date = File.mtime('VERSION').strftime('%Y-%m-%d') gem.name = 'sparql-client' - gem.homepage = 'http://ruby-rdf.github.com/sparql-client/' + gem.homepage = 'https://github.com/ruby-rdf/sparql-client/' gem.license = 'Unlicense' gem.summary = 'SPARQL client for RDF.rb.' gem.description = %(Executes SPARQL queries and updates against a remote SPARQL 1.0 or 1.1 endpoint, diff --git a/spec/fixtures/triples.ru b/spec/fixtures/triples.ru index 5b797a9c..7aea3424 100644 --- a/spec/fixtures/triples.ru +++ b/spec/fixtures/triples.ru @@ -5,10 +5,10 @@ PREFIX rdfs: CLEAR ALL; INSERT DATA { - a doap:Project; + a doap:Project; doap:name "RDF.rb"; - doap:homepage ; - doap:license ; + doap:homepage ; + doap:license ; doap:shortdesc "A Ruby library for working with Resource Description Framework (RDF) data."@en; doap:description "RDF.rb is a pure-Ruby library for working with Resource Description Framework (RDF) data."@en; doap:created "2007-10-23"; @@ -18,22 +18,20 @@ INSERT DATA { doap:implements , , ; - doap:download-page ; - doap:bug-database ; - doap:blog ; - doap:blog ; - doap:vendor ; - foaf:maker ; - dc:creator ; - doap:developer , - , - ; - doap:maintainer , - , - ; - doap:documenter , - , - ; + doap:download-page ; + doap:bug-database ; + doap:blog ; + foaf:maker ; + dc:creator ; + doap:developer , + , + ; + doap:maintainer , + , + ; + doap:documenter , + , + ; doap:helper [ a foaf:Person; foaf:name "Călin Ardelean"; foaf:mbox_sha1sum "274bd18402fc773ffc0606996aa1fb90b603aa29" ], [ @@ -54,28 +52,28 @@ INSERT DATA { a foaf:Person; foaf:name "Pius Uzamere"; foaf:mbox_sha1sum "bedbbf2451e5beb38d59687c0460032aff92cd3c" ] . - a foaf:Person; + a foaf:Person; foaf:name "Arto Bendiken"; foaf:mbox ; foaf:mbox_sha1sum "a033f652c84a4d73b8c26d318c2395699dd2bdfb", "d0737cceb55eb7d740578d2db1bc0727e3ed49ce"; foaf:homepage ; - foaf:made ; - rdfs:isDefinedBy . + foaf:made ; + rdfs:isDefinedBy . - a foaf:Person; + a foaf:Person; foaf:name "Ben Lavender"; foaf:mbox ; foaf:mbox_sha1sum "dbf45f4ffbd27b67aa84f02a6a31c144727d10af"; - foaf:homepage ; - rdfs:isDefinedBy . + foaf:homepage ; + rdfs:isDefinedBy . - a foaf:Person; + a foaf:Person; foaf:name "Gregg Kellogg"; foaf:mbox ; foaf:mbox_sha1sum "35bc44e6d0070e5ad50ccbe0d24403c96af2b9bd"; - foaf:homepage ; - rdfs:isDefinedBy . + foaf:homepage ; + rdfs:isDefinedBy . "1"^^ . "1"^^ . From 040316b8fecc80dff48b04aa6828ca1208ca1016 Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Thu, 28 May 2020 16:29:02 -0700 Subject: [PATCH 02/12] Update doap:license to https://unlicense.org/. --- etc/doap.ttl | 57 +++++++++++++++++++--------------------- spec/fixtures/triples.ru | 2 +- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/etc/doap.ttl b/etc/doap.ttl index 74e61555..ce7dea5a 100644 --- a/etc/doap.ttl +++ b/etc/doap.ttl @@ -1,4 +1,4 @@ -@base . +@base . @prefix rdf: . @prefix rdfs: . @prefix dc: . @@ -7,27 +7,26 @@ <> a doap:Project ; doap:name "SPARQL::Client" ; - doap:homepage ; - doap:license ; + doap:homepage ; + doap:license ; doap:shortdesc "SPARQL client for RDF.rb."@en ; doap:description """Executes SPARQL queries and updates against a remote SPARQL 1.0 or 1.1 endpoint, or against a local repository. Generates SPARQL queries using a simple DSL."""@en ; doap:created "2007-11-03" ; - doap:platform "Ruby" ; - doap:category , - ; - doap:implements , - , - , - , - ; - doap:download-page ; - doap:bug-database ; - doap:blog , , ; - doap:vendor ; - doap:developer , , ; - doap:maintainer , , ; - doap:documenter , , ; + doap:programming-language "Ruby" ; + doap:category , + ; + doap:implements , + , + , + , + ; + doap:download-page ; + doap:bug-database ; + doap:blog , ; + doap:developer , , ; + doap:maintainer ; + doap:documenter , , ; doap:helper [a foaf:Person ; foaf:name "Christoph Badura" ; foaf:mbox_sha1sum "3a9c4bbe13feec63b1c8292ebf90e8da6caa0afd"] ; @@ -61,28 +60,26 @@ doap:helper [a foaf:Person ; foaf:name "Thomas Feron" ; foaf:mbox_sha1sum "8c6ba34fcf8705a63af3858140ba0107b9ee756a"] ; - foaf:maker ; - dc:creator . + foaf:maker ; + dc:creator . - a foaf:Person ; + a foaf:Person ; foaf:name "Arto Bendiken" ; foaf:mbox ; foaf:mbox_sha1sum "a033f652c84a4d73b8c26d318c2395699dd2bdfb", "d0737cceb55eb7d740578d2db1bc0727e3ed49ce" ; - foaf:homepage ; - foaf:made <> ; - rdfs:isDefinedBy . + foaf:homepage ; + foaf:made <> . - a foaf:Person ; + a foaf:Person ; foaf:name "Ben Lavender" ; foaf:mbox ; foaf:mbox_sha1sum "dbf45f4ffbd27b67aa84f02a6a31c144727d10af" ; - foaf:homepage ; - rdfs:isDefinedBy . + foaf:homepage . - a foaf:Person ; + a foaf:Person ; foaf:name "Gregg Kellogg" ; foaf:mbox ; foaf:mbox_sha1sum "35bc44e6d0070e5ad50ccbe0d24403c96af2b9bd" ; - foaf:homepage ; - rdfs:isDefinedBy . \ No newline at end of file + foaf:homepage ; + rdfs:isDefinedBy . \ No newline at end of file diff --git a/spec/fixtures/triples.ru b/spec/fixtures/triples.ru index 7aea3424..33b6f282 100644 --- a/spec/fixtures/triples.ru +++ b/spec/fixtures/triples.ru @@ -8,7 +8,7 @@ INSERT DATA { a doap:Project; doap:name "RDF.rb"; doap:homepage ; - doap:license ; + doap:license ; doap:shortdesc "A Ruby library for working with Resource Description Framework (RDF) data."@en; doap:description "RDF.rb is a pure-Ruby library for working with Resource Description Framework (RDF) data."@en; doap:created "2007-10-23"; From 685a974cd659f3b1ce43b0fe6cc33625fd51af17 Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Sat, 30 May 2020 13:31:59 -0700 Subject: [PATCH 03/12] Update doap:license. --- etc/doap.ttl | 2 +- spec/fixtures/triples.ru | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/doap.ttl b/etc/doap.ttl index ce7dea5a..7ba9d176 100644 --- a/etc/doap.ttl +++ b/etc/doap.ttl @@ -8,7 +8,7 @@ <> a doap:Project ; doap:name "SPARQL::Client" ; doap:homepage ; - doap:license ; + doap:license ; doap:shortdesc "SPARQL client for RDF.rb."@en ; doap:description """Executes SPARQL queries and updates against a remote SPARQL 1.0 or 1.1 endpoint, or against a local repository. Generates SPARQL queries using a simple DSL."""@en ; diff --git a/spec/fixtures/triples.ru b/spec/fixtures/triples.ru index 33b6f282..c60cc8fe 100644 --- a/spec/fixtures/triples.ru +++ b/spec/fixtures/triples.ru @@ -8,7 +8,7 @@ INSERT DATA { a doap:Project; doap:name "RDF.rb"; doap:homepage ; - doap:license ; + doap:license ; doap:shortdesc "A Ruby library for working with Resource Description Framework (RDF) data."@en; doap:description "RDF.rb is a pure-Ruby library for working with Resource Description Framework (RDF) data."@en; doap:created "2007-10-23"; From eb883487375804f374675d5a5c7e801a32374bae Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Sat, 30 May 2020 13:33:11 -0700 Subject: [PATCH 04/12] Use `each_statement.count` instead of `each_statement {count+=1}`. as Enumerable#count will handle this case. --- lib/sparql/client/repository.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/sparql/client/repository.rb b/lib/sparql/client/repository.rb index 136d0e89..986a29fc 100644 --- a/lib/sparql/client/repository.rb +++ b/lib/sparql/client/repository.rb @@ -179,9 +179,7 @@ def count binding[:count].value.to_i rescue 0 rescue SPARQL::Client::MalformedQuery => e # SPARQL 1.0 does not include support for aggregate functions: - count = 0 - each_statement { count += 1 } # TODO: optimize this - count + each_statement.count end end @@ -264,7 +262,9 @@ def delete(*statements) # @see RDF::Query#execute def query_execute(query, **options, &block) return nil unless block_given? - q = SPARQL::Client::Query.select(query.variables, **{}).where(*query.patterns) + q = SPARQL::Client::Query. + select(query.variables, **{}). + where(*query.patterns) client.query(q, **options).each do |solution| yield solution end From 622ad17a89b49ecc810438dbf19f157aeee9d8c8 Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Sat, 30 May 2020 13:33:43 -0700 Subject: [PATCH 05/12] Use `optimize: true` for queries to the sparql gem. --- examples/workergnome-literal-issue.rb | 2 -- lib/sparql/client.rb | 4 ++-- spec/client_spec.rb | 2 +- spec/query_spec.rb | 2 +- spec/repository_spec.rb | 3 +-- spec/update_spec.rb | 2 +- spec/version_spec.rb | 2 +- 7 files changed, 7 insertions(+), 10 deletions(-) diff --git a/examples/workergnome-literal-issue.rb b/examples/workergnome-literal-issue.rb index 36ad0f82..b928a56f 100644 --- a/examples/workergnome-literal-issue.rb +++ b/examples/workergnome-literal-issue.rb @@ -1,13 +1,11 @@ #require 'rdf/turtle' require 'sparql/client' -require 'byebug' sparql = SPARQL::Client.new("http://data.americanartcollaborative.org/sparql") uri = RDF.URI("http://data.crystalbridges.org/object/2258") label = RDF::RDFS.label query = sparql.construct([uri, label, :o]).where([uri, label, :o]) -require 'byebug'; byebug query.each_statement do |s| puts s.object.inspect end diff --git a/lib/sparql/client.rb b/lib/sparql/client.rb index 3e556356..54acc916 100644 --- a/lib/sparql/client.rb +++ b/lib/sparql/client.rb @@ -315,7 +315,7 @@ def query(query, **options) when RDF::Queryable require 'sparql' unless defined?(::SPARQL::Grammar) begin - SPARQL.execute(query, @url, **options) + SPARQL.execute(query, @url, optimize: true, **options) rescue SPARQL::MalformedQuery $stderr.puts "error running #{query}: #{$!}" raise @@ -342,7 +342,7 @@ def update(query, **options) case @url when RDF::Queryable require 'sparql' unless defined?(::SPARQL::Grammar) - SPARQL.execute(query, @url, update: true, **options) + SPARQL.execute(query, @url, update: true, optimize: true, **options) else response(query, **options) end diff --git a/spec/client_spec.rb b/spec/client_spec.rb index 3a33d225..e2fc6823 100644 --- a/spec/client_spec.rb +++ b/spec/client_spec.rb @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -require File.join(File.dirname(__FILE__), 'spec_helper') +require_relative 'spec_helper' require 'webmock/rspec' require 'json' require 'rdf/turtle' diff --git a/spec/query_spec.rb b/spec/query_spec.rb index d3cc31d8..72004413 100644 --- a/spec/query_spec.rb +++ b/spec/query_spec.rb @@ -1,4 +1,4 @@ -require File.join(File.dirname(__FILE__), 'spec_helper') +require_relative 'spec_helper' describe SPARQL::Client::Query do subject {SPARQL::Client::Query} diff --git a/spec/repository_spec.rb b/spec/repository_spec.rb index ff42ad26..1667d89f 100644 --- a/spec/repository_spec.rb +++ b/spec/repository_spec.rb @@ -1,5 +1,4 @@ -# -*- coding: utf-8 -*- -require File.join(File.dirname(__FILE__), 'spec_helper') +require_relative 'spec_helper' require 'webmock/rspec' require 'rdf/spec/repository' diff --git a/spec/update_spec.rb b/spec/update_spec.rb index 16459364..2a54b9ef 100644 --- a/spec/update_spec.rb +++ b/spec/update_spec.rb @@ -1,4 +1,4 @@ -require File.join(File.dirname(__FILE__), 'spec_helper') +require_relative 'spec_helper' describe SPARQL::Client::Update do subject {SPARQL::Client::Update} diff --git a/spec/version_spec.rb b/spec/version_spec.rb index b0ff007a..d0b72507 100644 --- a/spec/version_spec.rb +++ b/spec/version_spec.rb @@ -1,4 +1,4 @@ -require File.join(File.dirname(__FILE__), 'spec_helper') +require_relative 'spec_helper' describe 'SPARQL::Client::VERSION' do it "matches the VERSION file" do From 369d0517d85857a45c7e197c48d34aa9b99cdbdc Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Sun, 25 Oct 2020 16:50:23 -0700 Subject: [PATCH 06/12] Update PDD info in the README. --- CONTRIBUTING.md | 8 +++++--- README.md | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 645d8275..1b7b4b75 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -28,9 +28,11 @@ This repository uses [Git Flow](https://github.com/nvie/gitflow) to manage devel enough, be assured we will eventually add you in there. * Do note that in order for us to merge any non-trivial changes (as a rule of thumb, additions larger than about 15 lines of code), we need an - explicit [public domain dedication][PDD] on record from you. + explicit [public domain dedication][PDD] on record from you, + which you will be asked to agree to on the first commit to a repo within the organization. + Note that the agreement applies to all repos in the [Ruby RDF](https://github.com/ruby-rdf/) organization. [YARD]: https://yardoc.org/ [YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md -[PDD]: https://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html -[pr]: https://github.com/ruby-rdf/sparql-client/compare/ +[PDD]: https://unlicense.org/#unlicensing-contributions +[pr]: https://github.com/ruby-rdf/rdf/compare/ diff --git a/README.md b/README.md index 016574a9..0d1cdbed 100644 --- a/README.md +++ b/README.md @@ -184,7 +184,9 @@ This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange develo list in the the `README`. Alphabetical order applies. * Do note that in order for us to merge any non-trivial changes (as a rule of thumb, additions larger than about 15 lines of code), we need an - explicit [public domain dedication][PDD] on record from you. + explicit [public domain dedication][PDD] on record from you, + which you will be asked to agree to on the first commit to a repo within the organization. + Note that the agreement applies to all repos in the [Ruby RDF](https://github.com/ruby-rdf/) organization. ## Resources From 7365f99bc7110b7ad5c38c48aa322ab464f3b72f Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Sat, 19 Dec 2020 13:35:24 -0800 Subject: [PATCH 07/12] Update gem dependencies. --- .travis.yml | 2 ++ sparql-client.gemspec | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2b531323..2726685a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,10 +11,12 @@ rvm: - 2.5 - 2.6 - 2.7 + - ruby-head - jruby cache: bundler sudo: false matrix: allow_failures: + - rvm: ruby-head - rvm: jruby dist: trusty diff --git a/sparql-client.gemspec b/sparql-client.gemspec index d94db85d..449b8fa0 100755 --- a/sparql-client.gemspec +++ b/sparql-client.gemspec @@ -25,13 +25,13 @@ Gem::Specification.new do |gem| gem.required_ruby_version = '>= 2.4' gem.requirements = [] gem.add_runtime_dependency 'rdf', '~> 3.1' - gem.add_runtime_dependency 'net-http-persistent', '~> 3.1' + gem.add_runtime_dependency 'net-http-persistent', '~> 4.0' gem.add_development_dependency 'rdf-spec', '~> 3.1' gem.add_development_dependency 'sparql', '~> 3.1' - gem.add_development_dependency 'rspec', '~> 3.9' + gem.add_development_dependency 'rspec', '~> 3.10' gem.add_development_dependency 'rspec-its', '~> 1.3' - gem.add_development_dependency 'webmock', '~> 3.7' - gem.add_development_dependency 'yard' , '~> 0.9.20' + gem.add_development_dependency 'webmock', '~> 3.11' + gem.add_development_dependency 'yard' , '~> 0.9' gem.post_install_message = nil end From 2cf42364e45eea4231c9488d2eb8d8936461f3ce Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Mon, 21 Dec 2020 14:43:33 -0800 Subject: [PATCH 08/12] CI on GitHub. --- .github/workflows/ci.yml | 43 ++++++++++++++++++++++++++++++++++++++++ README.md | 3 ++- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..0b15b3bc --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,43 @@ +# This workflow runs continuous CI across different versions of ruby on all branches and pull requests to develop. + +name: CI +on: + push: + branches: [ '**' ] + pull_request: + branches: [ develop ] + workflow_dispatch: + +jobs: + tests: + name: Ruby ${{ matrix.ruby }} ${{ matrix.gemfile }} + if: "contains(github.event.commits[0].message, '[ci skip]') == false" + runs-on: ubuntu-latest + env: + CI: true + BUNDLE_GEMFILE: "${{ matrix.gemfile }}" + strategy: + fail-fast: false + matrix: + ruby: + - 2.4 + - 2.5 + - 2.6 + - 2.7 + #- ruby-head # Until net-http-persistent updated + - jruby + gemfile: + - Gemfile + - Gemfile-pure + steps: + - name: Clone repository + uses: actions/checkout@v2 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + - name: Install dependencies + run: bundle install --jobs 4 --retry 3 + - name: Run tests + run: bundle exec rspec spec + diff --git a/README.md b/README.md index 0d1cdbed..d27ea3fe 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,9 @@ This is a [Ruby][] implementation of a [SPARQL][] client for [RDF.rb][]. * [![Gem Version](https://badge.fury.io/rb/sparql-client.png)](https://badge.fury.io/rb/sparql-client) -[![Build Status](https://travis-ci.org/ruby-rdf/sparql-client.png?branch=master)](https://travis-ci.org/ruby-rdf/sparql-client) +[![Build Status](https://github.com/ruby-rdf/sparql-client./workflows/CI/badge.svg?branch=develop)](https://github.com/ruby-rdf/sparql-client./actions?query=workflow%3ACI) [![Coverage Status](https://coveralls.io/repos/ruby-rdf/sparql-client/badge.svg?branch=master&service=github)](https://coveralls.io/github/ruby-rdf/sparql-client?branch=master) +[![Gitter chat](https://badges.gitter.im/ruby-rdf/rdf.png)](https://gitter.im/ruby-rdf/rdf) ## Features From b4eea17fe5ab4e61d0770e0dd01ebff79b2f4b4a Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Mon, 21 Dec 2020 14:46:31 -0800 Subject: [PATCH 09/12] Fix README badges. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d27ea3fe..7ddcf740 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This is a [Ruby][] implementation of a [SPARQL][] client for [RDF.rb][]. * [![Gem Version](https://badge.fury.io/rb/sparql-client.png)](https://badge.fury.io/rb/sparql-client) -[![Build Status](https://github.com/ruby-rdf/sparql-client./workflows/CI/badge.svg?branch=develop)](https://github.com/ruby-rdf/sparql-client./actions?query=workflow%3ACI) +[![Build Status](https://github.com/ruby-rdf/sparql-client/workflows/CI/badge.svg?branch=develop)](https://github.com/ruby-rdf/sparql-client/actions?query=workflow%3ACI) [![Coverage Status](https://coveralls.io/repos/ruby-rdf/sparql-client/badge.svg?branch=master&service=github)](https://coveralls.io/github/ruby-rdf/sparql-client?branch=master) [![Gitter chat](https://badges.gitter.im/ruby-rdf/rdf.png)](https://gitter.im/ruby-rdf/rdf) From 7da400534a68fcbf8a53c71dad3ebd776375258a Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Tue, 22 Dec 2020 16:47:47 -0800 Subject: [PATCH 10/12] Fix bug in values when value is not a literal. Fixes #96 --- examples/issue96.rb | 5 +++++ lib/sparql/client/query.rb | 2 +- spec/query_spec.rb | 13 +++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 examples/issue96.rb diff --git a/examples/issue96.rb b/examples/issue96.rb new file mode 100644 index 00000000..f21317db --- /dev/null +++ b/examples/issue96.rb @@ -0,0 +1,5 @@ +require 'sparql/client' +SPARQL::Client::Query + .select + .where(%i[s p o]) + .values(:s, RDF::URI('http://example.com/1'), RDF::URI('http://example.com/2')) diff --git a/lib/sparql/client/query.rb b/lib/sparql/client/query.rb index ef59a351..3201cda8 100644 --- a/lib/sparql/client/query.rb +++ b/lib/sparql/client/query.rb @@ -601,7 +601,7 @@ def values(*args) case nil_literal_or_term when nil then nil when String then RDF::Literal(nil_literal_or_term) - when RDF::Value then graph_uri_or_var + when RDF::Value then nil_literal_or_term else raise ArgumentError end end diff --git a/spec/query_spec.rb b/spec/query_spec.rb index 72004413..d30084f2 100644 --- a/spec/query_spec.rb +++ b/spec/query_spec.rb @@ -129,6 +129,7 @@ expect(subject.select(:s).where([:s, :p, :o]).values([:o, :p], ["Object", "Predicate"]).to_s).to eq 'SELECT ?s WHERE { ?s ?p ?o . VALUES (?o ?p) { ( "Object" "Predicate" ) } }' expect(subject.select(:s).where([:s, :p, :o]).values([:o, :p], ["1", "2"], ["3", "4"]).to_s).to eq 'SELECT ?s WHERE { ?s ?p ?o . VALUES (?o ?p) { ( "1" "2" ) ( "3" "4" ) } }' expect(subject.select(:s).where([:s, :p, :o]).values([:o, :p], [nil, "2"], ["3", nil]).to_s).to eq 'SELECT ?s WHERE { ?s ?p ?o . VALUES (?o ?p) { ( UNDEF "2" ) ( "3" UNDEF ) } }' + expect(subject.select.where.values(:s, RDF::URI('a'), RDF::URI('b')).to_s).to eq 'SELECT * WHERE { VALUES (?s) { ( ) ( ) } }' end it "supports GROUP BY" do @@ -331,4 +332,16 @@ expect(subject.construct([:s, :p, :o]).where([:s, :p, :o])).to be_expects_statements end end + + context "issues" do + it "issue #96" do + expect { + require 'sparql/client' + SPARQL::Client::Query + .select + .where(%i[s p o]) + .values(:s, RDF::URI('http://example.com/1'), RDF::URI('http://example.com/2')) + }.not_to raise_error + end + end end From 76b2a20bc534f9b662939207acac2d980185afcc Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Wed, 23 Dec 2020 15:37:16 -0800 Subject: [PATCH 11/12] Explicitlly require 'delegate' and add example for #92. --- examples/issue92.rb | 8 ++++++++ lib/sparql/client/query.rb | 2 ++ 2 files changed, 10 insertions(+) create mode 100644 examples/issue92.rb diff --git a/examples/issue92.rb b/examples/issue92.rb new file mode 100644 index 00000000..dc09c622 --- /dev/null +++ b/examples/issue92.rb @@ -0,0 +1,8 @@ +require 'rdf' +require 'sparql/client' +dnbt = RDF::Vocabulary.new("https://d-nb.info/standards/elementset/dnb#") +rdf_gndid = RDF::Literal.new("https://d-nb.info/gnd/1059461498") +sparql_client = SPARQL::Client.new("http://127.0.0.1:9292/") +gndo = RDF::Vocabulary.new("http://d-nb.info/gnd/standards/elementset/gnd#") +query = sparql_client.select.where([:subject, dnbt.deprecatedUri, rdf_gndid]).where([:subject, gndo.gndIdentifier, :gndid]) +query.each_solution { |solution| new_gndid = solution[:gndid].to_s } \ No newline at end of file diff --git a/lib/sparql/client/query.rb b/lib/sparql/client/query.rb index 3201cda8..1d8e7a48 100644 --- a/lib/sparql/client/query.rb +++ b/lib/sparql/client/query.rb @@ -1,3 +1,5 @@ +require 'delegate' + class SPARQL::Client ## # A SPARQL query builder. From 3c802f0ade0fa3e10449f373144475ec35c22c39 Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Fri, 25 Dec 2020 19:05:35 -0800 Subject: [PATCH 12/12] Version 3.1.1. --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index fd2a0186..94ff29cc 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.1.0 +3.1.1