hanami-router 0.8.1 → 1.0.0.beta1

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: 3700c021edbbd63744f0ccd14145fbf2f43bb74c
4
- data.tar.gz: 181c99cb03d8b06a8b23afdb1a01c603a13e257d
3
+ metadata.gz: 459ea54d61819ab58f2fbaf0e0ee5dc14386ce58
4
+ data.tar.gz: 3507f38ff7540320daf7c086af56db3861d8108b
5
5
  SHA512:
6
- metadata.gz: e3c88dffa47882138ed426e40430eca285dae96ef93d2dba5f423ef5280b317c829d740918fd324a2bf17f83b6ce6b6a5822e00f43728d3bd940f2141fb9bf2e
7
- data.tar.gz: 1b6953416125bb0b1b2e7ec4e1beca690dc1629fd291056241fb70507210aee3a6d0c7c4fbea4e21c1f2b5f2ead2f890d0e6f2db264d0fea5999970cae2e2d59
6
+ metadata.gz: 6a5b0fa43e6dcaffa276be494bb3abec4be4cd58a0d8049ec78e7ca6d736e5f272b9e8743d4fef9629841c79f49c812468ec2f4d91a01f0bd3da26733501fa01
7
+ data.tar.gz: 8b9e93acf33e481ea75547c2c97c0f20c8b9bb52e9d3ed32243795bde569f087409b01ce6dc4731b977c2fed0a1a7ac0a79c030d88fbb99ef1ad5826a6cc4bdf
data/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # Hanami::Router
2
2
  Rack compatible HTTP router for Ruby
3
3
 
4
+ ## v1.0.0.beta1 - 2017-02-14
5
+ ### Added
6
+ - [Luca Guidi] Official support for Ruby: MRI 2.4
7
+ - [Jakub Pavlík] Added `:as` option for RESTful resources (eg. `resources :psi, controller: 'dogs', as: 'dogs'`)
8
+
9
+ ### Changed
10
+ - [Pascal Betz] Make compatible with Rack 2.0 only
11
+
4
12
  ## v0.8.1 - 2016-11-18
5
13
  ### Fixed
6
14
  - [Luca Guidi] Ensure JSON body parser to not eval untrusted input
@@ -19,9 +19,9 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
  spec.required_ruby_version = '>= 2.3.0'
21
21
 
22
- spec.add_dependency 'rack', '~> 1.6'
23
- spec.add_dependency 'http_router', '~> 0.11'
24
- spec.add_dependency 'hanami-utils', '~> 0.9', '>= 0.9.1'
22
+ spec.add_dependency 'rack', '~> 2.0'
23
+ spec.add_dependency 'http_router', '0.11.2'
24
+ spec.add_dependency 'hanami-utils', '~> 1.0.0.beta1'
25
25
 
26
26
  spec.add_development_dependency 'bundler', '~> 1.5'
27
27
  spec.add_development_dependency 'minitest', '~> 5'
@@ -1,6 +1,6 @@
1
1
  module Hanami
2
2
  class Router
3
3
  # @since 0.1.0
4
- VERSION = '0.8.1'.freeze
4
+ VERSION = '1.0.0.beta1'.freeze
5
5
  end
6
6
  end
@@ -198,7 +198,7 @@ module Hanami
198
198
  end
199
199
 
200
200
  def classify(string)
201
- Utils::String.new(string).classify
201
+ Utils::String.new(string).underscore.classify
202
202
  end
203
203
 
204
204
  private
@@ -6,6 +6,7 @@ require 'hanami/routing/parsers'
6
6
  require 'hanami/routing/force_ssl'
7
7
  require 'hanami/routing/error'
8
8
  require 'hanami/utils/path_prefix'
9
+ require 'hanami/routing/http_router_monkey_patch'
9
10
 
10
11
  module Hanami
