nyny 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +3 -0
- data/README.md +27 -19
- data/lib/nyny/router.rb +7 -5
- data/lib/nyny/version.rb +1 -1
- data/spec/router_spec.rb +21 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eefb757442e7e6fee6409340e2764aaf6f561481
|
4
|
+
data.tar.gz: 43d71751f9f6563bdf36c86058b2b122e22ff528
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a99b05e35b1e634dc51a4351d19291a41020e31a81a1a592bfc623755833008422bfa77b020fe6b9372cf94f23d3ad8afdb8b485bf8a2105edcf9c15d8372fd1
|
7
|
+
data.tar.gz: c7cf0199e55dec48be37d4ef923058cc0ed25b61fc70c31bbc1683d7e1cd64633ca5066432cc7de69da3dcc357dbde973bc0de6ed4895d9644a53e57949aea52
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -7,25 +7,31 @@
|
|
7
7
|
[![Dependency Status](https://gemnasium.com/alisnic/nyny.png)](https://gemnasium.com/alisnic/nyny)
|
8
8
|
[![Gem Version](https://badge.fury.io/rb/nyny.png)](http://badge.fury.io/rb/nyny)
|
9
9
|
|
10
|
-
|
10
|
+
```ruby
|
11
|
+
# myapp.rb
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
require 'nyny'
|
14
|
+
class App < NYNY::App
|
15
|
+
get '/' do
|
16
|
+
'Hello world!'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
App.run!
|
21
|
+
```
|
18
22
|
|
19
|
-
App.run!
|
20
|
-
|
21
23
|
Install the gem:
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
+
```bash
|
26
|
+
gem install nyny
|
27
|
+
```
|
28
|
+
|
25
29
|
Run the file:
|
26
|
-
|
27
|
-
|
28
|
-
|
30
|
+
|
31
|
+
```bash
|
32
|
+
ruby myapp.rb
|
33
|
+
```
|
34
|
+
|
29
35
|
Open the browser at [http://localhost:9292](http://localhost:9292)
|
30
36
|
|
31
37
|
- [TOP](#new-york-new-york)
|
@@ -74,11 +80,13 @@ as middleware.
|
|
74
80
|
|
75
81
|
A NYNY app must _always_ be in a class which inherits from `NYNY::App`:
|
76
82
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
83
|
+
```ruby
|
84
|
+
class App < NYNY::App
|
85
|
+
get '/' do
|
86
|
+
'Hello, World'
|
87
|
+
end
|
88
|
+
end
|
89
|
+
```
|
82
90
|
|
83
91
|
## Environment
|
84
92
|
To get the directory in which your app is running use `NYNY.root`
|
data/lib/nyny/router.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
module NYNY
|
2
2
|
class Router
|
3
|
-
NullHandler = Class.new
|
4
|
-
|
5
3
|
attr_reader :fallback, :routes, :before_hooks, :after_hooks
|
6
4
|
def initialize options
|
7
5
|
@fallback = options[:fallback]
|
@@ -30,12 +28,16 @@ module NYNY
|
|
30
28
|
end
|
31
29
|
|
32
30
|
def eval_response scope, handler
|
33
|
-
catch (:halt) do
|
31
|
+
response = catch (:halt) do
|
34
32
|
before_hooks.each {|h| scope.instance_eval &h }
|
35
|
-
|
33
|
+
scope.apply_to &handler
|
34
|
+
end
|
35
|
+
|
36
|
+
catch (:halt) do
|
36
37
|
after_hooks.each {|h| scope.instance_eval &h }
|
37
|
-
response
|
38
38
|
end
|
39
|
+
|
40
|
+
response
|
39
41
|
end
|
40
42
|
end
|
41
43
|
end
|
data/lib/nyny/version.rb
CHANGED
data/spec/router_spec.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Router do
|
4
|
+
let (:app) do
|
5
|
+
mock_app do
|
6
|
+
get '/' do
|
7
|
+
halt 200, {}, "Bar"
|
8
|
+
"Foo"
|
9
|
+
end
|
10
|
+
|
11
|
+
after do
|
12
|
+
response.body = "Zaz"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should eval after blocks even if the request was halted" do
|
18
|
+
response = app.get('/')
|
19
|
+
response.body.should == "Zaz"
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nyny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
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-10-
|
11
|
+
date: 2013-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- spec/nyny_spec.rb
|
99
99
|
- spec/primitives_spec.rb
|
100
100
|
- spec/request_scope_spec.rb
|
101
|
+
- spec/router_spec.rb
|
101
102
|
- spec/runner_spec.rb
|
102
103
|
- spec/spec_helper.rb
|
103
104
|
homepage: http://alisnic.github.io/nyny/
|
@@ -120,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
121
|
version: '0'
|
121
122
|
requirements: []
|
122
123
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.
|
124
|
+
rubygems_version: 2.1.9
|
124
125
|
signing_key:
|
125
126
|
specification_version: 4
|
126
127
|
summary: New York, New York.
|
@@ -129,5 +130,6 @@ test_files:
|
|
129
130
|
- spec/nyny_spec.rb
|
130
131
|
- spec/primitives_spec.rb
|
131
132
|
- spec/request_scope_spec.rb
|
133
|
+
- spec/router_spec.rb
|
132
134
|
- spec/runner_spec.rb
|
133
135
|
- spec/spec_helper.rb
|