nyny 3.3.1 → 3.4.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/CHANGELOG +58 -54
- data/README.md +22 -5
- data/lib/nyny/app.rb +1 -1
- data/lib/nyny/base.rb +9 -1
- data/lib/nyny/router.rb +3 -2
- data/lib/nyny/version.rb +1 -1
- data/nyny.gemspec +1 -1
- data/spec/app_spec.rb +17 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76cdf68418dfc6310bff3b868bd2c9c170f758e4
|
4
|
+
data.tar.gz: c2b1c2e3bfa9b35ff82f471d4e05e47bc75d162f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8c96d40213a62519ffa4e68bfe545b252ce93dcf8f0f5548941fb3169dc86b89e1c3c257ed1e5e33bef452c0fae90b2dd22bda1f07398602c767d85f422fda1
|
7
|
+
data.tar.gz: 2ea78edc573c77a82cdf6431c456710aa50d0d38721bd7298396a4bfe28fa9bdd0a1b169600e6d4bb4e11901374548eb6d4b33338efb2bea8160cb2eb6475702
|
data/CHANGELOG
CHANGED
@@ -1,81 +1,85 @@
|
|
1
|
+
3.4.0
|
2
|
+
- Fix constraint matching
|
3
|
+
- Add constraints class method to group constraints
|
4
|
+
|
1
5
|
3.3.1
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
+
- if the response of the route is a enumerable, NYNY will try to
|
7
|
+
send it in chunks (given that both the client and the server support it)
|
8
|
+
- NYNY::Base for those who love the barebone (lacks config, namespaces,
|
9
|
+
templates, and run!)
|
6
10
|
|
7
11
|
3.3.0
|
8
|
-
|
9
|
-
|
10
|
-
|
12
|
+
- App.config
|
13
|
+
- before_initialize hooks
|
14
|
+
- after_initialize hooks
|
11
15
|
|
12
16
|
3.2.2
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
- Use Journey directly from ActionDispatch, since rails/journey is obsolete
|
18
|
+
- Fix indifferent nested params
|
19
|
+
- Make helpers accessible inside namespaces
|
20
|
+
- Fix namespaces inheritance behaviour
|
17
21
|
|
18
22
|
3.2.1
|
19
|
-
|
20
|
-
|
21
|
-
|
23
|
+
- Fallback to Tilt 1.4.1 since 2.0.0 has conflicts with a lot
|
24
|
+
of gems
|
25
|
+
- Improved and fixed the outdated examples
|
22
26
|
|
23
27
|
3.2.0
|
24
|
-
|
25
|
-
|
28
|
+
- Use Rails' Journey router as router to conquer the world and shorten
|
29
|
+
the codebase
|
26
30
|
|
27
31
|
3.1.0
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
- use latest Tilt (2.0.0)
|
33
|
+
- get rid of silly Rack::Response hacks, write to body properly
|
34
|
+
- Response#rewrite (body= aliases it for backward compatibility)
|
35
|
+
- Refactor .run! implementation, prefer thin, webrik.
|
36
|
+
- NYNY now ships with better_errors, which is only enabled in development
|
37
|
+
- Fixed builder instanciation logic
|
38
|
+
- removed benchmark script, since tilt dep version is not compatible with
|
39
|
+
Sinatra
|
36
40
|
|
37
41
|
3.0.1
|
38
|
-
|
42
|
+
- File SystemStackError when accessing missing param (@holies)
|
39
43
|
|
40
44
|
3.0.0
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
45
|
+
- Use Rack builder to shorten and simplify the code
|
46
|
+
- Add support for namespaces by using the builder
|
47
|
+
- Add ruby-prof as a development dependency
|
48
|
+
- NYNY will return a Rack-like response on each request ([status, headers, body])
|
49
|
+
- headers behave like a hash
|
50
|
+
- cookies behave like a hash
|
51
|
+
- added sprockets integration example
|
52
|
+
- improved documentation
|
53
|
+
- Fixed inheritance behaviour for App (routes, filters, helpers, middlewares
|
54
|
+
will be passed down the inheritance chain)
|
51
55
|
|
52
56
|
2.2.1
|
53
|
-
|
57
|
+
- Added support for templates
|
54
58
|
|
55
59
|
2.1.1
|
56
|
-
|
60
|
+
- After blocks will now be evaluated even if the request was halted
|
57
61
|
|
58
62
|
2.1.0
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
63
|
+
- Add ability to define helpers with a block
|
64
|
+
- Remove benchmark folder, and create a single benchmark file which can be
|
65
|
+
executed easily
|
66
|
+
- Simplified and optimized routing logic
|
67
|
+
- Fixed root path processing when a NYNY app is mounted
|
68
|
+
- Added Rails interop example
|
69
|
+
- Added session example
|
70
|
+
- Added NYNY.root
|
71
|
+
- Added NYNY.env
|
72
|
+
- NYNY will not show exceptions in production env
|
69
73
|
|
70
74
|
2.0.0
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
75
|
+
- Simplified and improved RouteSignature implementation
|
76
|
+
- Simplified and improved RequestScope implementation
|
77
|
+
- Made response object available in RequestScope
|
78
|
+
- removed .use_protection! (the rack-protection middleware can be easily
|
79
|
+
used manually)
|
80
|
+
- added support for extensions (using .register, which works the same way as in sinatra)
|
77
81
|
|
78
82
|
1.0.2
|
79
|
-
|
83
|
+
- Add rack to runtime deps (@etehtsea)
|
80
84
|
|
81
85
|
1.0.0 Initial release
|
data/README.md
CHANGED
@@ -108,7 +108,7 @@ true
|
|
108
108
|
## Configuration
|
109
109
|
You can configure your app by attaching arbitrary properties to config object:
|
110
110
|
```ruby
|
111
|
-
class App
|
111
|
+
class App < NYNY::App
|
112
112
|
config.foo = 'bar'
|
113
113
|
end
|
114
114
|
|
@@ -197,12 +197,31 @@ Each route definition call optionally accepts constraints:
|
|
197
197
|
|
198
198
|
```ruby
|
199
199
|
class App < NYNY::App
|
200
|
-
get '/', :constraints => {:
|
200
|
+
get '/', :constraints => {:content_type => 'text/html'} do
|
201
201
|
'html'
|
202
202
|
end
|
203
203
|
end
|
204
204
|
```
|
205
|
-
|
205
|
+
|
206
|
+
What are constraints? Constraints are assertions on the request object.
|
207
|
+
That means that the route from above will match only if
|
208
|
+
`request.content_type` is 'text/html'.
|
209
|
+
|
210
|
+
To group multiple routes for a single constraint, use the constraints block:
|
211
|
+
|
212
|
+
``ruby
|
213
|
+
class App < NYNY::App
|
214
|
+
constraints :content_type => 'text/html' do
|
215
|
+
get '/' do
|
216
|
+
'html'
|
217
|
+
end
|
218
|
+
|
219
|
+
get '/foo' do
|
220
|
+
'foo html'
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
```
|
206
225
|
|
207
226
|
Besides the constraints, you can specify defaults:
|
208
227
|
```ruby
|
@@ -224,8 +243,6 @@ This means that several methods/objects available inside that block:
|
|
224
243
|
- `request` - A `Rack::Request` object which encapsulates the request
|
225
244
|
to that route. (see [Rack::Request documentation][3] for more info)
|
226
245
|
- `response` - A `Rack::Response` object which encapsulates the response.
|
227
|
-
Additionally, NYNY's response exposes 2 more methods in addition to Rack's ones.
|
228
|
-
(see [primitives.rb][primitivesrb])
|
229
246
|
- `params` - a hash which contains both POST body params and GET querystring params.
|
230
247
|
- `headers` - a hash with the response headers
|
231
248
|
(ex: `headers['Content-Type'] = 'text/html'`)
|
data/lib/nyny/app.rb
CHANGED
data/lib/nyny/base.rb
CHANGED
@@ -15,6 +15,7 @@ module NYNY
|
|
15
15
|
inheritable :after_hooks, []
|
16
16
|
inheritable :before_init_hooks, []
|
17
17
|
inheritable :after_init_hooks, []
|
18
|
+
inheritable :default_constraints, {}
|
18
19
|
|
19
20
|
def initialize app=nil
|
20
21
|
self.class.before_init_hooks.each {|h| h.call(self)}
|
@@ -39,7 +40,7 @@ module NYNY
|
|
39
40
|
class << self
|
40
41
|
HTTP_VERBS.each do |method|
|
41
42
|
define_method method do |path, options={}, &block|
|
42
|
-
options[:constraints]
|
43
|
+
options[:constraints] = default_constraints.merge(options[:constraints] || {})
|
43
44
|
options[:constraints].merge!(:request_method => method.to_s.upcase)
|
44
45
|
define_route path, options, &block
|
45
46
|
end
|
@@ -49,6 +50,13 @@ module NYNY
|
|
49
50
|
self.route_defs << [path, options, Proc.new(&block)]
|
50
51
|
end
|
51
52
|
|
53
|
+
def constraints args, &block
|
54
|
+
current = self.default_constraints.dup
|
55
|
+
self.default_constraints = args
|
56
|
+
instance_eval &block
|
57
|
+
self.default_constraints = current
|
58
|
+
end
|
59
|
+
|
52
60
|
def before &blk
|
53
61
|
before_hooks << Proc.new(&blk)
|
54
62
|
end
|
data/lib/nyny/router.rb
CHANGED
@@ -29,7 +29,8 @@ module NYNY
|
|
29
29
|
def prepare_for_journey route_defs
|
30
30
|
routes = ActionDispatch::Journey::Routes.new
|
31
31
|
@journey = ActionDispatch::Journey::Router.new(routes, {
|
32
|
-
:parameters_key => 'nyny.params'
|
32
|
+
:parameters_key => 'nyny.params',
|
33
|
+
:request_class => NYNY::Request
|
33
34
|
})
|
34
35
|
|
35
36
|
route_defs.each do |path, options, handler|
|
@@ -58,4 +59,4 @@ module NYNY
|
|
58
59
|
end
|
59
60
|
end
|
60
61
|
end
|
61
|
-
end
|
62
|
+
end
|
data/lib/nyny/version.rb
CHANGED
data/nyny.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = NYNY::VERSION
|
9
9
|
spec.authors = ["Andrei Lisnic"]
|
10
10
|
spec.email = ["andrei.lisnic@gmail.com"]
|
11
|
-
spec.description = %q{New York, New York - (
|
11
|
+
spec.description = %q{New York, New York - a (ridiculously) small and powerful web framework.}
|
12
12
|
spec.summary = %q{New York, New York.}
|
13
13
|
spec.homepage = "http://alisnic.github.io/nyny/"
|
14
14
|
spec.license = "MIT"
|
data/spec/app_spec.rb
CHANGED
@@ -19,6 +19,23 @@ describe App do
|
|
19
19
|
response.status.should == 404
|
20
20
|
end
|
21
21
|
|
22
|
+
it 'can use constraints block' do
|
23
|
+
app = mock_app do
|
24
|
+
constraints :content_type => 'text/html' do
|
25
|
+
get '/' do
|
26
|
+
'HTML!'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
get '/' do
|
31
|
+
'not html'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
app.get('/').body.should == 'not html'
|
36
|
+
app.get('/', 'CONTENT_TYPE' => 'text/html').body.should == 'HTML!'
|
37
|
+
end
|
38
|
+
|
22
39
|
it 'should able to register a extension' do
|
23
40
|
module Foo
|
24
41
|
def foo
|
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: 3.
|
4
|
+
version: 3.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrei Lisnic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack-contrib
|
@@ -108,7 +108,7 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
-
description: New York, New York - (
|
111
|
+
description: New York, New York - a (ridiculously) small and powerful web framework.
|
112
112
|
email:
|
113
113
|
- andrei.lisnic@gmail.com
|
114
114
|
executables: []
|
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
166
|
version: '0'
|
167
167
|
requirements: []
|
168
168
|
rubyforge_project:
|
169
|
-
rubygems_version: 2.2.
|
169
|
+
rubygems_version: 2.2.2
|
170
170
|
signing_key:
|
171
171
|
specification_version: 4
|
172
172
|
summary: New York, New York.
|