hanami 2.0.0.alpha7.1 → 2.0.0.beta1.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.
Files changed (223) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +457 -237
  3. data/FEATURES.md +30 -9
  4. data/README.md +1 -3
  5. data/hanami.gemspec +21 -11
  6. data/lib/hanami/app.rb +141 -0
  7. data/lib/hanami/assets/application_configuration.rb +10 -4
  8. data/lib/hanami/configuration/actions/content_security_policy.rb +118 -0
  9. data/lib/hanami/configuration/actions/cookies.rb +29 -0
  10. data/lib/hanami/configuration/actions/sessions.rb +46 -0
  11. data/lib/hanami/configuration/actions.rb +23 -12
  12. data/lib/hanami/configuration/logger.rb +13 -10
  13. data/lib/hanami/configuration/router.rb +2 -6
  14. data/lib/hanami/configuration/sessions.rb +1 -1
  15. data/lib/hanami/configuration/views.rb +86 -0
  16. data/lib/hanami/configuration.rb +139 -82
  17. data/lib/hanami/constants.rb +30 -2
  18. data/lib/hanami/errors.rb +4 -1
  19. data/lib/hanami/extensions/action/slice_configured_action.rb +103 -0
  20. data/lib/hanami/extensions/action.rb +79 -0
  21. data/lib/hanami/extensions/view/context.rb +106 -0
  22. data/lib/hanami/extensions/view/slice_configured_context.rb +71 -0
  23. data/lib/hanami/extensions/view/slice_configured_view.rb +107 -0
  24. data/lib/hanami/extensions/view.rb +33 -0
  25. data/lib/hanami/extensions.rb +10 -0
  26. data/lib/hanami/providers/inflector.rb +13 -0
  27. data/lib/hanami/providers/logger.rb +13 -0
  28. data/lib/hanami/providers/rack.rb +27 -0
  29. data/lib/hanami/providers/routes.rb +33 -0
  30. data/lib/hanami/providers/settings.rb +23 -0
  31. data/lib/hanami/rake_tasks.rb +61 -0
  32. data/lib/hanami/routes.rb +51 -0
  33. data/lib/hanami/server.rb +1 -1
  34. data/lib/hanami/settings/dotenv_store.rb +58 -0
  35. data/lib/hanami/settings.rb +90 -0
  36. data/lib/hanami/setup.rb +4 -2
  37. data/lib/hanami/{application → slice}/router.rb +18 -13
  38. data/lib/hanami/slice/routes_helper.rb +37 -0
  39. data/lib/hanami/{application → slice}/routing/middleware/stack.rb +43 -5
  40. data/lib/hanami/slice/routing/resolver.rb +97 -0
  41. data/lib/hanami/slice/view_name_inferrer.rb +63 -0
  42. data/lib/hanami/slice.rb +252 -82
  43. data/lib/hanami/slice_configurable.rb +62 -0
  44. data/lib/hanami/slice_name.rb +111 -0
  45. data/lib/hanami/slice_registrar.rb +119 -0
  46. data/lib/hanami/version.rb +1 -1
  47. data/lib/hanami/web/rack_logger.rb +1 -1
  48. data/lib/hanami.rb +34 -26
  49. data/spec/integration/application_middleware_stack_spec.rb +84 -0
  50. data/spec/integration/assets/cdn_spec.rb +48 -0
  51. data/spec/integration/assets/fingerprint_spec.rb +42 -0
  52. data/spec/integration/assets/helpers_spec.rb +50 -0
  53. data/spec/integration/assets/serve_spec.rb +70 -0
  54. data/spec/integration/assets/subresource_integrity_spec.rb +54 -0
  55. data/spec/integration/body_parsers_spec.rb +50 -0
  56. data/spec/integration/cli/assets/precompile_spec.rb +147 -0
  57. data/spec/integration/cli/assets_spec.rb +14 -0
  58. data/spec/integration/cli/console_spec.rb +105 -0
  59. data/spec/integration/cli/db/apply_spec.rb +74 -0
  60. data/spec/integration/cli/db/console_spec.rb +40 -0
  61. data/spec/integration/cli/db/create_spec.rb +50 -0
  62. data/spec/integration/cli/db/drop_spec.rb +54 -0
  63. data/spec/integration/cli/db/migrate_spec.rb +108 -0
  64. data/spec/integration/cli/db/prepare_spec.rb +36 -0
  65. data/spec/integration/cli/db/rollback_spec.rb +96 -0
  66. data/spec/integration/cli/db/version_spec.rb +38 -0
  67. data/spec/integration/cli/db_spec.rb +21 -0
  68. data/spec/integration/cli/destroy/action_spec.rb +143 -0
  69. data/spec/integration/cli/destroy/app_spec.rb +118 -0
  70. data/spec/integration/cli/destroy/mailer_spec.rb +74 -0
  71. data/spec/integration/cli/destroy/migration_spec.rb +70 -0
  72. data/spec/integration/cli/destroy/model_spec.rb +113 -0
  73. data/spec/integration/cli/destroy_spec.rb +18 -0
  74. data/spec/integration/cli/generate/action_spec.rb +469 -0
  75. data/spec/integration/cli/generate/app_spec.rb +215 -0
  76. data/spec/integration/cli/generate/mailer_spec.rb +189 -0
  77. data/spec/integration/cli/generate/migration_spec.rb +72 -0
  78. data/spec/integration/cli/generate/model_spec.rb +290 -0
  79. data/spec/integration/cli/generate/secret_spec.rb +56 -0
  80. data/spec/integration/cli/generate_spec.rb +19 -0
  81. data/spec/integration/cli/new/database_spec.rb +235 -0
  82. data/spec/integration/cli/new/hanami_head_spec.rb +27 -0
  83. data/spec/integration/cli/new/template_spec.rb +118 -0
  84. data/spec/integration/cli/new/test_spec.rb +274 -0
  85. data/spec/integration/cli/new_spec.rb +970 -0
  86. data/spec/integration/cli/plugins_spec.rb +39 -0
  87. data/spec/integration/cli/routes_spec.rb +49 -0
  88. data/spec/integration/cli/server_spec.rb +626 -0
  89. data/spec/integration/cli/version_spec.rb +85 -0
  90. data/spec/integration/early_hints_spec.rb +35 -0
  91. data/spec/integration/handle_exceptions_spec.rb +244 -0
  92. data/spec/integration/head_spec.rb +89 -0
  93. data/spec/integration/http_headers_spec.rb +29 -0
  94. data/spec/integration/mailer_spec.rb +32 -0
  95. data/spec/integration/middleware_spec.rb +81 -0
  96. data/spec/integration/mount_applications_spec.rb +88 -0
  97. data/spec/integration/project_initializers_spec.rb +40 -0
  98. data/spec/integration/rackup_spec.rb +35 -0
  99. data/spec/integration/rake/with_minitest_spec.rb +67 -0
  100. data/spec/integration/rake/with_rspec_spec.rb +69 -0
  101. data/spec/integration/routing_helpers_spec.rb +61 -0
  102. data/spec/integration/security/content_security_policy_spec.rb +46 -0
  103. data/spec/integration/security/csrf_protection_spec.rb +42 -0
  104. data/spec/integration/security/force_ssl_spec.rb +29 -0
  105. data/spec/integration/security/x_content_type_options_spec.rb +46 -0
  106. data/spec/integration/security/x_frame_options_spec.rb +46 -0
  107. data/spec/integration/security/x_xss_protection_spec.rb +46 -0
  108. data/spec/integration/send_file_spec.rb +51 -0
  109. data/spec/integration/sessions_spec.rb +247 -0
  110. data/spec/integration/static_middleware_spec.rb +21 -0
  111. data/spec/integration/streaming_spec.rb +41 -0
  112. data/spec/integration/unsafe_send_file_spec.rb +52 -0
  113. data/spec/isolation/hanami/application/already_configured_spec.rb +19 -0
  114. data/spec/isolation/hanami/application/inherit_anonymous_class_spec.rb +10 -0
  115. data/spec/isolation/hanami/application/inherit_concrete_class_spec.rb +14 -0
  116. data/spec/isolation/hanami/application/not_configured_spec.rb +9 -0
  117. data/spec/isolation/hanami/application/routes/configured_spec.rb +44 -0
  118. data/spec/isolation/hanami/application/routes/not_configured_spec.rb +16 -0
  119. data/spec/isolation/hanami/boot/success_spec.rb +50 -0
  120. data/spec/new_integration/action/configuration_spec.rb +26 -0
  121. data/spec/new_integration/action/cookies_spec.rb +58 -0
  122. data/spec/new_integration/action/csrf_protection_spec.rb +54 -0
  123. data/spec/new_integration/action/routes_spec.rb +73 -0
  124. data/spec/new_integration/action/sessions_spec.rb +50 -0
  125. data/spec/new_integration/action/view_integration_spec.rb +165 -0
  126. data/spec/new_integration/action/view_rendering/automatic_rendering_spec.rb +247 -0
  127. data/spec/new_integration/action/view_rendering/paired_view_inference_spec.rb +115 -0
  128. data/spec/new_integration/action/view_rendering_spec.rb +107 -0
  129. data/spec/new_integration/code_loading/loading_from_app_spec.rb +152 -0
  130. data/spec/new_integration/code_loading/loading_from_slice_spec.rb +165 -0
  131. data/spec/new_integration/container/application_routes_helper_spec.rb +48 -0
  132. data/spec/new_integration/container/auto_injection_spec.rb +53 -0
  133. data/spec/new_integration/container/auto_registration_spec.rb +86 -0
  134. data/spec/new_integration/container/autoloader_spec.rb +80 -0
  135. data/spec/new_integration/container/imports_spec.rb +253 -0
  136. data/spec/new_integration/container/prepare_container_spec.rb +123 -0
  137. data/spec/new_integration/container/shutdown_spec.rb +91 -0
  138. data/spec/new_integration/container/standard_bootable_components_spec.rb +124 -0
  139. data/spec/new_integration/rack_app/middleware_spec.rb +215 -0
  140. data/spec/new_integration/rack_app/non_booted_rack_app_spec.rb +105 -0
  141. data/spec/new_integration/rack_app/rack_app_spec.rb +524 -0
  142. data/spec/new_integration/settings_spec.rb +115 -0
  143. data/spec/new_integration/slices/external_slice_spec.rb +92 -0
  144. data/spec/new_integration/slices/slice_configuration_spec.rb +40 -0
  145. data/spec/new_integration/slices/slice_routing_spec.rb +226 -0
  146. data/spec/new_integration/slices/slice_settings_spec.rb +141 -0
  147. data/spec/new_integration/slices_spec.rb +101 -0
  148. data/spec/new_integration/view/configuration_spec.rb +49 -0
  149. data/spec/new_integration/view/context/assets_spec.rb +67 -0
  150. data/spec/new_integration/view/context/inflector_spec.rb +48 -0
  151. data/spec/new_integration/view/context/request_spec.rb +61 -0
  152. data/spec/new_integration/view/context/routes_spec.rb +86 -0
  153. data/spec/new_integration/view/context/settings_spec.rb +50 -0
  154. data/spec/new_integration/view/inflector_spec.rb +57 -0
  155. data/spec/new_integration/view/part_namespace_spec.rb +96 -0
  156. data/spec/new_integration/view/path_spec.rb +56 -0
  157. data/spec/new_integration/view/template_spec.rb +68 -0
  158. data/spec/new_integration/view/views_spec.rb +103 -0
  159. data/spec/spec_helper.rb +16 -0
  160. data/spec/support/app_integration.rb +91 -0
  161. data/spec/support/coverage.rb +1 -0
  162. data/spec/support/fixtures/hanami-plugin/Gemfile +8 -0
  163. data/spec/support/fixtures/hanami-plugin/README.md +35 -0
  164. data/spec/support/fixtures/hanami-plugin/Rakefile +4 -0
  165. data/spec/support/fixtures/hanami-plugin/bin/console +15 -0
  166. data/spec/support/fixtures/hanami-plugin/bin/setup +8 -0
  167. data/spec/support/fixtures/hanami-plugin/hanami-plugin.gemspec +28 -0
  168. data/spec/support/fixtures/hanami-plugin/lib/hanami/plugin/cli.rb +19 -0
  169. data/spec/support/fixtures/hanami-plugin/lib/hanami/plugin/version.rb +7 -0
  170. data/spec/support/fixtures/hanami-plugin/lib/hanami/plugin.rb +8 -0
  171. data/spec/support/rspec.rb +27 -0
  172. data/spec/support/shared_examples/cli/generate/app.rb +494 -0
  173. data/spec/support/shared_examples/cli/generate/migration.rb +32 -0
  174. data/spec/support/shared_examples/cli/generate/model.rb +81 -0
  175. data/spec/support/shared_examples/cli/new.rb +97 -0
  176. data/spec/unit/hanami/configuration/actions/content_security_policy_spec.rb +102 -0
  177. data/spec/unit/hanami/configuration/actions/cookies_spec.rb +46 -0
  178. data/spec/unit/hanami/configuration/actions/csrf_protection_spec.rb +57 -0
  179. data/spec/unit/hanami/configuration/actions/default_values_spec.rb +52 -0
  180. data/spec/unit/hanami/configuration/actions/sessions_spec.rb +50 -0
  181. data/spec/unit/hanami/configuration/actions_spec.rb +78 -0
  182. data/spec/unit/hanami/configuration/base_url_spec.rb +25 -0
  183. data/spec/unit/hanami/configuration/inflector_spec.rb +35 -0
  184. data/spec/unit/hanami/configuration/logger_spec.rb +203 -0
  185. data/spec/unit/hanami/configuration/views_spec.rb +120 -0
  186. data/spec/unit/hanami/configuration_spec.rb +43 -0
  187. data/spec/unit/hanami/env_spec.rb +54 -0
  188. data/spec/unit/hanami/routes_spec.rb +25 -0
  189. data/spec/unit/hanami/settings/dotenv_store_spec.rb +119 -0
  190. data/spec/unit/hanami/settings_spec.rb +56 -0
  191. data/spec/unit/hanami/slice_configurable_spec.rb +104 -0
  192. data/spec/unit/hanami/slice_name_spec.rb +47 -0
  193. data/spec/unit/hanami/slice_spec.rb +17 -0
  194. data/spec/unit/hanami/version_spec.rb +7 -0
  195. data/spec/unit/hanami/web/rack_logger_spec.rb +78 -0
  196. metadata +363 -55
  197. data/lib/hanami/application/container/providers/inflector.rb +0 -7
  198. data/lib/hanami/application/container/providers/logger.rb +0 -7
  199. data/lib/hanami/application/container/providers/rack_logger.rb +0 -15
  200. data/lib/hanami/application/container/providers/rack_monitor.rb +0 -12
  201. data/lib/hanami/application/container/providers/routes_helper.rb +0 -9
  202. data/lib/hanami/application/container/providers/settings.rb +0 -7
  203. data/lib/hanami/application/routes.rb +0 -55
  204. data/lib/hanami/application/routes_helper.rb +0 -34
  205. data/lib/hanami/application/routing/resolver/node.rb +0 -50
  206. data/lib/hanami/application/routing/resolver/trie.rb +0 -59
  207. data/lib/hanami/application/routing/resolver.rb +0 -87
  208. data/lib/hanami/application/routing/router.rb +0 -36
  209. data/lib/hanami/application/settings/dotenv_store.rb +0 -60
  210. data/lib/hanami/application/settings.rb +0 -93
  211. data/lib/hanami/application/slice_registrar.rb +0 -106
  212. data/lib/hanami/application.rb +0 -299
  213. data/lib/hanami/boot/source_dirs.rb +0 -44
  214. data/lib/hanami/cli/application/cli.rb +0 -40
  215. data/lib/hanami/cli/application/command.rb +0 -47
  216. data/lib/hanami/cli/application/commands/console.rb +0 -81
  217. data/lib/hanami/cli/application/commands.rb +0 -16
  218. data/lib/hanami/cli/base_command.rb +0 -48
  219. data/lib/hanami/cli/commands/command.rb +0 -171
  220. data/lib/hanami/cli/commands/server.rb +0 -88
  221. data/lib/hanami/cli/commands.rb +0 -65
  222. data/lib/hanami/configuration/middleware.rb +0 -20
  223. data/lib/hanami/configuration/source_dirs.rb +0 -42
