hanami 2.0.0.alpha1 → 2.0.0.alpha5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +306 -5
  3. data/FEATURES.md +9 -1
  4. data/LICENSE.md +1 -1
  5. data/README.md +9 -6
  6. data/hanami.gemspec +12 -11
  7. data/lib/hanami/application/autoloader/inflector_adapter.rb +22 -0
  8. data/lib/hanami/application/container/boot/inflector.rb +7 -0
  9. data/lib/hanami/application/container/boot/logger.rb +7 -0
  10. data/lib/hanami/application/container/boot/rack_logger.rb +19 -0
  11. data/lib/hanami/application/container/boot/rack_monitor.rb +12 -0
  12. data/lib/hanami/application/container/boot/routes_helper.rb +9 -0
  13. data/lib/hanami/application/container/boot/settings.rb +7 -0
  14. data/lib/hanami/application/router.rb +59 -0
  15. data/lib/hanami/application/routes.rb +55 -0
  16. data/lib/hanami/application/routes_helper.rb +34 -0
  17. data/lib/hanami/application/routing/middleware/stack.rb +89 -0
  18. data/lib/hanami/application/routing/resolver/node.rb +50 -0
  19. data/lib/hanami/application/routing/resolver/trie.rb +59 -0
  20. data/lib/hanami/application/routing/resolver.rb +87 -0
  21. data/lib/hanami/application/routing/router.rb +36 -0
  22. data/lib/hanami/application/settings/dotenv_store.rb +60 -0
  23. data/lib/hanami/application/settings.rb +93 -0
  24. data/lib/hanami/application.rb +330 -34
  25. data/lib/hanami/assets/application_configuration.rb +63 -0
  26. data/lib/hanami/assets/configuration.rb +54 -0
  27. data/lib/hanami/boot/source_dirs.rb +44 -0
  28. data/lib/hanami/boot.rb +1 -2
  29. data/lib/hanami/cli/application/cli.rb +40 -0
  30. data/lib/hanami/cli/application/command.rb +47 -0
  31. data/lib/hanami/cli/application/commands/console.rb +81 -0
  32. data/lib/hanami/cli/application/commands.rb +16 -0
  33. data/lib/hanami/cli/base_command.rb +48 -0
  34. data/lib/hanami/cli/commands/command.rb +4 -4
  35. data/lib/hanami/cli/commands.rb +3 -2
  36. data/lib/hanami/configuration/logger.rb +84 -0
  37. data/lib/hanami/configuration/middleware.rb +4 -4
  38. data/lib/hanami/configuration/null_configuration.rb +14 -0
  39. data/lib/hanami/configuration/router.rb +52 -0
  40. data/lib/hanami/configuration/sessions.rb +5 -5
  41. data/lib/hanami/configuration/source_dirs.rb +42 -0
  42. data/lib/hanami/configuration.rb +122 -131
  43. data/lib/hanami/init.rb +5 -0
  44. data/lib/hanami/setup.rb +9 -0
  45. data/lib/hanami/slice.rb +189 -0
  46. data/lib/hanami/version.rb +1 -1
  47. data/lib/hanami/web/rack_logger.rb +96 -0
  48. data/lib/hanami.rb +17 -30
  49. metadata +116 -50
  50. data/bin/hanami +0 -8
  51. data/lib/hanami/configuration/cookies.rb +0 -24
  52. data/lib/hanami/configuration/security.rb +0 -141
  53. data/lib/hanami/container.rb +0 -107
  54. data/lib/hanami/frameworks.rb +0 -28
  55. data/lib/hanami/routes.rb +0 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c197523a333228ef0596099b121a0f3a3e02c4a5a0da3f3f4fe837e794b7cf8
4
- data.tar.gz: 5a7526ef47fc6f64ebffdae725d26a17944e390274dbc478ff52d593c7ba63b9
3
+ metadata.gz: 9c8875d3320057cffe3af1a7bb2ff781cd8ad2145c446fc9e9190d344a4a48e6
4
+ data.tar.gz: c003bc2117815e10f2c15f458fb3bc6d94b480dfe9f2ec98e6458804f8a0d06d
5
5
  SHA512:
