Skip to content

Commit 203890d

Browse files
committed
Finish 2.2.0
2 parents 20f587d + 546482a commit 203890d

File tree

9 files changed

+407
-63
lines changed

9 files changed

+407
-63
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ tmp
99
doc
1010
coverage
1111
.bundle
12+
/.byebug_history

.travis.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@ script: "bundle exec rspec spec"
44
env:
55
- CI=true
66
rvm:
7-
- 2.2.5
8-
- 2.3.1
9-
- jruby
10-
- rbx
11-
gemfile:
12-
- Gemfile
13-
- Gemfile-pure
7+
- 2.2
8+
- 2.3
9+
- 2.4
10+
- jruby-9
11+
- rbx-3
1412
cache: bundler
1513
sudo: false
1614
matrix:
1715
allow_failures:
18-
- rvm: rbx
19-
- rvm: jruby
16+
- rvm: jruby-9
17+
- rvm: rbx-3
18+
dist: trusty

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#SPARQL Client for RDF.rb
1+
# SPARQL Client for RDF.rb
22

33
This is a [Ruby][] implementation of a [SPARQL][] client for [RDF.rb][].
44

@@ -8,7 +8,7 @@ This is a [Ruby][] implementation of a [SPARQL][] client for [RDF.rb][].
88
[![Build Status](https://travis-ci.org/ruby-rdf/sparql-client.png?branch=master)](http://travis-ci.org/ruby-rdf/sparql-client)
99
[![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)
1010

11-
##Features
11+
## Features
1212

1313
* Executes queries against any SPARQL 1.0/1.1-compatible endpoint over HTTP,
1414
or against an `RDF::Queryable` instance, using the `SPARQL` gem.
@@ -22,7 +22,7 @@ This is a [Ruby][] implementation of a [SPARQL][] client for [RDF.rb][].
2222
* Supports accessing endpoints as read/write [`RDF::Repository`][RDF::Repository]
2323
instances {SPARQL::Client::Repository}.
2424

25-
##Examples
25+
## Examples
2626

2727
### Querying a remote SPARQL endpoint
2828
require 'sparql/client'
@@ -83,29 +83,29 @@ This is a [Ruby][] implementation of a [SPARQL][] client for [RDF.rb][].
8383
end
8484
delete_data(data)
8585

86-
##Documentation
86+
## Documentation
8787

8888
* {SPARQL::Client}
8989
* {SPARQL::Client::Query}
9090
* {SPARQL::Client::Repository}
9191
* {SPARQL::Client::Update}
9292

93-
##Dependencies
93+
## Dependencies
9494

9595
* [Ruby](http://ruby-lang.org/) (>= 2.2.2)
9696
* [RDF.rb](http://rubygems.org/gems/rdf) (>= 2.0)
9797
* [Net::HTTP::Persistent](http://rubygems.org/gems/net-http-persistent) (>= 1.4)
9898
* Soft dependency on [SPARQL](http://rubygems.org/gems/sparql) (>= 2.0)
9999
* Soft dependency on [Nokogiri](http://rubygems.org/gems/nokogiri) (>= 1.6)
100100

101-
##Installation
101+
## Installation
102102

103103
The recommended installation method is via [RubyGems](http://rubygems.org/).
104104
To install the latest official release of the `SPARQL::Client` gem, do:
105105

106106
% [sudo] gem install sparql-client
107107

108-
##Download
108+
## Download
109109

110110
To get a local working copy of the development repository, do:
111111

@@ -116,17 +116,17 @@ follows:
116116

117117
% wget http://github.com/ruby-rdf/sparql-client/tarball/master
118118

119-
##Mailing List
119+
## Mailing List
120120

121121
* <http://lists.w3.org/Archives/Public/public-rdf-ruby/>
122122

123-
##Authors
123+
## Authors
124124

125125
* [Arto Bendiken](http://github.com/bendiken) - <http://ar.to/>
126126
* [Ben Lavender](http://github.com/bhuga) - <http://bhuga.net/>
127127
* [Gregg Kellogg](http://github.com/gkellogg) - <http://greggkellogg.net/>
128128

129-
##Contributors
129+
## Contributors
130130

131131
* [Christoph Badura](http://github.com/bad) - <http://github.com/bad>
132132
* [James Hetherington](http://github.com/jamespjh) - <http://twitter.com/jamespjh>
@@ -140,7 +140,7 @@ follows:
140140
* [Thomas Feron](http://github.com/thoferon) - <http://github.com/thoferon>
141141
* [Nick Gottlieb](http://github.com/ngottlieb) - <http://www.nicholasgottlieb.com>
142142

143-
##Contributing
143+
## Contributing
144144
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.
145145

146146
* Do your best to adhere to the existing coding conventions and idioms.
@@ -155,7 +155,7 @@ This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange develo
155155
of thumb, additions larger than about 15 lines of code), we need an
156156
explicit [public domain dedication][PDD] on record from you.
157157

158-
##Resources
158+
## Resources
159159

160160
* <http://ruby-rdf.github.com/sparql-client/>
161161
* <http://github.com/ruby-rdf/sparql-client>
@@ -164,7 +164,7 @@ This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange develo
164164
* <http://raa.ruby-lang.org/project/sparql-client/>
165165
* <http://www.ohloh.net/p/rdf>
166166

167-
##License
167+
## License
168168

169169
This is free and unencumbered public domain software. For more information,
170170
see <http://unlicense.org/> or the accompanying {file:UNLICENSE} file.

examples/workergnome-literal-issue.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#require 'rdf/turtle'
2+
require 'sparql/client'
3+
require 'byebug'
4+
5+
sparql = SPARQL::Client.new("http://data.americanartcollaborative.org/sparql")
6+
uri = RDF.URI("http://data.crystalbridges.org/object/2258")
7+
label = RDF::RDFS.label
8+
9+
query = sparql.construct([uri, label, :o]).where([uri, label, :o])
10+
require 'byebug'; byebug
11+
query.each_statement do |s|
12+
puts s.object.inspect
13+
end
14+
15+
# <http://data.crystalbridges.org/object/2258> <http://www.w3.org/2000/01/rdf-schema#label> "Bison-Dance of the Mandan Indians in front of their Medicine Lodge in Mih-Tuta-Hankush" .
16+
# <http://data.crystalbridges.org/object/2258> <http://www.w3.org/2000/01/rdf-schema#label> "From \"Voyage dans l’intérieur de l’Amérique du Nord, executé pendant les années 1832, 1833 et 1834, par le prince Maximilien de Wied-Neuwied\" (Paris & Coblenz, 1839-1843)" .
17+
18+
# "<http://data.crystalbridges.org/object/2258> <http://www.w3.org/2000/01/rdf-schema#label> \"Bison-Dance of the Mandan Indians in front of their Medicine Lodge in Mih-Tuta-Hankush\" .\n<http://data.crystalbridges.org/object/2258> <http://www.w3.org/2000/01/rdf-schema#label> \"From \\\"Voyage dans l\xE2\x80\x99int\xC3\xA9rieur de l\xE2\x80\x99Am\xC3\xA9rique du Nord, execut\xC3\xA9 pendant les ann\xC3\xA9es 1832, 1833 et 1834, par le prince Maximilien de Wied-Neuwied\\\" (Paris & Coblenz, 1839-1843)\" .\n"

lib/sparql/client.rb

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -609,11 +609,15 @@ def self.serialize_predicate(value,rdepth=0)
609609
# @private
610610
def self.serialize_patterns(patterns, use_vars = false)
611611
patterns.map do |pattern|
612-
serialized_pattern = RDF::Statement.from(pattern).to_triple.each_with_index.map do |v, i|
613-
if i == 1
614-
SPARQL::Client.serialize_predicate(v)
615-
else
616-
SPARQL::Client.serialize_value(v, use_vars)
612+
serialized_pattern = case pattern
613+
when SPARQL::Client::QueryElement then [pattern.to_s]
614+
else
615+
RDF::Statement.from(pattern).to_triple.each_with_index.map do |v, i|
616+
if i == 1
617+
SPARQL::Client.serialize_predicate(v)
618+
else
619+
SPARQL::Client.serialize_value(v, use_vars)
620+
end
617621
end
618622
end
619623
serialized_pattern.join(' ') + ' .'
@@ -654,7 +658,11 @@ def http_klass(scheme)
654658
value = ENV['https_proxy']
655659
proxy_url = URI.parse(value) unless value.nil? || value.empty?
656660
end
657-
klass = Net::HTTP::Persistent.new(self.class.to_s, proxy_url)
661+
klass = if Net::HTTP::Persistent::VERSION >= '3.0'
662+
Net::HTTP::Persistent.new(name: self.class.to_s, proxy: proxy_url)
663+
else
664+
Net::HTTP::Persistent.new(self.class.to_s, proxy_url)
665+
end
658666
klass.keep_alive = @options[:keep_alive] || 120
659667
klass.read_timeout = @options[:read_timeout] || 60
660668
klass
@@ -748,5 +756,18 @@ def make_post_request(query, headers = {})
748756
end
749757
request
750758
end
759+
760+
# A query element can be used as a component of a query. It may be initialized with a string, which is wrapped in an appropriate container depending on the type of QueryElement. Implements {#to_s} to property serialize when generating a SPARQL query.
761+
class QueryElement
762+
attr_reader :elements
763+
764+
def initialize(*args)
765+
@elements = args
766+
end
767+
768+
def to_s
769+
raise NotImplemented
770+
end
771+
end
751772
end # Client
752773
end # SPARQL

0 commit comments

Comments
 (0)