drb_sqlite 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/drb_sqlite.rb +38 -8
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14e8618477946900f490b2a4ec23267bf2c3128bb5d99259d6462e892aa067ec
|
4
|
+
data.tar.gz: f5f33b7870b201df683d36172e0b8b99bdfc145f06b84ea353b19a7ea7970f9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f609fa2d44d5e39d9348740e0566f953a2f0d9f87e59993bdd0de3a4f57da1b78ef827a4b830a5319e278c16343bcd6a2c3ada3016d1d0c80e2fc55f63146f2
|
7
|
+
data.tar.gz: f2b275ec2b8ef66b21a5065a20e3ef637188d4198f96067aa92ce23b8821d967617a06868365bc307d8010bb84555917c38462bea1902f934c227f5fdf3ff9ee
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/drb_sqlite.rb
CHANGED
@@ -4,25 +4,55 @@
|
|
4
4
|
|
5
5
|
require 'drb'
|
6
6
|
|
7
|
+
class SQLiteServerError < Exception
|
8
|
+
end
|
7
9
|
|
8
10
|
class DRbSQLite
|
9
11
|
|
10
|
-
def initialize(
|
11
|
-
|
12
|
-
@dbfile = dbfile
|
12
|
+
def initialize(raw_dbfile=nil, host: nil, port: '57000')
|
13
|
+
|
13
14
|
DRb.start_service
|
14
|
-
@server = DRbObject.new nil, "druby://#{host}:#{port}"
|
15
|
-
|
15
|
+
@server = DRbObject.new nil, "druby://#{host}:#{port}"
|
16
|
+
load(raw_dbfile) if raw_dbfile
|
16
17
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def execute(*args, &blk)
|
20
|
-
|
21
|
+
|
22
|
+
r = @server.execute @dbfile, *args, &blk
|
23
|
+
|
24
|
+
if r.is_a? String and r =~ /^SQLiteServerError:/ then
|
25
|
+
raise SQLiteServerError, r[/(?<=^SQLiteServerError: )(.*)/]
|
26
|
+
end
|
27
|
+
|
28
|
+
r
|
29
|
+
end
|
30
|
+
|
31
|
+
def exists?(dbfile)
|
32
|
+
@server.exists? dbfile
|
33
|
+
end
|
34
|
+
|
35
|
+
def load(raw_dbfile)
|
36
|
+
|
37
|
+
if raw_dbfile =~ /^sqlite:\/\// then
|
38
|
+
host, @dbfile = raw_dbfile\
|
39
|
+
.match(/(?<=^sqlite:\/\/)([^\/]+)\/(.*)/).captures
|
40
|
+
else
|
41
|
+
@dbfile = raw_dbfile
|
42
|
+
end
|
43
|
+
|
44
|
+
@server.load(@dbfile)
|
21
45
|
end
|
22
46
|
|
23
47
|
def query(*args, &blk)
|
24
|
-
|
48
|
+
|
49
|
+
r = @server.query @dbfile, *args, &blk
|
50
|
+
|
51
|
+
if r.is_a? String and r =~ /^SQLiteServerError:/ then
|
52
|
+
raise SQLiteServerError, r[/(?<=^SQLiteServerError: )(.*)/]
|
53
|
+
end
|
54
|
+
|
55
|
+
r
|
25
56
|
end
|
26
57
|
|
27
58
|
end
|
28
|
-
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|