6
- metadata.gz: dd55bf77935140473affae77676eae8afe042f385dee3288dd9d80729fb887899f89950f26b83e2b793161545347cdc3dab8a5f6e0915013aa333c2caf2e080d
7
- data.tar.gz: d254599b55640e0e3a27b718c1ae7141a40662c7291e60463d9620383cc419d49f06f5c8d1712b484f50ba758b71bf3f0ae79729452243532a0769e00478af8b
6
+ metadata.gz: 7b133de3c728132ef6255480b10068482d58cf1e2708df395f00cc5981cdccac70cbecdb2c8325cd822298d7c92c0ee0253ab1f8f9d95ddf84b0d6de556e7f3f
7
+ data.tar.gz: 42b525e3163e7bb73938b5e2fa444ccc15cc38def3e74225086f0e90bb0d805979e0a88a47703fcc73956d68598260ab366a1c155eb94b7114515b8ffc56671e
data/CHANGELOG.md CHANGED
@@ -1,6 +1,276 @@
1
1
  # Hanami
2
2
  The web, with simplicity.
3
3
 
4
+ ## v2.0.0.alpha5 - 2022-01-12
5
+ ### Changed
6
+ - [Luca Guidi] Sensible default configuration for application logger, with per-environment defaults:
7
+
8
+ The defaults are:
9
+
10
+ - In **production**, log for level `info`, send logs to `$stdout` in JSON format without colours
11
+ - In **development**, log for level `debug`, send logs to `$stdout` in single-line format with colours
12
+ - In **test**, log for level `debug`, send logs to `log/test.log` in single-line format without colours
13
+
14
+ To configure the logger:
15
+
16
+ ```ruby
17
+ module MyApp
18
+ class Application < Hanami::Application
19
+ config.logger.level = :info
20
+
21
+ config.logger.stream = $stdout
22
+ config.logger.stream = "/path/to/file"
23
+ config.logger.stream = StringIO.new
24
+
25
+ config.logger.format = :json
26
+ config.logger.format = MyCustomFormatter.new
27
+
28
+ config.logger.color = false # disable coloring
29
+ config.logger.color = MyCustomColorizer.new
30
+
31
+ config.logger.filters << "secret" # add
32
+ config.logger.filters += ["yet", "another"] # add
33
+ config.logger.filters = ["foo"] # replace
34
+
35
+ # See https://ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger.html
36
+ config.logger.options = ["daily"] # time based log rotation
37
+ config.logger.options = [0, 1048576] # size based log rotation
38
+ end
39
+ end
40
+ ```
41
+
42
+ To configure the logger for specific environments:
43
+
44
+ ```ruby
45
+ module MyApp
46
+ class Application < Hanami::Application
47
+ config.environment(:staging) do
48
+ config.logger.level = :info
49
+ end
50
+ end
51
+ end
52
+ ```
53
+
54
+ To assign a custom replacement logger object:
55
+
56
+ ```ruby
57
+ module MyApp
58
+ class Application < Hanami::Application
59
+ config.logger = MyCustomLogger.new
60
+ end
61
+ end
62
+ ```
63
+ - [Tim Riley] Comprehensive `config.source_dirs` setting
64
+
65
+ This replaces the previous `component_dir_paths` setting, and contains two nested settings:
66
+
67
+ - `config.source_dirs.component_dirs` (backed by `Dry::System::Config::ComponentDirs`), for directories of source files intended to be registered as components
68
+ - `config.source_dirs.autoload_paths`, for directories of source files not intended for registration as components, but still to be made accessible by the autoloader
69
+
70
+ To add and configure your own additional component dirs:
71
+
72
+ ```ruby
73
+ module MyApp
74
+ class Application < Hanami::Application
75
+ # Adding a simple component dir
76
+ config.source_dirs.component_dirs.add "serializers"
77
+
78
+ # Adding a component dir with custom configuration
79
+ config.source_dirs.component_dirs.add "serializers" do |dir|
80
+ dir.auto_register = proc { |component|
81
+ !component.identifier.start_with?("structs")
82
+ }
83
+ end
84
+ end
85
+ end
86
+ ```
87
+
88
+ To customize the configuration of the default component dirs ("lib", "actions", "repositories", "views"):
89
+
90
+ ```ruby
91
+ module MyApp
92
+ class Application < Hanami::Application
93
+ # Customising a default component dir
94
+ config.source_dirs.component_dirs.dir("lib").auto_register = proc { |component|
95
+ !component.identifier.start_with?("structs")
96
+ }
97
+
98
+ # Setting default config to apply to all component dirs
99
+ config.source_dirs.component_dirs.auto_register = proc { |component|
100
+ !component.identifier.start_with?("entities")
101
+ }
102
+
103
+ # Removing a default component dir
104
+ config.source_dirs.component_dirs.delete("views")
105
+ end
106
+ end
107
+ ```
108
+
109
+ To configure the autoload paths (defaulting to `["entities"]`):
110
+
111
+ ```ruby
112
+ module MyApp
113
+ class Application < Hanami::Application
114
+ # Adding your own autoload paths
115
+ config.source_dirs.autoload_paths << "structs"
116
+
117
+ # Or providing a full replacement
118
+ config.source_dirs.autoload_paths = ["structs"]
119
+ end
120
+ end
121
+ ```
122
+ - [Tim Riley] Application router is lazy loaded (not requiring application to be fully booted) and now available via `Hanami.rack_app` or `Hanami.application.rack_app`, instead of the previous `Hanami.app` (which required the app to be booted first).
123
+
124
+ ## v2.0.0.alpha4 - 2021-12-07
125
+ ### Added
126
+ - [Luca Guidi] Manage Content Security Policy (CSP) with "zero-defaults" policy. New API to change CSP values and to disable the feature.
127
+ ```ruby
128
+ # Read a CSP value
129
+
130
+ module MyApp
131
+ class Application < Hanami::Application
132
+ config.actions.content_security_policy[:base_uri] # => "'self'"
133
+ end
134
+ end
135
+ ```
136
+
137
+ ```ruby
138
+ # Override a default CSP value
139
+
140
+ module MyApp
141
+ class Application < Hanami::Application
142
+ # This line will generate the following CSP fragment
143
+ # plugin-types ;
144
+ config.actions.content_security_policy[:plugin_types] = nil
145
+ end
146
+ end
147
+ ```
148
+
149
+ ```ruby
150
+ # Append to a default CSP value
151
+
152
+ module MyApp
153
+ class Application < Hanami::Application
154
+ # This line will generate the following CSP fragment
155
+ # script-src 'self' https://my.cdn.test;
156
+ config.actions.content_security_policy[:script_src] += " https://my.cdn.test"
157
+ end
158
+ end
159
+ ```
160
+
161
+ ```ruby
162
+ # Add a custom CSP key. Useful when CSP standard evolves.
163
+
164
+ module MyApp
165
+ class Application < Hanami::Application
166
+ # This line will generate the following CSP fragment
167
+ # my-custom-setting 'self';
168
+ config.actions.content_security_policy[:my-custom-setting] = "'self'"
169
+ end
170
+ end
171
+ ```
172
+
173
+ ```ruby
174
+ # Delete a CSP key.
175
+
176
+ module MyApp
177
+ class Application < Hanami::Application
178
+ config.actions.content_security_policy.delete(:object_src)
179
+ end
180
+ end
181
+ ```
182
+
183
+ ```ruby
184
+ # Disable CSP feature.
185
+
186
+ module MyApp
187
+ class Application < Hanami::Application
188
+ config.actions.content_security_policy = false
189
+ end
190
+ end
191
+ ```
192
+
193
+ ## v2.0.0.alpha3 - 2021-11-09
194
+ ### Added
195
+ - [Luca Guidi] Added `Hanami.shutdown` to stop all bootable components in the application container
196
+ - [Tim Riley] Added `component_dir_paths` application setting to allow for components to be loaded from additional directories inside each slice directory. To begin with, this defaults to `%w[actions repositories views]`. Components inside these directories are expected to be namespaced to match the directory name; e.g. given a `main` slice, `slices/main/actions/home.rb` is expected to define `Main::Actions::Home`, and will be registered in the slice container as `"actions.home"`.
197
+
198
+ ### Changed
199
+ - [Tim Riley] A slice's classes can now be defined directly inside `slices/[slice_name]/lib/`; e.g. given a `main` slice, `slices/main/lib/example.rb` is expected to define `Main::Example`, and will be registered in the slice container as `"example"`
200
+ - [Tim Riley] The root `lib/` directory is no longer configured as a component dir, and classes inside `lib/[app_namespace]/` will no longer be auto-registered into the container. If you need to share components, create them in their own slices as appropriate, and import those slices into the other slices that require them.
201
+ - [Tim Riley] `lib/[app_namespace]/` is configured for autoloading, and `lib/` is added to `$LOAD_PATH` to support explicit requires for source files outside `lib/[app_namespace]/`.
202
+ - [Tim Riley] (Internal) Ported `Hanami::Configuration` and related classes to use dry-configurable
203
+ - [Tim Riley] Application inflector can be entirely replaced, if required, via `Hanami::Configuration#inflector=`. Custom inflection rules can still be provided to the default inflector via `Hanami::Configuration#inflections`.
204
+ - [Marc Busqué] App settings are defined within a concrete class rather than an anonymous block, to allow for users to leverage the typical behavior of Ruby classes, such as for defining their own types module to use for coercing setting values. This class also relies on dry-configurable for its settings implementation, so the standard dry-configurable `setting` API is available, such as the `constructor:` and `default:` options.
205
+ ```ruby
206
+ # frozen_string_literal: true
207
+
208
+ require "dry/types"
209
+ require "hanami/application/settings"
210
+
211
+ module TestApp
212
+ class Settings < Hanami::Application::Settings
213
+ # Example usage of a types module (previously not possible inside the anonymous block)
214
+ Types = Dry.Types()
215
+
216
+ setting :session_secret, constructor: Types::String.constrained(min_size: 20)
217
+
218
+ setting :some_bool, constructor: Types::Params::Bool, default: false
219
+ end
220
+ end
221
+ ```
222
+ - [Marc Busqué] Application `settings_loader` and `settings_loader_options` have been replaced with `settings_store`, which is an updated abstraction for providing setting values to work with the new `Hanami::Application::Settings` implementation noted above (see `Application::Settings::DotenvStore` for the default store, which provides the same behavior as previously)
223
+ - [Marc Busqué] Routes are defined within a concrete class rather than an anonymous block, to provide consistency with the settings (noted above), as well a place for additional behavior (in future releases):
224
+ ```ruby
225
+ # frozen_string_literal: true
226
+
227
+ require "hanami/application/routes"
228
+
229
+ module MyApp
230
+ class Routes < Hanami::Application::Routes
231
+ define do
232
+ slice :main, at: "/" do
233
+ root to: "home.show"
234
+ end
235
+ end
236
+ end
237
+ end
238
+ ```
239
+
240
+ ## v2.0.0.alpha2 - 2021-05-04
241
+ ### Added
242
+ - [Luca Guidi] Official support for Ruby: MRI 3.0
243
+ - [Tim Riley] Code autoloading via Zeitwerk
244
+ - [Tim Riley] `Hanami::Application` subclasses generate and configure a `Dry::System::Container`, accessible via `.container` and `AppNamespace::Container`, with several common container methods available directly via the application subclass (e.g. `Bookshelf::Application["foo"]` or `Hanami.application["foo"]`)
245
+ - [Tim Riley] Introduced `Hanami::Application.register_bootable` to register custom components
246
+ - [Tim Riley] Introduced `Hanami::Application.keys` to get the list of resolved components
247
+ - [Tim Riley] Dynamically create an auto-injection mixin (e.g. `Bookshelf::Deps`)
248
+ ```ruby
249
+ # frozen_string_literal: true
250
+
251
+ module Bookshelf
252
+ class CreateThing
253
+ include Deps[service_client: "some_service.client"]
254
+
255
+ def call(attrs)
256
+ # Validate attrs, etc.
257
+ service_client.create(attrs)
258
+ end
259
+ end
260
+ end
261
+ ```
262
+ - [Tim Riley] Introduced application settings. They are accessible via `Hanami.application.settings` in `config/settings.rb`
263
+ - [Tim Riley] Introduced application slices to organise high-level application concerns. Slices are generated based on subdirectories of `slices/`, and map onto corresponding ruby module namespaces, e.g. `slices/main` -> `Main`, with the slice instance itself being `Main::Slice` (as well as being accessible via `Hanami.application.slices[:main]`)
264
+ - [Tim Riley] Each slice generates and configures has its own `Dry::System::Container`, accessible via the slice instance (e.g. `Main::Slice.container`) as well as via its own constant (e.g. `Main::Container`)
265
+ - [Tim Riley] Slice containers automatically import the application container, under the `"application"` namespace
266
+ - [Tim Riley] Allow slice containers to be imported by other slice containers
267
+
268
+ ### Changed
269
+ - [Luca Guidi] Drop support for Ruby: MRI 2.5
270
+ - [Tim Riley] Removed `config.cookies` in favor of `config.actions.cookies`
271
+ - [Tim Riley] Removed `config.sessions` in favor of `config.actions.sessions`
272
+ - [Tim Riley] Removed `config.security` settings
273
+
4
274
  ## v2.0.0.alpha1 - 2019-01-30