data/CHANGELOG.md CHANGED
@@ -1,139 +1,228 @@
1
1
  # Hanami
2
+
2
3
  The web, with simplicity.
3
4
 
4
- ## v2.0.0.alpha7.1 - 2020-03-09
5
+ ## v2.0.0.beta1.1 - 2022-07-22
6
+
7
+ - [Andrew Croome] Specified 2.0.0.beta dependencies for hanami-cli and hanami-utils (to prefer these over previously installed alpha versions) [#1187]
8
+
9
+ ## v2.0.0.beta1 - 2022-07-20
10
+
11
+ ### Added
12
+
13
+ - [Luca Guidi] Added support for `hanami` CLI [#1096]
14
+ - [Luca Guidi] Added support for Rake tasks for compatibility with Ruby hosting services (`db:migrate` and `assets:precompile`) [#1096]
15
+ - [Tim Riley] Add `app/` as source dir for application container [#1174]
16
+ - [Piotr Solnica] Allow Rack middleware to be inserted before/after a specific router middleware [#1176]
17
+
18
+ ```ruby
19
+ # config/routes.rb:
20
+
21
+ module TestApp
22
+ class Routes < Hanami::Routes
23
+ slice :admin, at: "/admin" do
24
+ use TestApp::Middlewares::AppendOne
25
+ use TestApp::Middlewares::Prepare, before: TestApp::Middlewares::AppendOne
26
+ use TestApp::Middlewares::AppendTwo, after: TestApp::Middlewares::AppendOne
27
+ end
28
+ end
29
+ end
30
+ ```
31
+
32
+ ### Fixed
33
+
34
+ - [Tim Riley] Fallback to `RACK_ENV` if `HANAMI_ENV` isn't set [#1168]
35
+ - [Tim Riley] Print error friendly messages when a soft dependency isn't installed [#1166]
36
+ - [Piotr Solnica] Ensure to handle properly Rack middleware that accept a block
37
+
38
+ ```ruby
39
+ # config/app.rb:
40
+
41
+ module TestApp
42
+ class App < Hanami::App
43
+ config.middleware.use(TestApp::TestMiddleware) do |env|
44
+ env["tested"] = "yes"
45
+ end
46
+ end
47
+ end
48
+ ```
49
+
50
+ - [Tim Riley] Ensure to correctly activate session middleware [#1179]
51
+ - [Tim Riley] Avoid redundant auto-registrations for `lib/` files [#1184]
52
+
53
+ ### Changed
54
+
55
+ - [Luca Guidi] Make `app/` the core of Hanami 2 apps
56
+ - [Luca Guidi] `Hanami::Application` -> `Hanami::App`
57
+ - [Luca Guidi] `Hanami.application` -> `Hanami.app`
58
+ - [Luca Guidi] `config/application.rb` -> `config/app.rb`
59
+ - [Luca Guidi] Remove `::Application::` namespace in public API class names (e.g. `Hanami::Application::Routes` -> `Hanami::Routes`) [#1172]
60
+ - [Tim Riley] Removed `Hanami::Configuration#settings_path`, `#settings_class_name` [#1175]
61
+ - [Tim Riley] Removed `Hanami::Configuration::Router#routes_path`, and `#routes_class_name` [#1175]
62
+ - [Tim Riley] Make `Hanami::App` to inherit from `Hanami::Slice` [#1162]
63
+
64
+ ## v2.0.0.alpha8 - 2022-05-19
65
+
66
+ ### Added
67
+
68
+ - [Tim Riley] Introduced `Hanami::Application::Action` as base class for actions that integrate with Hanami applications. Base action classes in Hanami applications should now inherit from this.
69
+ - [Tim Riley] Introduced `Hanami::Application::View` and `Hanami::Application::View::Context` as base classes for views and view contexts that integrate with Hanami applications. Base view classes in Hanami applications should now inherit from these.
70
+ - [Tim Riley] Introduced `Hanami::Application.application_name`, which returns an `Hanami::SliceName` instance, with methods for representing the application name in various formats.
71
+
72
+ ### Fixed
73
+
74
+ - [Andrew Croome] When a request is halted, do not attempt to automatically render any view paired with an `Hanami::Application::Action`
75
+
76
+ ### Changed
77
+
78
+ - [Tim Riley] `Hanami::Application.namespace_name`, `.namespace_path` have been removed. These can now be accessed from the `.application_name`.
79
+ - [Tim Riley] `Hanami::Slice.slice_name` now returns an `Hanami::SliceName` instance instead of a Symbol
80
+ - [Tim Riley] `Hanami::Slice.namespace_path` has been removed. This can now be accessed from the `.slice_name`.
81
+
82
+ ## v2.0.0.alpha7.1 - 2022-03-09
83
+
84
+ ### Fixed
5
85
 
6
- ## Fixed
7
86
  - [Tim Riley] Fixed error creating slice classes when the enclosing module did not already exist
8
87
 
9
- ## v2.0.0.alpha7 - 2020-03-08
88
+ ## v2.0.0.alpha7 - 2022-03-08
89
+
90
+ ### Added
10
91
 
11
- ## Added
12
92
  - [Tim Riley] Introduced `Hanami::ApplicationLoadError` and `Hanami::SliceLoadError` exceptions to represent errors encountered during application and slice loading.
13
93
  - [Tim Riley] `Hanami::Slice.shutdown` can be used to stop all the providers in a slice
14
94
 
15
- ## Changed
95
+ ### Changed
96
+
16
97
  - [Tim Riley] Slices are now represented as concrete classes (such as `Main::Slice`) inheriting from `Hanami::Slice`, as opposed to _instances_ of `Hanami::Slice`. You may create your own definitions for these slices in `config/slices/[slice_name].rb`, which you can then use for customising per-slice config and behavior, e.g.
17
98
 
18
- ```ruby
19
- # config/slices/main.rb:
99
+ ```ruby
100
+ # config/slices/main.rb:
20
101
 
21
- module Main
22
- class Slice < Hanami::Slice
23
- # slice config here
24
- end
102
+ module Main
103
+ class Slice < Hanami::Slice
104
+ # slice config here
25
105
  end
26
- ```
106
+ end
107
+ ```
108
+
27
109
  - [Tim Riley] Application-level `config.slice(slice_name, &block)` setting has been removed in favour of slice configuration within concrete slice class definitions
28
110
  - [Tim Riley] You can configure your slice imports inside your slice classes, e.g.
29
111
 
30
- ```ruby
31
- # config/slices/main.rb:
112
+ ```ruby
113
+ # config/slices/main.rb:
32
114
 
33
- module Main
34
- class Slice < Hanami::Slice
35
- # Import all exported components from "search" slice
36
- import from: :search
37
- end
115
+ module Main
116
+ class Slice < Hanami::Slice
117
+ # Import all exported components from "search" slice
118
+ import from: :search
38
119
  end
39
- ```
120
+ end
121
+ ```
122
+
40
123
  - [Tim Riley] You can configure your slice exports inside your slice classes, e.g.
41
124
 
42
- ```ruby
43
- # config/slices/search.rb:
125
+ ```ruby
126
+ # config/slices/search.rb:
44
127
 
45
- module Search
46
- class Slice < Hanami::Slice
47
- # Export the "index_entity" component only
48
- export ["index_entity"]
49
- end
128
+ module Search
129
+ class Slice < Hanami::Slice
130
+ # Export the "index_entity" component only
131
+ export ["index_entity"]
50
132
  end
51
- ```
133
+ end
134
+ ```
135
+
52
136
  - [Tim Riley] For advanced cases, you can configure your slice's container via a `prepare_container` block:
53
137
 
54
- ```ruby
55
- # config/slices/search.rb:
138
+ ```ruby
139
+ # config/slices/search.rb:
56
140
 
57
- module Search
58
- class Slice < Hanami::Slice
59
- prepare_container do |container|
60
- # `container` object is available here, with
61
- # slice-specific configuration already applied
62
- end
141
+ module Search
142
+ class Slice < Hanami::Slice
143
+ prepare_container do |container|
144
+ # `container` object is available here, with
145
+ # slice-specific configuration already applied
63
146
  end
64
147
  end
65
- ```
148
+ end
149
+ ```
150
+
66
151
  - [Tim Riley] `Hanami::Application.shutdown` will now also shutdown all registered slices
67
152
 
68
153
  ## v2.0.0.alpha6 - 2022-02-10
154
+
69
155
  ### Added
156
+
70
157
  - [Luca Guidi] Official support for Ruby: MRI 3.1
71
158
  - [Tim Riley] Introduce partial Slice imports and exports. It allows to selectively export a functionality from a slice and import into another.
72
159
 
73
- Import from `search` slice, uses `search` as the imported key namespace:
160
+ Import from `search` slice, uses `search` as the imported key namespace:
74
161
 
75
- ```ruby
76
- # config/application.rb
162
+ ```ruby
163
+ # config/application.rb
77
164
 
78
- module MyApp
79
- class Application < Hanami::Application
80
- config.slice(:admin) do
81
- import(from: :search)
82
- end
165
+ module MyApp
166
+ class Application < Hanami::Application
167
+ config.slice(:admin) do
168
+ import(from: :search)
83
169
  end
84
170
  end
85
- ```
171
+ end
172
+ ```
86
173
 
87
- Import from `search` slice with custom namespace:
174
+ Import from `search` slice with custom namespace:
88
175
 
89
- ```ruby
90
- # config/application.rb
176
+ ```ruby
177
+ # config/application.rb
91
178
 
92
- module MyApp
93
- class Application < Hanami::Application
94
- config.slice(:admin) do
95
- import(from: :search, as: :search_engine)
96
- end
179
+ module MyApp
180
+ class Application < Hanami::Application
181
+ config.slice(:admin) do
182
+ import(from: :search, as: :search_engine)
97
183
  end
98
184
  end
99
- ```
185
+ end
186
+ ```
100
187
 
101
- Import specific keys from `search` slice
188
+ Import specific keys from `search` slice
102
189
 
103
- ```ruby
104
- # config/application.rb
190
+ ```ruby
191
+ # config/application.rb
105
192
 
106
- module MyApp
107
- class Application < Hanami::Application
108
- config.slice(:admin) do
109
- import(keys: ["run_query"], from: :search)
110
- end
193
+ module MyApp
194
+ class Application < Hanami::Application
195
+ config.slice(:admin) do
196
+ import(keys: ["run_query"], from: :search)
111
197
  end
112
198
  end
113
- ```
199
+ end
200
+ ```
114
201
 
115
- Export only specific keys from `search` slice, and import them in `admin`
202
+ Export only specific keys from `search` slice, and import them in `admin`
116
203
 
117
- ```ruby
118
- # config/application.rb
204
+ ```ruby
205
+ # config/application.rb
119
206
 
120
- module MyApp
121
- class Application < Hanami::Application
122
- config.slice(:admin) do
123
- import(from: :search)
124
- end
207
+ module MyApp
208
+ class Application < Hanami::Application
209
+ config.slice(:admin) do
210
+ import(from: :search)
211
+ end
125
212
 
126
- config.slice(:search) do
127
- container.config.exports = %w[run_query index_item]
128
- end
213
+ config.slice(:search) do
214
+ container.config.exports = %w[run_query index_item]
129
215
  end
130
216
  end
131
- ```
217
+ end
218
+ ```
132
219
 
133
220
  ### Fixed
221
+
134
222
  - [Luca Guidi] Ensure request logger to respect logger formatter option.
135
223
 
136
224
  ### Changed
225
+
137
226
  - [Luca Guidi] Drop support for Ruby: MRI 2.6 and 2.7.
138
227
  - [Tim Riley] `Hanami.init` => `Hanami.prepare` and `hanami/init` => `hanami/prepare`
139
228
  - [Tim Riley] `Hanami.register_bootable` => `Hanami.register_provider`
@@ -143,263 +232,280 @@ The web, with simplicity.
143
232
  - [Tim Riley] `Hanami::Slice#start_bootable` => `Hanami::Slice#start`
144
233
 
145
234
  ## v2.0.0.alpha5 - 2022-01-12
235
+
146
236
  ### Changed
237
+
147
238
  - [Luca Guidi] Sensible default configuration for application logger, with per-environment defaults:
148
239
 
149
- The defaults are:
240
+ The defaults are:
150
241
 
151
- - In **production**, log for level `info`, send logs to `$stdout` in JSON format without colours
152
- - In **development**, log for level `debug`, send logs to `$stdout` in single-line format with colours
153
- - In **test**, log for level `debug`, send logs to `log/test.log` in single-line format without colours
242
+ - In **production**, log for level `info`, send logs to `$stdout` in JSON format without colours
243
+ - In **development**, log for level `debug`, send logs to `$stdout` in single-line format with colours
244
+ - In **test**, log for level `debug`, send logs to `log/test.log` in single-line format without colours
154
245
 
155
- To configure the logger:
246
+ To configure the logger:
156
247
 
157
- ```ruby
158
- module MyApp
159
- class Application < Hanami::Application
160
- config.logger.level = :info
248
+ ```ruby
249
+ module MyApp
250
+ class Application < Hanami::Application
251
+ config.logger.level = :info
161
252
 
162
- config.logger.stream = $stdout
163
- config.logger.stream = "/path/to/file"
164
- config.logger.stream = StringIO.new
253
+ config.logger.stream = $stdout
254
+ config.logger.stream = "/path/to/file"
255
+ config.logger.stream = StringIO.new
165
256
 
166
- config.logger.format = :json
167
- config.logger.format = MyCustomFormatter.new
257
+ config.logger.format = :json
258
+ config.logger.format = MyCustomFormatter.new
168
259
 
169
- config.logger.color = false # disable coloring
170
- config.logger.color = MyCustomColorizer.new
260
+ config.logger.color = false # disable coloring
261
+ config.logger.color = MyCustomColorizer.new
171
262
 
172
- config.logger.filters << "secret" # add
173
- config.logger.filters += ["yet", "another"] # add
174
- config.logger.filters = ["foo"] # replace
263
+ config.logger.filters << "secret" # add
264
+ config.logger.filters += ["yet", "another"] # add
265
+ config.logger.filters = ["foo"] # replace
175
266
 
176
- # See https://ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger.html
177
- config.logger.options = ["daily"] # time based log rotation
178
- config.logger.options = [0, 1048576] # size based log rotation
179
- end
267
+ # See https://ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger.html
268
+ config.logger.options = ["daily"] # time based log rotation
269
+ config.logger.options = [0, 1048576] # size based log rotation
180
270
  end
181
- ```
271
+ end
272
+ ```
182
273
 
183
- To configure the logger for specific environments:
274
+ To configure the logger for specific environments:
184
275
 
185
- ```ruby
186
- module MyApp
187
- class Application < Hanami::Application
188
- config.environment(:staging) do
189
- config.logger.level = :info
190
- end
276
+ ```ruby
277
+ module MyApp
278
+ class Application < Hanami::Application
279
+ config.environment(:staging) do
280
+ config.logger.level = :info
191
281
  end
192
282
  end
193
- ```
283
+ end
284
+ ```
194
285
 
195
- To assign a custom replacement logger object:
286
+ To assign a custom replacement logger object:
196
287
 
197
- ```ruby
198
- module MyApp
199
- class Application < Hanami::Application
200
- config.logger = MyCustomLogger.new
201
- end
288
+ ```ruby
289
+ module MyApp
290
+ class Application < Hanami::Application
291
+ config.logger = MyCustomLogger.new
202
292
  end
203
- ```
293
+ end
294
+ ```
295
+
204
296
  - [Tim Riley] Comprehensive `config.source_dirs` setting
205
297
 
206
- This replaces the previous `component_dir_paths` setting, and contains two nested settings:
298
+ This replaces the previous `component_dir_paths` setting, and contains two nested settings:
207
299
 
208
- - `config.source_dirs.component_dirs` (backed by `Dry::System::Config::ComponentDirs`), for directories of source files intended to be registered as components
209
- - `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
300
+ - `config.source_dirs.component_dirs` (backed by `Dry::System::Config::ComponentDirs`), for directories of source files intended to be registered as components
301
+ - `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
210
302
 
211
- To add and configure your own additional component dirs:
303
+ To add and configure your own additional component dirs:
212
304
 
213
- ```ruby
214
- module MyApp
215
- class Application < Hanami::Application
216
- # Adding a simple component dir
217
- config.source_dirs.component_dirs.add "serializers"
305
+ ```ruby
306
+ module MyApp
307
+ class Application < Hanami::Application
308
+ # Adding a simple component dir
309
+ config.source_dirs.component_dirs.add "serializers"
218
310
 
219
- # Adding a component dir with custom configuration
220
- config.source_dirs.component_dirs.add "serializers" do |dir|
221
- dir.auto_register = proc { |component|
222
- !component.identifier.start_with?("structs")
223
- }
224
- end
311
+ # Adding a component dir with custom configuration
312
+ config.source_dirs.component_dirs.add "serializers" do |dir|
313
+ dir.auto_register = proc { |component|
314
+ !component.identifier.start_with?("structs")
315
+ }
225
316
  end
226
317
  end
227
- ```
318
+ end
319
+ ```
228
320
 
229
- To customize the configuration of the default component dirs ("lib", "actions", "repositories", "views"):
321
+ To customize the configuration of the default component dirs ("lib", "actions", "repositories", "views"):
230
322
 
231
- ```ruby
232
- module MyApp
233
- class Application < Hanami::Application
234
- # Customising a default component dir
235
- config.source_dirs.component_dirs.dir("lib").auto_register = proc { |component|
236
- !component.identifier.start_with?("structs")
237
- }
323
+ ```ruby
324
+ module MyApp
325
+ class Application < Hanami::Application
326
+ # Customising a default component dir
327
+ config.source_dirs.component_dirs.dir("lib").auto_register = proc { |component|
328
+ !component.identifier.start_with?("structs")
329
+ }
238
330
 
239
- # Setting default config to apply to all component dirs
240
- config.source_dirs.component_dirs.auto_register = proc { |component|
241
- !component.identifier.start_with?("entities")
242
- }
331
+ # Setting default config to apply to all component dirs
332
+ config.source_dirs.component_dirs.auto_register = proc { |component|
333
+ !component.identifier.start_with?("entities")
334
+ }
243
335
 
244
- # Removing a default component dir
245
- config.source_dirs.component_dirs.delete("views")
246
- end
336
+ # Removing a default component dir
337
+ config.source_dirs.component_dirs.delete("views")
247
338
  end
248
- ```
339
+ end
340
+ ```
249
341
 
250
- To configure the autoload paths (defaulting to `["entities"]`):
342
+ To configure the autoload paths (defaulting to `["entities"]`):
251
343
 
252
- ```ruby
253
- module MyApp
254
- class Application < Hanami::Application
255
- # Adding your own autoload paths
256
- config.source_dirs.autoload_paths << "structs"
344
+ ```ruby
345
+ module MyApp
346
+ class Application < Hanami::Application
347
+ # Adding your own autoload paths
348
+ config.source_dirs.autoload_paths << "structs"
257
349
 
258
- # Or providing a full replacement
259
- config.source_dirs.autoload_paths = ["structs"]
260
- end
350
+ # Or providing a full replacement
351
+ config.source_dirs.autoload_paths = ["structs"]
261
352
  end
262
- ```
353
+ end
354
+ ```
355
+
263
356
  - [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).
264
357
 
265
358
  ## v2.0.0.alpha4 - 2021-12-07
359
+
266
360
  ### Added
361
+
267
362
  - [Luca Guidi] Manage Content Security Policy (CSP) with "zero-defaults" policy. New API to change CSP values and to disable the feature.
268
- ```ruby
269
- # Read a CSP value
270
363
 
271
- module MyApp
272
- class Application < Hanami::Application
273
- config.actions.content_security_policy[:base_uri] # => "'self'"
274
- end
364
+ ```ruby
365
+ # Read a CSP value
366
+
367
+ module MyApp
368
+ class Application < Hanami::Application
369
+ config.actions.content_security_policy[:base_uri] # => "'self'"
275
370
  end
276
- ```
371
+ end
372
+ ```
277
373
 
278
- ```ruby
279
- # Override a default CSP value
374
+ ```ruby
375
+ # Override a default CSP value
280
376
 
281
- module MyApp
282
- class Application < Hanami::Application
283
- # This line will generate the following CSP fragment
284
- # plugin-types ;
285
- config.actions.content_security_policy[:plugin_types] = nil
286
- end
377
+ module MyApp
378
+ class Application < Hanami::Application
379
+ # This line will generate the following CSP fragment
380
+ # plugin-types ;
381
+ config.actions.content_security_policy[:plugin_types] = nil
287
382
  end
288
- ```
383
+ end
384
+ ```
289
385
 
290
- ```ruby
291
- # Append to a default CSP value
386
+ ```ruby
387
+ # Append to a default CSP value
292
388
 
293
- module MyApp
294
- class Application < Hanami::Application
295
- # This line will generate the following CSP fragment
296
- # script-src 'self' https://my.cdn.test;
297
- config.actions.content_security_policy[:script_src] += " https://my.cdn.test"
298
- end
389
+ module MyApp
390
+ class Application < Hanami::Application
391
+ # This line will generate the following CSP fragment
392
+ # script-src 'self' https://my.cdn.test;
393
+ config.actions.content_security_policy[:script_src] += " https://my.cdn.test"
299
394
  end
300
- ```
395
+ end
396
+ ```
301
397
 
302
- ```ruby
303
- # Add a custom CSP key. Useful when CSP standard evolves.
398
+ ```ruby
399
+ # Add a custom CSP key. Useful when CSP standard evolves.
304
400
 
305
- module MyApp
306
- class Application < Hanami::Application
307
- # This line will generate the following CSP fragment
308
- # my-custom-setting 'self';
309
- config.actions.content_security_policy[:my-custom-setting] = "'self'"
310
- end
401
+ module MyApp
402
+ class Application < Hanami::Application
403
+ # This line will generate the following CSP fragment
404
+ # my-custom-setting 'self';
405
+ config.actions.content_security_policy['my-custom-setting'] = "'self'"
311
406
  end
312
- ```
407
+ end
408
+ ```
313
409
 
314
- ```ruby
315
- # Delete a CSP key.
410
+ ```ruby
411
+ # Delete a CSP key.
316
412
 
317
- module MyApp
318
- class Application < Hanami::Application
319
- config.actions.content_security_policy.delete(:object_src)
320
- end
413
+ module MyApp
414
+ class Application < Hanami::Application
415
+ config.actions.content_security_policy.delete(:object_src)
321
416
  end
322
- ```
417
+ end
418
+ ```
323
419
 
324
- ```ruby
325
- # Disable CSP feature.
420
+ ```ruby
421
+ # Disable CSP feature.
326
422
 
327
- module MyApp
328
- class Application < Hanami::Application
329
- config.actions.content_security_policy = false
330
- end
423
+ module MyApp
424
+ class Application < Hanami::Application
425
+ config.actions.content_security_policy = false
331
426
  end
332
- ```
427
+ end
428
+ ```
333
429
 
334
430
  ## v2.0.0.alpha3 - 2021-11-09
431
+
335
432
  ### Added
433
+
336
434
  - [Luca Guidi] Added `Hanami.shutdown` to stop all bootable components in the application container
337
435
  - [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"`.
338
436
 
339
437
  ### Changed
438
+
340
439
  - [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"`
341
440
  - [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.
342
441
  - [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]/`.
343
442
  - [Tim Riley] (Internal) Ported `Hanami::Configuration` and related classes to use dry-configurable
344
443
  - [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`.
345
444
  - [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.
346
- ```ruby
347
- # frozen_string_literal: true
348
445
 
349
- require "dry/types"
350
- require "hanami/application/settings"
446
+ ```ruby
447
+ # frozen_string_literal: true
351
448
 
352
- module TestApp
353
- class Settings < Hanami::Application::Settings
354
- # Example usage of a types module (previously not possible inside the anonymous block)
355
- Types = Dry.Types()
449
+ require "dry/types"
450
+ require "hanami/application/settings"
356
451
 
357
- setting :session_secret, constructor: Types::String.constrained(min_size: 20)
452
+ module TestApp
453
+ class Settings < Hanami::Application::Settings
454
+ # Example usage of a types module (previously not possible inside the anonymous block)
455
+ Types = Dry.Types()
358
456
 
359
- setting :some_bool, constructor: Types::Params::Bool, default: false
360
- end
457
+ setting :session_secret, constructor: Types::String.constrained(min_size: 20)
458
+
459
+ setting :some_bool, constructor: Types::Params::Bool, default: false
361
460
  end
362
- ```
461
+ end
462
+ ```
463
+
363
464
  - [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)
364
465
  - [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):
365
- ```ruby
366
- # frozen_string_literal: true
367
466
 
368
- require "hanami/application/routes"
467
+ ```ruby
468
+ # frozen_string_literal: true
369
469
 
370
- module MyApp
371
- class Routes < Hanami::Application::Routes
372
- define do
373
- slice :main, at: "/" do
374
- root to: "home.show"
375
- end
470
+ require "hanami/application/routes"
471
+
472
+ module MyApp
473
+ class Routes < Hanami::Application::Routes
474
+ define do
475
+ slice :main, at: "/" do
476
+ root to: "home.show"
376
477
  end
377
478
  end
378
479
  end
379
- ```
480
+ end
481
+ ```
380
482
 
381
483
  ## v2.0.0.alpha2 - 2021-05-04
484
+
382
485
  ### Added
486
+
383
487
  - [Luca Guidi] Official support for Ruby: MRI 3.0
384
488
  - [Tim Riley] Code autoloading via Zeitwerk
385
489
  - [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"]`)
386
490
  - [Tim Riley] Introduced `Hanami::Application.register_bootable` to register custom components
387
491
  - [Tim Riley] Introduced `Hanami::Application.keys` to get the list of resolved components
388
492
  - [Tim Riley] Dynamically create an auto-injection mixin (e.g. `Bookshelf::Deps`)
389
- ```ruby
390
- # frozen_string_literal: true
391
493
 
392
- module Bookshelf
393
- class CreateThing
394
- include Deps[service_client: "some_service.client"]
494
+ ```ruby
495
+ # frozen_string_literal: true
395
496
 
396
- def call(attrs)
397
- # Validate attrs, etc.
398
- service_client.create(attrs)
399
- end
497
+ module Bookshelf
498
+ class CreateThing
499
+ include Deps[service_client: "some_service.client"]
500
+
501
+ def call(attrs)
502
+ # Validate attrs, etc.
503
+ service_client.create(attrs)
400
504
  end
401
505
  end
402
- ```
506
+ end
507
+ ```
508
+
403
509
  - [Tim Riley] Introduced application settings. They are accessible via `Hanami.application.settings` in `config/settings.rb`
404
510
  - [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]`)
405
511
  - [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`)
@@ -407,13 +513,16 @@ The web, with simplicity.
407
513
  - [Tim Riley] Allow slice containers to be imported by other slice containers
408
514
 
409
515
  ### Changed
516
+
410
517
  - [Luca Guidi] Drop support for Ruby: MRI 2.5
411
518
  - [Tim Riley] Removed `config.cookies` in favor of `config.actions.cookies`
412
519
  - [Tim Riley] Removed `config.sessions` in favor of `config.actions.sessions`
413
520
  - [Tim Riley] Removed `config.security` settings
414
521
 
415
522
  ## v2.0.0.alpha1 - 2019-01-30
523
+
416
524
  ### Added
525
+
417
526
  - [Luca Guidi] Implemented from scratch `hanami version`
418
527
  - [Luca Guidi] Implemented from scratch `hanami server`
419
528
  - [Luca Guidi] Main configuration is opinionated: when a setting is not specified in generated code, it uses a framework default.
@@ -436,6 +545,7 @@ The web, with simplicity.
436
545
  (e.g. `config.security.content_security_policy[:plugin_types] = nil` to override the settings)
437
546
 
438
547
  ### Changed
548
+
439
549
  - [Luca Guidi] Drop support for Ruby: MRI 2.3, and 2.4.
440
550
  - [Luca Guidi] `Hanami::Application` must be used as superclass for main application under `config/application.rb` (e.g. `Bookshelf::Application`)
441
551
  - [Luca Guidi] Main configuration is available at `config/application.rb` instead of `config/enviroment.rb`
@@ -444,6 +554,7 @@ The web, with simplicity.
444
554
  - [Luca Guidi] Per enviroment settings must be wrapped in a block (e.g. `config.enviroment(:production) { |c| c.logger = {} }`)
445
555
  - [Luca Guidi] Concrete applications are no longer supported (e.g. `Web::Application` in `apps/web/application.rb`)
446
556
  - [Luca Guidi] Main routes must be configured at `config/routes.rb`:
557
+
447
558
  ```ruby
448
559
  # frozen_string_literal: true
449
560
 
@@ -457,113 +568,153 @@ Hanami.application.routes do
457
568
  end
458
569
  end
459
570
  ```
571
+
460
572
  - [Luca Guidi] Per application routes are no longer supported (e.g. `apps/web/config/routes.rb`)
461
573
  - [Luca Guidi] Removed `shotgun` and code reloading from the core. Code reloading is implemented by `hanami-reloader` gem.
462
574
  - [Luca Guidi] Removed support for `.hanamirc`
463
575
 
464
576
  ## v1.3.4 - 2021-05-02
577
+
465
578
  ### Fixed
579
+
466
580
  - [Slava Kardakov] Fix generated `config.ru` `require_relative` statement
467
581
  - [Armin] Fix `Hanami::CommonLogger` elapsed time compatibility with `rack` 2.1.0+
468
582
  - [Adam Daniels] Fix generated tests compatibility with `minitest` 6.0+
469
583
 
470
584
  ## v1.3.3 - 2019-09-20
585
+
471
586
  ### Added
587
+
472
588
  - [Gray Manley] Standardize file loading for `.env` files (see: https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use)
473
589
 
474
590
  ### Fixed
591
+
475
592
  - [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"`)
476
593
 
477
594
  ## v1.3.2 - 2019-07-26
595
+
478
596
  ### Added
597
+
479
598
  - [Luca Guidi] Support both `hanami-validations` 1 and 2
480
599
 
481
600
  ### Fixed
601
+
482
602
  - [Wisnu Adi Nurcahyo] Ensure `hanami generate` syntax for Welcome page is compatible with ZSH
483
603
  - [Luca Guidi] Don't let `hanami` to crash when called without `bundle exec`
484
604
 
485
605
  ## v1.3.1 - 2019-01-18
606
+
486
607
  ### Added
608
+
487
609
  - [Luca Guidi] Official support for Ruby: MRI 2.6
488
610
  - [Luca Guidi] Support `bundler` 2.0+
489
611
 
490
612
  ### Fixed
613
+
491
614
  - [Aidan Coyle] Remove from app generator support for deprecated `force_ssl` setting
492
615
  - [Alessandro Caporrini] Remove from app generator support for deprecated `body_parsers` setting
493
616
  - [Daphne Rouw & Sean Collins] Make app generator to work when code in `config/environment.rb` uses double quotes
494
617
 
495
618
  ## v1.3.0 - 2018-10-24
619
+
496
620
  ### Added
621
+
497
622
  - [Luca Guidi] Automatically log body payload from body parsers
498
623
 
499
624
  ### Fixed
625
+
500
626
  - [Luca Guidi] Generate correct syntax for layout unit tests
501
627
  - [Vladislav Yashin] Fix concatenation of `Pathname` and `String` in `Hanami::CommonLogger`
502
628
 
503
629
  ## v1.3.0.beta1 - 2018-08-08
630
+
504
631
  ### Added
632
+
505
633
  - [Sean Collins] Generate new projects with RSpec as default testing framework
506
634
  - [Alfonso Uceda] Generate actions/views/mailers with nested module/class definition
507
635
 
508
636
  ### Fixed
637
+
509
638
  - [Anton Davydov] Make possible to pass extra settings for custom logger instances (eg. `logger SemanticLogger.new, :foo, :bar`)
510
639
  - [graywolf] Ensure `hanami generate app` to work without `require_relative` entries in `config/environment.rb`
511
640
  - [Makoto Tajitsu & Luca Guidi] Fixed regression for `hanami new .` that used to generate a broken project
512
641
 
513
642
  ### Fixed
643
+
514
644
  - [John Downey] Don't use thread unsafe `Dir.chdir` to serve static assets
515
645
 
516
646
  ## v1.2.0 - 2018-04-11
517
647
 
518
648
  ## v1.2.0.rc2 - 2018-04-06
649
+
519
650
  ### Fixed
651
+
520
652
  - [Kelsey Judson] Ensure to not reload code under `lib/` when `shotgun` isn't bundled
521
653
 
522
654
  ## v1.2.0.rc1 - 2018-03-30
523
655
 
524
656
  ## v1.2.0.beta2 - 2018-03-23
657
+
525
658
  ### Fixed
659
+
526
660
  - [Luca Guidi] Raise meaningful error message when trying to access `session` or `flash` with disabled sessions
527
661
  - [Pistos] Print stack trace to standard output when a CLI command raises an error
528
662
 
529
663
  ## v1.2.0.beta1 - 2018-02-28
664
+
530
665
  ### Added
666
+
531
667
  - [Luca Guidi] HTTP/2 Early Hints
532
668
 
533
669
  ### Fixed
670
+
534
671
  - [Alfonso Uceda] Render custom template if an exception is raised from a view or template
535
672
 
536
673
  ## v1.1.1 - 2018-02-27
674
+
537
675
  ### Added
676
+
538
677
  - [Luca Guidi] Official support for Ruby MRI 2.5+
539
678
 
540
679
  ### Fixed
680
+
541
681
  - [Alfonso Uceda] Fixed regression for mailer generator: when using options like `--from` and `--to` the generated Ruby code isn't valid as it was missing string quotes.
542
682
  - [Luca Guidi] Generate tests for views including `:format` in `exposures`. This fixes view unit tests when the associated template renders a partial.
543
683
 
544
684
  ## v1.1.0 - 2017-10-25
685
+
545
686
  ### Fixed
687
+
546
688
  - [Luca Guidi] Ensure `hanami db rollback` steps to be a positive integer
547
689
 
548
690
  ## v1.1.0.rc1 - 2017-10-16
691
+
549
692
  ### Added
693
+
550
694
  - [Yuji Ueki] Generate RSpec tests with `:type` metadata (eg `type: :action`)
551
695
  - [Kirill] Add `--relation` option for `hanami generate model` (eg `bundle exec hanami generate model user --relation=accounts`)
552
696
 
553
697
  ## v1.1.0.beta3 - 2017-10-04
698
+
554
699
  ### Fixed
700
+
555
701
  - [Luca Guidi] Don't require `:plugins` group when running `hanami new`
556
702
 
557
703
  ## v1.1.0.beta2 - 2017-10-03
704
+
558
705
  ### Added
706
+
559
707
  - [Luca Guidi] Introduce `:plugins` group for `Gemfile` in order enable Hanami plugin gems
560
708
  - [Alfonso Uceda] CLI: `hanami db rollback` to revert one or more migrations at once
561
709
 
562
710
  ### Fixed
711
+
563
712
  - [Gabriel Gizotti] Fix generate/destroy for nested actions
564
713
 
565
714
  ## v1.1.0.beta1 - 2017-08-11
715
+
566
716
  ### Added
717
+
567
718
  - [Ben Johnson] Allow to use custom logger as `Hanami.logger` (eg. `Hanami.configure { logger Timber::Logger.new($stdout) }`)
568
719
  - [akhramov] Generate spec file for application layout when generating a new app
569
720
  - [Anton Davydov] Generate `README.md` file for new projects
@@ -572,23 +723,29 @@ end
572
723
  - [Marion Duprey & Gabriel Gizotti] Filter sensitive data in logs
573
724
 
574
725
  ### Fixed
726
+
575
727
  - [jarosluv] Ensure to remove the correct migration file when executing `hanami db destroy model`
576
728
  - [sovetnik] Fix require path for Minitest spec helper
577
729
 
578
730
  ## v1.0.0 - 2017-04-06
579
731
 
580
732
  ## v1.0.0.rc1 - 2017-03-31
733
+
581
734
  ### Added
735
+
582
736
  - [Luca Guidi] Allow `logger` setting in `config/environment.rb` to accept arbitrary arguments to make `Hanami::Logger` to be compatible with Ruby's `Logger`. (eg. `logger 'daily', level: :info`)
583
737
 
584
738
  ### Fixed
739
+
585
740
  - [Luca Guidi] Ensure code reloading don't misconfigure mailer settings (regression from v1.0.0.beta3)
586
741
  - [Luca Guidi] Ensure database disconnection to happen in the same thread of `Hanami.boot`
587
742
  - [Luca Guidi] Ensure `mailer` block in `config/environment.rb` to be evaluated multiple times, according to the current Hanami environment
588
743
  - [Luca Guidi] Ensure a Hanami project to require only once the code under `lib/`
589
744
 
590
745
  ## v1.0.0.beta3 - 2017-03-17
746
+
591
747
  ### Fixed
748
+
592
749
  - [Luca Guidi] Try to disconnect from database at the boot time. This is useful to prune stale connection during production deploys.
593
750
  - [Tobias Sandelius] Don't mount `Hanami::CommonLogger` middleware if logging is disabled for the project.
594
751
  - [Anton Davydov] Don't configure mailers, if it's mailing is disabled for the project.
@@ -596,12 +753,15 @@ end
596
753
  - [Jimmy Börjesson] Make `apps/web/application.rb` code to wrap around the 80th column
597
754
 
598
755
  ### Changed
756
+
599
757
  - [Luca Guidi] Removed deprecated `ApplicationConfiguration#default_format`. Use `#default_request_format` instead.
600
758
 
601
759
  ## v1.0.0.beta2 - 2017-03-02
602
760
 
603
761
  ## v1.0.0.beta1 - 2017-02-14
762
+
604
763
  ### Added
764
+
605
765
  - [Luca Guidi] Official support for Ruby: MRI 2.4
606
766
  - [yjukaku] CLI: `hanami generate model` now also generates a migration
607
767
  - [Luca Guidi] Generate `config/boot.rb` for new Hanami projects.
@@ -610,6 +770,7 @@ end
610
770
  - [Luca Guidi] Introduced `environment` for env specific settings in `config/environment.rb`
611
771
 
612
772
  ### Fixed
773
+
613
774
  - [Marcello Rocha] Fix Hanami::Mailer loading
614
775
  - [Kai Kuchenbecker] Serve only existing assets with `Hanami::Static`
615
776
  - [Gabriel Gizotti] Ensure inline ENV vars to not be overwritten by `.env.*` files
@@ -620,6 +781,7 @@ end
620
781
  - [Victor Franco] Fixed CLI subcommands help output
621
782
 
622
783
  ### Changed
784
+
623
785
  - [Ozawa Sakuro] Don't include `bundler` as a dependency `Gemfile` for new Hanami projects
624
786
  - [Luca Guidi] Make compatible with Rack 2.0 only
625
787
  - [Luca Guidi] Removed `logger` settings from Hanami applications
@@ -627,23 +789,31 @@ end
627
789
  - [Luca Guidi] Changed mailer syntax in `config/environment.rb`
628
790
 
629
791
  ## v0.9.2 - 2016-12-19
792
+
630
793
  ## Added
794
+
631
795
  - [The Crab] Mark unit tests/specs as pending for generated actions and views
632
796
 
633
797
  ### Fixed
798
+
634
799
  - [Luca Guidi] Rake task `:environment` no longer depends on the removed `:preload` task
635
800
  - [Luca Guidi] Ensure force SSL to use the default port, or the configured one
636
801
  - [Luca Guidi] Boot the project when other it's started without `hanami server` (eg. `puma` or `rackup`)
637
802
 
638
803
  ## v0.9.1 - 2016-11-18
804
+
639
805
  ### Fixed
806
+
640
807
  - [Luca Guidi] Ensure JSON body parser to not eval untrusted input
641
808
 
642
809
  ## v0.9.0 - 2016-11-15
810
+
643
811
  ### Added
812
+
644
813
  - [Christophe Philemotte] Introduced `hanami secret` to generate and print a new sessions secret
645
814
 
646
815
  ### Fixed
816
+
647
817
  - [Bruz Marzolf] Skip project code preloading when code reloading is enabled
648
818
  - [Bruz Marzolf] Ensure to generate project in current directory when running `hanami new .`
649
819
  - [Pascal Betz] Fix constant lookup within the project namespace
@@ -652,6 +822,7 @@ end
652
822
  - [Luca Guidi] Fix duplicated Rack middleware in single Hanami application stacks
653
823
 
654
824
  ### Changed
825
+
655
826
  - [Luca Guidi] Official support for Ruby MRI 2.3+
656
827
  - [Luca Guidi] Removed support for "application" architecture
657
828
  - [Luca Guidi] Removed `Hanami::Container.new` in favor of `Hanami.app`
@@ -663,7 +834,9 @@ end
663
834
  - [Luca Guidi & Sean Collins] Renamed assets configuration `digest` into `fingerprint`
664
835
 
665
836
  ## v0.8.0 - 2016-07-22
837
+
666
838
  ### Added
839
+
667
840
  - [Luca Guidi] Generate new projects with Subresurce Integrity enabled in production (security).
668
841
  - [Luca Guidi] Include `X-XSS-Protection: 1; mode=block` in default response headers (security).
669
842
  - [Luca Guidi] Include `X-Content-Type-Options: nosniff` in default response headers (security).
@@ -677,6 +850,7 @@ end
677
850
  - [Sean Collins] Add `--version` and `-v` for `hanami version` CLI
678
851
 
679
852
  ### Fixed
853
+
680
854
  - [Josh Bodah] Ensure consistent CLI messages
681
855
  - [Andrey Morskov] Ensure consistent user experience and messages for generators
682
856
  - [Luca Guidi] Fixed generators for camel case project names
@@ -696,7 +870,9 @@ end
696
870
  - [Luca Guidi & Lucas Amorim] Make model generator not dependendent on the current directory name, but to the project name stored in `.hanamirc`
697
871
 
698
872
  ### Changed
873
+
699
874
  – [Luca Guidi] Drop support for Ruby 2.0 and 2.1
875
+
700
876
  - [Trung Lê] Database env var is now `DATABASE_URL` (without the project name prefix like `BOOKSHELF_DATABASE_URL`
701
877
  - [Trung Lê] `lib/config/mapping.rb` is no longer generated for new projects and no longer loaded.
702
878
  - [Anton Davydov] New generated projects will depend (in their `Gemfile`) on `hanami` tiny version (`~> 0.8'`) instead of patch version (`0.8.0`)
@@ -708,24 +884,34 @@ end
708
884
  - [Luca Guidi] Allow views to render any HTTP status code. In actions use `halt(422)` for default status page or `self.status = 422` for view rendering.
709
885
 
710
886
  ## v0.7.3 - 2016-05-23
887
+
711
888
  ### Fixed
889
+
712
890
  - [Pascal Betz] Use `Shotgun::Static` to serve static files in development mode and avoid to reload the env
713
891
 
714
892
  ## v0.7.2 - 2016-02-09
893
+
715
894
  ### Fixed
895
+
716
896
  - [Alfonso Uceda Pompa] Fixed routing issue when static assets server tried to hijack paths that are matching directories in public directory
717
897
 
718
898
  ## v0.7.1 - 2016-02-05
899
+
719
900
  ### Fixed
901
+
720
902
  - [Anton Davydov] Fixed routing issue when static assets server tried to hijack requests belonging to dynamic endpoints
721
903
  - [Anatolii Didukh] Ensure to fallback to default engine for `hanami console`
722
904
 
723
905
  ## v0.7.0 - 2016-01-22
906
+
724
907
  ### Changed
908
+
725
909
  - [Luca Guidi] Renamed the project
726
910
 
727
911
  ## v0.6.1 - 2016-01-19
912
+
728
913
  ### Fixed
914
+
729
915
  - [Anton Davydov] Show the current app name in Welcome page (eg. `/admin` shows instructions on how to generate an action for `Admin` app)
730
916
  - [Anton Davydov] Fix project creation when name contains dashes (eg. `"awesome-project" => "AwesomeProject"`)
731
917
  - [Anton Davydov] Ensure to add assets related entries to `.gitignore` when a project is generated with the `--database` flag
@@ -734,7 +920,9 @@ end
734
920
  - [Serg Ikonnikov & Trung Lê] Ensure console to use the bundled engine
735
921
 
736
922
  ## v0.6.0 - 2016-01-12
923
+
737
924
  ### Added
925
+
738
926
  - [Luca Guidi] Introduced configurable assets compressors
739
927
  - [Luca Guidi] Introduced "CDN mode" in order to serve static assets via Content Distribution Networks
740
928
  - [Luca Guidi] Introduced "Digest mode" in production in order to generate and serve assets with checksum suffix
@@ -753,6 +941,7 @@ end
753
941
  - [Gonzalo Rodríguez-Baltanás Díaz] Generate new applications with default favicon
754
942
 
755
943
  ### Fixed
944
+
756
945
  - [Neil Matatall] Use "secure compare" for CSRF tokens in order to prevent timing attacks
757
946
  - [Bernardo Farah] Fix support for chunked response body (via `Rack::Chunked::Body`)
758
947
  - [Lucas Allan Amorim] Add `bundler` as a runtime dependency
@@ -769,6 +958,7 @@ end
769
958
  - [Alfonso Uceda Pompa] Convert dasherized names into underscored names when generating projects (eg. `awesome-project` to `awesome_project`)
770
959
 
771
960
  ### Changed
961
+
772
962
  - [Sean Collins] Welcome page shows current year in copyright notes
773
963
  - [Luca Guidi] Add `/public/assets*` to `.gitignore` of new projects
774
964
  - [Luca Guidi] Removed support for `default_format` in favor of `default_request_format`
@@ -777,7 +967,9 @@ end
777
967
  - [Luca Guidi] `assets` configuration in `apps/web/application.rb` now accepts a block to configure sources and other settings
778
968
 
779
969
  ## v0.5.0 - 2015-09-30
970
+
780
971
  ### Added
972
+
781
973
  - [Ines Coelho & Rosa Faria] Introduced mailers support
782
974
  - [Theo Felippe] Added configuration entries: `#default_request_format` and `default_response_format`
783
975
  - [Rodrigo Panachi] Introduced `logger` configuration for applications, to be used like this: `Web::Logger.debug`
@@ -785,6 +977,7 @@ end
785
977
  - [Pascal Betz] Introduced `--method` CLI argument for action generator as a way to specify the HTTP verb
786
978
 
787
979
  ### Fixed
980
+
788
981
  - [Luca Guidi] Handle conflicts between directories with the same name while serving static assets
789
982
  - [Derk-Jan Karrenbeld] Include default value `font-src: self` for CSP HTTP header
790
983
  - [Cam Huynh] Make CLI arguments immutable for `Lotus::Environment`
@@ -792,13 +985,17 @@ end
792
985
  - [Alfonso Uceda Pompa] Print error message and exit when no name is provided to model generator
793
986
 
794
987
  ### Changed
988
+
795
989
  - [Theo Felippe] Deprecated `#default_format` in favor of: `#default_request_format`
796
990
 
797
991
  ## v0.4.1 - 2015-07-10
992
+
798
993
  ### Added
994
+
799
995
  - [Trung Lê] Alias `--database` as `--db` for `lotus new`
800
996
 
801
997
  ### Fixed
998
+
802
999
  - [Alfonso Uceda Pompa] Ensure to load correctly apps in `lotus console`
803
1000
  - [Alfonso Uceda Pompa] Ensure to not duplicate prefix for Container mounted apps (eg `/admin/admin/dashboard`)
804
1001
  - [Alfonso Uceda Pompa] Ensure generator for "application" architecture to generate session secret
@@ -807,7 +1004,9 @@ end
807
1004
  - [Luca Guidi] Ensure to prepend sessions middleware, so other Rack components can have access to HTTP session
808
1005
 
809
1006
  ## v0.4.0 - 2015-06-23
1007
+
810
1008
  ### Added
1009
+
811
1010
  - [Luca Guidi] Database migrations and new CLI commands for database operations
812
1011
  - [Luca Guidi] Cross Site Request Forgery (CSRF) protection
813
1012
  - [Hiếu Nguyễn & Luca Guidi] Application Architecture
@@ -816,23 +1015,28 @@ end
816
1015
  - [Luca Guidi] Added `rendered` "let" variable for new generated tests for views
817
1016
 
818
1017
  ### Fixed
1018
+
819
1019
  - [Alfonso Uceda Pompa] Fix generated routes for Container applications mounted on a path different from `/`.
820
1020
  - [Luca Guidi] Reading `.lotusrc` pollutes `ENV` with unwanted variables.
821
1021
  - [Alfonso Uceda Pompa] Added sqlite extension to SQLite/SQLite3 database URL.
822
1022
 
823
1023
  ### Changed
1024
+
824
1025
  - [Luca Guidi] `.env`, `.env.development` and `.env.test` are generated and expected to be placed at the root of the project.
825
1026
  - [Luca Guidi] Remove database mapping from generated apps.
826
1027
  - [Trung Lê & Luca Guidi] Remove default generated from new apps.
827
1028
  - [Luca Guidi] New projects should depend on `lotus-model ~> 0.4`
828
1029
 
829
1030
  ## v0.3.2 - 2015-05-22
1031
+
830
1032
  ### Added
1033
+
831
1034
  - [Alfonso Uceda Pompa] Automatic secure cookies if the current connection is using HTTPS.
832
1035
  - [Alfonso Uceda Pompa] Routing helpers for actions (via `#routes`).
833
1036
  - [My Mai] Introduced `Lotus.root`. It returns the top level directory of the project.
834
1037
 
835
1038
  ### Fixed
1039
+
836
1040
  - [Ngọc Nguyễn] Model generator should use new RSpec syntax.
837
1041
  - [Ngọc Nguyễn] Model generator must respect file name conventions for Ruby.
838
1042
  - [Ngọc Nguyễn] Action generator must respect file name conventions for Ruby.
@@ -840,17 +1044,22 @@ end
840
1044
  - [Luca Guidi] Container generator for RSpec let the application to be preloaded (discard `config.before(:suite)`)
841
1045
 
842
1046
  ## v0.3.1 - 2015-05-15
1047
+
843
1048
  ### Added
1049
+
844
1050
  - [Hiếu Nguyễn] Introduced application generator (eg. `bundle exec lotus generate app admin` creates `apps/admin`).
845
1051
  - [Ngọc Nguyễn] Introduced model generator (eg. `bundle exec lotus generate model user` creates entity, repository and test files).
846
1052
  - [Ngọc Nguyễn] Introduced `Lotus.env`, `Lotus.env?` for current environment introspection (eg. `Lotus.env?(:test)` or `Lotus.env?(:staging, :production)`)
847
1053
  - [Miguel Molina] Skip view creation when an action is generated via `--skip-view` CLI arg.
848
1054
 
849
1055
  ### Fixed
1056
+
850
1057
  - [Luca Guidi] Ensure routes to be loaded for unit tests
851
1058
 
852
1059
  ## v0.3.0 - 2015-03-23
1060
+
853
1061
  ### Added
1062
+
854
1063
  - [Luca Guidi] Introduced action generator. Eg. `bundle exec lotus generate action web dashboard#index`
855
1064
  - [Alfonso Uceda Pompa] Allow to specify default cookies options in application configuration. Eg. `cookies true, { domain: 'lotusrb.org' }`
856
1065
  - [Tom Kadwill] Include `Lotus::Helpers` in views.
@@ -862,12 +1071,16 @@ end
862
1071
  - [Luca Guidi] Dynamic finders for relative and absolute routes. It implements method missing: `Web::Routes.home_path` will resolve to `Web::Routes.path(:home)`.
863
1072
 
864
1073
  ### Changed
1074
+
865
1075
  – [Alfonso Uceda Pompa] Cookies will send `HttpOnly` by default. This is for security reasons.
1076
+
866
1077
  - [Jan Lelis] Enable `templates` configuration for new generated apps
867
1078
  - [Mark Connell] Change SQLite file extension from `.db` to `.sqlite3`
868
1079
 
869
1080
  ## v0.2.1 - 2015-02-06
1081
+
870
1082
  ### Added
1083
+
871
1084
  - [Huy Đỗ] Introduced `Lotus::Logger`
872
1085
  - [Jimmy Zhang] `lotus new` accepts a `--path` argument
873
1086
  - [Jimmy Zhang] Project generator for the current directory (`lotus new .`). This is useful to provide a web deliverable for existing Ruby gems.
@@ -875,6 +1088,7 @@ end
875
1088
  - [Hiếu Nguyễn] RSpec support for project generator: `--test=rspec` or `--test=minitest` (default)
876
1089
 
877
1090
  ### Fixed
1091
+
878
1092
  - [Luca Guidi] `lotus version` to previx `v` (eg `v0.2.1`)
879
1093
  - [Rob Yurkowski] Ensure project name doesn't contain special or forbidden characters
880
1094
  - [Luca Guidi] Ensure all the applications are loaded in console
@@ -882,7 +1096,9 @@ end
882
1096
  - [Hiếu Nguyễn] Fixed `lotus new` to print usage when project name isn't provided
883
1097
 
884
1098
  ## v0.2.0 - 2014-06-23
1099
+
885
1100
  ### Added
1101
+
886
1102
  - [Luca Guidi] Introduced `lotus new` as a command to generate projects. It supports "container" architecture for now.
887
1103
  - [Luca Guidi] Show a welcome page when one mounted Lotus application doesn't have routes
888
1104
  - [Luca Guidi] Introduced `Lotus::Application.preload!` to preload all the Lotus applications in a given Ruby process. (Bulk `Lotus::Application.load!`)
@@ -912,13 +1128,17 @@ end
912
1128
  - [Luca Guidi] Official support for MRI 2.1 and 2.2
913
1129
 
914
1130
  ### Changed
1131
+
915
1132
  - [Alfonso Uceda Pompa] Changed semantic of `assets` configuration. Now it's only used to set the sources for the assets. Static serving assets has now a new configuration: `serve_assets`.
916
1133
 
917
1134
  ### Fixed
1135
+
918
1136
  - [Luca Guidi] Ensure `HEAD` requests return empty body
919
1137
 
920
1138
  ## v0.1.0 - 2014-06-23
1139
+
921
1140
  ### Added
1141
+
922
1142
  - [Luca Guidi] Allow to run multiple Lotus applications in the same Ruby process (framework duplication)
923
1143
  - [Luca Guidi] Introduced `Lotus::Routes` as factory to generate application URLs
924
1144
  - [Luca Guidi] Allow to configure scheme, host and port (`scheme`, `host` and `port` configuration)