11
12
  module Routing
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ #
3
+ # This monkey patches http_router to make it Rack 2.0 compatible.
4
+ # Details see: https://github.com/hanami/router/issues/136
5
+ #
6
+ class HttpRouter
7
+ class Node
8
+ class Path < Node
9
+ def to_code
10
+ path_ivar = inject_root_ivar(self)
11
+ "#{"if !callback && request.path.size == 1 && request.path.first == '' && (request.rack_request.head? || request.rack_request.get?) && request.rack_request.path_info[-1] == ?/
12
+ response = ::Rack::Response.new
13
+ response.redirect(request.rack_request.path_info[0, request.rack_request.path_info.size - 1], 302)
14
+ return response.finish
15
+ end" if router.redirect_trailing_slash?}
16
+
17
+ #{"if request.#{router.ignore_trailing_slash? ? 'path_finished?' : 'path.empty?'}" unless route.match_partially}
18
+ if callback
19
+ request.called = true
20
+ callback.call(Response.new(request, #{path_ivar}))
21
+ else
22
+ env = request.rack_request.env
23
+ env['router.request'] = request
24
+ env['router.params'] ||= {}
25
+ #{"env['router.params'].merge!(Hash[#{param_names.inspect}.zip(request.params)])" if dynamic?}
26
+ @router.rewrite#{"_partial" if route.match_partially}_path_info(env, request)
27
+ response = @router.process_destination_path(#{path_ivar}, env)
28
+ return response unless router.pass_on_response(response)
29
+ end
30
+ #{"end" unless route.match_partially}"
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -258,7 +258,8 @@ module Hanami
258
258
  # @api private
259
259
  # @since 0.4.0
260
260
  def _singularized_as
261
- resource_name.split(NESTED_ROUTES_SEPARATOR).map do |name|
261
+ name = @options[:as] ? @options[:as].to_s : resource_name
262
+ name.split(NESTED_ROUTES_SEPARATOR).map do |name|
262
263
  Hanami::Utils::String.new(name).singularize
263
264
  end
264
265
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-router
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 1.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-11-18 00:00:00.000000000 Z
13
+ date: 2017-02-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
@@ -18,48 +18,42 @@ dependencies:
18
18
  requirements:
19
19
  - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: '1.6'
21
+ version: '2.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - "~>"
27
27
  - !ruby/object:Gem::Version
28
- version: '1.6'
28
+ version: '2.0'
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: http_router
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - "~>"
33
+ - - '='
34
34
  - !ruby/object:Gem::Version
35
- version: '0.11'
35
+ version: 0.11.2
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - "~>"
40
+ - - '='
41
41
  - !ruby/object:Gem::Version
42
- version: '0.11'
42
+ version: 0.11.2
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: hanami-utils
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: '0.9'
50
- - - ">="
51
- - !ruby/object:Gem::Version
52
- version: 0.9.1
49
+ version: 1.0.0.beta1
53
50
  type: :runtime
54
51
  prerelease: false
55
52
  version_requirements: !ruby/object:Gem::Requirement
56
53
  requirements:
57
54
  - - "~>"
58
55
  - !ruby/object:Gem::Version
59
- version: '0.9'
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: 0.9.1
56
+ version: 1.0.0.beta1
63
57
  - !ruby/object:Gem::Dependency
64
58
  name: bundler
65
59
  requirement: !ruby/object:Gem::Requirement
@@ -137,6 +131,7 @@ files:
137
131
  - lib/hanami/routing/error.rb
138
132
  - lib/hanami/routing/force_ssl.rb
139
133
  - lib/hanami/routing/http_router.rb
134
+ - lib/hanami/routing/http_router_monkey_patch.rb
140
135
  - lib/hanami/routing/namespace.rb
141
136
  - lib/hanami/routing/parsers.rb
142
137
  - lib/hanami/routing/parsing/json_parser.rb
@@ -165,9 +160,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
165
160
  version: 2.3.0
166
161
  required_rubygems_version: !ruby/object:Gem::Requirement
167
162
  requirements:
168
- - - ">="
163
+ - - ">"
169
164
  - !ruby/object:Gem::Version
170
- version: '0'
165
+ version: 1.3.1
171
166
  requirements: []
172
167
  rubyforge_project:
173
168
  rubygems_version: 2.6.8