gnista 0.0.4 → 0.0.5

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
  SHA1:
3
- metadata.gz: 36552dd994d8f7ed18d1f26290fca5eaab21608f
4
- data.tar.gz: 778bd89aef04ff8f9ef1e2e1e7e2b3d24c0c4cd5
3
+ metadata.gz: ceb37e2f495af129a1626ca3cc184252378a2200
4
+ data.tar.gz: a61becb74a8c88c437e918c9ac5771fe3e06134e
5
5
  SHA512:
6
- metadata.gz: 8ebbd55366f654164ea6b182b90526a64691423331580572253b316c1beb2b5a07b396db8c65e301de84c077e6884cc2759e5f10208ab163af3d02fdaed39024
7
- data.tar.gz: bf3ce23592e12a42f12f11ff678a483efdd9ceb2128330ad2446eb645fbd858ea5a225b7e7ffb6f0a11081c1497133d7058858fd7a2fb52cb2fa4a1f53b4bc88
6
+ metadata.gz: 76b51e8b8e8764535b94cb7c163519c6e6024e8a7d8cb165f23a73283e2bcf8994f11cf36fde211c922a924f88f0639a0c3be8fb7567b4d4ca7d50423bb02e1a
7
+ data.tar.gz: 60320d0666a4bd17a27290f2aebbf15eff3f2cac1909ec4f4bd9026dd20f5d65631107f9f968529a0d98c82bcedf1a5cf02e37b8fac1f0952a7063188ff91c42
data/HISTORY.md CHANGED
@@ -1,3 +1,17 @@
1
+ # Version 0.0.5
2
+
3
+ Release date 2014-03-26
4
+
5
+ ### Added
6
+
7
+ * Useful error messages on build.
8
+ * Rubinius compatible tests.
9
+
10
+ ### Fixed
11
+
12
+ * SEGFAULT on interrupted initialization.
13
+ * Boolean consistency.
14
+
1
15
  # Version 0.0.4
2
16
 
3
17
  Release date 2013-09-16
@@ -47,4 +61,4 @@ Release date 2013-09-12
47
61
 
48
62
  Release date 2013-09-11
49
63
 
50
- __Initial release__
64
+ __Initial release__
@@ -3,7 +3,7 @@ require 'mkmf'
3
3
  extension_name = 'gnista'
4
4
  dir_config(extension_name)
5
5
 
6
- have_library('sparkey') or raise
7
- have_header('sparkey/sparkey.h') or raise
6
+ have_library('sparkey') or raise "Sparkey is missing"
7
+ have_header('sparkey/sparkey.h') or raise "sparkey.h could not be found"
8
8
 
9
- create_makefile(extension_name)
9
+ create_makefile(extension_name)
data/ext/gnista/gnista.c CHANGED
@@ -1,24 +1,24 @@
1
1
  #include <ruby.h>
2
2
  #include <sparkey/sparkey.h>
3
3
 
4
- typedef int bool;
4
+ typedef uint8_t bool;
5
5
  #define true 1
6
6
  #define false 0
7
7
 
8
8
 
9
9
  typedef struct instance_logwriter {
10
10
  sparkey_logwriter *logwriter;
11
- int open;
11
+ bool open;
12
12
  } instance_logwriter;
13
13
 
14
14
  typedef struct instance_logreader {
15
15
  sparkey_logreader *logreader;
16
- int open;
16
+ bool open;
17
17
  } instance_logreader;
18
18
 
19
19
  typedef struct instance_hashreader {
20
20
  sparkey_hashreader *hashreader;
21
- int open;
21
+ bool open;
22
22
  } instance_hashreader;
23
23
 
24
24
  /********************************************************************************/