5
275
  ### Added
6
276
  - [Luca Guidi] Implemented from scratch `hanami version`
@@ -50,6 +320,37 @@ end
50
320
  - [Luca Guidi] Removed `shotgun` and code reloading from the core. Code reloading is implemented by `hanami-reloader` gem.
51
321
  - [Luca Guidi] Removed support for `.hanamirc`
52
322
 
323
+ ## v1.3.4 - 2021-05-02
324
+ ### Fixed
325
+ - [Slava Kardakov] Fix generated `config.ru` `require_relative` statement
326
+ - [Armin] Fix `Hanami::CommonLogger` elapsed time compatibility with `rack` 2.1.0+
327
+ - [Adam Daniels] Fix generated tests compatibility with `minitest` 6.0+
328
+
329
+ ## v1.3.3 - 2019-09-20
330
+ ### Added
331
+ - [Gray Manley] Standardize file loading for `.env` files (see: https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use)
332
+
333
+ ### Fixed
334
+ - [Alfonso Uceda & Luca Guidi] Ensure to use `:host` option when mounting an application in main router (e.g. `mount Beta::Application.new, at: "/", host: "beta.hanami.test"`)
335
+
336
+ ## v1.3.2 - 2019-07-26
337
+ ### Added
338
+ - [Luca Guidi] Support both `hanami-validations` 1 and 2
339
+
340
+ ### Fixed
341
+ - [Wisnu Adi Nurcahyo] Ensure `hanami generate` syntax for Welcome page is compatible with ZSH
342
+ - [Luca Guidi] Don't let `hanami` to crash when called without `bundle exec`
343
+
344
+ ## v1.3.1 - 2019-01-18
345
+ ### Added
346
+ - [Luca Guidi] Official support for Ruby: MRI 2.6
347
+ - [Luca Guidi] Support `bundler` 2.0+
348
+
349
+ ### Fixed
350
+ - [Aidan Coyle] Remove from app generator support for deprecated `force_ssl` setting
351
+ - [Alessandro Caporrini] Remove from app generator support for deprecated `body_parsers` setting
352
+ - [Daphne Rouw & Sean Collins] Make app generator to work when code in `config/environment.rb` uses double quotes
353
+
53
354
  ## v1.3.0 - 2018-10-24
