nyny 3.4.2 → 3.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39c4e5e1013febaf7a0b8d40202c2e2cbc481e6f
4
- data.tar.gz: b2144b7cb42eaaa5135e2042b357b258df86765a
3
+ metadata.gz: 0cd8ab47b272401fcc5e5a7f719c57a041f0f662
4
+ data.tar.gz: 22e425e40965eb74639305d03305295bbf8034ee
5
5
  SHA512:
6
- metadata.gz: 52e7699ecb41b50e5b8ac23cc7bd05b684b8a9c1df1cd7d8bc7b1374f261c1a2e406bec1038380e9dd8037342923d04188fa7d7852f79eef669b5a38eee41b73
7
- data.tar.gz: 00b60be3b8df426424a3b6baae0bf52fdf7b7e07887933ebdc3f348754b39a7e6acd018c95071f56d7d5322dddb138767f58851e0489420afb0052d06926b81f
6
+ metadata.gz: dcdbbbb3939394d04021a4f75fecf17c38735f8c4c1c4ed02568c7e8bbb37b5949d96b633d8f76a20d3bf949db61733f4eac1d07bc7160b3af6b4b878f6e4f01
7
+ data.tar.gz: 7a725faaf6a0f455e3a0d9e15816ba0f2756ac924ba9684f2daca33b5653886bf9c04cb0c204fd9fe163cbed32825187b1c986a252211a25ea24e1c94b985464
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ 3.4.3
2
+ - Do not use Rack::Chunked by default, leave the option to the user
3
+ - Expose Rack's map method for low level url mapping
4
+ - Bump ActionPack dependency
5
+
6
+ 3.4.2
7
+ - Add support for passing an app directly to the namespace
8
+
1
9
  3.4.1
2
10
  - Fix a bug when a NYNY app is used inside a namespace
3
11
 
data/README.md CHANGED
@@ -6,6 +6,15 @@
6
6
  [![Code Climate](https://codeclimate.com/repos/521b7ee513d637348712864a/badges/60e3637788bbac94f1cb/gpa.png)](https://codeclimate.com/repos/521b7ee513d637348712864a/feed)
7
7
  [![Gem Version](https://badge.fury.io/rb/nyny.png)](http://badge.fury.io/rb/nyny)
8
8
 
9
+ Install the gem:
10
+
11
+ ```bash
12
+ gem install nyny
13
+ ```
14
+
15
+ Create the `myapp.rb` file:
16
+
17
+
9
18
  ```ruby
10
19
  # myapp.rb
11
20
 
@@ -19,12 +28,6 @@ end
19
28
  App.run!
20
29
  ```
21
30
 
22
- Install the gem:
23
-
24
- ```bash
25
- gem install nyny
26
- ```
27
-
28
31
  Run the file:
29
32
 
30
33
  ```bash
@@ -43,6 +46,7 @@ Open the browser at [http://localhost:9292](http://localhost:9292)
43
46
  - [Running](#running)
44
47
  - [Defining routes](#defining-routes)
45
48
  - [Request scope](#request-scope)
49
+ - [Maps](#maps)
46
50
  - [Namespaces](#namespaces)
47
51
  - [Templates](#templates)
48
52
  - [Filters](#filters)
@@ -256,6 +260,29 @@ This means that several methods/objects available inside that block:
256
260
  - `halt` - allows you to instantly return a response, interrupting current
257
261
  handler execution (see [halt][halt-definition])
258
262
 
263
+ ## Maps
264
+ NYNY uses a Rack::Builder underneath to generate a proper Rack app when it is
265
+ being run. Because of that, NYNY exposes the Builder's `map` method to allow
266
+ fine grained low-level url mapping. The most common use case for that is to
267
+ integrate sprockets into a NYNY app:
268
+
269
+ ```ruby
270
+ class AppWithAsses < NYNY::App
271
+ map '/assets' do
272
+ environment = Sprockets::Environment.new
273
+ environment.append_path 'app/assets/javascripts'
274
+ environment.append_path 'app/assets/stylesheets'
275
+ run environment
276
+ end
277
+
278
+ get '/' do
279
+ 'hello'
280
+ end
281
+ ```
282
+
283
+ Please note that none of the NYNY's routing helpers are being exposed in a
284
+ map block, the block gets executed in the context of a `Rack::Builder`
285
+ (stuff you're used to see in a config.ru file)
259
286
 
260
287
  ## Namespaces
261
288
  You can define namespaces for routes in NYNY. Each namespace is an isolated
@@ -7,7 +7,6 @@ module NYNY
7
7
  class App < Base
8
8
  inheritable :config, OpenStruct.new
9
9
  register NYNY::Templates
10
- use Rack::Chunked
11
10
 
12
11
  class << self
13
12
  def configure *envs, &block
@@ -16,7 +16,7 @@ module NYNY
16
16
  inheritable :after_init_hooks, []
17
17
  inheritable :default_constraints, {}
18
18
  inheritable :middlewares, []
19
- inheritable :map, {}
19
+ inheritable :url_map, {}
20
20
 
21
21
  def initialize app=nil
22
22
  self.class.before_init_hooks.each {|h| h.call(self)}
@@ -37,7 +37,7 @@ module NYNY
37
37
  def initialize_builder
38
38
  builder = Rack::Builder.new
39
39
  self.class.middlewares.each { |m, args, blk| builder.use m, *args, &blk }
40
- self.class.map.each {|url, klass| builder.map(url) { use klass } }
40
+ self.class.url_map.each {|url, block| builder.map(url, &block) }
41
41
  builder
42
42
  end
43
43
 
@@ -55,6 +55,10 @@ module NYNY
55
55
  end
56
56
  end
57
57
 
58
+ def map url, &block
59
+ url_map[url] = block
60
+ end
61
+
58
62
  def namespace url, app=nil, &block
59
63
  scope = self.scope_class
60
64
 
@@ -63,7 +67,7 @@ module NYNY
63
67
  class_eval(&block)
64
68
  end
65
69
 
66
- map[url] = app
70
+ map (url) { use app }
67
71
  end
68
72
 
69
73
  def define_route path, options, &block
@@ -1,3 +1,3 @@
1
1
  module NYNY
2
- VERSION = "3.4.2"
2
+ VERSION = "3.4.3"
3
3
  end
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_dependency "rack-contrib", "~> 1.1.0"
22
22
  spec.add_dependency "tilt", "~> 1.4.1"
23
23
  spec.add_dependency "better_errors", "~> 1.1.0"
24
- spec.add_dependency "actionpack", "~> 4.0.2"
24
+ spec.add_dependency "actionpack", "~> 4.1.6"
25
25
  spec.add_development_dependency "bundler", "~> 1.3"
26
26
  spec.add_development_dependency "rake"
27
27
  spec.add_development_dependency "rspec", "~> 2.14.1"
@@ -14,6 +14,21 @@ describe App do
14
14
  res[2].should respond_to(:each)
15
15
  end
16
16
 
17
+ it 'can use the builder map method' do
18
+ app = mock_app do
19
+ map '/map' do
20
+ run lambda {|env| [200, {}, ["map"]]}
21
+ end
22
+
23
+ get '/' do
24
+ 'root'
25
+ end
26
+ end
27
+
28
+ app.get('/').body.should == 'root'
29
+ app.get('/map').body.should == 'map'
30
+ end
31
+
17
32
  it 'should return 404 for non-matched routes' do
18
33
  response = app.get random_url
19
34
  response.status.should == 404
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.2
4
+ version: 3.4.3
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-08-15 00:00:00.000000000 Z
11
+ date: 2014-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack-contrib
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 4.0.2
61
+ version: 4.1.6
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 4.0.2
68
+ version: 4.1.6
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement