nyara 0.0.1.pre.9 → 0.1.pre.0
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/bin/nyara +3 -3
- data/changes +1 -0
- data/ext/event.c +16 -22
- data/ext/hashes.c +222 -4
- data/ext/inc/rdtsc.h +56 -0
- data/ext/inc/status_codes.inc +64 -0
- data/ext/inc/version.inc +1 -1
- data/ext/nyara.c +12 -10
- data/ext/nyara.h +5 -5
- data/ext/request.c +18 -24
- data/ext/request_parse.c +1 -1
- data/ext/route.cc +2 -4
- data/ext/url_encoded.c +51 -193
- data/lib/nyara/command.rb +39 -12
- data/lib/nyara/config.rb +10 -10
- data/lib/nyara/controller.rb +60 -14
- data/lib/nyara/cookie.rb +1 -1
- data/lib/nyara/hashes/config_hash.rb +2 -24
- data/lib/nyara/nyara.rb +33 -19
- data/lib/nyara/part.rb +7 -3
- data/lib/nyara/reload.rb +85 -0
- data/lib/nyara/request.rb +1 -1
- data/lib/nyara/route.rb +55 -19
- data/lib/nyara/templates/Gemfile +10 -1
- data/lib/nyara/templates/Rakefile +6 -1
- data/lib/nyara/templates/app/controllers/application_controller.rb +3 -0
- data/lib/nyara/templates/app/controllers/welcome_controller.rb +5 -0
- data/lib/nyara/templates/app/views/layouts/application.erb +12 -0
- data/lib/nyara/templates/app/views/welcome/index.erb +1 -0
- data/lib/nyara/templates/config/application.rb +34 -0
- data/lib/nyara/templates/config/boot.rb +4 -0
- data/lib/nyara/templates/config/development.rb +5 -0
- data/lib/nyara/templates/config/production.rb +8 -0
- data/lib/nyara/templates/config/test.rb +2 -0
- data/lib/nyara/templates/public/css/app.css +1 -0
- data/lib/nyara/templates/public/js/app.js +1 -0
- data/lib/nyara/templates/spec/spec_helper.rb +9 -0
- data/lib/nyara/test.rb +10 -2
- data/lib/nyara/view.rb +116 -67
- data/nyara.gemspec +3 -1
- data/rakefile +1 -1
- data/readme.md +1 -1
- data/spec/command_spec.rb +28 -24
- data/spec/config_spec.rb +24 -1
- data/spec/dummy/app/controllers/dummy_controller.rb +2 -0
- data/spec/dummy/app/models/dmmy_model.rb +2 -0
- data/spec/evented_io_spec.rb +2 -1
- data/spec/ext_route_spec.rb +2 -2
- data/spec/flash_spec.rb +8 -0
- data/spec/hashes_spec.rb +127 -0
- data/spec/integration_spec.rb +15 -0
- data/spec/path_helper_spec.rb +17 -5
- data/spec/performance/escape.rb +15 -4
- data/spec/performance/layout_render.rb +15 -10
- data/spec/performance/parse_accept_value.rb +24 -8
- data/spec/performance/parse_param.rb +14 -8
- data/spec/performance/performance_helper.rb +8 -21
- data/spec/performance_spec.rb +5 -4
- data/spec/route_spec.rb +7 -2
- data/spec/url_encoded_spec.rb +18 -74
- data/spec/view_spec.rb +1 -3
- data/spec/views/_partial.slim +1 -0
- data/spec/views/_partial_with_yield.erb +1 -0
- metadata +73 -43
- data/example/factorial.rb +0 -19
- data/example/hello.rb +0 -5
- data/example/project.rb +0 -11
- data/example/stream.rb +0 -14
- data/lib/nyara/controllers/public_controller.rb +0 -14
- data/lib/nyara/templates/config/session.key +0 -1
- data/tools/bench-cookie.rb +0 -22
- data/tools/foo.rb +0 -9
- data/tools/hello.rb +0 -46
- data/tools/memcheck.rb +0 -33
- data/tools/s.rb +0 -11
data/example/factorial.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'nyara'
|
2
|
-
|
3
|
-
get '/factorial(%u)' do |n|
|
4
|
-
redirect_to '#product', 1, n
|
5
|
-
end
|
6
|
-
|
7
|
-
meta '#product'
|
8
|
-
get '/%u*factorial(%u)' do |product, n|
|
9
|
-
if n == 0
|
10
|
-
redirect_to '#result', product
|
11
|
-
else
|
12
|
-
redirect_to '#product', product * n, n - 1
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
meta '#result'
|
17
|
-
get '/%u' do |result|
|
18
|
-
send_string result
|
19
|
-
end
|
data/example/hello.rb
DELETED
data/example/project.rb
DELETED
data/example/stream.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
module Nyara
|
2
|
-
# serve public dir
|
3
|
-
class PublicController < Controller
|
4
|
-
get '/%z' do |path|
|
5
|
-
path = Config.public_path path
|
6
|
-
if path and File.file?(path)
|
7
|
-
send_file path
|
8
|
-
else
|
9
|
-
status 404
|
10
|
-
Ext.request_send_data request, "HTTP/1.1 404 Not Found\r\nConnection: close\r\nContent-Length: 0\r\n\r\n"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
<%= Nyara::Session.generate_key %>
|
data/tools/bench-cookie.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require_relative "../lib/nyara/nyara"
|
2
|
-
include Nyara
|
3
|
-
require "benchmark"
|
4
|
-
|
5
|
-
def cookie1 s
|
6
|
-
res = ParamHash.new
|
7
|
-
s.split(/[,;] */n).reverse_each do |seg|
|
8
|
-
Ext.parse_url_encoded_seg res, seg, false
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def cookie2 s
|
13
|
-
res = ParamHash.new
|
14
|
-
Ext.parse_cookie res, s
|
15
|
-
end
|
16
|
-
|
17
|
-
history = CGI.escape '历史'
|
18
|
-
s = "pgv_pvi; pgv_si=; pgv_pvi=som; sid=1d6c75f0 ; PLHistory=<#{history}>;"
|
19
|
-
|
20
|
-
puts Benchmark.measure{ 1000.times{cookie1 s} }
|
21
|
-
puts Benchmark.measure{ 1000.times{cookie2 s} }
|
22
|
-
# cookie2 should be faster
|
data/tools/foo.rb
DELETED
data/tools/hello.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
require_relative "../lib/nyara/nyara"
|
2
|
-
# require "open-uri"
|
3
|
-
require "pry"
|
4
|
-
|
5
|
-
configure do
|
6
|
-
# set :env, 'production'
|
7
|
-
# set :workers, 3
|
8
|
-
map '/', 'my'
|
9
|
-
# set :logger, false
|
10
|
-
end
|
11
|
-
|
12
|
-
class MyController < Nyara::Controller
|
13
|
-
get '/' do
|
14
|
-
p param
|
15
|
-
send_string 'hello world'
|
16
|
-
end
|
17
|
-
|
18
|
-
get '/exit' do
|
19
|
-
exit
|
20
|
-
end
|
21
|
-
|
22
|
-
get '/form' do
|
23
|
-
send_string <<-HTML
|
24
|
-
<form action="/form" enctype="multipart/form-data" method="post" accept-charset="utf-8">
|
25
|
-
bar
|
26
|
-
<input type="file" name="bar">
|
27
|
-
<br>
|
28
|
-
baz
|
29
|
-
<input type="file" name="baz[你好]">
|
30
|
-
<br>
|
31
|
-
foo<input name="foo">
|
32
|
-
<br>
|
33
|
-
</form>
|
34
|
-
HTML
|
35
|
-
end
|
36
|
-
|
37
|
-
post '/form' do
|
38
|
-
b = request.body
|
39
|
-
binding.pry
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
Nyara.setup
|
44
|
-
Nyara.start_server
|
45
|
-
|
46
|
-
# GC.stress = true
|
data/tools/memcheck.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require_relative "../lib/nyara/nyara"
|
2
|
-
|
3
|
-
module Nyara
|
4
|
-
class SimpleController < Controller
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
%w[on tag get post put delete patch options].each do |m|
|
9
|
-
eval <<-RUBY
|
10
|
-
def #{m} *xs, &blk
|
11
|
-
Nyara::SimpleController.#{m} *xs, &blk
|
12
|
-
end
|
13
|
-
RUBY
|
14
|
-
end
|
15
|
-
|
16
|
-
configure do
|
17
|
-
map '/', 'nyara::simple'
|
18
|
-
end
|
19
|
-
|
20
|
-
get '/' do
|
21
|
-
send_string 'hello world'
|
22
|
-
end
|
23
|
-
|
24
|
-
get '/gc' do
|
25
|
-
GC.stress = true
|
26
|
-
end
|
27
|
-
|
28
|
-
get '/ngc' do
|
29
|
-
GC.stress = false
|
30
|
-
end
|
31
|
-
|
32
|
-
Nyara.setup
|
33
|
-
Nyara.start_server
|