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 +4 -4
- data/README.md +2 -26
- data/ext/rr3/tree.c +22 -5
- data/ext/rr3/tree.h +2 -0
- data/lib/rr3/version.rb +1 -1
- data/spec/rr3_spec.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 79cf5b768741ab760688cc79a7e065ee19a0e4aa
|
|
4
|
+
data.tar.gz: 910a647c96a6d64c2379982835c23998aa1a7dba
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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
|
-
|
|
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
data/spec/rr3_spec.rb
CHANGED