Skip to content

Commit 337276b

Browse files
committed
Update RSpec version.
Use graph_name instead of context for RDF.rb 1.99.
1 parent 0d126cd commit 337276b

10 files changed

Lines changed: 232 additions & 210 deletions

File tree

Gemfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,11 @@ source "http://rubygems.org"
22

33
# Specify your gem's dependencies in rdf-virtuoso.gemspec
44
gemspec
5+
6+
gem "rdf", git: "git://github.com/ruby-rdf/rdf.git", branch: "develop"
7+
8+
group :development, :test do
9+
gem "rdf-spec", git: "git://github.com/ruby-rdf/rdf-spec.git", branch: "develop"
10+
gem "rdf-vocab", git: "git://github.com/ruby-rdf/rdf-vocab.git", branch: "develop"
11+
gem "wirble"
12+
end

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ This example assumes you have a local installation of Virtoso running at standar
1919
uri = "http://localhost:8890/sparql"
2020
update_uri = "http://localhost:8890/sparql-auth"
2121
repo = RDF::Virtuoso::Repository.new(uri,
22-
:update_uri => update_uri,
23-
:username => 'admin',
24-
:password => 'secret',
25-
:auth_method => 'digest')
22+
update_uri: update_uri,
23+
username: 'admin',
24+
password: 'secret',
25+
auth_method: 'digest')
2626

2727
:auth_method can be 'digest' or 'basic'. a repository connection without auth requires only uri
2828

lib/rdf/virtuoso/parser.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ def self.parse_json_value(value, nodes = {})
2929
when :uri
3030
RDF::URI.new(value['value'])
3131
when :literal
32-
RDF::Literal.new(value['value'], :language => value['xml:lang'])
32+
RDF::Literal.new(value['value'], language: value['xml:lang'])
3333
when :'typed-literal'
34-
RDF::Literal.new(value['value'], :datatype => value['datatype'])
34+
RDF::Literal.new(value['value'], datatype: value['datatype'])
3535
else nil
3636
end
3737
end

lib/rdf/virtuoso/query.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ def union(*patterns)
414414
##
415415
# @private
416416
# make RDF::Query::Pattern from triple array if not already done
417-
# include :context in Statement
417+
# include :graph_name in Statement
418418
# @return [RDF::Query::Pattern]
419419
def build_patterns(patterns)
420420
patterns.map do |pattern|
@@ -603,10 +603,10 @@ def to_s
603603
buffer << '{' if options[:unions]
604604

605605
# iterate patterns
606-
# does patterns have :context hash? build with GRAPH statement
606+
# does patterns have :graph_name hash? build with GRAPH statement
607607
patterns.each do | pattern|
608-
if pattern.context
609-
buffer << "GRAPH #{serialize_value(RDF::URI(pattern.context))}"
608+
if pattern.graph_name
609+
buffer << "GRAPH #{serialize_value(RDF::URI(pattern.graph_name))}"
610610
buffer << '{'
611611
buffer << serialize_patterns(pattern)
612612
buffer << '}'
@@ -620,8 +620,8 @@ def to_s
620620
buffer << 'OPTIONAL {'
621621

622622
patterns.each do | pattern|
623-
if pattern.context
624-
buffer << "GRAPH #{serialize_value(RDF::URI(pattern.context))}"
623+
if pattern.graph_name
624+
buffer << "GRAPH #{serialize_value(RDF::URI(pattern.graph_name))}"
625625
buffer << '{'
626626
buffer << serialize_patterns(pattern)
627627
buffer << '}'
@@ -639,8 +639,8 @@ def to_s
639639
buffer << 'MINUS {'
640640

641641
patterns.each do | pattern|
642-
if pattern.context
643-
buffer << "GRAPH #{serialize_value(RDF::URI(pattern.context))}"
642+
if pattern.graph_name
643+
buffer << "GRAPH #{serialize_value(RDF::URI(pattern.graph_name))}"
644644
buffer << '{'
645645
buffer << serialize_patterns(pattern)
646646
buffer << '}'

lib/rdf/virtuoso/repository.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,51 +73,51 @@ def headers
7373
end
7474

7575
def base_query_options
76-
{ :format => RESULT_JSON }
76+
{ format: RESULT_JSON }
7777
end
7878

7979
def base_request_options
80-
{ :headers => headers }
80+
{ headers: headers }
8181
end
8282

8383
def extra_request_options
8484
case @auth_method
8585
when 'basic'
86-
{ :basic_auth => auth }
86+
{ basic_auth: auth }
8787
when 'digest'
88-
{ :digest_auth => auth }
88+
{ digest_auth: auth }
8989
end
9090
end
9191

9292
def auth
93-
{ :username => @username, :password => @password }
93+
{ username: @username, password: @password }
9494
end
9595

