hanami 2.0.0.alpha7 → 2.0.0.beta1

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