Permalink
Browse files

Merge branch 'upmaster'

Conflicts:
	lib/allegro_graph/repository.rb
  • Loading branch information...
2 parents f473656 + 8ae6168 commit bb5d4cb3f90e9e2b05638daf7d81ddcfacd11f7a @abrisse abrisse committed Mar 4, 2013
Showing with 52 additions and 73 deletions.
  1. +2 −1 .gitignore
  2. +8 −0 .travis.yml
  3. +9 −0 Gemfile
  4. +2 −0 README.rdoc
  5. +1 −1 Rakefile
  6. +3 −3 agraph.gemspec
  7. +1 −1 lib/allegro_graph/repository.rb
  8. +24 −24 lib/allegro_graph/session.rb
  9. +2 −2 spec/integration/server_spec.rb
  10. +0 −41 test.rb
View
@@ -1,3 +1,4 @@
.idea
*.gem
-doc
+doc
+Gemfile.lock
View
@@ -0,0 +1,8 @@
+rvm:
+ - 1.8.7 # (current default)
+ - 1.9.2
+ - 1.9.3
+ - rbx-2.0
+ - jruby
+ - ruby-head
+ - ree
View
@@ -0,0 +1,9 @@
+source :rubygems
+
+gem "rake"
+gem "transport"
+
+group :test do
+ gem "rspec"
+ gem "reek"
+end
View
@@ -13,6 +13,8 @@ The features that are exposed by this client are...
* performing SparQL and Prolog queries
* mapping of data type
+{<img src="http://travis-ci.org/phifty/agraph.png" />}[http://travis-ci.org/phifty/agraph]
+
== Installation
There are no special dependencies. Just type
View
@@ -7,7 +7,7 @@ require 'rspec/core/rake_task'
gem 'reek'
require 'reek/rake/task'
-require 'rake/rdoctask'
+require 'rdoc/task'
task :default => :spec
View
@@ -3,14 +3,14 @@
specification = Gem::Specification.new do |specification|
specification.name = "agraph"
specification.version = "0.1.5"
- specification.date = "2011-09-21"
- specification.email = "aymeric.brisse@gmail.com"
+ specification.date = "2011-10-10"
+ specification.email = "b.phifty@gmail.com"
specification.homepage = "http://github.com/abrisse/agraph"
specification.summary = "Client for the AllegroGraph 4.x graph database."
specification.description = "The gem provides a client for the AllegroGraph 4.x RDF graph database. Features like searching geo-spatial data, type mapping and transactions are supported."
specification.rubyforge_project = "agraph"
specification.has_rdoc = true
- specification.authors = [ "Aymeric Brisse", "Philipp Brüll" ]
+ specification.authors = [ "Philipp Brüll", "Aymeric Brisse" ]
specification.files = [ "README.rdoc", "Rakefile" ] + Dir["{lib,spec}/**/*"]
specification.extra_rdoc_files = [ "README.rdoc" ]
specification.require_path = "lib"
@@ -90,7 +90,7 @@ def transaction(options={}, &block)
self.class.transaction self, options, &block
end
- def self.transaction(repository, options={}, &block)
+ def self.transaction(repository, options = { }, &block)
session = Session.create repository, options
begin
session.instance_eval &block
@@ -42,30 +42,16 @@ def size
response.to_i
end
- class << self
-
- def create(repository_or_server, options={})
- response = repository_or_server.request_http :post, repository_or_server.path + "/session", { :expected_status_code => 200, :parameters => parse_session_options(options, repository_or_server.path.empty?) }
- url = response.sub(/^"/, "").sub(/"$/, "")
- server = repository_or_server.server
- new :url => url, :username => server.username, :password => server.password
- end
-
- def parse_session_options(opts, store_required)
- opts ||= {}
- options = {}
- if store_required
- raise ArgumentError.new('The parameter store is required') unless opts.has_key?(:store)
- options[:store] = opts[:store].is_a?(Array) ? "<#{opts[:store].join('>+<')}>" : "<#{opts[:store].to_s}>"
- end
- # See http://www.franz.com/agraph/support/documentation/current/http-protocol.html#sessions
- [:autoCommit, :lifetime, :loadInitFile, :script].each do |p|
- options[p] = opts[p] if opts.has_key?(p)
- end
- options
- end
- private :parse_session_options
-
+ def self.create(repository_or_server, options = { })
+ path = repository_or_server.path
+ raise ArgumentError, "The :store parameter is missing!" if path.empty? && !options.has_key?(:store)
+
+ response = repository_or_server.request_http :post,
+ path + "/session",
+ { :expected_status_code => 200, :parameters => build_parameters(options) }
+ url = response.sub(/^"/, "").sub(/"$/, "")
+ server = repository_or_server.server
+ new :url => url, :username => server.username, :password => server.password
end
private
@@ -74,6 +60,20 @@ def credentials
{ :auth_type => :basic, :username => @username, :password => @password }
end
+ def self.build_parameters(options)
+ parameters = { }
+
+ store = options[:store]
+ parameters[:store] = store.is_a?(Array) ? "<#{store.join('>+<')}>" : "<#{store}>" if store
+
+ # See http://www.franz.com/agraph/support/documentation/current/http-protocol.html#sessions
+ [ :autoCommit, :lifetime, :loadInitFile, :script ].each do |parameters_name|
+ parameters[parameters_name] = options[parameters_name] if options.has_key?(parameters_name)
+ end
+
+ parameters
+ end
+
end
end
@@ -11,8 +11,8 @@
it "should return the server's version" do
@server.version.should == {
- :version => "4.1.1",
- :date => "October 23, 2010 16:25:51 GMT-0700",
+ :version => "4.3.3",
+ :date => "September 30, 2011 11:55:21 GMT-0700",
:revision => "internal reversion unknown"
}
end
View
@@ -1,41 +0,0 @@
-require 'lib/agraph'
-
-server = AllegroGraph::Server.new :username => "test", :password => "test"
-
-catalog = AllegroGraph::Catalog.new server, "tests"
-repository = AllegroGraph::Repository.new catalog, "foo"
-
-repository.create!
-
-# repository = AllegroGraph::Repository.new server, "test_repository"
-
-type = repository.geometric.cartesian_type :strip_width => 1,
- :x_min => -100,
- :y_min => -100,
- :x_max => 100,
- :y_max => 100
-
-repository.statements.create "\"foo\"", "\"at\"", "\"+1+1\"^^#{type}"
-repository.statements.create "\"bar\"", "\"at\"", "\"-2.5+3.4\"^^#{type}"
-repository.statements.create "\"baz\"", "\"at\"", "\"-1+1\"^^#{type}"
-repository.statements.create "\"bug\"", "\"at\"", "\"+10-2.421553215\"^^#{type}"
-
-polygon = [ [ 0, -100 ], [ 0, 100 ], [ 100, 100 ], [ 100, -100 ] ]
-
-repository.geometric.create_polygon polygon,
- :name => "right",
- :type => type
-
-#url = URI "http://localhost:10035/catalogs/tests/repositories/foo/geo/polygon?resource=%22right%22&point=%22%2B0-100%22%5E%5E%3Chttp%3A//franz.com/ns/allegrograph/3.0/geospatial/cartesian/-100.0/100.0/-100.0/100.0/1.0%3E&point=%22%2B0%2B100%22%5E%5E%3Chttp%3A//franz.com/ns/allegrograph/3.0/geospatial/cartesian/-100.0/100.0/-100.0/100.0/1.0%3E&point=%22%2B100%2B100%22%5E%5E%3Chttp%3A//franz.com/ns/allegrograph/3.0/geospatial/cartesian/-100.0/100.0/-100.0/100.0/1.0%3E&point=%22%2B100-100%22%5E%5E%3Chttp%3A//franz.com/ns/allegrograph/3.0/geospatial/cartesian/-100.0/100.0/-100.0/100.0/1.0%3E"
-
-#AllegroGraph::ExtendedTransport.request :put, url,
-# :auth_type => :basic,
-# :username => "test",
-# :password => "test",
-# :expected_status_code => 204
-
-result = repository.statements.find_inside_polygon :polygon_name => "right",
- :type => type,
- :predicate => "\"at\""
-
-puts result.inspect

0 comments on commit bb5d4cb

Please sign in to comment.