54
355
  ### Added
55
356
  - [Luca Guidi] Automatically log body payload from body parsers
@@ -65,7 +366,7 @@ end
65
366
 
66
367
  ### Fixed
67
368
  - [Anton Davydov] Make possible to pass extra settings for custom logger instances (eg. `logger SemanticLogger.new, :foo, :bar`)
68
- - [graywolf] Ensure `hanami generate app` to work without `require_relative` entries in `config/enviroment.rb`
369
+ - [graywolf] Ensure `hanami generate app` to work without `require_relative` entries in `config/environment.rb`
69
370
  - [Makoto Tajitsu & Luca Guidi] Fixed regression for `hanami new .` that used to generate a broken project
70
371
 
71
372
  ### Fixed
@@ -182,7 +483,7 @@ end
182
483
  - [Luca Guidi] Make compatible with Rack 2.0 only
183
484
  - [Luca Guidi] Removed `logger` settings from Hanami applications
184
485
  - [Luca Guidi] Removed logger for Hanami applications (eg `Web.logger`)
185
- - [Luca Guidi] Changed mailer syntax in `config/enviroment.rb`
486
+ - [Luca Guidi] Changed mailer syntax in `config/environment.rb`
186
487
 
187
488
  ## v0.9.2 - 2016-12-19
