Skip to content
Browse files

Update to RDF 1.0

Signed-off-by: Aymeric Brisse <aymeric.brisse@perfect-memory.com>
  • Loading branch information...
1 parent 1133b83 commit ca4428155c54b19355539a2979a0365358b33663 @abrisse abrisse committed Mar 5, 2013
View
4 AUTHORS
@@ -1,2 +1,2 @@
-* Eric Kidd <git@randomhacks.net>
-* Aymeric Brisse <aymeric.brisse@gmail.com>
+* Eric Kidd <https://github.com/emk>
+* Aymeric Brisse <https://github.com/abrisse>
View
11 Gemfile
@@ -1,10 +1,3 @@
-source :rubygems
+source 'https://rubygems.org'
-# Automatically compute our required gems based on our Gemspec. This code
-# is based on http://gist.github.com/277349 .
-gemspec_path = File.join(File.dirname(__FILE__), '.gemspec')
-gemspec = eval(File.read(gemspec_path))
-gemspec.dependencies.each do |dep|
- group = dep.type == :development ? :development : :default
- gem dep.name, dep.requirement, :group => group
-end
+gemspec
View
62 Gemfile.lock
@@ -1,37 +1,43 @@
+PATH
+ remote: .
+ specs:
+ rdf-agraph (0.3.2)
+ agraph (~> 0.2)
+ json (~> 1.7)
+ rdf (~> 1.0)
+
GEM
- remote: http://rubygems.org/
+ remote: https://rubygems.org/
specs:
- BlueCloth (1.0.1)
- addressable (2.2.8)
- agraph (0.1.5)
- transport (>= 1.0.0)
+ addressable (2.3.3)
+ agraph (0.2)
+ transport (~> 1.0.5)
diff-lcs (1.1.3)
- json (1.7.3)
- rake (0.9.2.2)
- rdf (0.3.7)
- addressable (>= 2.2.6)
- rdf-spec (0.3.5.1)
- rspec (>= 2.8.0)
- rspec (2.11.0)
- rspec-core (~> 2.11.0)
- rspec-expectations (~> 2.11.0)
- rspec-mocks (~> 2.11.0)
- rspec-core (2.11.0)
- rspec-expectations (2.11.1)
+ dotenv (0.5.0)
+ json (1.7.7)
+ rake (10.0.3)
+ rdf (1.0.3)
+ addressable (>= 2.2)
+ rdf-spec (1.0.0)
+ rspec (>= 2.12)
+ rspec (2.12.0)
+ rspec-core (~> 2.12.0)
+ rspec-expectations (~> 2.12.0)
+ rspec-mocks (~> 2.12.0)
+ rspec-core (2.12.2)
+ rspec-expectations (2.12.1)
diff-lcs (~> 1.1.3)
- rspec-mocks (2.11.0)
- transport (1.0.4)
- yard (0.8.2.1)
+ rspec-mocks (2.12.2)
+ transport (1.0.5)
+ yard (0.8.5.2)
PLATFORMS
ruby
DEPENDENCIES
- BlueCloth (>= 1.0.1)
- agraph (>= 0.1.5)
- json (~> 1.7)
- rake (>= 0.8.7)
- rdf (>= 0.3.5)
- rdf-spec (>= 0.3.5.1)
- rspec (>= 2.5.0)
- yard (>= 0.6.0)
+ dotenv (~> 0.5)
+ rake (~> 10.0.0)
+ rdf-agraph!
+ rdf-spec (~> 1.0)
+ rspec (~> 2.12.0)
+ yard (~> 0.8)
View
5 Rakefile
@@ -1,7 +1,4 @@
-require 'rubygems'
-require 'bundler'
-Bundler.require(:default, :development)
-
+require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
task :default => :spec
View
1 lib/rdf/allegro_graph.rb
@@ -1,4 +1,5 @@
require 'rdf'
+require 'rdf/ntriples'
require 'agraph'
require 'enumerator'
View
5 lib/rdf/allegro_graph/abstract_repository.rb
@@ -388,6 +388,7 @@ def clear(options = {})
def serialize(value)
case value
when RDF::Query::Variable then value.to_s
+ when false then nil
else RDF::NTriples::Writer.serialize(map_to_server(value))
end
end
@@ -469,7 +470,7 @@ def query_to_sparql(query)
variables = []
patterns = []
query.patterns.each do |p|
- p.variables.each {|_,v| variables << v unless variables.include?(v) }
+ variables.concat(p.variables.values)
triple = [p.subject, p.predicate, p.object]
str = triple.map {|v| serialize(v) }.join(" ")
# TODO: Wrap in graph block for context!
@@ -478,7 +479,7 @@ def query_to_sparql(query)
end
patterns << "#{str} ."
end
- "SELECT #{variables.join(" ")}\nWHERE {\n #{patterns.join("\n ")} }"
+ "SELECT #{variables.uniq.join(" ")}\nWHERE {\n #{patterns.join("\n ")} }"
end
# Convert a JSON query solution to a list of RDF::Query::Solution
View
4 lib/rdf/allegro_graph/query.rb
@@ -102,10 +102,10 @@ def to_prolog(repository)
functors = []
patterns.each do |p|
# Extract any new variables we see in the query.
- p.variables.each {|_,v| variables << v unless variables.include?(v) }
+ variables.concat(p.variables.values)
functors << convert_to_functor(p).to_prolog(repository)
end
- "(select (#{variables.join(" ")})\n #{functors.join("\n ")})"
+ "(select (#{variables.uniq.join(" ")})\n #{functors.join("\n ")})"
end
protected
View
19 .gemspec → rdf-agraph.gemspec
@@ -9,7 +9,7 @@ Gem::Specification.new do |gem|
gem.summary = "AllegroGraph adapter for RDF.rb"
gem.description = "An AllegroGraph adapter for use with RDF.rb."
gem.rubyforge_project = 'rdf-agraph'
-
+
gem.authors = ['Eric Kidd']
gem.email = 'rdf-agraph@kiddsoftware.com'
@@ -19,17 +19,16 @@ Gem::Specification.new do |gem|
#gem.executables = %w()
gem.require_paths = %w(lib)
gem.has_rdoc = false
-
+
gem.required_ruby_version = '>= 1.8.7'
- gem.add_runtime_dependency 'rdf', '>= 0.3.5'
- gem.add_runtime_dependency 'agraph', '>= 0.1.5'
- # This should be pulled in by agraph, but it isn't.
+ gem.add_runtime_dependency 'rdf', '~> 1.0'
+ gem.add_runtime_dependency 'agraph', '~> 0.2'
gem.add_runtime_dependency 'json', '~> 1.7'
- gem.add_development_dependency 'rdf-spec', '>= 0.3.5.1'
- gem.add_development_dependency 'yard', '>= 0.6.0'
- gem.add_development_dependency 'BlueCloth', '>= 1.0.1' # For yard.
- gem.add_development_dependency 'rspec', '>= 2.5.0'
- gem.add_development_dependency 'rake', '>= 0.8.7'
+ gem.add_development_dependency 'rdf-spec', '~> 1.0'
+ gem.add_development_dependency 'yard', '~> 0.8'
+ gem.add_development_dependency 'rspec', '~> 2.12.0'
+ gem.add_development_dependency 'rake', '~> 10.0.0'
+ gem.add_development_dependency 'dotenv', '~> 0.5'
end
View
32 spec/query_spec.rb
@@ -1,85 +1,87 @@
require 'spec_helper'
-require 'rdf/spec/query'
+require 'rdf/spec/queryable'
describe RDF::AllegroGraph::Query do
before :each do
@repository = RDF::AllegroGraph::Repository.new(REPOSITORY_OPTIONS)
@new = RDF::AllegroGraph::Query.method(:new)
+ @queryable = @repository
end
after :each do
@repository.clear
end
- it_should_behave_like RDF_Query
+ include RDF_Queryable
describe "#run" do
-
+
context "in any case" do
before do
+ @repository.clear # because of include RDF_Queryable
@repository.insert(
[EX.me, RDF.type, FOAF.Person],
[EX.john, RDF.type, FOAF.Person])
@query = RDF::AllegroGraph::Query.new(@repository) do |q|
q.pattern [:person, RDF.type, FOAF.Person]
end
end
-
+
it "runs the query against the repository" do
@query.run.to_a.should include_solution(:person => EX.me)
end
-
+
it "accepts a block argument" do
solutions = []
@query.run {|s| solutions << s }
solutions.should include_solution(:person => EX.me)
end
-
+
it "should not limit the number of results by default" do
- sln = @query.run.to_a.should have(2).items
+ sln = @query.run.to_a.should have(2).items
end
-
+
it "should limit the number of results when passed :limit => n" do
@repository.build_query(:limit => 1) do |q|
q << [:person, RDF.type, FOAF.Person]
end.run.to_a.should have(1).items
end
end
-
+
context "with an RDFS/OWL ontology" do
Concepts = RDF::Vocabulary.new("http://www.example.com/Concepts#")
-
+
before do
@repository.insert(
[Concepts.Celine, RDF.type, Concepts.Woman],
[Concepts.Woman, RDF.type, RDF::OWL.Class],
[Concepts.Person, RDF.type, RDF::OWL.Class],
[Concepts.Woman, RDF::RDFS.subClassOf, Concepts.Person])
end
-
+
it "does not run inference by default" do
sln = @repository.build_query do |q|
q << [Concepts.Celine, RDF.type, :klass]
end.run.to_a
sln.should include_solution(:klass => Concepts.Woman)
sln.should_not include_solution(:klass => Concepts.Person)
end
-
+
it "does run inference when passed :infer => true" do
sln = @repository.build_query(:infer => true) do |q|
q << [Concepts.Celine, RDF.type, :klass]
end.run.to_a
sln.should include_solution(:klass => Concepts.Woman)
- sln.should include_solution(:klass => Concepts.Person)
+ sln.should include_solution(:klass => Concepts.Person)
end
-
+
it "does run inference when passed :infer => 'rdfs++'" do
sln = @repository.build_query(:infer => 'rdfs++') do |q|
q << [Concepts.Celine, RDF.type, :klass]
end.run.to_a
sln.should include_solution(:klass => Concepts.Woman)
- sln.should include_solution(:klass => Concepts.Person)
+ sln.should include_solution(:klass => Concepts.Person)
end
end
end
View
2 spec/shared_abstract_repository_examples.rb
@@ -9,7 +9,7 @@
shared_examples_for RDF::AllegroGraph::AbstractRepository do
# This pulls in a huge number of specifications from rdf-spec, ensuring
# that we implement the standard API correctly.
- it_should_behave_like RDF_Repository
+ include RDF_Repository
describe "#supports?" do
it "returns true if passed :context" do
View
2 spec/sna_functors_spec.rb
@@ -79,7 +79,7 @@
q.neighbor_count(EX.me, @knows, :n)
end.run.to_a
solutions.length.should == 1
- solutions.first.n.should == 3
+ solutions.first.n.object.should == 3
end
end
View
5 spec/spec_helper.rb
@@ -1,6 +1,7 @@
# Set up bundler and require all our support gems.
require 'rubygems'
require 'bundler'
+require 'dotenv'
Bundler.require(:default, :development)
# Add our library directory to our require path.
@@ -9,10 +10,12 @@
# Load the entire gem through our top-level file.
require 'rdf-agraph'
+Dotenv.load
+
# Options that we use to connect to a repository.
REPOSITORY_OPTIONS = {
:id => 'rdf_agraph_test',
- :url => 'http://test:test@localhost:10035'
+ :url => "http://#{ENV['AG_USER']}:#{ENV['AG_PASS']}@localhost:10035"
}
server = RDF::AllegroGraph::Server.new(REPOSITORY_OPTIONS[:url])
server.repository(REPOSITORY_OPTIONS[:id], :create => true)

0 comments on commit ca44281

Please sign in to comment.
Something went wrong with that request. Please try again.