rrudb 0.0.3 → 0.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: f370cffff83adbbec822fdeb83d4cd96e768351fb0a592473d1aeddafaa7d413
4
- data.tar.gz: 52413e39845297cd3c63ff23309645795a2145d7252b99327d9a4c9778047c38
3
+ metadata.gz: 68b985de38c600da033bd457d4b1eb7f666aa93ce7e5ab629739a5a235923221
4
+ data.tar.gz: 1981b6a50f49bd7aba204725afc8b5e5556eb3261439c3525bdcbe773cf6d64b
5
5
  SHA512:
6
- metadata.gz: 4bd35fd8dae07048ce9889453b7b70197a95cf7b6aef3c81e2dbb91ce887cb618fa85bc800ac4ac542fd4867b424a4c1fc6456861e6a8795ac9b1b68f5ad208b
7
- data.tar.gz: 5038eae0823c6ba1c465976e07008e746fff3865165ce22b6eecf4024c14622b880eabca77281261deaef4e56e39e652f9eb687f7a18db1b83ee436423bc5f3d
6
+ metadata.gz: ec718c5f4ab0ec65b9bb4b72ea7fa9681be8f7cc09da0029bbbcadaeab0b975b4e350771aa399b9cd7085b6971f048d98e7036273701d623efd6f1e3e53e42e2
7
+ data.tar.gz: abbc5a916c3daabd1d158487bc3d81f286bf2736430e44e89c056a902627bb89e6e74297b39c3afa6b755b664a2ecb07c1e5beb43ea851a565ad60b5fa7edae1
data/ext/rudb/rudb.cpp CHANGED
@@ -23,12 +23,28 @@ VALUE ec2obj(nudb::error_code* ec){
23
23
  return Data_Wrap_Struct(cRuDB_ec, 0, ec_free, ec);
24
24
  }
25
25
 
26
+ static VALUE ec_alloc(VALUE klass){
27
+ nudb::error_code* ec_pointer = ALLOC(nudb::error_code);
28
+ return Data_Wrap_Struct(klass, 0, ec_free, ec_pointer);
29
+ }
30
+
26
31
  VALUE rudb_ec_value(VALUE _self){
27
32
  nudb::error_code* ec_pointer;
28
33
  Data_Get_Struct(_self, nudb::error_code , ec_pointer);
29
34
  return INT2NUM(ec_pointer->value());
30
35
  }
31
36
 
37
+ VALUE rudb_ec_value_eq(VALUE _self, VALUE _val){
38
+ Check_Type(_val, T_FIXNUM);
39
+ int _vali = NUM2INT(_val);
40
+
41
+ nudb::error_code* ec_pointer;
42
+ Data_Get_Struct(_self, nudb::error_code , ec_pointer);
43
+ ec_pointer->assign(_vali, ec_pointer->category());
44
+
45
+ return INT2NUM(ec_pointer->value());
46
+ }
47
+
32
48
  VALUE rudb_ec_message(VALUE _self){
33
49
  nudb::error_code* ec_pointer;
34
50
  Data_Get_Struct(_self, nudb::error_code , ec_pointer);
@@ -247,7 +263,9 @@ extern "C"{
247
263
  rb_define_method(cRuDB_store, "close", (METHOD)rudb_store_close, 0);
248
264
 
249
265
  cRuDB_ec = rb_define_class_under(mRuDB, "ErrorCode", rb_cObject);
250
- rb_define_method(cRuDB_ec, "value", (METHOD)rudb_ec_value, 0);
251
- rb_define_method(cRuDB_ec, "message", (METHOD)rudb_ec_message, 0);
266
+ rb_define_alloc_func(cRuDB_ec, ec_alloc);
267
+ rb_define_method(cRuDB_ec, "value", (METHOD)rudb_ec_value, 0);
268
+ rb_define_method(cRuDB_ec, "value=", (METHOD)rudb_ec_value_eq, 1);
269
+ rb_define_method(cRuDB_ec, "message", (METHOD)rudb_ec_message, 0);
252
270
  }
253
271
  }
data/lib/rudb/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RuDB
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end # module RuDB
data/lib/rudb.rb CHANGED
@@ -6,4 +6,15 @@ module RuDB
6
6
  yield key, val
7
7
  })
8
8
  end
9
+
10
+ # FIXME: should also marshal error_category (somehow)
11
+ class ErrorCode
12
+ def marshal_dump
13
+ value
14
+ end
15
+
16
+ def marshal_load(val)
17
+ self.value = val
18
+ end
19
+ end
9
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rrudb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dev Null Productions
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-15 00:00:00.000000000 Z
11
+ date: 2019-05-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby NuDB Wrapper
14
14
  email: