nyny 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -2
- data/Performance.md +45 -39
- data/README.md +18 -14
- data/lib/nyny/request_scope.rb +0 -1
- data/lib/nyny/version.rb +1 -1
- data/nyny.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4590f5f6c66d42152fecc4f0749bfe4f198d6987
|
4
|
+
data.tar.gz: 799af0e6c6f79f90fa6ecf627a83d7e7f40e64bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1605466f98f71349ea745155617b54bcf91d245b92f878931457ffdffe7e44c55b348d280c20eeb84f73f6efbb4e4ee64bc4cbd203172d7ed6b8803b8930c31e
|
7
|
+
data.tar.gz: 28bb352a548d9eb62b759284c3cb153a624db86b640029fc318263c21ae5b1bc6f91df4c593895f32f7afb15d8588a2711c262db2a62b39a363e021ac418841d
|
data/Gemfile
CHANGED
data/Performance.md
CHANGED
@@ -20,48 +20,54 @@ See below the code for each benchmark
|
|
20
20
|
|
21
21
|
## Code
|
22
22
|
### Simple
|
23
|
+
```ruby
|
24
|
+
class App < NYNY::App #(or Sinatra::Base)
|
25
|
+
get '/' do
|
26
|
+
'Hello World!'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
```
|
23
30
|
|
24
|
-
class App < NYNY::App #(or Sinatra::Base)
|
25
|
-
get '/' do
|
26
|
-
'Hello World!'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
31
|
### UrlPattern
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
```ruby
|
33
|
+
class App < NYNY::App #(or Sinatra::Base)
|
34
|
+
get '/hello/:name' do
|
35
|
+
"Hello #{params[:name]}!"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
```
|
36
39
|
|
37
40
|
### Filters
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
41
|
+
```ruby
|
42
|
+
class App < NYNY::App #(or Sinatra::Base)
|
43
|
+
before do
|
44
|
+
request
|
45
|
+
end
|
46
|
+
|
47
|
+
after do
|
48
|
+
response
|
49
|
+
end
|
50
|
+
|
51
|
+
get '/' do
|
52
|
+
'Hello World!'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
```
|
56
|
+
|
52
57
|
### Helpers
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
get '/' do
|
63
|
-
da_request_man
|
64
|
-
'Hello World!'
|
65
|
-
end
|
66
|
-
end
|
58
|
+
```ruby
|
59
|
+
module Dude
|
60
|
+
def da_request_man
|
61
|
+
request
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class App < NYNY::App #(or Sinatra::Base)
|
66
|
+
helpers Dude
|
67
67
|
|
68
|
+
get '/' do
|
69
|
+
da_request_man
|
70
|
+
'Hello World!'
|
71
|
+
end
|
72
|
+
end
|
73
|
+
```
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# New York, New York.
|
2
2
|
(very) small Sinatra clone.
|
3
3
|
|
4
|
-
![
|
4
|
+
[![Build Status](https://api.travis-ci.org/alisnic/nyny.png)](https://travis-ci.org/alisnic/nyny)
|
5
5
|
[![Coverage Status](https://coveralls.io/repos/alisnic/nyny/badge.png)](https://coveralls.io/r/alisnic/nyny)
|
6
6
|
[![Code Climate](https://codeclimate.com/repos/521b7ee513d637348712864a/badges/60e3637788bbac94f1cb/gpa.png)](https://codeclimate.com/repos/521b7ee513d637348712864a/feed)
|
7
7
|
|
@@ -18,13 +18,13 @@
|
|
18
18
|
|
19
19
|
Install the gem:
|
20
20
|
|
21
|
-
gem install nyny
|
21
|
+
gem install nyny
|
22
22
|
|
23
|
-
Run the file
|
23
|
+
Run the file:
|
24
24
|
|
25
25
|
ruby myapp.rb
|
26
26
|
|
27
|
-
Open the browser at [http://localhost:9292]()
|
27
|
+
Open the browser at [http://localhost:9292](http://localhost:9292)
|
28
28
|
|
29
29
|
- [TOP](#new-york-new-york)
|
30
30
|
- [Motivation](#motivation)
|
@@ -68,12 +68,12 @@ as middleware.
|
|
68
68
|
|
69
69
|
# Usage
|
70
70
|
|
71
|
-
A NYNY app must _always_ be in a class which inherits from `NYNY::App
|
71
|
+
A NYNY app must _always_ be in a class which inherits from `NYNY::App`:
|
72
72
|
|
73
73
|
class App < NYNY::App
|
74
|
-
|
75
|
-
|
76
|
-
|
74
|
+
get '/' do
|
75
|
+
'Hello, World'
|
76
|
+
end
|
77
77
|
end
|
78
78
|
|
79
79
|
## Running
|
@@ -82,14 +82,16 @@ There are two ways to run a NYNY app __directly__ [[?]](#middleware):
|
|
82
82
|
- by requiring it in a `config.ru` file, and then passing it as argument to the
|
83
83
|
Rack's `run` function:
|
84
84
|
|
85
|
-
#config.ru
|
85
|
+
# config.ru
|
86
|
+
|
86
87
|
require 'app'
|
87
88
|
run App.new
|
88
89
|
|
89
90
|
- by using the `run!` method directly on the app class:
|
90
91
|
|
91
|
-
#app.rb
|
92
|
-
|
92
|
+
# app.rb
|
93
|
+
|
94
|
+
# ...app class definition...
|
93
95
|
|
94
96
|
App.run!
|
95
97
|
|
@@ -115,7 +117,7 @@ NYNY also suports basic URL patterns:
|
|
115
117
|
|
116
118
|
class App < NYNY::App
|
117
119
|
get '/greet/:first_name/:last_name' do
|
118
|
-
#
|
120
|
+
# the last expression in the block is _always_ considered the response body.
|
119
121
|
"Hello #{params[:first_name]} #{params[:last_name]}!"
|
120
122
|
end
|
121
123
|
end
|
@@ -148,6 +150,8 @@ This means that several methods/objects available inside that block:
|
|
148
150
|
(ex: `cookies[:foo] = 'bar'`)
|
149
151
|
- `session` - a hash which allows you to access/modify/remove session variables
|
150
152
|
(ex: `session[:foo] = 'bar'`)
|
153
|
+
- `halt` - allows you to instantly return a response, interrupting current
|
154
|
+
handler execution (see [halt][halt-definition])
|
151
155
|
|
152
156
|
## Filters
|
153
157
|
|
@@ -188,7 +192,7 @@ NYNY also supports middleware itself, and that means you can use Rack middleware
|
|
188
192
|
(or a Sinatra app) inside a NYNY app:
|
189
193
|
|
190
194
|
class App < NYNY::App
|
191
|
-
#this will serve all the files in the "public" folder
|
195
|
+
# this will serve all the files in the "public" folder
|
192
196
|
use Rack::Static :url => ['public']
|
193
197
|
use SinatraApp
|
194
198
|
end
|
@@ -210,7 +214,6 @@ definition block.
|
|
210
214
|
# F. A. Q.
|
211
215
|
TBD.
|
212
216
|
|
213
|
-
|
214
217
|
# Contributing
|
215
218
|
|
216
219
|
1. Fork it
|
@@ -226,3 +229,4 @@ TBD.
|
|
226
229
|
[4]: http://rack.rubyforge.org/doc/classes/Rack/Response.html
|
227
230
|
[performance]: https://github.com/alisnic/nyny/blob/master/Performance.md
|
228
231
|
[rack-middleware]: https://github.com/rack/rack/wiki/List-of-Middleware
|
232
|
+
[halt-definition]: https://github.com/alisnic/nyny/blob/master/lib/nyny/request_scope.rb#L36
|
data/lib/nyny/request_scope.rb
CHANGED
data/lib/nyny/version.rb
CHANGED
data/nyny.gemspec
CHANGED
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.add_dependency "rack"
|
21
22
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
23
|
spec.add_development_dependency "rake"
|
23
24
|
spec.add_development_dependency "rspec"
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nyny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrei Lisnic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rack
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|