@@ -57,6 +57,7 @@ static void dealloc_logwriter(void *p) {
57
57
 
58
58
  static VALUE alloc_logwriter(VALUE klass) {
59
59
  instance_logwriter *i_logwriter = ALLOC(instance_logwriter);
60
+ i_logwriter->open = false;
60
61
  return Data_Wrap_Struct(klass, 0, dealloc_logwriter, i_logwriter);
61
62
  }
62
63
 
@@ -91,7 +92,6 @@ static VALUE method_logwriter_initialize(VALUE self, VALUE args) {
91
92
 
92
93
  if (returncode != SPARKEY_SUCCESS) {
93
94
  raise_sparkey(returncode);
94
- i_logwriter->open = false;
95
95
  } else {
96
96
  i_logwriter->open = true;
97
97
  rb_iv_set(self, "@logpath", rb_ary_entry(args, 0));
@@ -186,6 +186,7 @@ static void dealloc_logreader(void *p) {
186
186
 
187
187
  static VALUE alloc_logreader(VALUE klass) {
188
188
  instance_logreader *i_logreader = ALLOC(instance_logreader);
189
+ i_logreader->open = false;
189
190
  return Data_Wrap_Struct(klass, 0, dealloc_logreader, i_logreader);
190
191
  }
191
192
 
@@ -204,7 +205,6 @@ static VALUE method_logreader_initialize(VALUE self, VALUE filename) {
204
205
 
205
206
  if (returncode != SPARKEY_SUCCESS) {
206
207
  raise_sparkey(returncode);
207
- i_logreader->open = false;
208
208
  } else {
209
209
  i_logreader->open = true;
210
210
  rb_iv_set(self, "@logpath", filename);
@@ -238,7 +238,7 @@ static VALUE method_logreader_each(VALUE self) {
238
238
  VALUE del_sym = ID2SYM(rb_intern("delete"));
239
239
  uint8_t *keybuf = malloc(sparkey_logreader_maxkeylen(i_logreader->logreader));
240
240
  uint8_t *valuebuf = malloc(sparkey_logreader_maxvaluelen(i_logreader->logreader));
241
- while (1) {
241
+ while (true) {
242
242
  returncode = sparkey_logiter_next(logiter, i_logreader->logreader);
243
243
 
244
244
  if (sparkey_logiter_state(logiter) != SPARKEY_ITER_ACTIVE) {
@@ -332,6 +332,7 @@ static void dealloc_hashreader(void *p) {
332
332
 
333
333
  static VALUE alloc_hashreader(VALUE klass) {
334
334
  instance_hashreader *i_hashreader = ALLOC(instance_hashreader);
335
+ i_hashreader->open = false;
335
336
  return Data_Wrap_Struct(klass, 0, dealloc_hashreader, i_hashreader);
336
337
  }
337
338
 
@@ -378,7 +379,6 @@ static VALUE method_hash_initialize(VALUE self, VALUE hash_filename, VALUE log_f
378
379
 
379
380
  if (returncode != SPARKEY_SUCCESS) {
380
381
  raise_sparkey(returncode);
381
- i_hashreader->open = false;
382
382
  } else {
383
383
  i_hashreader->open = true;
384
384
  rb_iv_set(self, "@hashpath", hash_filename);
@@ -412,7 +412,7 @@ static VALUE method_hash_each(VALUE self) {
412
412
 
413
413
  uint8_t *keybuf = malloc(sparkey_logreader_maxkeylen(logreader));
414
414
  uint8_t *valuebuf = malloc(sparkey_logreader_maxvaluelen(logreader));
415
- while (1) {
415
+ while (true) {
416
416
  returncode = sparkey_logiter_hashnext(logiter, i_hashreader->hashreader);
417
417
 
418
418
  if (sparkey_logiter_state(logiter) != SPARKEY_ITER_ACTIVE) {
@@ -1,3 +1,3 @@
1
1
  module Gnista
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -238,9 +238,7 @@ describe Gnista do
238
238
  end
239
239
 
240
240
  logreader = Gnista::Logreader.new log_path
241
- _,value,_ = logreader.first
242
- value.must_equal "value1"
243
-
241
+ logreader.count.must_equal 1
244
242
  logreader.close!
245
243
  end
246
244
 
data/test/test_gnista.rb CHANGED
@@ -54,4 +54,18 @@ describe Gnista do
54
54
  FileUtils.rm log_path
55
55
  end
56
56
 
57
+ it "will throw exception on invalid arguments" do
58
+ assert_raises TypeError do
59
+ Gnista::Logwriter.new 123
60
+ end
61
+
62
+ assert_raises GnistaException do
63
+ Gnista::Logreader.new "none_existing_file"
64
+ end
65
+
66
+ assert_raises GnistaException do
67
+ Gnista::Hash.new "none_existing_file", "none_existing_file"
68
+ end
69
+ end
70
+
57
71
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gnista
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emanuel Andersson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-16 00:00:00.000000000 Z
11
+ date: 2014-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler