actsasflinn-ruby-tokyotyrant 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -2
- data/ext/tokyo_tyrant_query.c +23 -10
- data/ext/tokyo_tyrant_table.c +1 -1
- data/spec/tokyo_tyrant_query_spec.rb +8 -1
- metadata +2 -2
data/Rakefile
CHANGED
@@ -20,7 +20,7 @@ CLEAN.include('pkg', 'tmp')
|
|
20
20
|
|
21
21
|
gemspec = Gem::Specification.new do |s|
|
22
22
|
s.name = 'ruby-tokyotyrant'
|
23
|
-
s.version = '0.1.
|
23
|
+
s.version = '0.1.8'
|
24
24
|
s.authors = [ 'Flinn' ]
|
25
25
|
s.email = 'flinn@actsasflinn.com'
|
26
26
|
s.homepage = 'http://github.com/actsasflinn/ruby-tokyotyrant/'
|
@@ -34,7 +34,7 @@ gemspec = Gem::Specification.new do |s|
|
|
34
34
|
s.files = ['COPYING',
|
35
35
|
'Rakefile',
|
36
36
|
'README.rdoc'] +
|
37
|
-
Dir['ext
|
37
|
+
Dir['ext/**/*.[rb|c|h]'] +
|
38
38
|
Dir['spec/**/*'] +
|
39
39
|
Dir['benchmarks/**/*']
|
40
40
|
s.extensions << "ext/extconf.rb"
|
data/ext/tokyo_tyrant_query.c
CHANGED
@@ -24,7 +24,7 @@ static VALUE cQuery_addcond(VALUE vself, VALUE vname, VALUE vop, VALUE vexpr){
|
|
24
24
|
|
25
25
|
if (TYPE(vop) == T_STRING){
|
26
26
|
vop = StringValueEx(vop);
|
27
|
-
vop = tctdbqrystrtocondop(RSTRING_PTR(
|
27
|
+
vop = tctdbqrystrtocondop(RSTRING_PTR(vop));
|
28
28
|
vop = INT2NUM(vop);
|
29
29
|
}
|
30
30
|
|
@@ -34,22 +34,35 @@ static VALUE cQuery_addcond(VALUE vself, VALUE vname, VALUE vop, VALUE vexpr){
|
|
34
34
|
return vself;
|
35
35
|
}
|
36
36
|
|
37
|
-
static VALUE cQuery_setorder(
|
37
|
+
static VALUE cQuery_setorder(int argc, VALUE *argv, VALUE vself){
|
38
|
+
VALUE vname, vtype;
|
39
|
+
int type;
|
38
40
|
VALUE vqry;
|
39
41
|
RDBQRY *qry;
|
40
|
-
vname = StringValueEx(vname);
|
41
42
|
|
42
|
-
|
43
|
+
rb_scan_args(argc, argv, "11", &vname, &vtype);
|
44
|
+
if(NIL_P(vtype)) vtype = INT2NUM(RDBQOSTRASC);
|
45
|
+
|
46
|
+
vname = StringValueEx(vname);
|
43
47
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
+
switch(TYPE(vtype)){
|
49
|
+
case T_SYMBOL:
|
50
|
+
vtype = rb_str_new2(rb_id2name(SYM2ID(vtype)));
|
51
|
+
case T_STRING:
|
52
|
+
vtype = StringValueEx(vtype);
|
53
|
+
type = tctdbqrystrtoordertype(RSTRING_PTR(vtype));
|
54
|
+
break;
|
55
|
+
case T_FIXNUM:
|
56
|
+
type = NUM2INT(vtype);
|
57
|
+
break;
|
58
|
+
default:
|
59
|
+
rb_raise(rb_eArgError, "type must be symbol, string or integer");
|
60
|
+
break;
|
48
61
|
}
|
49
62
|
|
50
63
|
vqry = rb_iv_get(vself, RDBQRYVNDATA);
|
51
64
|
Data_Get_Struct(vqry, RDBQRY, qry);
|
52
|
-
tcrdbqrysetorder(qry, RSTRING_PTR(vname),
|
65
|
+
tcrdbqrysetorder(qry, RSTRING_PTR(vname), type);
|
53
66
|
return vself;
|
54
67
|
}
|
55
68
|
|
@@ -158,7 +171,7 @@ void init_query(){
|
|
158
171
|
rb_define_alias(cQuery, "add_condition", "addcond");
|
159
172
|
rb_define_alias(cQuery, "condition", "addcond");
|
160
173
|
rb_define_alias(cQuery, "add", "addcond"); // Rufus Compat
|
161
|
-
rb_define_method(cQuery, "setorder", cQuery_setorder,
|
174
|
+
rb_define_method(cQuery, "setorder", cQuery_setorder, -1);
|
162
175
|
rb_define_alias(cQuery, "order_by", "setorder"); // Rufus Compat
|
163
176
|
rb_define_method(cQuery, "setlimit", cQuery_setlimit, -1);
|
164
177
|
rb_define_alias(cQuery, "setmax", "setlimit"); // Rufus Compat
|
data/ext/tokyo_tyrant_table.c
CHANGED
@@ -165,7 +165,7 @@ static VALUE cTable_setindex(VALUE vself, VALUE vname, VALUE vtype){
|
|
165
165
|
|
166
166
|
if (TYPE(vtype) == T_STRING){
|
167
167
|
vtype = StringValueEx(vtype);
|
168
|
-
vtype = tctdbstrtoindextype(RSTRING_PTR(
|
168
|
+
vtype = tctdbstrtoindextype(RSTRING_PTR(vtype));
|
169
169
|
vtype = INT2NUM(vtype);
|
170
170
|
}
|
171
171
|
|
@@ -26,6 +26,13 @@ describe TokyoTyrant::Query, "with an open database" do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
it "should get ordered keys for search conditions with default order" do
|
30
|
+
q = @db.query
|
31
|
+
q.addcond(:type, :streq, 'Spinach')
|
32
|
+
q.setorder(:variety)
|
33
|
+
q.search.should == ["3332", "34173"]
|
34
|
+
end
|
35
|
+
|
29
36
|
it "should get ordered keys for search conditions with ascending order" do
|
30
37
|
q = @db.query
|
31
38
|
q.addcond('type', :streq, 'Spinach')
|
@@ -36,7 +43,7 @@ describe TokyoTyrant::Query, "with an open database" do
|
|
36
43
|
it "should get ordered keys for search conditions with decending order" do
|
37
44
|
q = @db.query
|
38
45
|
q.addcond('type', :streq, 'Spinach')
|
39
|
-
q.order_by('variety', :
|
46
|
+
q.order_by('variety', :StrDesc)
|
40
47
|
q.search.should == ["34173", "3332"]
|
41
48
|
end
|
42
49
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actsasflinn-ruby-tokyotyrant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flinn
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-26 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|