188
489
  ## Added
@@ -271,11 +572,11 @@ end
271
572
 
272
573
  ## v0.7.2 - 2016-02-09
273
574
  ### Fixed
274
- - [Alfonso Uceda Pompa] Fixed routing issue when static assets server tried to hijiack paths that are matching directories in public directory
575
+ - [Alfonso Uceda Pompa] Fixed routing issue when static assets server tried to hijack paths that are matching directories in public directory
275
576
 
276
577
  ## v0.7.1 - 2016-02-05
277
578
  ### Fixed
278
- - [Anton Davydov] Fixed routing issue when static assets server tried to hijiack requests belonging to dynamic endpoints
579
+ - [Anton Davydov] Fixed routing issue when static assets server tried to hijack requests belonging to dynamic endpoints
279
580
  - [Anatolii Didukh] Ensure to fallback to default engine for `hanami console`
280
581
 
281
582
  ## v0.7.0 - 2016-01-22
@@ -410,7 +711,7 @@ end
410
711
  ## v0.3.0 - 2015-03-23
411
712
  ### Added
412
713
  - [Luca Guidi] Introduced action generator. Eg. `bundle exec lotus generate action web dashboard#index`
413
- - [Alfonso Uceda Pompa] Allow to specify default coookies options in application configuration. Eg. `cookies true, { domain: 'lotusrb.org' }`
714
+ - [Alfonso Uceda Pompa] Allow to specify default cookies options in application configuration. Eg. `cookies true, { domain: 'lotusrb.org' }`
414
715
  - [Tom Kadwill] Include `Lotus::Helpers` in views.
