hanami-controller 1.3.2 → 1.3.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
  SHA256:
3
- metadata.gz: 546fec0f371e76fa6e8f494ed3b66fb75cc7250226ffdcdbe6e7c52cce953204
4
- data.tar.gz: 82f4c7eca712806b6960f72eef8f62703008f45df342f6ad0ca83dffe232fe4b
3
+ metadata.gz: 3bc65546cbce3a2801eb75980f6f3d43a47c46bd98c3cd1128992d650da4b457
4
+ data.tar.gz: 1380fea8cc79b2a7506e872b27fc629b15c4dd43353ee83dc98fdd110d3e8cf4
5
5
  SHA512:
6
- metadata.gz: c36ec8f8f6b8ffca2ecafe33e4ed5b748578e0469368b2af6ba6b833cc334892d3b73bf555d8afc3c8c63d956a24a1b6ab13133f528f73aee855a084fb4b58af
7
- data.tar.gz: ac75c0c499f36ad8d44f334028f6081843ad829b486e6e5787521167d1b5b48e5f9e2723b00641baea769619e8a9844ef4f5231251cbc7db023b1b39ecf84094
6
+ metadata.gz: 075ebe574b4d001f463887d89823b2589682d772e92756be28d9e9a348b893902d620ac6a4716ea79c5c58167224539eff658544e23abdc8bdb1c1133166c50a
7
+ data.tar.gz: 94a22cb0e1b2c5920fdf2252405b5d2c7e7f9daa9457be96197f0552c5141972b0af98af1c6991175e156d0df3825fe5eba7d2dc28c1f4d547bf0797535deb6c
@@ -1,6 +1,12 @@
1
1
  # Hanami::Controller
2
2
  Complete, fast and testable actions for Rack
3
3
 
4
+ ## v1.3.3 - 2020-01-14
5
+ ### Added
6
+ - [Luca Guidi] Official support for Ruby: MRI 2.7
7
+ - [Luca Guidi] Support `rack` 2.1
8
+ - [Luca Guidi] Support for both `hanami-validations` 1 and 2
9
+
4
10
  ## v1.3.2 - 2019-06-28
5
11
  ### Fixed
6
12
  - [Ian Ker-Seymer] Ensure `Etag` to work when `If-Modified-Since` is sent from browser and upstream proxy sets `Last-Modified` automatically.
