hanami 2.1.0.rc3 → 2.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f126bd2f756323d71dfe0eedd34a45f998882fd1ef2e0afcc8d05c27de224e3a
4
- data.tar.gz: c9b360c13dbb7ce88e935df753a4d9ec4234f02bc625c403664fb44617ff6261
3
+ metadata.gz: 3f9161e98415778e746f9140d2ee9e23b7d8388eca678e7ddeb696c2bb8cdfee
4
+ data.tar.gz: 7deffed8c1081258db7182306bf95bf484fa9e08dbd37193ca36659a06d45040
5
5
  SHA512:
6
- metadata.gz: ef015d93dfbd94b0f0617cc0966f1d081e06859b2559de39c3b180dc9afc9d0e9034d53dc66117ea7305e80afd8f643a4204246dcba202da8f3c49b59c108426
7
- data.tar.gz: bced4c311fbcf6ee66e3036cb70fd9f9edc7cb897f6ff26eca660b30a94629297ec5abc3dfb5c849d04f682f66d45e0c2aa55b46829b9ce7b5edeef80a3e9247
6
+ metadata.gz: 1acff67204a42604558bce5455d36454cc8c176a741906750a536ae72f3048a006c798db7192918d64f06cc4b1fce7ce5c4f46726d0a27b309c82a1263b3d72b
7
+ data.tar.gz: aadb05898198c750f485f5a78f6d35f1e82c6b95ee052f749cfb0241b11f6706c367f7cfc01c31205664ff508853a3415884b7b729097e689d2f9f72c6bdf0fc
data/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  The web, with simplicity.
4
4
 
5
+ ## v2.1.0 - 2024-02-27
6
+
7
+ ### Changed
8
+
9
+ - [Pat Allan] Pass keyword arguments through to configured middleware
10
+ - [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/`.
11
+
5
12
  ## v2.1.0.rc3 - 2024-02-16
6
13
 
7
14
  ### Changed
@@ -10,7 +17,7 @@ The web, with simplicity.
10
17
  allows it to be used with tempalte output tags (such as ERB's `<%=`) that capture a block for the
11
18
  given content. (#1369)
12
19
 
13
- ## Fixed
20
+ ### Fixed
14
21
 
15
22
  - [Tim Riley] Ensure assets Rake task for Heroku works (#1368)
16
23
 
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", "= 2.1.0.rc3"
42
- spec.add_dependency "hanami-utils", "~> 2.1.rc"
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"
@@ -382,7 +382,7 @@ module Hanami
382
382
  #
383
383
  # <%= favicon_tag "favicon.ico", id: "fav" %>
384
384
  #
385
- # # <link id: "fav" href="/assets/favicon.ico" rel="shortcut icon" type="image/x-icon">
385
+ # # <link id="fav" href="/assets/favicon.ico" rel="shortcut icon" type="image/x-icon">
386
386
  #
387
387
  # @example Fingerprint Mode
388
388
  #
@@ -29,8 +29,7 @@ module Hanami
29
29
 
30
30
  # @api private
31
31
  def start
32
- assets_dir = slice.slice_name.to_s unless slice.app.eql?(slice)
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
 
@@ -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([middleware, args, blk])
103
+ @stack[path_prefix].push(item)
104
104
  end
105
105
 
106
106
  self
@@ -7,7 +7,7 @@ module Hanami
7
7
  # @api private
8
8
  module Version
9
9
  # @api public
10
- VERSION = "2.1.0.rc3"
10
+ VERSION = "2.1.0"
11
11
 
12
12
  # @since 0.9.0
13
13
  # @api private
@@ -7,7 +7,7 @@
7
7
  <title>Hanami</title>
8
8
  <style>
9
9
  :root {
10
- --max-width: 1024px;
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(4, 1fr);
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/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>})
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/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})
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"
@@ -37,7 +37,7 @@ module RSpec
37
37
 
38
38
  write "public/assets/assets.json", JSON.generate(manifest_hash)
39
39
 
40
- # An assets dir isrequired to load the assets provider
40
+ # An assets dir is required to load the assets provider
41
41
  write "app/assets/.keep", ""
42
42
  end
43
43
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  RSpec.describe "Hanami::VERSION" do
4
4
  it "returns current version" do
5
- expect(Hanami::VERSION).to eq("2.1.0.rc3")
5
+ expect(Hanami::VERSION).to eq("2.1.0")
6
6
  end
7
7
  end
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.0.rc3
4
+ version: 2.1.0
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-02-16 00:00:00.000000000 Z
11
+ date: 2024-02-27 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.0.rc3
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.0.rc3
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.rc
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.rc
186
+ version: '2.1'
187
187
  - !ruby/object:Gem::Dependency
188
188
  name: zeitwerk
189
189
  requirement: !ruby/object:Gem::Requirement