415
716
  - [Linus Pettersson] Allow to specify `--database` CLI option when generate a new project. Eg. `lotus new bookshelf --database=postgresql`
416
717
  - [Linus Pettersson] Initialize a Git repository when generating a new project
data/FEATURES.md CHANGED
@@ -5,6 +5,14 @@
5
5
 
6
6
  ## v2.0.0.alpha1 - 2019-01-30
7
7
 
8
+ ## v1.3.3 - 2019-09-20
9
+
10
+ - Standardize file loading for `.env` files (see: https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use)
11
+
12
+ ## v1.3.2 - 2019-07-26
13
+
14
+ ## v1.3.1 - 2019-01-18
15
+
8
16
  ## v1.3.0 - 2018-10-24
9
17
 
10
18
  - Default testing framework is RSpec
@@ -20,7 +28,7 @@
20
28
  - Unobtrusive JavaScript (UJS) (via `hanami-ujs` gem)
21
29
  - Interactive console for development error page (via `hanami-webconsole` gem)
22
30
  - CLI: register callbacks for `hanami` commands (`Hanami::CLI.after("db migrate", MyCallback.new)` or `Hanami::CLI.after("db migrate") { ... }`)
23
- - Project level Rack middleware stack (`Hanami.configure { middleware.use MyRackMiddlewre }`)
31
+ - Project level Rack middleware stack (`Hanami.configure { middleware.use MyRackMiddleware }`)
24
32
  - Plugins can hook into project configuration (`Hanami.plugin { middleware.use AnotherRackMiddleware }`)
25
33
  - Custom repository commands
26
34
  - Coloured logging
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright © 2014-2017 Luca Guidi
1
+ Copyright © 2014-2021 Luca Guidi
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  The web, with simplicity.
4
4
 
5
+ ## Version
6
+
7
+ **This branch contains the code for `hanami` 2.0.x.**
8
+
5
9
  ## Frameworks
6
10
 
7
11
  Hanami is a **full-stack** Ruby web framework.
@@ -18,7 +22,6 @@ which provides the glue that ties all the parts together:
18
22
  * [**Hanami::Helpers**](https://github.com/hanami/helpers) - View helpers for Ruby applications
19
23
  * [**Hanami::Mailer**](https://github.com/hanami/mailer) - Mail for Ruby applications
20
24
  * [**Hanami::Assets**](https://github.com/hanami/assets) - Assets management for Ruby
21
- * [**Hanami::CLI**](https://github.com/hanami/cli) - Ruby command line interface
22
25
  * [**Hanami::Utils**](https://github.com/hanami/utils) - Ruby core extensions and class utilities
23
26
 
24
27
  These components are designed to be used independently or together in a Hanami application.
@@ -26,14 +29,14 @@ These components are designed to be used independently or together in a Hanami a
26
29
  ## Status
27
30
 
28
31
  [![Gem Version](https://badge.fury.io/rb/hanami.svg)](https://badge.fury.io/rb/hanami)
29
- [![TravisCI](https://travis-ci.org/hanami/hanami.svg?branch=master)](https://travis-ci.org/hanami/hanami)
30
- [![Test Coverage](https://codecov.io/gh/hanami/hanami/branch/master/graph/badge.svg)](https://codecov.io/gh/hanami/hanami)
32
+ [![CI](https://github.com/hanami/hanami/workflows/ci/badge.svg?branch=main)](https://github.com/hanami/hanami/actions?query=workflow%3Aci+branch%3Amain)
33
+ [![Test Coverage](https://codecov.io/gh/hanami/hanami/branch/main/graph/badge.svg)](https://codecov.io/gh/hanami/hanami)
31
34
  [![Depfu](https://badges.depfu.com/badges/ba000e0f69e6ef1c44cd3038caaa1841/overview.svg)](https://depfu.com/github/hanami/hanami?project=Bundler)
32
35
  [![Inline Docs](http://inch-ci.org/github/hanami/hanami.svg)](http://inch-ci.org/github/hanami/hanami)
33
36
 
34
37
  ## Installation
35
38
 
36
- __Hanami__ supports Ruby (MRI) 2.5+
39
+ __Hanami__ supports Ruby (MRI) 2.6+
37
40
 
38
41
  ```shell
39
42
  gem install hanami
@@ -55,7 +58,7 @@ You can give back to Open Source, by supporting Hanami development via a [donati
55
58
 
56
59
  ### Supporters
57
60
 
58
- * [Trung Lê](https://github.com/joneslee85)
61
+ * [Trung Lê](https://github.com/runlevel5)
59
62
  * [James Carlson](https://github.com/jxxcarlson)
60
63
  * [Creditas](https://www.creditas.com.br/)
61
64
 
@@ -137,4 +140,4 @@ Released under MIT License.
137
140
 
138
141
  This project was formerly known as Lotus (`lotusrb`).
139
142
 
140
- Copyright © 2014-2019 Luca Guidi.
143
+ Copyright © 2014-2021 Luca Guidi.
data/hanami.gemspec CHANGED
@@ -4,7 +4,7 @@ lib = File.expand_path("../lib", __FILE__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require "hanami/version"
6
6
 
7
- Gem::Specification.new do |spec|
7
+ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
8
8
  spec.name = "hanami"
9
9
  spec.version = Hanami::VERSION
10
10
  spec.authors = ["Luca Guidi"]
@@ -15,22 +15,23 @@ Gem::Specification.new do |spec|
15
15
  spec.license = "MIT"
16
16
 
17
17
  spec.files = `git ls-files -c -o --exclude-standard -z -- lib/* bin/* LICENSE.md README.md CODE_OF_CONDUCT.md CHANGELOG.md FEATURES.md hanami.gemspec`.split("\x0")
18
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
18
  spec.test_files = spec.files.grep(%r{^(test)/})
20
19
  spec.require_paths = ["lib"]
21
- spec.required_ruby_version = ">= 2.5.0"
20
+ spec.required_ruby_version = ">= 2.6.0"
22
21
 
23
22
  spec.metadata["allowed_push_host"] = "https://rubygems.org"
24
23
 
25
- spec.add_dependency "hanami-utils", "~> 2.0.alpha"
26
- spec.add_dependency "hanami-router", "~> 2.0.alpha"
27
- spec.add_dependency "hanami-controller", "~> 2.0.alpha"
28
- spec.add_dependency "hanami-cli", "~> 1.0.alpha"
29
- spec.add_dependency "dry-system", "~> 0.10"
30
- spec.add_dependency "dry-inflector", "~> 0.1", ">= 0.1.2"
31
24
  spec.add_dependency "bundler", ">= 1.16", "< 3"
25
+ spec.add_dependency "dry-configurable", "~> 0.12", ">= 0.12.1"
26
+ spec.add_dependency "dry-core", "~> 0.4"
27
+ spec.add_dependency "dry-inflector", "~> 0.2", ">= 0.2.1"
28
+ spec.add_dependency "dry-monitor"
29
+ spec.add_dependency "dry-system", "~> 0.22", ">= 0.22.0"
30
+ spec.add_dependency "hanami-cli", "~> 2.0.alpha"
31
+ spec.add_dependency "hanami-utils", "~> 2.0.alpha"
32
+ spec.add_dependency "zeitwerk", "~> 2.4"
32
33
 
33
- spec.add_development_dependency "rspec", "~> 3.8"
34
+ spec.add_development_dependency "rspec", "~> 3.8"
34
35
  spec.add_development_dependency "rack-test", "~> 1.1"
35
- spec.add_development_dependency "rake", "~> 12.0"
36
+ spec.add_development_dependency "rake", "~> 13.0"
36
37
  end
@@ -0,0 +1,22 @@
1
+ module Hanami
2
+ class Application
3
+ module Autoloader
4
+ # Allows the Hanami standard inflector (from dry-inflector) to be used with Zeitwerk
5
+ class InflectorAdapter
6
+ def initialize(inflector)
7
+ @inflector = inflector
8
+ end
9
+
10
+ def camelize(basename, _abspath)
11
+ # Discard unused `_abspath` argument before calling our own inflector's
12
+ # `#camelize` (which takes only one argument)
13
+ inflector.camelize(basename)
14
+ end
15
+
16
+ private
17
+
18
+ attr_reader :inflector
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ Hanami.application.register_bootable :inflector do
4
+ start do
5
+ register :inflector, Hanami.application.inflector
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ Hanami.application.register_bootable :logger do
4
+ start do
5
+ register :logger, Hanami.application.configuration.logger_instance
6
+ end
7
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ Hanami.application.register_bootable :rack_logger do |container|
4
+ start do
5
+ require "hanami/web/rack_logger"
6
+
7
+ use :logger
8
+ use :rack_monitor
9
+
10
+ rack_logger = Hanami::Web::RackLogger.new(
11
+ container[:logger],
12
+ filter_params: Hanami.application.configuration.logger.filters
13
+ )
14
+
15
+ rack_logger.attach container[:rack_monitor]
16
+
17
+ register :rack_logger, rack_logger
18
+ end
19
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ Hanami.application.register_bootable :rack_monitor do |container|
4
+ start do
5
+ require "dry/monitor"
6
+ require "dry/monitor/rack/middleware"
7
+
8
+ middleware = Dry::Monitor::Rack::Middleware.new(container[:notifications])
9
+
10
+ register :rack_monitor, middleware
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ Hanami.application.register_bootable :routes_helper do
4
+ start do
5
+ require "hanami/application/routes_helper"
6
+
7
+ register :routes_helper, Hanami::Application::RoutesHelper.new(Hanami.application.router)
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ Hanami.application.register_bootable :settings do
4
+ start do
5
+ register :settings, Hanami.application.settings
6
+ end
7
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami/router"
4
+ require "hanami/application/routing/middleware/stack"
5
+
6
+ module Hanami
7
+ class Application
8
+ # Hanami application router
9
+ # @since 2.0.0
10
+ class Router < ::Hanami::Router
11
+ # @since 2.0.0
12
+ # @api private
13
+ def initialize(routes:, middleware_stack: Routing::Middleware::Stack.new, **kwargs, &blk)
14
+ @middleware_stack = middleware_stack
15
+ instance_eval(&blk)
16
+ super(**kwargs, &routes)
17
+ end
18
+
19
+ # @since 2.0.0
20
+ # @api private
21
+ def freeze
22
+ return self if frozen?
23
+
24
+ remove_instance_variable(:@middleware_stack)
25
+ super
26
+ end
27
+
28
+ # @since 2.0.0
29
+ # @api private
30
+ def use(middleware, *args, &blk)
31
+ @middleware_stack.use(middleware, *args, &blk)
32
+ end
33
+
34
+ # @since 2.0.0
35
+ # @api private
36
+ def scope(*args, &blk)
37
+ @middleware_stack.with(args.first) do
38
+ super
39
+ end
40
+ end
41
+
42
+ # @since 2.0.0
43
+ def slice(name, at:, &blk)
44
+ path = prefixed_path(at)
45
+ @resolver.register_slice_at_path(name, path)
46
+
47
+ scope(path, &blk)
48
+ end
49
+
50
+ # @since 2.0.0
51
+ # @api private
52
+ def to_rack_app
53
+ return self if @middleware_stack.empty?
54
+
55
+ @middleware_stack.to_rack_app(self)
56
+ end
57
+ end
58
+ end
59
+ end