hanami-controller 2.3.0 → 2.3.2

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.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015-2026 Hanakai team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,22 +1,9 @@
1
- # Hanami::Controller
1
+ <!--- This file is synced from hanakai-rb/repo-sync -->
2
2
 
3
- Complete, fast, and testable actions for Rack and [Hanami](http://hanamirb.org)
4
-
5
- ## Status
6
-
7
- [![Gem Version](https://badge.fury.io/rb/hanami-controller.svg)](https://badge.fury.io/rb/hanami-controller)
8
- [![CI](https://github.com/hanami/hanami-controller/actions/workflows/ci.yml/badge.svg)](https://github.com/hanami/hanami-controller/actions?query=workflow%3Aci+branch%3Amain)
9
- [![Test Coverage](https://codecov.io/gh/hanami/hanami-controller/branch/main/graph/badge.svg)](https://codecov.io/gh/hanami/hanami-controller)
10
-
11
- ## Contact
12
-
13
- * Home page: http://hanamirb.org
14
- * Community: http://hanamirb.org/community
15
- * Guides: https://guides.hanamirb.org
16
- * Mailing List: http://hanamirb.org/mailing-list
17
- * API Doc: http://rubydoc.info/gems/hanami-controller
18
- * Chat: http://chat.hanamirb.org
3
+ [rubygem]: https://rubygems.org/gems/hanami-controller
4
+ [actions]: https://github.com/hanami/hanami-controller/actions
19
5
 
6
+ # Hanami Controller [![Gem Version](https://badge.fury.io/rb/hanami-controller.svg)][rubygem] [![CI Status](https://github.com/hanami/hanami-controller/workflows/CI/badge.svg)][actions]
20
7
 
21
8
  ## Installation
22
9
 
@@ -936,10 +923,6 @@ end
936
923
 
937
924
  An Action is **immutable**, it works without global state, so it's thread-safe by design.
938
925
 
939
- ## Versioning
940
-
941
- __Hanami::Controller__ uses [Semantic Versioning 2.0.0](http://semver.org)
942
-
943
926
  ## Contributing
944
927
 
945
928
  1. Fork it
@@ -948,6 +931,13 @@ __Hanami::Controller__ uses [Semantic Versioning 2.0.0](http://semver.org)
948
931
  4. Push to the branch (`git push origin my-new-feature`)
949
932
  5. Create new Pull Request
950
933
 
951
- ## Copyright
934
+ ## Links
935
+
936
+ - [User documentation](https://hanamirb.org)
937
+ - [API documentation](http://rubydoc.info/gems/hanami-controller)
938
+
939
+
940
+ ## License
941
+
942
+ See `LICENSE` file.
952
943
 
953
- Copyright © 2014–2024 Hanami Team – Released under MIT License
@@ -1,34 +1,40 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path("../lib", __FILE__)
3
+ # This file is synced from hanakai-rb/repo-sync. To update it, edit repo-sync.yml.
4
+
5
+ lib = File.expand_path("lib", __dir__)
4
6
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
7
  require "hanami/controller/version"
6
8
 
7
9
  Gem::Specification.new do |spec|
8
10
  spec.name = "hanami-controller"
9
- spec.version = Hanami::Controller::VERSION
10
11
  spec.authors = ["Hanakai team"]
11
12
  spec.email = ["info@hanakai.org"]
12
- spec.description = "Complete, fast and testable actions for Rack"
13
- spec.summary = "Complete, fast and testable actions for Rack and Hanami"
14
- spec.homepage = "http://hanamirb.org"
15
13
  spec.license = "MIT"
14
+ spec.version = Hanami::Controller::VERSION.dup
16
15
 
17
- spec.files = `git ls-files -- lib/* CHANGELOG.md LICENSE.md README.md hanami-controller.gemspec`.split($/)
18
- spec.executables = []
16
+ spec.summary = "Complete, fast and testable actions for Rack and Hanami"
17
+ spec.description = spec.summary
18
+ spec.homepage = "https://hanamirb.org"
19
+ spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "hanami-controller.gemspec", "lib/**/*"]
20
+ spec.bindir = "exe"
21
+ spec.executables = Dir["exe/*"].map { |f| File.basename(f) }
19
22
  spec.require_paths = ["lib"]
20
- spec.metadata["rubygems_mfa_required"] = "true"
23
+
24
+ spec.extra_rdoc_files = ["README.md", "CHANGELOG.md", "LICENSE"]
25
+
26
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
27
+ spec.metadata["changelog_uri"] = "https://github.com/hanami/hanami-controller/blob/main/CHANGELOG.md"
28
+ spec.metadata["source_code_uri"] = "https://github.com/hanami/hanami-controller"
29
+ spec.metadata["bug_tracker_uri"] = "https://github.com/hanami/hanami-controller/issues"
30
+ spec.metadata["funding_uri"] = "https://github.com/sponsors/hanami"
31
+
21
32
  spec.required_ruby_version = ">= 3.2"
22
33
 
23
- spec.add_dependency "rack", ">= 2.1"
24
- spec.add_dependency "hanami-utils", "~> 2.3.0"
25
- spec.add_dependency "dry-configurable", "~> 1.0", "< 2"
26
- spec.add_dependency "dry-core", "~> 1.0"
27
- spec.add_dependency "zeitwerk", "~> 2.6"
28
-
29
- spec.add_development_dependency "bundler", ">= 1.6", "< 3"
30
- spec.add_development_dependency "rack-test", "~> 2.0"
31
- spec.add_development_dependency "rake", "~> 13"
32
- spec.add_development_dependency "rspec", "~> 3.9"
33
- spec.add_development_dependency "rubocop", "~> 1.0"
34
+ spec.add_runtime_dependency "rack", ">= 2.2.16"
35
+ spec.add_runtime_dependency "hanami-utils", "~> 2.3.0"
36
+ spec.add_runtime_dependency "dry-configurable", "~> 1.0", "< 2"
37
+ spec.add_runtime_dependency "dry-core", "~> 1.0"
38
+ spec.add_runtime_dependency "zeitwerk", "~> 2.6"
34
39
  end
40
+
@@ -86,7 +86,7 @@ module Hanami
86
86
 
87
87
  # @since 0.3.0
88
88
  # @api private
89
- def fresh? # rubocop:disable Naming/PredicateMethod
89
+ def fresh?
90
90
  yield if @validations.any?(&:fresh?)
91
91
  end
92
92
 
@@ -67,7 +67,7 @@ module Hanami
67
67
 
68
68
  # @since 2.0.0
69
69
  # @api private
70
- private def initialize_copy(original) # rubocop:disable Style/AccessModifierDeclarations
70
+ private def initialize_copy(original)
71
71
  super
72
72
  @accepted = original.accepted.dup
73
73
  @default = original.default
@@ -54,7 +54,11 @@ module Hanami
54
54
  def handle_exception(exceptions)
55
55
  self.handled_exceptions = handled_exceptions
56
56
  .merge(exceptions)
57
- .sort { |(ex1, _), (ex2, _)| ex1.ancestors.include?(ex2) ? -1 : 1 }
57
+ .sort do |(ex1, _), (ex2, _)|
58
+ next 0 if [ex1, ex2].any?(String)
59
+
60
+ ex1.ancestors.include?(ex2) ? -1 : 1
61
+ end
58
62
  .to_h
59
63
  end
60
64
 
@@ -158,7 +158,7 @@ module Hanami
158
158
  if no_arg
159
159
  @next.merge!(@flash)
160
160
  else
161
- self[key] = self[key] # rubocop:disable Lint/SelfAssignment
161
+ self[key] = self[key]
162
162
  end
163
163
  end
164
164
 
@@ -8,7 +8,7 @@ require_relative "errors"
8
8
  module Hanami
9
9
  class Action
10
10
  # @api private
11
- module Mime # rubocop:disable Metrics/ModuleLength
11
+ module Mime
12
12
  # Most commom media types used for responses
13
13
  #
14
14
  # @since 1.0.0
@@ -48,7 +48,7 @@ module Hanami
48
48
 
49
49
  # @since 2.0.0
50
50
  # @api private
51
- def initialize(request:, config:, content_type: nil, env: {}, headers: {}, view_options: nil, session_enabled: false) # rubocop:disable Layout/LineLength, Metrics/ParameterLists
51
+ def initialize(request:, config:, content_type: nil, env: {}, headers: {}, view_options: nil, session_enabled: false) # rubocop:disable Layout/LineLength
52
52
  super([], 200, headers.dup)
53
53
  self.content_type = content_type if content_type
54
54
 
data/lib/hanami/action.rb CHANGED
@@ -7,11 +7,11 @@ require "hanami/utils/kernel"
7
7
  require "hanami/utils/string"
8
8
  require "rack"
9
9
  require "rack/utils"
10
- require "hanami/action/rack_utils"
11
10
  require "zeitwerk"
12
11
 
13
12
  require_relative "action/constants"
14
13
  require_relative "action/errors"
14
+ require_relative "action/rack_utils"
15
15
 
16
16
  module Hanami
17
17
  # An HTTP endpoint
@@ -40,7 +40,7 @@ module Hanami
40
40
  loader.ignore(
41
41
  "#{root}/hanami-controller.rb",
42
42
  "#{root}/hanami/controller/version.rb",
43
- "#{root}/hanami/action/{constants,errors,validatable}.rb"
43
+ "#{root}/hanami/action/{constants,errors,rack_utils,validatable}.rb"
44
44
  )
45
45
  loader.inflector.inflect("csrf_protection" => "CSRFProtection")
46
46
  end
@@ -373,13 +373,15 @@ module Hanami
373
373
  # Otherwise, it sets the response body with the default message associated
374
374
  # to the code (eg 404 will set `"Not Found"`).
375
375
  #
376
- # @param status [Fixnum] a valid HTTP status code
376
+ # @param status [Integer, Symbol] A valid HTTP status code or a symbol representing the HTTP status code
377
377
  # @param body [String] the response body
378
378
  #
379
379
  # @raise [StandardError] if the code isn't valid
380
380
  #
381
381
  # @since 0.2.0
382
382
  #
383
+ # @see https://hanakai.org/learn/hanami/actions/status-codes List of status codes and symbols
384
+ #
383
385
  # @see Hanami::Action::Throwable#handle_exception
384
386
  # @see Hanami::Http::Status:ALL
385
387
  #
@@ -8,6 +8,6 @@ module Hanami
8
8
  #
9
9
  # @since 0.1.0
10
10
  # @api public
11
- VERSION = "2.3.0"
11
+ VERSION = "2.3.2"
12
12
  end
13
13
  end
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-controller
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hanakai team
8
- bindir: bin
8
+ bindir: exe
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: '2.1'
18
+ version: 2.2.16
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: '2.1'
25
+ version: 2.2.16
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: hanami-utils
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -85,91 +85,18 @@ dependencies:
85
85
  - - "~>"
86
86
  - !ruby/object:Gem::Version
87
87
  version: '2.6'
88
- - !ruby/object:Gem::Dependency
89
- name: bundler
90
- requirement: !ruby/object:Gem::Requirement
91
- requirements:
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- version: '1.6'
95
- - - "<"
96
- - !ruby/object:Gem::Version
97
- version: '3'
98
- type: :development
99
- prerelease: false
100
- version_requirements: !ruby/object:Gem::Requirement
101
- requirements:
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- version: '1.6'
105
- - - "<"
106
- - !ruby/object:Gem::Version
107
- version: '3'
108
- - !ruby/object:Gem::Dependency
109
- name: rack-test
110
- requirement: !ruby/object:Gem::Requirement
111
- requirements:
112
- - - "~>"
113
- - !ruby/object:Gem::Version
114
- version: '2.0'
115
- type: :development
116
- prerelease: false
117
- version_requirements: !ruby/object:Gem::Requirement
118
- requirements:
119
- - - "~>"
120
- - !ruby/object:Gem::Version
121
- version: '2.0'
122
- - !ruby/object:Gem::Dependency
123
- name: rake
124
- requirement: !ruby/object:Gem::Requirement
125
- requirements:
126
- - - "~>"
127
- - !ruby/object:Gem::Version
128
- version: '13'
129
- type: :development
130
- prerelease: false
131
- version_requirements: !ruby/object:Gem::Requirement
132
- requirements:
133
- - - "~>"
134
- - !ruby/object:Gem::Version
135
- version: '13'
136
- - !ruby/object:Gem::Dependency
137
- name: rspec
138
- requirement: !ruby/object:Gem::Requirement
139
- requirements:
140
- - - "~>"
141
- - !ruby/object:Gem::Version
142
- version: '3.9'
143
- type: :development
144
- prerelease: false
145
- version_requirements: !ruby/object:Gem::Requirement
146
- requirements:
147
- - - "~>"
148
- - !ruby/object:Gem::Version
149
- version: '3.9'
150
- - !ruby/object:Gem::Dependency
151
- name: rubocop
152
- requirement: !ruby/object:Gem::Requirement
153
- requirements:
154
- - - "~>"
155
- - !ruby/object:Gem::Version
156
- version: '1.0'
157
- type: :development
158
- prerelease: false
159
- version_requirements: !ruby/object:Gem::Requirement
160
- requirements:
161
- - - "~>"
162
- - !ruby/object:Gem::Version
163
- version: '1.0'
164
- description: Complete, fast and testable actions for Rack
88
+ description: Complete, fast and testable actions for Rack and Hanami
165
89
  email:
166
90
  - info@hanakai.org
167
91
  executables: []
168
92
  extensions: []
169
- extra_rdoc_files: []
93
+ extra_rdoc_files:
94
+ - CHANGELOG.md
95
+ - LICENSE
96
+ - README.md
170
97
  files:
171
98
  - CHANGELOG.md
172
- - LICENSE.md
99
+ - LICENSE
173
100
  - README.md
174
101
  - hanami-controller.gemspec
175
102
  - lib/hanami-controller.rb
@@ -202,11 +129,15 @@ files:
202
129
  - lib/hanami/controller.rb
203
130
  - lib/hanami/controller/version.rb
204
131
  - lib/hanami/http/status.rb
205
- homepage: http://hanamirb.org
132
+ homepage: https://hanamirb.org
206
133
  licenses:
207
134
  - MIT
208
135
  metadata:
209
- rubygems_mfa_required: 'true'
136
+ allowed_push_host: https://rubygems.org
137
+ changelog_uri: https://github.com/hanami/hanami-controller/blob/main/CHANGELOG.md
138
+ source_code_uri: https://github.com/hanami/hanami-controller
139
+ bug_tracker_uri: https://github.com/hanami/hanami-controller/issues
140
+ funding_uri: https://github.com/sponsors/hanami
210
141
  rdoc_options: []
211
142
  require_paths:
212
143
  - lib
data/LICENSE.md DELETED
@@ -1,22 +0,0 @@
1
- Copyright © 2014 Hanami Team
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.