9696
def api_get(query, options = {})
9797
# prefer sparul endpoint with auth if present to allow SELECT/CONSTRUCT access to protected graphs
9898
if @sparul_endpoint
9999
self.class.endpoint @sparul_endpoint
100100
Timeout::timeout(@timeout) {
101-
get '/', :extra_query => { :query => query }.merge(options),
102-
:extra_request => extra_request_options,
103-
:transform => RDF::Virtuoso::Parser::JSON
101+
get '/', extra_query: { query: query }.merge(options),
102+
extra_request: extra_request_options,
103+
transform: RDF::Virtuoso::Parser::JSON
104104
}
105105
else
106106
self.class.endpoint @sparql_endpoint
107107
Timeout::timeout(@timeout) {
108108
puts self.inspect
109-
get '/', :extra_query => { :query => query }.merge(options),
110-
:transform => RDF::Virtuoso::Parser::JSON
109+
get '/', extra_query: { query: query }.merge(options),
110+
transform: RDF::Virtuoso::Parser::JSON
111111
}
112112
end
113113
end
114114

115115
def api_post(query, options = {})
116116
self.class.endpoint @sparul_endpoint
117117
Timeout::timeout(@timeout) {
118-
post '/', :extra_body => { :query => query }.merge(options),
119-
:extra_request => extra_request_options,
120-
:response_container => [
118+
post '/', extra_body: { query: query }.merge(options),
119+
extra_request: extra_request_options,
120+
response_container: [
121121
"results", "bindings", 0, "callret-0", "value"]
122122
}
123123
end

rdf-virtuoso.gemspec

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ Gem::Specification.new do |s|
1919
s.files += Dir['spec/**/*.rb'] + Dir['doc/**/**/*.rb']
2020
s.require_paths = ['lib']
2121

22-
s.add_development_dependency 'rspec', '~> 2.14.1'
23-
s.add_development_dependency 'rdf-spec', '~> 1.1.0'
22+
s.add_development_dependency 'rspec', '~> 3.2'
23+
s.add_development_dependency 'rdf-spec', '~> 1.1'
24+
s.add_development_dependency 'rdf-vocab', '~> 0.8'
2425

25-
s.add_runtime_dependency 'rdf', '~> 1.1.0'
26+
s.add_runtime_dependency 'rdf', '>= 1.99'
2627
s.add_runtime_dependency 'httparty', '~> 0.12.0'
2728
s.add_runtime_dependency 'api_smith', '~> 1.3.0'
2829

spec/prefixes_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,43 @@
55
subject { RDF::Virtuoso::Prefixes.new(foo: 'bar', baz: 'quux') }
66

77
it "takes a hash when initialized" do
8-
subject.should be_a RDF::Virtuoso::Prefixes
8+
is_expected.to be_a RDF::Virtuoso::Prefixes
99
end
1010

1111
it "responds to to_a" do
12-
subject.should respond_to :to_a
12+
is_expected.to respond_to :to_a
1313
end
1414

1515
it "returns a nice array" do
16-
subject.to_a.should == ["foo: <bar>", "baz: <quux>"]
16+
expect(subject.to_a).to include("foo: <bar>", "baz: <quux>")
1717
end
1818

1919
it "presents itself nicely" do
20-
subject.to_s.should == "{:foo=>\"bar\", :baz=>\"quux\"}"
20+
expect(subject.to_s).to eql "{:foo=>\"bar\", :baz=>\"quux\"}"
2121
end
2222

2323
context "when creating prefixes" do
24-
let(:uris) { [RDF::DC.title.to_s, "http://example.org/foo/bar", "http://hash.org/foo#bar"] }
24+
let(:uris) { [RDF::Vocab::DC.title.to_s, "http://example.org/foo/bar", "http://hash.org/foo#bar"] }
2525

2626
it "creates prefixes from uris" do
27-
RDF::Virtuoso::Prefixes.parse(uris).should == [
27+
expect(RDF::Virtuoso::Prefixes.parse(uris)).to include(
2828
"purl: <http://purl.org/dc/terms/>",
2929
"example: <http://example.org/foo/>",
3030
"hash: <http://hash.org/foo#>"
31-
]
31+
)
3232
end
3333

3434
it "only creates unique prefixes from uris" do
3535
uris << 'http://example.org/foo/baz'
36-
RDF::Virtuoso::Prefixes.parse(uris).should == [
36+
expect(RDF::Virtuoso::Prefixes.parse(uris)).to include(
3737
"purl: <http://purl.org/dc/terms/>",
3838
"example: <http://example.org/foo/>",
3939
"hash: <http://hash.org/foo#>"
40-
]
40+
)
4141
end
4242

4343
it "returns an error object if a disallowed param is sent" do
44-
RDF::Virtuoso::Prefixes.parse({}).should be_a RDF::Virtuoso::UnProcessable
44+
expect(RDF::Virtuoso::Prefixes.parse({})).to be_a RDF::Virtuoso::UnProcessable
4545
end
4646

4747
end

0 commit comments

Comments
 (0)