hanami 2.1.0.rc3 → 2.1.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -7
- data/FEATURES.md +1 -1
- data/hanami.gemspec +2 -2
- data/lib/hanami/app.rb +1 -1
- data/lib/hanami/config/actions.rb +1 -1
- data/lib/hanami/config/assets.rb +1 -1
- data/lib/hanami/config/logger.rb +2 -2
- data/lib/hanami/config.rb +1 -1
- data/lib/hanami/extensions/view/context.rb +1 -1
- data/lib/hanami/extensions/view/part.rb +1 -1
- data/lib/hanami/extensions/view/slice_configured_helpers.rb +1 -1
- data/lib/hanami/helpers/assets_helper.rb +6 -6
- data/lib/hanami/helpers/form_helper/form_builder.rb +2 -2
- data/lib/hanami/middleware/public_errors_app.rb +2 -2
- data/lib/hanami/providers/assets.rb +1 -2
- data/lib/hanami/providers/rack.rb +2 -2
- data/lib/hanami/rake_tasks.rb +1 -1
- data/lib/hanami/settings.rb +3 -3
- data/lib/hanami/slice/routing/middleware/stack.rb +3 -3
- data/lib/hanami/slice.rb +6 -6
- data/lib/hanami/version.rb +1 -1
- data/lib/hanami/web/rack_logger.rb +3 -3
- data/lib/hanami/web/welcome.html.erb +2 -6
- data/spec/integration/assets/assets_spec.rb +4 -4
- data/spec/integration/rack_app/middleware_spec.rb +66 -0
- data/spec/integration/view/config/template_spec.rb +1 -1
- data/spec/integration/view/context/request_spec.rb +1 -1
- data/spec/support/app_integration.rb +1 -1
- data/spec/unit/hanami/helpers/form_helper_spec.rb +2 -2
- data/spec/unit/hanami/slice_spec.rb +1 -1
- data/spec/unit/hanami/version_spec.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 190712bdfa529ad5769aa5effd9335e436b067cd91b6a109a3aa9a4718a73507
|
|
4
|
+
data.tar.gz: 353ccb232425a07133e981d5d8ae6c6906f49cb48d38d7f2b55dc4e28a9c797b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4a4e7e1885c9b3eb494863b63f4d376739d6736764b435b83ce75e9a1bb68340681a26bea3883ed20c679e4d88bf99b3d487ae40e2e80f0fb15adb99acfa561d
|
|
7
|
+
data.tar.gz: 8fe1a9d8f9f7372d67ee3f7b9c6e55b0e1aa59acbaee7264028d876dd5cd7b586f147ae08cd268d67c923d5028344bf37868d190cd2d56229932db56828dcce1
|
data/CHANGELOG.md
CHANGED
|
@@ -2,15 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
The web, with simplicity.
|
|
4
4
|
|
|
5
|
+
## v2.1.1 - 2024-05-12
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- [Tim Riley] Ensure Rack logging continues to work when upgrading to dry-logger 1.0.4 (#1384)
|
|
10
|
+
|
|
11
|
+
## v2.1.0 - 2024-02-27
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- [Pat Allan] Pass keyword arguments through to configured middleware
|
|
16
|
+
- [Tim Riley] Expect underscored slice names in `public/assets/` to avoid naming conflicts with nested asset entry points. In this arrangement, an "admin" slice will have its assets compiled into `public/assets/_admin/`.
|
|
17
|
+
|
|
5
18
|
## v2.1.0.rc3 - 2024-02-16
|
|
6
19
|
|
|
7
20
|
### Changed
|
|
8
21
|
|
|
9
22
|
- [Tim Riley] Return `nil` when setting content via `#content_for` on the app's view context. This
|
|
10
|
-
allows it to be used with
|
|
23
|
+
allows it to be used with template output tags (such as ERB's `<%=`) that capture a block for the
|
|
11
24
|
given content. (#1369)
|
|
12
25
|
|
|
13
|
-
|
|
26
|
+
### Fixed
|
|
14
27
|
|
|
15
28
|
- [Tim Riley] Ensure assets Rake task for Heroku works (#1368)
|
|
16
29
|
|
|
@@ -45,7 +58,6 @@ The web, with simplicity.
|
|
|
45
58
|
- Keep `video_tag` (remove `video` alias)
|
|
46
59
|
- Keep `audio_tag` (remove `audio` alias)
|
|
47
60
|
|
|
48
|
-
|
|
49
61
|
## v2.1.0.beta2.1 - 2023-10-04
|
|
50
62
|
|
|
51
63
|
### Added
|
|
@@ -144,7 +156,7 @@ The web, with simplicity.
|
|
|
144
156
|
### Fixed
|
|
145
157
|
|
|
146
158
|
- [Luca Guidi] Ensure to properly mount Rack middleware in routing scope and slice
|
|
147
|
-
- [Tim Riley] Simplify and clarify usage of `Hanami::Config#
|
|
159
|
+
- [Tim Riley] Simplify and clarify usage of `Hanami::Config#environment`
|
|
148
160
|
- [Tim Riley] Improve error message for missing action class
|
|
149
161
|
- [Tim Riley] Expect nested slices to use parent’s namespace
|
|
150
162
|
|
|
@@ -804,7 +816,7 @@ The web, with simplicity.
|
|
|
804
816
|
- [Luca Guidi] Main configuration is available at `config/application.rb` instead of `config/enviroment.rb`
|
|
805
817
|
- [Luca Guidi] Removed `Hanami.configure` in favor of main application configuration (e.g. `Bookshelf::Application.config`)
|
|
806
818
|
- [Luca Guidi] Removed DSL syntax for main configuration (from `cookies max_age: 600` to `config.cookies = { max_age: 600 }`)
|
|
807
|
-
- [Luca Guidi] Per
|
|
819
|
+
- [Luca Guidi] Per environment settings must be wrapped in a block (e.g. `config.environment(:production) { |c| c.logger = {} }`)
|
|
808
820
|
- [Luca Guidi] Concrete applications are no longer supported (e.g. `Web::Application` in `apps/web/application.rb`)
|
|
809
821
|
- [Luca Guidi] Main routes must be configured at `config/routes.rb`:
|
|
810
822
|
|
|
@@ -1120,7 +1132,7 @@ end
|
|
|
1120
1132
|
- [Mahesh] Fix destroy action for application architecture
|
|
1121
1133
|
- [Karim Tarek & akhramov] Reference rendering errors in Rack env's `rack.exception` variable. This enables compatibility with exception reporting SaaS.
|
|
1122
1134
|
- [Luca Guidi] Detect assets dependencies changes in development (Sass/SCSS)
|
|
1123
|
-
- [Luca Guidi & Lucas Amorim] Make model generator not
|
|
1135
|
+
- [Luca Guidi & Lucas Amorim] Make model generator not dependent on the current directory name, but to the project name stored in `.hanamirc`
|
|
1124
1136
|
|
|
1125
1137
|
### Changed
|
|
1126
1138
|
|
|
@@ -1375,7 +1387,7 @@ end
|
|
|
1375
1387
|
- [Piotr Kurek] Allow to yield multiple configurations per application, according to the current environment
|
|
1376
1388
|
- [David Celis] Allow to configure Rack middleware stack (`middleware` configuration)
|
|
1377
1389
|
- [David Celis] Introduced `lotus console` command. It runs the REPL configured in `Gemfile` (eg. pry or ripl). Defaults to IRb.
|
|
1378
|
-
- [Luca Guidi] Introduced `Lotus::Environment` which holds the
|
|
1390
|
+
- [Luca Guidi] Introduced `Lotus::Environment` which holds the information about the current environment, and CLI arguments
|
|
1379
1391
|
- [Luca Guidi] Introduced `Lotus::Application.load!` to load and configure an application without requiring user defined code (controllers, views, etc.)
|
|
1380
1392
|
- [Leonard Garvey] Introduced `lotus server` command. It runs the application with the Rack server declared in `Gemfile` (eg. puma, thin, unicorn). It defaults to `WEBRick`.
|
|
1381
1393
|
- [Luca Guidi] Official support for MRI 2.1 and 2.2
|
data/FEATURES.md
CHANGED
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
|
|
123
123
|
### v0.6.0 - 2016-01-12
|
|
124
124
|
|
|
125
|
-
- Assets preprocessors support (eg. Sass, ES6, Opal, Less,
|
|
125
|
+
- Assets preprocessors support (eg. Sass, ES6, Opal, Less, CoffeeScript..)
|
|
126
126
|
- Assets compressors (eg. YUI, UglifyJS2, Google Closure Compiler, Sass..)
|
|
127
127
|
- Assets helpers:
|
|
128
128
|
- `javascript`
|
data/hanami.gemspec
CHANGED
|
@@ -38,8 +38,8 @@ Gem::Specification.new do |spec|
|
|
|
38
38
|
spec.add_dependency "dry-monitor", "~> 1.0", ">= 1.0.1", "< 2"
|
|
39
39
|
spec.add_dependency "dry-system", "~> 1.0", "< 2"
|
|
40
40
|
spec.add_dependency "dry-logger", "~> 1.0", "< 2"
|
|
41
|
-
spec.add_dependency "hanami-cli", "
|
|
42
|
-
spec.add_dependency "hanami-utils", "~> 2.1
|
|
41
|
+
spec.add_dependency "hanami-cli", "~> 2.1"
|
|
42
|
+
spec.add_dependency "hanami-utils", "~> 2.1"
|
|
43
43
|
spec.add_dependency "zeitwerk", "~> 2.6"
|
|
44
44
|
|
|
45
45
|
spec.add_development_dependency "rspec", "~> 3.8"
|
data/lib/hanami/app.rb
CHANGED
|
@@ -129,7 +129,7 @@ module Hanami
|
|
|
129
129
|
end
|
|
130
130
|
end
|
|
131
131
|
|
|
132
|
-
# When auto-registering components in app
|
|
132
|
+
# When auto-registering components in `app/`, ignore files in `app/lib/` (these will be
|
|
133
133
|
# auto-registered as above), as well as the configured no_auto_register_paths
|
|
134
134
|
no_auto_register_paths = ([LIB_DIR] + config.no_auto_register_paths)
|
|
135
135
|
.map { |path|
|
data/lib/hanami/config/assets.rb
CHANGED
data/lib/hanami/config/logger.rb
CHANGED
|
@@ -25,7 +25,7 @@ module Hanami
|
|
|
25
25
|
attr_reader :env
|
|
26
26
|
|
|
27
27
|
# @!attribute [rw] level
|
|
28
|
-
# Sets or returns the logger level.
|
|
28
|
+
# Sets or returns the logger's level.
|
|
29
29
|
#
|
|
30
30
|
# Defaults to `:info` for the production environment and `:debug` for all others.
|
|
31
31
|
#
|
|
@@ -191,7 +191,7 @@ module Hanami
|
|
|
191
191
|
end
|
|
192
192
|
|
|
193
193
|
# @api private
|
|
194
|
-
def respond_to_missing?(name,
|
|
194
|
+
def respond_to_missing?(name, _include_all = false)
|
|
195
195
|
config.respond_to?(name) || super
|
|
196
196
|
end
|
|
197
197
|
end
|
data/lib/hanami/config.rb
CHANGED
|
@@ -156,7 +156,7 @@ module Hanami
|
|
|
156
156
|
@assets
|
|
157
157
|
end
|
|
158
158
|
|
|
159
|
-
# Returns the current request, if
|
|
159
|
+
# Returns the current request, if the view is rendered from within an action.
|
|
160
160
|
#
|
|
161
161
|
# @return [Hanami::Action::Request] the request
|
|
162
162
|
#
|
|
@@ -46,7 +46,7 @@ module Hanami
|
|
|
46
46
|
# Standalone helpers class including both {StandardHelpers} as well as the user-defined
|
|
47
47
|
# helpers for the slice.
|
|
48
48
|
#
|
|
49
|
-
# Used
|
|
49
|
+
# Used where helpers should be addressed via an intermediary object (i.e. in parts),
|
|
50
50
|
# rather than mixed into a class directly.
|
|
51
51
|
#
|
|
52
52
|
# @api private
|
|
@@ -81,7 +81,7 @@ module Hanami
|
|
|
81
81
|
# If the "CDN mode" is on, the `src` is an absolute URL of the
|
|
82
82
|
# application CDN.
|
|
83
83
|
#
|
|
84
|
-
# If the "subresource integrity mode" is on, `
|
|
84
|
+
# If the "subresource integrity mode" is on, `integrity` is the
|
|
85
85
|
# name of the algorithm, then a hyphen, then the hash value of the file.
|
|
86
86
|
# If more than one algorithm is used, they"ll be separated by a space.
|
|
87
87
|
#
|
|
@@ -185,7 +185,7 @@ module Hanami
|
|
|
185
185
|
# If the "CDN mode" is on, the `href` is an absolute URL of the
|
|
186
186
|
# application CDN.
|
|
187
187
|
#
|
|
188
|
-
# If the "subresource integrity mode" is on, `
|
|
188
|
+
# If the "subresource integrity mode" is on, `integrity` is the
|
|
189
189
|
# name of the algorithm, then a hyphen, then the hashed value of the file.
|
|
190
190
|
# If more than one algorithm is used, they"ll be separated by a space.
|
|
191
191
|
#
|
|
@@ -270,7 +270,7 @@ module Hanami
|
|
|
270
270
|
# Generate `img` tag for given source
|
|
271
271
|
#
|
|
272
272
|
# It accepts one string representing the name of the asset, if it comes
|
|
273
|
-
# from the application or third party gems. It also accepts
|
|
273
|
+
# from the application or third party gems. It also accepts strings
|
|
274
274
|
# representing absolute URLs in case of public CDN (eg. Bootstrap CDN).
|
|
275
275
|
#
|
|
276
276
|
# `alt` Attribute is auto generated from `src`.
|
|
@@ -382,7 +382,7 @@ module Hanami
|
|
|
382
382
|
#
|
|
383
383
|
# <%= favicon_tag "favicon.ico", id: "fav" %>
|
|
384
384
|
#
|
|
385
|
-
# # <link id
|
|
385
|
+
# # <link id="fav" href="/assets/favicon.ico" rel="shortcut icon" type="image/x-icon">
|
|
386
386
|
#
|
|
387
387
|
# @example Fingerprint Mode
|
|
388
388
|
#
|
|
@@ -412,7 +412,7 @@ module Hanami
|
|
|
412
412
|
# Generate `video` tag for given source
|
|
413
413
|
#
|
|
414
414
|
# It accepts one string representing the name of the asset, if it comes
|
|
415
|
-
# from the application or third party gems. It also accepts
|
|
415
|
+
# from the application or third party gems. It also accepts strings
|
|
416
416
|
# representing absolute URLs in case of public CDN (eg. Bootstrap CDN).
|
|
417
417
|
#
|
|
418
418
|
# Alternatively, it accepts a block that allows to specify one or more
|
|
@@ -514,7 +514,7 @@ module Hanami
|
|
|
514
514
|
# Generate `audio` tag for given source
|
|
515
515
|
#
|
|
516
516
|
# It accepts one string representing the name of the asset, if it comes
|
|
517
|
-
# from the application or third party gems. It also accepts
|
|
517
|
+
# from the application or third party gems. It also accepts strings
|
|
518
518
|
# representing absolute URLs in case of public CDN (eg. Bootstrap CDN).
|
|
519
519
|
#
|
|
520
520
|
# Alternatively, it accepts a block that allows to specify one or more
|
|
@@ -190,7 +190,7 @@ module Hanami
|
|
|
190
190
|
# @param name [String] the input name, also used as the base input name for all fields
|
|
191
191
|
# within the block
|
|
192
192
|
# @yieldparam [FormBuilder] the form builder for the nested fields
|
|
193
|
-
# @yieldparam [Integer] the index of the iteration over the
|
|
193
|
+
# @yieldparam [Integer] the index of the iteration over the collection, starting from zero
|
|
194
194
|
# @yieldparam [Object] the value of the element from the collection
|
|
195
195
|
#
|
|
196
196
|
# @example Basic usage
|
|
@@ -694,7 +694,7 @@ module Hanami
|
|
|
694
694
|
#
|
|
695
695
|
# @example Advanced attributes
|
|
696
696
|
# f.number_field("book.percent_read", min: 1, max: 100, step: 1)
|
|
697
|
-
# => <input type="number" name="book[percent_read]" id="book-
|
|
697
|
+
# => <input type="number" name="book[percent_read]" id="book-percent-read" value="" min="1" max="100" step="1">
|
|
698
698
|
#
|
|
699
699
|
# @api public
|
|
700
700
|
# @since 2.1.0
|
|
@@ -4,8 +4,8 @@ require "rack"
|
|
|
4
4
|
|
|
5
5
|
module Hanami
|
|
6
6
|
module Middleware
|
|
7
|
-
# The errors app given to {Hanami::Middleware::RenderErrors}, which renders
|
|
8
|
-
# from HTML pages kept in `public/`
|
|
7
|
+
# The errors app given to {Hanami::Middleware::RenderErrors}, which renders error responses
|
|
8
|
+
# from HTML pages kept in `public/` as simple JSON structures.
|
|
9
9
|
#
|
|
10
10
|
# @see Hanami::Middleware::RenderErrors
|
|
11
11
|
#
|
|
@@ -29,8 +29,7 @@ module Hanami
|
|
|
29
29
|
|
|
30
30
|
# @api private
|
|
31
31
|
def start
|
|
32
|
-
|
|
33
|
-
root = slice.app.root.join("public", "assets", assets_dir.to_s)
|
|
32
|
+
root = slice.app.root.join("public", "assets", Hanami::Assets.public_assets_dir(slice).to_s)
|
|
34
33
|
|
|
35
34
|
assets = Hanami::Assets.new(config: slice.config.assets, root: root)
|
|
36
35
|
|
|
@@ -20,8 +20,8 @@ module Hanami
|
|
|
20
20
|
# Explicitly register the Rack middleware events on our notifications bus. The Dry::Monitor
|
|
21
21
|
# rack extension (activated above) does register these globally, but if the notifications
|
|
22
22
|
# bus has been used before this provider loads, then it will have created its own separate
|
|
23
|
-
#
|
|
24
|
-
# the Rack events globally
|
|
23
|
+
# local copy of all registered events as of that moment in time, which will not be included
|
|
24
|
+
# in the Rack events globally registered above.
|
|
25
25
|
notifications = target["notifications"]
|
|
26
26
|
notifications.register_event(Dry::Monitor::Rack::Middleware::REQUEST_START)
|
|
27
27
|
notifications.register_event(Dry::Monitor::Rack::Middleware::REQUEST_STOP)
|
data/lib/hanami/rake_tasks.rb
CHANGED
|
@@ -32,7 +32,7 @@ Hanami::CLI::RakeTasks.register_tasks do
|
|
|
32
32
|
# Please use them when you're in control of your deployment environment.
|
|
33
33
|
#
|
|
34
34
|
# If you're not in control and your deployment requires these "standard"
|
|
35
|
-
# Rake tasks, they are here to solve this
|
|
35
|
+
# Rake tasks, they are here only to solve this specific problem.
|
|
36
36
|
#
|
|
37
37
|
# namespace :db do
|
|
38
38
|
# task :migrate do
|
data/lib/hanami/settings.rb
CHANGED
|
@@ -8,7 +8,7 @@ module Hanami
|
|
|
8
8
|
# Provides user-defined settings for an Hanami app or slice.
|
|
9
9
|
#
|
|
10
10
|
# Define your own settings by inheriting from this class in `config/settings.rb` within an app or
|
|
11
|
-
# slice. Your settings will be loaded from matching ENV vars (with upper-cased names) and
|
|
11
|
+
# slice. Your settings will be loaded from matching ENV vars (with upper-cased names) and be
|
|
12
12
|
# registered as a component as part of the Hanami app {Hanami::Slice::ClassMethods#prepare
|
|
13
13
|
# prepare} step.
|
|
14
14
|
#
|
|
@@ -160,8 +160,8 @@ module Hanami
|
|
|
160
160
|
value = store.fetch(name, Undefined)
|
|
161
161
|
|
|
162
162
|
if value.eql?(Undefined)
|
|
163
|
-
# When a key is missing entirely from the store, _read_ its value from the config instead
|
|
164
|
-
#
|
|
163
|
+
# When a key is missing entirely from the store, _read_ its value from the config instead.
|
|
164
|
+
# This ensures its setting constructor runs (with a `nil` argument given) and raises any
|
|
165
165
|
# necessary errors.
|
|
166
166
|
public_send(name)
|
|
167
167
|
else
|
|
@@ -91,16 +91,16 @@ module Hanami
|
|
|
91
91
|
#
|
|
92
92
|
# @api public
|
|
93
93
|
# @since 2.0.0
|
|
94
|
-
def use(spec, *args, path_prefix: ::Hanami::Router::DEFAULT_PREFIX, before: nil, after: nil, &blk)
|
|
94
|
+
def use(spec, *args, path_prefix: ::Hanami::Router::DEFAULT_PREFIX, before: nil, after: nil, **kwargs, &blk)
|
|
95
95
|
middleware = resolve_middleware_class(spec)
|
|
96
|
-
item = [middleware, args, blk]
|
|
96
|
+
item = [middleware, args, kwargs, blk]
|
|
97
97
|
|
|
98
98
|
if before
|
|
99
99
|
@stack[path_prefix].insert((idx = index_of(before, path_prefix)).zero? ? 0 : idx - 1, item)
|
|
100
100
|
elsif after
|
|
101
101
|
@stack[path_prefix].insert(index_of(after, path_prefix) + 1, item)
|
|
102
102
|
else
|
|
103
|
-
@stack[path_prefix].push(
|
|
103
|
+
@stack[path_prefix].push(item)
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
self
|
data/lib/hanami/slice.rb
CHANGED
|
@@ -189,7 +189,7 @@ module Hanami
|
|
|
189
189
|
# @api public
|
|
190
190
|
# @since 2.0.0
|
|
191
191
|
def root
|
|
192
|
-
#
|
|
192
|
+
# Provides a best guess for a root when it is not yet configured.
|
|
193
193
|
#
|
|
194
194
|
# This is particularly useful for user-defined slice classes that access `settings` inside
|
|
195
195
|
# the class body (since the root needed to find the settings file). In this case,
|
|
@@ -265,7 +265,7 @@ module Hanami
|
|
|
265
265
|
#
|
|
266
266
|
# @example
|
|
267
267
|
# module MySlice
|
|
268
|
-
# class
|
|
268
|
+
# class Slice < Hanami::Slice
|
|
269
269
|
# prepare_container do |container|
|
|
270
270
|
# # ...
|
|
271
271
|
# end
|
|
@@ -404,7 +404,7 @@ module Hanami
|
|
|
404
404
|
# @param key [String] the component's key
|
|
405
405
|
# @param object [Object] the object to register as the component
|
|
406
406
|
#
|
|
407
|
-
# @overload
|
|
407
|
+
# @overload register(key, memoize: false, &block)
|
|
408
408
|
# Registers the given block as the component. When the component is resolved, the return
|
|
409
409
|
# value of the block will be returned.
|
|
410
410
|
#
|
|
@@ -422,7 +422,7 @@ module Hanami
|
|
|
422
422
|
# @param memoize [Boolean]
|
|
423
423
|
# @yieldreturn [Object] the object to register as the component
|
|
424
424
|
#
|
|
425
|
-
# @overload
|
|
425
|
+
# @overload register(key, call: true, &block)
|
|
426
426
|
# Registers the given block as the component. When `call: false` is given, then the block
|
|
427
427
|
# itself will become the component.
|
|
428
428
|
#
|
|
@@ -430,7 +430,7 @@ module Hanami
|
|
|
430
430
|
# object for that block will be returned.
|
|
431
431
|
#
|
|
432
432
|
# @param key [String] the component's key
|
|
433
|
-
# @param call [
|
|
433
|
+
# @param call [Boolean]
|
|
434
434
|
#
|
|
435
435
|
# @return [container]
|
|
436
436
|
#
|
|
@@ -493,7 +493,7 @@ module Hanami
|
|
|
493
493
|
# namespace. May be an explicit string, or `true` for the namespace to be the provider's
|
|
494
494
|
# name
|
|
495
495
|
# @param from [Symbol, nil] the group for an external provider source to use, with the
|
|
496
|
-
# provider source name inferred from `name` or
|
|
496
|
+
# provider source name inferred from `name` or passed explicitly as `source:`
|
|
497
497
|
# @param source [Symbol, nil] the name of the external provider source to use, if different
|
|
498
498
|
# from the value provided as `name`
|
|
499
499
|
# @param if [Boolean] a boolean-returning expression to determine whether to register the
|
data/lib/hanami/version.rb
CHANGED
|
@@ -35,8 +35,8 @@ module Hanami
|
|
|
35
35
|
CONTENT_LENGTH = "CONTENT_LENGTH"
|
|
36
36
|
private_constant :CONTENT_LENGTH
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
private_constant :
|
|
38
|
+
MILLISECOND = "ms"
|
|
39
|
+
private_constant :MILLISECOND
|
|
40
40
|
|
|
41
41
|
MICROSECOND = "µs"
|
|
42
42
|
private_constant :MICROSECOND
|
|
@@ -79,7 +79,7 @@ module Hanami
|
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
def accepts_entry_payload?(logger)
|
|
82
|
-
logger.method(:info).parameters.
|
|
82
|
+
logger.method(:info).parameters.any? { |(type, _)| type == :keyrest }
|
|
83
83
|
end
|
|
84
84
|
end
|
|
85
85
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<title>Hanami</title>
|
|
8
8
|
<style>
|
|
9
9
|
:root {
|
|
10
|
-
--max-width:
|
|
10
|
+
--max-width: 768px;
|
|
11
11
|
--foreground-rgb: 0, 0, 0;
|
|
12
12
|
--background-rgb: 255, 255, 255;
|
|
13
13
|
--card-border-rgb: 200, 200, 200;
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
|
|
85
85
|
.grid {
|
|
86
86
|
display: grid;
|
|
87
|
-
grid-template-columns: repeat(
|
|
87
|
+
grid-template-columns: repeat(3, 1fr);
|
|
88
88
|
column-gap: 20px;
|
|
89
89
|
max-width: 100%;
|
|
90
90
|
margin-bottom: 8vh;
|
|
@@ -182,10 +182,6 @@
|
|
|
182
182
|
<h2>Guides</h2>
|
|
183
183
|
<p>Get started with the Hanami guides</p>
|
|
184
184
|
</a>
|
|
185
|
-
<a href="https://docs.hanamirb.org/" class="card">
|
|
186
|
-
<h2>API docs</h2>
|
|
187
|
-
<p>Learn more through the API docs</p>
|
|
188
|
-
</a>
|
|
189
185
|
<a href="http://github.com/hanami" class="card">
|
|
190
186
|
<h2>Code</h2>
|
|
191
187
|
<p>Contribute to the source code</p>
|
|
@@ -133,13 +133,13 @@ RSpec.describe "Assets", :app_integration do
|
|
|
133
133
|
|
|
134
134
|
output = Main::Slice["views.posts.show"].call.to_s
|
|
135
135
|
|
|
136
|
-
expect(output).to match(%r{<link href="/assets/
|
|
137
|
-
expect(output).to match(%r{<script src="/assets/
|
|
136
|
+
expect(output).to match(%r{<link href="/assets/_main/app-[A-Z0-9]{8}.css" type="text/css" rel="stylesheet">})
|
|
137
|
+
expect(output).to match(%r{<script src="/assets/_main/app-[A-Z0-9]{8}.js" type="text/javascript"></script>})
|
|
138
138
|
|
|
139
139
|
assets = Main::Slice["assets"]
|
|
140
140
|
|
|
141
|
-
expect(assets["app.css"].to_s).to match(%r{/assets/
|
|
142
|
-
expect(assets["app.js"].to_s).to match(%r{/assets/
|
|
141
|
+
expect(assets["app.css"].to_s).to match(%r{/assets/_main/app-[A-Z0-9]{8}.css})
|
|
142
|
+
expect(assets["app.js"].to_s).to match(%r{/assets/_main/app-[A-Z0-9]{8}.js})
|
|
143
143
|
end
|
|
144
144
|
end
|
|
145
145
|
|
|
@@ -147,6 +147,72 @@ RSpec.describe "Hanami web app", :app_integration do
|
|
|
147
147
|
expect(last_response.body).to eql("one.two")
|
|
148
148
|
end
|
|
149
149
|
|
|
150
|
+
specify "Setting a middleware that requires keyword arguments" do
|
|
151
|
+
write "config/app.rb", <<~RUBY
|
|
152
|
+
require "hanami"
|
|
153
|
+
|
|
154
|
+
module TestApp
|
|
155
|
+
class TestMiddleware
|
|
156
|
+
def initialize(app, key:, value:)
|
|
157
|
+
@app = app
|
|
158
|
+
@key = key
|
|
159
|
+
@value = value
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def call(env)
|
|
163
|
+
env[@key] = @value
|
|
164
|
+
@app.call(env)
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
class App < Hanami::App
|
|
169
|
+
config.logger.stream = StringIO.new
|
|
170
|
+
|
|
171
|
+
# Test middleware with keywords inside config
|
|
172
|
+
config.middleware.use(TestApp::TestMiddleware, key: "from_config", value: "config")
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
RUBY
|
|
176
|
+
|
|
177
|
+
write "config/routes.rb", <<~RUBY
|
|
178
|
+
require "hanami/router"
|
|
179
|
+
|
|
180
|
+
module TestApp
|
|
181
|
+
class Routes < Hanami::Routes
|
|
182
|
+
slice :main, at: "/" do
|
|
183
|
+
# Also test middleware with keywords inside routes
|
|
184
|
+
use TestApp::TestMiddleware, key: "from_routes", value: "routes"
|
|
185
|
+
|
|
186
|
+
root to: "home.index"
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
RUBY
|
|
191
|
+
|
|
192
|
+
write "slices/main/actions/home/index.rb", <<~RUBY
|
|
193
|
+
require "hanami/action"
|
|
194
|
+
|
|
195
|
+
module Main
|
|
196
|
+
module Actions
|
|
197
|
+
module Home
|
|
198
|
+
class Index < Hanami::Action
|
|
199
|
+
def handle(request, response)
|
|
200
|
+
response.body = [request.env["from_config"], request.env["from_routes"]].join(", ")
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
RUBY
|
|
207
|
+
|
|
208
|
+
require "hanami/boot"
|
|
209
|
+
|
|
210
|
+
get "/"
|
|
211
|
+
|
|
212
|
+
expect(last_response).to be_successful
|
|
213
|
+
expect(last_response.body).to eq "config, routes"
|
|
214
|
+
end
|
|
215
|
+
|
|
150
216
|
specify "Setting a middleware that requires a block" do
|
|
151
217
|
write "config/app.rb", <<~RUBY
|
|
152
218
|
require "hanami"
|
|
@@ -32,7 +32,7 @@ RSpec.describe "App view / Config / Template", :app_integration do
|
|
|
32
32
|
subject(:template) { view_class.config.template }
|
|
33
33
|
let(:view_class) { TestApp::Views::Article::Index }
|
|
34
34
|
|
|
35
|
-
it "configures the
|
|
35
|
+
it "configures the template to match the class name" do
|
|
36
36
|
expect(template).to eq "article/index"
|
|
37
37
|
end
|
|
38
38
|
end
|
|
@@ -80,8 +80,8 @@ RSpec.describe Hanami::Helpers::FormHelper do
|
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
it "allows to specify HTML attributes" do
|
|
83
|
-
html = form_for("/books", class: "form-
|
|
84
|
-
expect(html).to eq %(<form action="/books" class="form-
|
|
83
|
+
html = form_for("/books", class: "form-horizontal")
|
|
84
|
+
expect(html).to eq %(<form action="/books" class="form-horizontal" accept-charset="utf-8" method="POST"></form>)
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
context "input name" do
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hanami
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.1.
|
|
4
|
+
version: 2.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Luca Guidi
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-
|
|
11
|
+
date: 2024-05-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -160,30 +160,30 @@ dependencies:
|
|
|
160
160
|
name: hanami-cli
|
|
161
161
|
requirement: !ruby/object:Gem::Requirement
|
|
162
162
|
requirements:
|
|
163
|
-
- -
|
|
163
|
+
- - "~>"
|
|
164
164
|
- !ruby/object:Gem::Version
|
|
165
|
-
version: 2.1
|
|
165
|
+
version: '2.1'
|
|
166
166
|
type: :runtime
|
|
167
167
|
prerelease: false
|
|
168
168
|
version_requirements: !ruby/object:Gem::Requirement
|
|
169
169
|
requirements:
|
|
170
|
-
- -
|
|
170
|
+
- - "~>"
|
|
171
171
|
- !ruby/object:Gem::Version
|
|
172
|
-
version: 2.1
|
|
172
|
+
version: '2.1'
|
|
173
173
|
- !ruby/object:Gem::Dependency
|
|
174
174
|
name: hanami-utils
|
|
175
175
|
requirement: !ruby/object:Gem::Requirement
|
|
176
176
|
requirements:
|
|
177
177
|
- - "~>"
|
|
178
178
|
- !ruby/object:Gem::Version
|
|
179
|
-
version: 2.1
|
|
179
|
+
version: '2.1'
|
|
180
180
|
type: :runtime
|
|
181
181
|
prerelease: false
|
|
182
182
|
version_requirements: !ruby/object:Gem::Requirement
|
|
183
183
|
requirements:
|
|
184
184
|
- - "~>"
|
|
185
185
|
- !ruby/object:Gem::Version
|
|
186
|
-
version: 2.1
|
|
186
|
+
version: '2.1'
|
|
187
187
|
- !ruby/object:Gem::Dependency
|
|
188
188
|
name: zeitwerk
|
|
189
189
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -451,7 +451,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
451
451
|
- !ruby/object:Gem::Version
|
|
452
452
|
version: '0'
|
|
453
453
|
requirements: []
|
|
454
|
-
rubygems_version: 3.5.
|
|
454
|
+
rubygems_version: 3.5.9
|
|
455
455
|
signing_key:
|
|
456
456
|
specification_version: 4
|
|
457
457
|
summary: The web, with simplicity
|