extralite 0.3 → 0.4

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: 8063960fd539fc0384882cf017572baefe79b9e29591d03c790951c6fad4fac0
4
- data.tar.gz: 9f1c5be233721502dd0b97ffef2d195912ec029eccee977b16ca67b567299f04
3
+ metadata.gz: 8cdf5b562230dd1dc2e3dcc4083836c6d61ac4bfd51fdc12d7129ff57dc36148
4
+ data.tar.gz: 1db604b9d586ed4f3ca45516ad25ed73c4d668407616c5657372074a7d0d13a8
5
5
  SHA512:
6
- metadata.gz: b674b89217ff2231d7c48f7d93917c29e84bbcb8b240216854a87b85d0c4ca5588fe821d0e6db406df04adc5c0b29aca4e24335349084e45a7d98449119a981f
7
- data.tar.gz: 3f33b7ef708052e51033e2ca38f2323c8b78f95eecda2c328fba506762831e260ae03a66ff5944e4b961b22906aa42740ebdeaad1ff233f1141daded682a6d47
6
+ metadata.gz: bca80a7a86e23651cf7c672a74bbc423b696b080155a1932378af4028d282260b079754d99c0e6e52e1ab7bd2ca9417c67fe285af8bcd7e090c9b4d764f0f6a5
7
+ data.tar.gz: 74f35b4542eda30a6944403b1ea46d329a64deacf75a023bdae1ff718f7b0cce01278ffbc1e67f2a7a865d8fca44788454329d2aaedad69b402692c059ca8e90
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.4 2021-05-24
2
+
3
+ - Add support for loading extensions
4
+
1
5
  ## 0.3 2021-05-24
2
6
 
3
7
  - Add support for running multiple statements
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- extralite (0.3)
4
+ extralite (0.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -44,10 +44,14 @@ VALUE Database_initialize(VALUE self, VALUE path) {
44
44
 
45
45
  rc = sqlite3_open(StringValueCStr(path), &db->sqlite3_db);
46
46
  if (rc) {
47
- fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db->sqlite3_db));
48
47
  sqlite3_close(db->sqlite3_db);
49
- // TODO: raise error
50
- return Qfalse;
48
+ rb_raise(cError, "%s", sqlite3_errmsg(db->sqlite3_db));
49
+ }
50
+
51
+ rc = sqlite3_enable_load_extension(db->sqlite3_db, 1);
52
+ if (rc) {
53
+ sqlite3_close(db->sqlite3_db);
54
+ rb_raise(cError, "%s", sqlite3_errmsg(db->sqlite3_db));
51
55
  }
52
56
 
53
57
  return Qnil;
@@ -371,6 +375,21 @@ VALUE Database_transaction_active_p(VALUE self) {
371
375
  return sqlite3_get_autocommit(db->sqlite3_db) ? Qfalse : Qtrue;
372
376
  }
373
377
 
378
+ VALUE Database_load_extension(VALUE self, VALUE path) {
379
+ Database_t *db;
380
+ GetDatabase(self, db);
381
+ char *err_msg;
382
+
383
+ int rc = sqlite3_load_extension(db->sqlite3_db, RSTRING_PTR(path), 0, &err_msg);
384
+ if (rc != SQLITE_OK) {
385
+ VALUE error = rb_exc_new2(cError, err_msg);
386
+ sqlite3_free(err_msg);
387
+ rb_exc_raise(error);
388
+ }
389
+
390
+ return self;
391
+ }
392
+
374
393
  void Init_Extralite() {
375
394
  VALUE mExtralite = rb_define_module("Extralite");
376
395
  VALUE cDatabase = rb_define_class_under(mExtralite, "Database", rb_cObject);
@@ -388,6 +407,7 @@ void Init_Extralite() {
388
407
  rb_define_method(cDatabase, "changes", Database_changes, 0);
389
408
  rb_define_method(cDatabase, "filename", Database_filename, -1);
390
409
  rb_define_method(cDatabase, "transaction_active?", Database_transaction_active_p, 0);
410
+ rb_define_method(cDatabase, "load_extension", Database_load_extension, 1);
391
411
 
392
412
  cError = rb_define_class_under(mExtralite, "Error", rb_eRuntimeError);
393
413
  }
@@ -1,3 +1,3 @@
1
1
  module Extralite
2
- VERSION = '0.3'
2
+ VERSION = '0.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: extralite
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner