nyny 3.2.1 → 3.2.2

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: c200e1b2ab1e25cdb91af8dddd999ec3af0d254f
4
- data.tar.gz: d42091221d9fab3e6f6a5999ac9b43cc2758fa95
3
+ metadata.gz: 64027ca973fda52e94edacef4d3570f8e78a6e8c
4
+ data.tar.gz: 47763de06fb5ffb12babdcc07d7ad0ab61ff86a0
5
5
  SHA512:
6
- metadata.gz: be4f674778d164ec515061a2ef5f2ec2e855999fa908113b51d2b4a28e4478055764757c50b1ebf939dc1af8e38917e65cceefcacc9aedbad4054de9157a6c77
7
- data.tar.gz: 3f9750100ec7671af67eebb2bf08ae834ddda3ab6853314a56f07e1db2fc4fc52685780b884cfaca0c0ce5a3a409f0927d7d2044de3e230b4dfe9f477f847b51
6
+ metadata.gz: 72a4aaad4c7473ec7b680ff1f52cf490084cf88d969a960f976bf7d79b854e2dc19ff63fadf968af9fd0a94d54046bedfb430e1b368e61c3621502bb29ec80eb
7
+ data.tar.gz: 3a81393aa445660e1105fecbc2002f8802c27c571d239621cb8a9bdc6041c06e5ad5037922a2a01232a4b6a83aea50de7ed410364bf04f189369e8e220822526
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ 3.2.2
2
+ - Use Journey directly from ActionDispatch, since rails/journey is obsolete
3
+ - Fix indifferent nested params
4
+ - Make helpers accessible inside namespaces
5
+ - Fix namespaces inheritance behaviour
6
+
1
7
  3.2.1
2
8
  - Fallback to Tilt 1.4.1 since 2.0.0 has conflicts with a lot
3
9
  of gems
data/lib/nyny/app.rb CHANGED
@@ -66,8 +66,15 @@ module NYNY
66
66
  end
67
67
 
68
68
  def namespace url, &block
69
- app = Class.new(NYNY::App, &block)
70
- builder.map (url) { use app }
69
+ scope = self.scope_class
70
+ parent = self.superclass
71
+
72
+ klass = Class.new parent do
73
+ self.scope_class = scope
74
+ class_eval(&block)
75
+ end
76
+
77
+ builder.map (url) { use klass }
71
78
  end
72
79
 
73
80
  def before &blk
@@ -1,5 +1,10 @@
1
+ require 'active_support/hash_with_indifferent_access'
2
+
1
3
  module NYNY
2
4
  class Request < Rack::Request
5
+ def params
6
+ @params ||= ActiveSupport::HashWithIndifferentAccess.new(super)
7
+ end
3
8
  end
4
9
 
5
10
  class Response < Rack::Response
@@ -6,11 +6,12 @@ module NYNY
6
6
  extend Forwardable
7
7
 
8
8
  attr_reader :request, :response
9
- def_delegators :request, :params, :session
9
+ def_delegators :request, :session, :params
10
10
  def_delegators :response, :headers
11
11
 
12
- def initialize request
13
- @request = request
12
+ def initialize env
13
+ @request = Request.new(env)
14
+ @request.params.merge! env['nyny.params']
14
15
  @response = Response.new [], 200, {'Content-Type' => 'text/html'}
15
16
  end
16
17
 
data/lib/nyny/router.rb CHANGED
@@ -1,4 +1,6 @@
1
- require 'journey'
1
+ require 'active_support/concern'
2
+ require 'action_dispatch/routing'
3
+ require 'action_dispatch/journey'
2
4
 
3
5
  module NYNY
4
6
  class Router
@@ -25,12 +27,13 @@ module NYNY
25
27
  private
26
28
 
27
29
  def prepare_for_journey route_defs
