hanami 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/hanami/config/logger.rb +1 -1
- data/lib/hanami/slice.rb +1 -0
- data/lib/hanami/version.rb +1 -1
- data/lib/hanami/web/rack_logger.rb +7 -19
- data/spec/integration/slices/slice_registrations_spec.rb +80 -0
- data/spec/unit/hanami/config/logger_spec.rb +9 -0
- data/spec/unit/hanami/version_spec.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e4e96c0b8ba475c9f256fa14b1af20a353804df3f0db3847b814899f7cdd394
|
4
|
+
data.tar.gz: 8bc463f8095b0bff1ac433fe1869f90e5d7a98e88198546e2fd78ac0caf13639
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fc16cc328fc1756b03875d8e6ce6383771b432d85deab7c9fb55c77f9e9a573c0ed449312456c322dd202c0402dd40f5eb126d25b3d6c2b6666e6ff4d9d69c1
|
7
|
+
data.tar.gz: 903eaccd76b79b10d1ff1197fa6f12d99ce824d41a66be2579549884a9d45d25d3d186fc6f56e33b7badafec427b64da1455443ff674488f2bfb5e3502ca65f4
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,18 @@
|
|
2
2
|
|
3
3
|
The web, with simplicity.
|
4
4
|
|
5
|
+
## v2.0.3 - 2023-02-01
|
6
|
+
|
7
|
+
### Added
|
8
|
+
|
9
|
+
- [Luca Guidi] Official support for Ruby 3.2
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
|
13
|
+
- [Adam Lassek] Ensure to setup a logger in a non-default Hanami env
|
14
|
+
- [R Gibim] Use production logger settings for non-default Hanami env
|
15
|
+
- [Adam Lassek] Allow slices to have a default for registrations directory
|
16
|
+
|
5
17
|
## v2.0.2 - 2022-12-25
|
6
18
|
|
7
19
|
### Added
|
data/lib/hanami/config/logger.rb
CHANGED
@@ -126,7 +126,7 @@ module Hanami
|
|
126
126
|
config.level = :debug
|
127
127
|
config.stream = File.join("log", "#{env}.log") if env == :test
|
128
128
|
config.logger_constructor = method(:development_logger)
|
129
|
-
|
129
|
+
else
|
130
130
|
config.level = :info
|
131
131
|
config.formatter = :json
|
132
132
|
config.logger_constructor = method(:production_logger)
|
data/lib/hanami/slice.rb
CHANGED
@@ -843,6 +843,7 @@ module Hanami
|
|
843
843
|
container.config.name = slice_name.to_sym
|
844
844
|
container.config.root = root
|
845
845
|
container.config.provider_dirs = [File.join("config", "providers")]
|
846
|
+
container.config.registrations_dir = File.join("config", "registrations")
|
846
847
|
|
847
848
|
container.config.env = config.env
|
848
849
|
container.config.inflector = config.inflector
|
data/lib/hanami/version.rb
CHANGED
@@ -38,30 +38,16 @@ module Hanami
|
|
38
38
|
MICROSECOND = "µs"
|
39
39
|
private_constant :MICROSECOND
|
40
40
|
|
41
|
-
# Dynamic extension used in
|
42
|
-
# @api private
|
43
|
-
module Production
|
44
|
-
private
|
45
|
-
|
46
|
-
# @since 1.0.0
|
47
|
-
# @api private
|
48
|
-
def data(env, status:, elapsed:)
|
49
|
-
payload = super
|
50
|
-
payload[:elapsed] = elapsed
|
51
|
-
payload[:elapsed_unit] = MICROSECOND
|
52
|
-
payload
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
# Dynamic extension used in non-production environments
|
41
|
+
# Dynamic extension used in development and test environments
|
57
42
|
# @api private
|
58
43
|
module Development
|
59
44
|
private
|
60
45
|
|
61
|
-
# @since
|
46
|
+
# @since 2.0.0
|
62
47
|
# @api private
|
63
48
|
def data(env, status:, elapsed:)
|
64
49
|
payload = super
|
50
|
+
payload.delete(:elapsed_unit)
|
65
51
|
payload[:elapsed] = elapsed > 1000 ? "#{elapsed / 1000}ms" : "#{elapsed}#{MICROSECOND}"
|
66
52
|
payload
|
67
53
|
end
|
@@ -71,7 +57,7 @@ module Hanami
|
|
71
57
|
# @since 2.0.0
|
72
58
|
def initialize(logger, env: :development)
|
73
59
|
@logger = logger
|
74
|
-
extend(
|
60
|
+
extend(Development) if %i[development test].include?(env)
|
75
61
|
end
|
76
62
|
|
77
63
|
# @api private
|
@@ -116,7 +102,9 @@ module Hanami
|
|
116
102
|
ip: env[HTTP_X_FORWARDED_FOR] || env[REMOTE_ADDR],
|
117
103
|
path: "#{env[SCRIPT_NAME]}#{env[PATH_INFO]}",
|
118
104
|
length: extract_content_length(env),
|
119
|
-
params: env.fetch(ROUTER_PARAMS, EMPTY_PARAMS)
|
105
|
+
params: env.fetch(ROUTER_PARAMS, EMPTY_PARAMS),
|
106
|
+
elapsed: elapsed,
|
107
|
+
elapsed_unit: MICROSECOND,
|
120
108
|
}
|
121
109
|
end
|
122
110
|
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe "Slice Registrations", :app_integration do
|
4
|
+
matcher :have_key do |name, value|
|
5
|
+
match do |slice|
|
6
|
+
slice.resolve(name) == value
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
specify "Registrations are loaded" do
|
11
|
+
with_tmp_directory(Dir.mktmpdir) do
|
12
|
+
write "config/app.rb", <<~RUBY
|
13
|
+
require "hanami"
|
14
|
+
|
15
|
+
module TestApp
|
16
|
+
class App < Hanami::App
|
17
|
+
end
|
18
|
+
end
|
19
|
+
RUBY
|
20
|
+
|
21
|
+
write "config/registrations/foo.rb", <<~RUBY
|
22
|
+
TestApp::App.register("foo") { "bar" }
|
23
|
+
RUBY
|
24
|
+
|
25
|
+
require "hanami/prepare"
|
26
|
+
|
27
|
+
expect(Hanami.app).to have_key(:foo, "bar")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
specify "Slices load their own registrations" do
|
32
|
+
with_tmp_directory(Dir.mktmpdir) do
|
33
|
+
write "config/app.rb", <<~RUBY
|
34
|
+
require "hanami"
|
35
|
+
|
36
|
+
module TestApp
|
37
|
+
class App < Hanami::App
|
38
|
+
end
|
39
|
+
end
|
40
|
+
RUBY
|
41
|
+
|
42
|
+
write "config/slices/main.rb", <<~RUBY
|
43
|
+
module Admin
|
44
|
+
class Slice < Hanami::Slice
|
45
|
+
end
|
46
|
+
end
|
47
|
+
RUBY
|
48
|
+
|
49
|
+
write "config/slices/admin.rb", <<~RUBY
|
50
|
+
module Main
|
51
|
+
class Slice < Hanami::Slice
|
52
|
+
end
|
53
|
+
end
|
54
|
+
RUBY
|
55
|
+
|
56
|
+
write "config/registrations/foo.rb", <<~RUBY
|
57
|
+
TestApp::App.register("foo") { "bar" }
|
58
|
+
RUBY
|
59
|
+
|
60
|
+
write "slices/admin/config/registrations/bar.rb", <<~RUBY
|
61
|
+
Admin::Slice.register("bar") { "baz" }
|
62
|
+
RUBY
|
63
|
+
|
64
|
+
write "slices/main/config/registrations/baz.rb", <<~RUBY
|
65
|
+
Main::Slice.register("baz") { "quux" }
|
66
|
+
RUBY
|
67
|
+
|
68
|
+
require "hanami/prepare"
|
69
|
+
|
70
|
+
admin_slice = Hanami.app.slices[:admin]
|
71
|
+
main_slice = Hanami.app.slices[:main]
|
72
|
+
|
73
|
+
aggregate_failures do
|
74
|
+
expect(Hanami.app).to have_key(:foo, "bar")
|
75
|
+
expect(admin_slice).to have_key(:bar, "baz")
|
76
|
+
expect(main_slice).to have_key(:baz, "quux")
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -182,5 +182,14 @@ RSpec.describe Hanami::Config do
|
|
182
182
|
.to change { config.logger_instance }
|
183
183
|
.to logger_instance
|
184
184
|
end
|
185
|
+
|
186
|
+
context "unrecognized :env" do
|
187
|
+
let(:env) { :staging }
|
188
|
+
|
189
|
+
it "provides a fail-safe configuration" do
|
190
|
+
expect { config.logger_instance }.to_not raise_error
|
191
|
+
expect(config.logger_instance).to be_a(Dry::Logger::Dispatcher)
|
192
|
+
end
|
193
|
+
end
|
185
194
|
end
|
186
195
|
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.0.
|
4
|
+
version: 2.0.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:
|
11
|
+
date: 2023-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -337,6 +337,7 @@ files:
|
|
337
337
|
- spec/integration/slices/external_slice_spec.rb
|
338
338
|
- spec/integration/slices/slice_configuration_spec.rb
|
339
339
|
- spec/integration/slices/slice_loading_spec.rb
|
340
|
+
- spec/integration/slices/slice_registrations_spec.rb
|
340
341
|
- spec/integration/slices/slice_routing_spec.rb
|
341
342
|
- spec/integration/slices_spec.rb
|
342
343
|
- spec/integration/view/context/assets_spec.rb
|
@@ -407,7 +408,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
407
408
|
- !ruby/object:Gem::Version
|
408
409
|
version: '0'
|
409
410
|
requirements: []
|
410
|
-
rubygems_version: 3.4.
|
411
|
+
rubygems_version: 3.4.5
|
411
412
|
signing_key:
|
412
413
|
specification_version: 4
|
413
414
|
summary: The web, with simplicity
|
@@ -450,6 +451,7 @@ test_files:
|
|
450
451
|
- spec/integration/slices/external_slice_spec.rb
|
451
452
|
- spec/integration/slices/slice_configuration_spec.rb
|
452
453
|
- spec/integration/slices/slice_loading_spec.rb
|
454
|
+
- spec/integration/slices/slice_registrations_spec.rb
|
453
455
|
- spec/integration/slices/slice_routing_spec.rb
|
454
456
|
- spec/integration/slices_spec.rb
|
455
457
|
- spec/integration/view/context/assets_spec.rb
|