rdf-do 1.99.0.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README +7 -7
- data/VERSION +1 -1
- data/lib/rdf/do.rb +31 -44
- data/lib/rdf/do/adapters/defaults.rb +1 -1
- data/lib/rdf/do/version.rb +5 -8
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dadfca05d2490a554932159932c6f4e490fec32
|
4
|
+
data.tar.gz: ebd1901324d2a11d96b786ae815c368a16b92e3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b862f4178cc8dba2e4bf702ebfde6a00fcef90c754b01e2149db3c16868e8246ba5591de3026cd1f55d1b6866df8806bbc9e8ebb5aea6fb6d328b18d26b86e9
|
7
|
+
data.tar.gz: 958c80738b91d3bf0dbe722a27e6da468744b7af511c9fedf69fe6abdb37d431e1985a5f35ebe5a0cd369849cfb45910a20b2552a9a83c180e2643c7df3aba9c
|
data/README
CHANGED
@@ -16,7 +16,7 @@ and it passes all its tests on Heroku as well.
|
|
16
16
|
|
17
17
|
Example:
|
18
18
|
|
19
|
-
repository = RDF::DataObjects::Repository.new "sqlite3:test.db"
|
19
|
+
repository = RDF::DataObjects::Repository.new uri: "sqlite3:test.db"
|
20
20
|
repository.insert(statement)
|
21
21
|
repository.count #=> 1
|
22
22
|
repository.delete(statement)
|
@@ -33,15 +33,15 @@ The greatly preferred installation method is via RubyGems:
|
|
33
33
|
|
34
34
|
$ sudo gem install rdf-do
|
35
35
|
|
36
|
-
Requires Ruby >=
|
36
|
+
Requires Ruby >= 2.0
|
37
37
|
|
38
38
|
## Connecting
|
39
39
|
require 'rdf'
|
40
40
|
require 'rdf/do'
|
41
41
|
require 'do_postgres' # gem install do_postgres
|
42
42
|
require 'do_sqlite3' # gem install do_sqlite3
|
43
|
-
repo = RDF::DataObjects::Repository.new "postgres://localhost/database"
|
44
|
-
repo = RDF::DataObjects::Repository.new "sqlite3:test.db"
|
43
|
+
repo = RDF::DataObjects::Repository.new uri: "postgres://localhost/database"
|
44
|
+
repo = RDF::DataObjects::Repository.new uri: "sqlite3:test.db"
|
45
45
|
|
46
46
|
|
47
47
|
## Using
|
@@ -59,9 +59,9 @@ Example:
|
|
59
59
|
require 'do_sqlite3'
|
60
60
|
require 'rdf/do'
|
61
61
|
|
62
|
-
repo = RDF::DataObjects::Repository.new
|
63
|
-
# repo = RDF::DataObjects::Repository.new 'postgres://postgres@server/database'
|
64
|
-
# heroku_repo = RDF::DataObjects::Repository.new
|
62
|
+
repo = RDF::DataObjects::Repository.new uri: 'sqlite3:test.db'
|
63
|
+
# repo = RDF::DataObjects::Repository.new uri: 'postgres://postgres@server/database'
|
64
|
+
# heroku_repo = RDF::DataObjects::Repository.new uri: ENV['DATABASE_URL']
|
65
65
|
repo.load('http://datagraph.org/jhacker/foaf.nt')
|
66
66
|
|
67
67
|
# How many statements did we have?
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
data/lib/rdf/do.rb
CHANGED
@@ -23,37 +23,36 @@ module RDF
|
|
23
23
|
#
|
24
24
|
class Repository < RDF::Repository
|
25
25
|
|
26
|
-
##
|
26
|
+
##
|
27
|
+
# Initializes this repository instance.
|
27
28
|
#
|
28
|
-
# The `options` parameter can be anything that
|
29
|
-
# DataObjects::Connection.new accepts. The correct
|
30
|
-
# RDF::Repository::DataObjects adapter will be loaded based on the URI
|
31
|
-
# scheme of the created connection.
|
32
|
-
#
|
33
29
|
# @example
|
34
30
|
# RDF::DataObjects::Repository.new # => new Repository based on sqlite3://:memory:
|
35
|
-
# RDF::DataObjects::Repository.new 'postgres://localhost/database'
|
31
|
+
# RDF::DataObjects::Repository.new uri: 'postgres://localhost/database'
|
36
32
|
# => New repository based on postgres adapter
|
37
|
-
#
|
33
|
+
#
|
34
|
+
# @param [Hash{Symbol => Object}] options
|
35
|
+
# @option options [URI, #to_s] :uri (nil)
|
36
|
+
# @option options [String, #to_s] :title (nil)
|
37
|
+
# @option options [String, #to_s] :adaptor (nil)
|
38
|
+
# The default adapter will be loaded based on the URI
|
39
|
+
# scheme of the created connection.
|
40
|
+
# @option options [String] :db Synonym for :uri
|
38
41
|
# @return [RDF::DataObjects::Repository]
|
39
|
-
def initialize(options = {})
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
@db = ::DataObjects::Connection.new('sqlite3://:memory:')
|
49
|
-
end
|
50
|
-
adapter = @db.instance_variable_get("@uri").scheme
|
51
|
-
require 'rdf/do/adapters/' + adapter.to_s
|
52
|
-
rescue Exception => e
|
53
|
-
raise LoadError, "Could not load a DataObjects adapter for #{options}. You may need to add a 'require do_adapter', or you may be trying to use an unsupported adapter (Currently supporting postgres, sqlite3). The error message was: #{e.message}"
|
54
|
-
end
|
42
|
+
def initialize(options = {}, &block)
|
43
|
+
warn "[DEPRECATION] RDF::DataObjects::Repository#initialize expects a uri argument. Called from #{Gem.location_of_caller.join(':')}" unless options.is_a?(Hash)
|
44
|
+
options = {uri: options.to_s} unless options.is_a?(Hash)
|
45
|
+
db = options[:uri] || options[:db] || 'sqlite3://:memory:'
|
46
|
+
@db = ::DataObjects::Connection.new(db)
|
47
|
+
|
48
|
+
adapter = options[:adapter] || @db.instance_variable_get("@uri").scheme
|
49
|
+
require 'rdf/do/adapters/' + adapter.to_s
|
50
|
+
|
55
51
|
@adapter = RDF::DataObjects::Adapters::const_get(adapter.to_s.capitalize)
|
56
52
|
@adapter.migrate? self
|
53
|
+
super(options, &block)
|
54
|
+
rescue Exception => e
|
55
|
+
raise LoadError, "Could not load a DataObjects adapter for #{options}. You may need to add a 'require do_adapter', or you may be trying to use an unsupported adapter (Currently supporting postgres, sqlite3). The error message was: #{e.message}"
|
57
56
|
end
|
58
57
|
|
59
58
|
# @see RDF::Mutable#insert_statement
|
@@ -109,7 +108,8 @@ module RDF
|
|
109
108
|
# @param [RDF::Statement] statement
|
110
109
|
# @return [void]
|
111
110
|
def delete_statement(statement)
|
112
|
-
|
111
|
+
query = @adapter.delete_sql
|
112
|
+
exec(query, serialize(statement.subject), serialize(statement.predicate), serialize(statement.object), serialize(statement.graph_name))
|
113
113
|
end
|
114
114
|
|
115
115
|
##
|
@@ -132,25 +132,13 @@ module RDF
|
|
132
132
|
exec(query,*(args.flatten))
|
133
133
|
else
|
134
134
|
query = @adapter.insert_sql
|
135
|
-
statements.
|
135
|
+
each = statements.respond_to?(:each_statement) ? :each_statement : :each
|
136
|
+
statements.__send__(each) do |s|
|
136
137
|
exec(query, serialize(s.subject),serialize(s.predicate), serialize(s.object), serialize(s.graph_name))
|
137
138
|
end
|
138
139
|
end
|
139
140
|
end
|
140
141
|
|
141
|
-
##
|
142
|
-
# Remove multiple statements from this repository
|
143
|
-
#
|
144
|
-
# @see RDF::Mutable#delete_statements
|
145
|
-
# @param [Array<RDF::Statement>] statements
|
146
|
-
# @return [void]
|
147
|
-
def delete_statements(statements)
|
148
|
-
query = @adapter.delete_sql
|
149
|
-
statements.each do |s|
|
150
|
-
exec(query, serialize(s.subject), serialize(s.predicate), serialize(s.object), serialize(s.graph_name))
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
142
|
##
|
155
143
|
# Serialize an RDF::Value into N-triples format.
|
156
144
|
# Nil values will be encoded as 'nil' to avoid problems with SQL
|
@@ -286,12 +274,10 @@ module RDF
|
|
286
274
|
def each_graph(&block)
|
287
275
|
return enum_for(:each_graph) unless block_given?
|
288
276
|
|
289
|
-
|
290
|
-
yield RDF::Graph.new(nil, data: self)
|
291
|
-
reader = result(@adapter.each_context_sql)
|
277
|
+
reader = result(@adapter.each_graph_sql)
|
292
278
|
while reader.next!
|
293
279
|
graph_name = unserialize(reader.values[0])
|
294
|
-
yield RDF::Graph.new(graph_name, data: self)
|
280
|
+
yield RDF::Graph.new(graph_name: graph_name, data: self)
|
295
281
|
end
|
296
282
|
end
|
297
283
|
|
@@ -320,7 +306,8 @@ module RDF
|
|
320
306
|
# @param [RDF::Query::Pattern] pattern
|
321
307
|
# @see RDF::Queryable#query_pattern
|
322
308
|
# @see RDF::Query::Pattern
|
323
|
-
def query_pattern(pattern, &block)
|
309
|
+
def query_pattern(pattern, options = {}, &block)
|
310
|
+
return enum_for(:query_pattern, pattern, options) unless block_given?
|
324
311
|
@nodes = {} # reset cache. FIXME this should probably be in Node.intern
|
325
312
|
reader = @adapter.query(self,pattern.to_hash)
|
326
313
|
while reader.next!
|
data/lib/rdf/do/version.rb
CHANGED
@@ -1,16 +1,13 @@
|
|
1
1
|
module RDF::DataObjects
|
2
2
|
module VERSION
|
3
|
-
|
4
|
-
MINOR =
|
5
|
-
TINY = 3
|
6
|
-
EXTRA = nil
|
3
|
+
VERSION_FILE = File.join(File.expand_path(File.dirname(__FILE__)), "..", "..", "..", "VERSION")
|
4
|
+
MAJOR, MINOR, TINY, EXTRA = File.read(VERSION_FILE).chop.split(".")
|
7
5
|
|
8
|
-
STRING = [MAJOR, MINOR, TINY].join('.')
|
9
|
-
STRING << ".#{EXTRA}" if EXTRA
|
6
|
+
STRING = [MAJOR, MINOR, TINY, EXTRA].compact.join('.')
|
10
7
|
|
11
8
|
##
|
12
9
|
# @return [String]
|
13
|
-
def self.to_s()
|
10
|
+
def self.to_s() STRING end
|
14
11
|
|
15
12
|
##
|
16
13
|
# @return [String]
|
@@ -18,6 +15,6 @@ module RDF::DataObjects
|
|
18
15
|
|
19
16
|
##
|
20
17
|
# @return [Array(Integer, Integer, Integer)]
|
21
|
-
def self.to_a()
|
18
|
+
def self.to_a() STRING.split(".") end
|
22
19
|
end
|
23
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdf-do
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Lavender
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdf
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: data_objects
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '2.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '2.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -149,7 +149,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
149
|
requirements:
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
152
|
+
version: '2.0'
|
153
153
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
154
|
requirements:
|
155
155
|
- - ">="
|
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
157
|
version: '0'
|
158
158
|
requirements: []
|
159
159
|
rubyforge_project: rdf
|
160
|
-
rubygems_version: 2.4.
|
160
|
+
rubygems_version: 2.4.8
|
161
161
|
signing_key:
|
162
162
|
specification_version: 4
|
163
163
|
summary: RDF.rb extension providing a DataObjects storage adapter.
|