rr3 0.0.1 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39bff95bdacb4a4692d8ee60f5e77484bd66329d
4
- data.tar.gz: 22e3449e892865ad8eb08e98d024c8c71c8954f6
3
+ metadata.gz: 79cf5b768741ab760688cc79a7e065ee19a0e4aa
4
+ data.tar.gz: 910a647c96a6d64c2379982835c23998aa1a7dba
5
5
  SHA512:
6
- metadata.gz: 01d5a4def618250028ebb99b03fe8a83bf52e2e58c31de5f6c923fcf5d147cc86278ba6b5a7a1b03710f2a26eea8570b05c1cc71957d1065b90ccc6516f3b581
7
- data.tar.gz: 759ece92d7703e70a271944e002ed8599746f19cb1d32ec6aaf7cd387c546ac077be5a454530c6c73fb099b8aced5b951f28e8049237aa480e0b2bf3dd4d7f5d
6
+ metadata.gz: e34fac7bb2ca9bd2a3daee072f54087e9bfb9f3d2f828e622e0b6a27eeb4fe217f2872f96d3f92ba35d41e628b63c0153450a8e35ae06d73fd53eaa09e0ce987
7
+ data.tar.gz: 292b90c3e2c83e11e149626aff81c0ea69fe6c4081b73133b2375b29749e76c2df28093818631ade0a4cf04c93578f13672e8478e18b7be6dd76d645b7b58f99
data/README.md CHANGED
@@ -1,31 +1,7 @@
1
1
  # Rr3
2
2
 
3
- TODO: Write a gem description
4
-
5
3
  ## Installation
6
4
 
7
- Add this line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem 'rr3'
11
5
  ```
12
-
13
- And then execute:
14
-
15
- $ bundle
16
-
17
- Or install it yourself as:
18
-
19
- $ gem install rr3
20
-
21
- ## Usage
22
-
23
- TODO: Write usage instructions here
24
-
25
- ## Contributing
26
-
27
- 1. Fork it ( https://github.com/[my-github-username]/rr3/fork )
28
- 2. Create your feature branch (`git checkout -b my-new-feature`)
29
- 3. Commit your changes (`git commit -am 'Add some feature'`)
30
- 4. Push to the branch (`git push origin my-new-feature`)
31
- 5. Create a new Pull Request
6
+ $ gem install rr3
7
+ ```
data/ext/rr3/tree.c CHANGED
@@ -10,6 +10,7 @@ void init_tree(){
10
10
  cTree = rb_define_class_under(cRr3, "Tree", rb_cObject);
11
11
  rb_define_method(cTree, "initialize", initialize, 1);
12
12
  rb_define_method(cTree, "insert_path", insert_path, 1);
13
+ rb_define_method(cTree, "compile", compile, 0);
13
14
  rb_define_method(cTree, "dump", dump, 1);
14
15
  }
15
16
 
@@ -21,16 +22,32 @@ static VALUE initialize(VALUE self, VALUE size){
21
22
 
22
23
  static VALUE insert_path(VALUE self, VALUE path){
23
24
  VALUE obj = rb_ivar_get(self, rb_intern("node"));
24
- node *n;
25
- Data_Get_Struct(obj, node, n);
26
- r3_tree_insert_path(n, RSTRING_PTR(path), NULL);
25
+ node *n; Data_Get_Struct(obj, node, n);
26
+ r3_tree_insert_pathl(n, RSTRING_PTR(path), RSTRING_LEN(path), NULL); // TODO: support routedata
27
27
  return Qnil;
28
28
  }
29
29
 
30
+ static VALUE compile(VALUE self){
31
+ VALUE obj = rb_ivar_get(self, rb_intern("node"));
32
+ node *n; Data_Get_Struct(obj, node, n);
33
+ char *errstr = NULL;
34
+ if(r3_tree_compile(n, &errstr) != 0){
35
+ rb_raise(rb_eRuntimeError, "%s", errstr);
36
+ free(errstr);
37
+ }
38
+ return Qnil;
39
+ }
40
+
41
+ static VALUE match(VALUE self, VALUE path){
42
+ VALUE obj = rb_ivar_get(self, rb_intern("node"));
43
+ node *n; Data_Get_Struct(obj, node, n);
44
+ node *matched_node = r3_tree_matchl(n, RSTRING_PTR(path), RSTRING_LEN(path), NULL); // TODO: support entry
45
+ return matched_node ? Qtrue : Qfalse; // TODO: support data passing
46
+ }
47
+
30
48
  static VALUE dump(VALUE self, VALUE number){
31
49
  VALUE obj = rb_ivar_get(self, rb_intern("node"));
32
- node *n;
33
- Data_Get_Struct(obj, node, n);
50
+ node *n; Data_Get_Struct(obj, node, n);
34
51
  r3_tree_dump(n, FIX2INT(number));
35
52
  return Qnil;
36
53
  }
data/ext/rr3/tree.h CHANGED
@@ -6,6 +6,8 @@ void init_tree();
6
6
  // instance methods
7
7
  static VALUE initialize(VALUE self, VALUE size);
8
8
  static VALUE insert_path(VALUE self, VALUE path);
9
+ static VALUE compile(VALUE self);
10
+ static VALUE match(VALUE self, VALUE path);
9
11
  static VALUE dump(VALUE self, VALUE number);
10
12
 
11
13
  static void release(node *n);
data/lib/rr3/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rr3
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.1"
3
3
  end
data/spec/rr3_spec.rb CHANGED
@@ -5,6 +5,7 @@ describe Rr3 do
5
5
  it 'works' do
6
6
  t = Rr3::Tree.new(10)
7
7
  t.insert_path "/foo/bar"
8
+ t.compile
8
9
  t.dump(0)
9
10
  end
10
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rr3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Jian