nyara 0.0.1.pre.4 → 0.0.1.pre.5
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/ext/extconf.rb +1 -6
- data/ext/request.c +2 -4
- data/ext/route.cc +14 -11
- data/lib/nyara/view.rb +2 -1
- data/nyara.gemspec +1 -1
- data/readme.md +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff97920b70aa73d175c0c11ceabd1d2117d680da
|
4
|
+
data.tar.gz: 37bb1733ddfafef3a1ce806e58e1ddf145396a15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dabf49a57dd4c1e91693020c699e5dcb9a5726663af573a162d8c1df44d712c0ac4894b15e943010e5259488746d4da117d98c127563b7a75905813dcc2bceb5
|
7
|
+
data.tar.gz: 636bbcd0ab74719cb7feb9c93891dc04287c3445eb19465c8bb232495b935964b7e4f9da582e6faed3a33f5d6be14f7410b9534096832692cbafcda8ee35ab8e
|
data/ext/extconf.rb
CHANGED
@@ -11,12 +11,7 @@ end
|
|
11
11
|
|
12
12
|
def tweak_cflags
|
13
13
|
mf_conf = RbConfig::MAKEFILE_CONFIG
|
14
|
-
if mf_conf['CC'] =~ /
|
15
|
-
# enable c++0x. this can not be installed on $CPPFLAGS, wtf??
|
16
|
-
mf_conf['CXXFLAGS'] << ' -stdlib=libc++ -std=c++0x'
|
17
|
-
$CFLAGS << ' $(xflags)'
|
18
|
-
else
|
19
|
-
mf_conf['CXXFLAGS'] << ' -std=c++0x'
|
14
|
+
if mf_conf['CC'] =~ /gcc/
|
20
15
|
$CFLAGS << ' -std=c99 -Wno-declaration-after-statement $(xflags)'
|
21
16
|
end
|
22
17
|
|
data/ext/request.c
CHANGED
@@ -89,10 +89,8 @@ void nyara_request_term_close(VALUE self, bool write_last_chunk) {
|
|
89
89
|
P;
|
90
90
|
if (write_last_chunk || p->status == 200) {
|
91
91
|
// usually this succeeds, while not, it doesn't matter cause we are closing it
|
92
|
-
|
93
|
-
|
94
|
-
write(p->fd, "0\r\n\r\n", 5);
|
95
|
-
# pragma GCC diagnostic pop
|
92
|
+
if (write(p->fd, "0\r\n\r\n", 5)) {
|
93
|
+
}
|
96
94
|
}
|
97
95
|
nyara_detach_fd(p->fd);
|
98
96
|
p->fd = 0;
|
data/ext/route.cc
CHANGED
@@ -45,7 +45,11 @@ struct RouteEntry {
|
|
45
45
|
};
|
46
46
|
|
47
47
|
typedef std::vector<RouteEntry> RouteEntries;
|
48
|
-
|
48
|
+
typedef RouteEntries::iterator EntriesIter;
|
49
|
+
typedef std::map<enum http_method, RouteEntries*> RouteMap;
|
50
|
+
typedef RouteMap::iterator MapIter;
|
51
|
+
|
52
|
+
static RouteMap route_map;
|
49
53
|
static OnigRegion region; // we can reuse the region without worrying thread safety
|
50
54
|
static ID id_to_s;
|
51
55
|
static rb_encoding* u8_enc;
|
@@ -56,7 +60,7 @@ static bool start_with(const char* a, long a_len, const char* b, long b_len) {
|
|
56
60
|
if (b_len > a_len) {
|
57
61
|
return false;
|
58
62
|
}
|
59
|
-
for (
|
63
|
+
for (long i = 0; i < b_len; i++) {
|
60
64
|
if (a[i] != b[i]) {
|
61
65
|
return false;
|
62
66
|
}
|
@@ -76,9 +80,9 @@ static enum http_method canonicalize_http_method(VALUE m) {
|
|
76
80
|
}
|
77
81
|
|
78
82
|
static VALUE ext_clear_route(VALUE req) {
|
79
|
-
for (
|
83
|
+
for (MapIter i = route_map.begin(); i != route_map.end(); ++i) {
|
80
84
|
RouteEntries* entries = i->second;
|
81
|
-
for (
|
85
|
+
for (EntriesIter j = entries->begin(); j != entries->end(); ++j) {
|
82
86
|
j->dealloc();
|
83
87
|
}
|
84
88
|
delete entries;
|
@@ -91,7 +95,7 @@ static VALUE ext_register_route(VALUE self, VALUE v_e) {
|
|
91
95
|
// get route entries
|
92
96
|
enum http_method m = canonicalize_http_method(rb_iv_get(v_e, "@http_method"));
|
93
97
|
RouteEntries* route_entries;
|
94
|
-
|
98
|
+
MapIter map_iter = route_map.find(m);
|
95
99
|
if (map_iter == route_map.end()) {
|
96
100
|
route_entries = new RouteEntries();
|
97
101
|
route_map[m] = route_entries;
|
@@ -159,15 +163,14 @@ static VALUE ext_list_route(VALUE self) {
|
|
159
163
|
// note: prevent leak with init nil
|
160
164
|
volatile VALUE arr = Qnil;
|
161
165
|
volatile VALUE e = Qnil;
|
162
|
-
volatile VALUE prefix = Qnil;
|
163
166
|
volatile VALUE conv = Qnil;
|
164
167
|
|
165
168
|
volatile VALUE route_hash = rb_hash_new();
|
166
|
-
for (
|
169
|
+
for (MapIter j = route_map.begin(); j != route_map.end(); j++) {
|
167
170
|
RouteEntries* route_entries = j->second;
|
168
|
-
|
171
|
+
arr = rb_ary_new();
|
169
172
|
rb_hash_aset(route_hash, rb_str_new2(http_method_str(j->first)), arr);
|
170
|
-
for (
|
173
|
+
for (EntriesIter i = route_entries->begin(); i != route_entries->end(); i++) {
|
171
174
|
e = rb_ary_new();
|
172
175
|
rb_ary_push(e, i->is_sub ? Qtrue : Qfalse);
|
173
176
|
rb_ary_push(e, i->scope);
|
@@ -227,7 +230,7 @@ static VALUE extract_ext(const char* s, long len) {
|
|
227
230
|
extern "C"
|
228
231
|
RouteResult nyara_lookup_route(enum http_method method_num, VALUE vpath, VALUE accept_arr) {
|
229
232
|
RouteResult r = {Qnil, Qnil, Qnil, Qnil};
|
230
|
-
|
233
|
+
MapIter map_iter = route_map.find(method_num);
|
231
234
|
if (map_iter == route_map.end()) {
|
232
235
|
return r;
|
233
236
|
}
|
@@ -237,7 +240,7 @@ RouteResult nyara_lookup_route(enum http_method method_num, VALUE vpath, VALUE a
|
|
237
240
|
long len = RSTRING_LEN(vpath);
|
238
241
|
// must iterate all
|
239
242
|
bool last_matched = false;
|
240
|
-
|
243
|
+
EntriesIter i = route_entries->begin();
|
241
244
|
for (; i != route_entries->end(); ++i) {
|
242
245
|
bool matched;
|
243
246
|
if (i->is_sub && last_matched) { // save a bit compare
|
data/lib/nyara/view.rb
CHANGED
@@ -79,8 +79,9 @@ module Nyara
|
|
79
79
|
if src
|
80
80
|
sig = @meth2sig[meth].map{|k| "#{k}: nil" }.join ','
|
81
81
|
sig = '_={}' if sig.empty?
|
82
|
+
sig = "(#{sig})" # 2.0.0-p0 requirement
|
82
83
|
Renderable.class_eval <<-RUBY, path, 1
|
83
|
-
def render
|
84
|
+
def render#{sig}
|
84
85
|
#{src}
|
85
86
|
end
|
86
87
|
alias :#{meth.inspect} render
|
data/nyara.gemspec
CHANGED
data/readme.md
CHANGED
@@ -13,8 +13,8 @@ Not Yet Another Ruby Async web framework and server.
|
|
13
13
|
Requirement
|
14
14
|
|
15
15
|
- BSD/Linux/Mac OS X
|
16
|
-
- Ruby 2.0.0
|
17
|
-
-
|
16
|
+
- Ruby 2.0.0 or higher
|
17
|
+
- GCC or Clang
|
18
18
|
|
19
19
|
Install
|
20
20
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nyara
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.pre.
|
4
|
+
version: 0.0.1.pre.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zete Lui
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Fast, slim and fuzzy ruby web framework + server, based on preforked
|
14
14
|
event queue and Fiber. NO rack NOR eventmachine are used.
|