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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 430cd23f23fe750696819ed0983fc2d59ae834377baa110020f4cd1fc40b46e8
4
- data.tar.gz: f95b7c841e4db138ae6f9b2e07f518265310dc3c7f976f785cdd92eda7bdfec8
3
+ metadata.gz: 14e8618477946900f490b2a4ec23267bf2c3128bb5d99259d6462e892aa067ec
4
+ data.tar.gz: f5f33b7870b201df683d36172e0b8b99bdfc145f06b84ea353b19a7ea7970f9a
5
5
  SHA512:
6
- metadata.gz: 845c07f80418bb90bca9a2f06fc09cec3e5cb459d708c8ec2194597ca856e93f91ba028ea12bb37a502ea62aa21a21f6274214cf24c6825c9c5e77c5bd32d032
7
- data.tar.gz: 505fc7f928541802c9722eb166369cd1d890cc98078ccfd08b58be3d014c9e9bce8515d8287c2211e554deb8b89f1641d09db6eecca878b2669d7e0ca1e1380e
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(dbfile=nil, host: nil, port: '57000')
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
- @server.load(dbfile)
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
- @server.execute @dbfile, *args, &blk
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
- @server.query @dbfile, *args, &blk
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
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drb_sqlite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file