data/README.md CHANGED
@@ -5,7 +5,7 @@ Complete, fast and testable actions for Rack and [Hanami](http://hanamirb.org)
5
5
  ## Status
6
6
 
7
7
  [![Gem Version](https://badge.fury.io/rb/hanami-controller.svg)](https://badge.fury.io/rb/hanami-controller)
8
- [![TravisCI](https://travis-ci.org/hanami/controller.svg?branch=master)](https://travis-ci.org/hanami/controller)
8
+ [![Build Status](https://ci.hanamirb.org/api/badges/hanami/controller/status.svg)](https://ci.hanamirb.org/hanami/controller)
9
9
  [![CircleCI](https://circleci.com/gh/hanami/controller/tree/master.svg?style=svg)](https://circleci.com/gh/hanami/controller/tree/master)
10
10
  [![Test Coverage](https://codecov.io/gh/hanami/controller/branch/master/graph/badge.svg)](https://codecov.io/gh/hanami/controller)
11
11
  [![Depfu](https://badges.depfu.com/badges/7cd17419fba78b726be1353118fb01de/overview.svg)](https://depfu.com/github/hanami/controller?project=Bundler)
@@ -24,6 +24,6 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.add_development_dependency 'bundler', '>= 1.6', '< 3'
26
26
  spec.add_development_dependency 'rack-test', '~> 1.0'
27
- spec.add_development_dependency 'rake', '~> 12'
27
+ spec.add_development_dependency 'rake', '~> 13'
28
28
  spec.add_development_dependency 'rspec', '~> 3.7'
29
29
  end
@@ -83,6 +83,14 @@ module Hanami
83
83
  # The key that returns router parsed body from the Rack env
84
84
  ROUTER_PARSED_BODY = 'router.parsed_body'.freeze
85
85
 
86
+ # This is the root directory for `#unsafe_send_file`
87
+ #
88
+ # @since 1.3.3
89
+ # @api private
90
+ #
91
+ # @see #unsafe_send_file
92
+ FILE_SYSTEM_ROOT = Pathname.new("/").freeze
93
+
86
94
  # Override Ruby's hook for modules.
87
95
  # It includes basic Hanami::Action modules to the given class.
88
96
  #
@@ -353,7 +361,11 @@ module Hanami
353
361
  # end
354
362
  # end
355
363
  def unsafe_send_file(path)
356
- directory = self.class.configuration.root_directory if Pathname.new(path).relative?
364
+ directory = if Pathname.new(path).relative?
365
+ self.class.configuration.root_directory
366
+ else
367
+ FILE_SYSTEM_ROOT
368
+ end
357
369
 
358
370
  _send_file(
359
371
  File.new(path, directory).call(@_env)
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hanami
4
+ module Action
5
+ module Rack
6
+ # This module provides method to set exceptions to Rack env:
7
+ #
8
+ # * `rack.errors` - IO for errors, as requested by Rack SPEC
9
+ # * `rack.exception` - De-facto standard for Ruby exception tracking SaaS
10
+ #
11
+ # @see http://www.rubydoc.info/github/rack/rack/file/SPEC#The_Error_Stream
12
+ # @see https://github.com/hanami/controller/issues/133
13
+ #
14
+ # @since 1.3.3
15
+ # @api private
16
+ module Errors
17
+ # @since 1.3.3
18
+ # @api private
19
+ RACK_ERRORS = "rack.errors"
20
+
21
+ # @since 1.3.3
22
+ # @api private
23
+ RACK_EXCEPTION = "rack.exception"
24
+
25
+ # Set exception in Rack env
26
+ #
27
+ # @param env [Hash] the Rack environment
28
+ # @param exception [Exception] the exception to set
29
+ #
30
+ # @since 1.3.3
31
+ # @api private
32
+ def self.set(env, exception)
33
+ env[RACK_EXCEPTION] = exception
34
+
35
+ return unless errors = env[RACK_ERRORS] # rubocop:disable Lint/AssignmentInCondition
36
+
37
+ errors.write(_dump_exception(exception))
38
+ errors.flush
39
+ end
40
+
41
+ # Format exception info with name and backtrace
42
+ #
43
+ # @param exception [Exception]
44
+ #
45
+ # @since 1.3.3
46
+ # @api private
47
+ def self._dump_exception(exception)
48
+ [[exception.class, exception.message].compact.join(": "), *exception.backtrace].join("\n\t")
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -1,5 +1,6 @@
1
1
  require 'hanami/utils/class_attribute'
2
2
  require 'hanami/http/status'
3
+ require 'hanami/action/rack/errors'
3
4
 
4
5
  module Hanami
5
6
  module Action
@@ -11,23 +12,6 @@ module Hanami
11
12
  # @see Hanami::Action::Throwable#halt
12
13
  # @see Hanami::Action::Throwable#status
13
14
  module Throwable
14
- # @since 0.2.0
15
- # @api private
16
- RACK_ERRORS = 'rack.errors'.freeze
17
-
18
- # This isn't part of Rack SPEC
19
- #
20
- # Exception notifiers use <tt>rack.exception</tt> instead of
21
- # <tt>rack.errors</tt>, so we need to support it.
22
- #
23
- # @since 0.5.0
24
- # @api private
25
- #
26
- # @see Hanami::Action::Throwable::RACK_ERRORS
27
- # @see http://www.rubydoc.info/github/rack/rack/file/SPEC#The_Error_Stream
28
- # @see https://github.com/hanami/controller/issues/133
29
- RACK_EXCEPTION = 'rack.exception'.freeze
30
-
31
15
  # @since 0.1.0
32
16
  # @api private
33
17
  def self.included(base)
@@ -155,18 +139,7 @@ module Hanami
155
139
  def _reference_in_rack_errors(exception)
156
140
  return if configuration.handled_exception?(exception)
157
141
 
158
- @_env[RACK_EXCEPTION] = exception
159
-
160
- if errors = @_env[RACK_ERRORS]
161
- errors.write(_dump_exception(exception))
162
- errors.flush
163
- end
164
- end
165
-
166
- # @since 0.2.0
167
- # @api private
168
- def _dump_exception(exception)
169
- [[exception.class, exception.message].compact.join(": "), *exception.backtrace].join("\n\t")
142
+ Hanami::Action::Rack::Errors.set(@_env, exception)
170
143
  end
171
144
 
172
145
  # @since 0.1.0
@@ -3,6 +3,6 @@ module Hanami
3
3
  # Defines the version
4
4
  #
5
5
  # @since 0.1.0
6
- VERSION = '1.3.2'.freeze
6
+ VERSION = '1.3.3'.freeze
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-controller
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-28 00:00:00.000000000 Z
11
+ date: 2020-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -78,14 +78,14 @@ dependencies:
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '12'
81
+ version: '13'
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '12'
88
+ version: '13'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: rspec
91
91
  requirement: !ruby/object:Gem::Requirement
@@ -133,6 +133,7 @@ files:
133
133
  - lib/hanami/action/params.rb
134
134
  - lib/hanami/action/rack.rb
135
135
  - lib/hanami/action/rack/callable.rb
136
+ - lib/hanami/action/rack/errors.rb
136
137
  - lib/hanami/action/rack/file.rb
137
138
  - lib/hanami/action/redirect.rb
138
139
  - lib/hanami/action/request.rb
@@ -163,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
164
  - !ruby/object:Gem::Version
164
165
  version: '0'
165
166
  requirements: []
166
- rubygems_version: 3.0.3
167
+ rubygems_version: 3.1.2
167
168
  signing_key:
168
169
  specification_version: 4
169
170
  summary: Complete, fast and testable actions for Rack and Hanami