28
- @journey = Journey::Router.new(Journey::Routes.new, {
30
+ routes = ActionDispatch::Journey::Routes.new
31
+ @journey = ActionDispatch::Journey::Router.new(routes, {
29
32
  :parameters_key => 'nyny.params'
30
33
  })
31
34
 
32
35
  route_defs.each do |path, options, handler|
33
- pat = Journey::Path::Pattern.new(path)
36
+ pat = ActionDispatch::Journey::Path::Pattern.new(path)
34
37
  constraints = options.fetch(:constraints, {})
35
38
  defaults = options.fetch(:defaults, {})
36
39
 
@@ -40,13 +43,7 @@ module NYNY
40
43
 
41
44
  def compile handler
42
45
  Proc.new do |env|
43
- request = Request.new(env)
44
- request.params.merge! env["nyny.params"]
45
- request.params.default_proc = lambda do |h, k|
46
- h.fetch(k.to_s, nil) || h.fetch(k.to_sym, nil)
47
- end
48
-
49
- scope = scope_class.new(request)
46
+ scope = scope_class.new(env)
50
47
 
51
48
  response = catch (:halt) do
52
49
  before_hooks.each {|h| scope.instance_eval &h }
data/lib/nyny/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module NYNY
2
- VERSION = "3.2.1"
2
+ VERSION = "3.2.2"
3
3
  end
data/nyny.gemspec CHANGED
@@ -4,8 +4,6 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'nyny/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.required_ruby_version = ">= 1.9.2"
8
-
9
7
  spec.name = "nyny"
10
8
  spec.version = NYNY::VERSION
11
9
  spec.authors = ["Andrei Lisnic"]
@@ -20,11 +18,10 @@ Gem::Specification.new do |spec|
20
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
19
  spec.require_paths = ["lib"]
22
20
 
23
- spec.add_dependency "rack", "~> 1.5.2"
24
21
  spec.add_dependency "rack-contrib", "~> 1.1.0"
25
22
  spec.add_dependency "tilt", "~> 1.4.1"
26
23
  spec.add_dependency "better_errors", "~> 1.1.0"
27
- spec.add_dependency "journey", "~> 1.0.4"
24
+ spec.add_dependency "actionpack", "~> 4.0.2"
28
25
  spec.add_development_dependency "bundler", "~> 1.3"
29
26
  spec.add_development_dependency "rake"
30
27
  spec.add_development_dependency "rspec"
data/spec/app_spec.rb CHANGED
@@ -27,8 +27,15 @@ describe App do
27
27
  describe 'namespace' do
28
28
  let (:app) do
29
29
  mock_app do
30
+ helpers do
31
+ def le_helper
32
+ :lulwut
33
+ end
34
+ end
35
+
30
36
  namespace '/foo' do
31
37
  get '/' do
38
+ le_helper.should == :lulwut
32
39
  'bar'
33
40
  end
34
41
  end
@@ -36,6 +43,7 @@ describe App do
36
43
  namespace '/nested' do
37
44
  namespace '/space' do
38
45
  get '/' do
46
+ le_helper.should == :lulwut
39
47
  'caramba'
40
48
  end
41
49
  end
@@ -37,6 +37,12 @@ describe NYNY::App do
37
37
  headers['child after'] = 'true'
38
38
  end
39
39
 
40
+ namespace '/nested' do
41
+ get '/' do
42
+ parent_helper.should == :parent
43
+ end
44
+ end
45
+
40
46
  get '/helpers' do
41
47
  parent_helper.should == :parent
42
48
  child_helper.should == :child
@@ -73,5 +79,10 @@ describe NYNY::App do
73
79
  parent.get('/helpers')
74
80
  child.get('/helpers')
75
81
  end
82
+
83
+ it 'works correctly for namespaces' do
84
+ child.get('/nested').headers['parent before'].should_not be_nil
85
+ child.get('/nested').headers['parent after'].should_not be_nil
86
+ end
76
87
  end
77
88
  end
@@ -2,8 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe RequestScope do
4
4
  let (:env) { Rack::MockRequest.env_for '/', :params => {:some => 'param'} }
5
- let (:dummy_request) { Rack::Request.new(env) }
6
- let (:subject) { RequestScope.new dummy_request }
5
+ let (:subject) { RequestScope.new env.merge('nyny.params' => {}) }
6
+ let (:dummy_request) { subject.request }
7
7
  let (:handler) {
8
8
  Proc.new {"hello"}
9
9
  }
@@ -16,11 +16,11 @@ describe RequestScope do
16
16
  it 'params should have insensitive keys' do
17
17
  app = mock_app do
18
18
  get '/' do
19
- params[:foo].should == params['foo']
19
+ params[:foo][:bar].should == params['foo']['bar']
20
20
  end
21
21
  end
22
22
 
23
- app.get '/?foo=bar'
23
+ app.get '/', :params => {:foo => {:bar => 'baz'}}
24
24
  end
25
25
 
26
26
  describe 'cookies' do
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nyny
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.2.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: 2014-01-24 00:00:00.000000000 Z
11
+ date: 2014-01-28 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: 1.5.2
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 1.5.2
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rack-contrib
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -67,19 +53,19 @@ dependencies:
67
53
  - !ruby/object:Gem::Version
68
54
  version: 1.1.0
69
55
  - !ruby/object:Gem::Dependency
70
- name: journey
56
+ name: actionpack
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - "~>"
74
60
  - !ruby/object:Gem::Version
75
- version: 1.0.4
61
+ version: 4.0.2
76
62
  type: :runtime
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
- version: 1.0.4
68
+ version: 4.0.2
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: bundler
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -171,7 +157,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
171
157
  requirements:
172
158
  - - ">="
173
159
  - !ruby/object:Gem::Version
174
- version: 1.9.2
160
+ version: '0'
175
161
  required_rubygems_version: !ruby/object:Gem::Requirement
176
162
  requirements:
177
163
  - - ">="