hanami 2.3.2 → 3.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +55 -19
- data/LICENSE +20 -0
- data/README.md +18 -35
- data/hanami.gemspec +36 -37
- data/lib/hanami/config/db.rb +2 -0
- data/lib/hanami/config/i18n.rb +138 -0
- data/lib/hanami/config/logger.rb +15 -7
- data/lib/hanami/config/null_config.rb +1 -1
- data/lib/hanami/config/views.rb +17 -0
- data/lib/hanami/config.rb +66 -22
- data/lib/hanami/errors.rb +6 -0
- data/lib/hanami/extensions/action/slice_configured_action.rb +1 -1
- data/lib/hanami/extensions/action.rb +2 -2
- data/lib/hanami/extensions/mailer/slice_configured_mailer.rb +120 -0
- data/lib/hanami/extensions/mailer.rb +28 -0
- data/lib/hanami/extensions/operation/slice_configured_db_operation.rb +2 -0
- data/lib/hanami/extensions/view/context.rb +26 -4
- data/lib/hanami/extensions/view/part.rb +2 -0
- data/lib/hanami/extensions/view/slice_configured_context.rb +7 -0
- data/lib/hanami/extensions/view/slice_configured_part.rb +2 -0
- data/lib/hanami/extensions/view/slice_configured_view.rb +8 -8
- data/lib/hanami/extensions/view/standard_helpers.rb +4 -0
- data/lib/hanami/extensions.rb +6 -1
- data/lib/hanami/helpers/assets_helper.rb +0 -4
- data/lib/hanami/helpers/form_helper.rb +1 -1
- data/lib/hanami/helpers/i18n_helper.rb +176 -0
- data/lib/hanami/logger/rack_formatter.rb +73 -0
- data/lib/hanami/logger/sql_formatter.rb +80 -0
- data/lib/hanami/logger/sql_logger.rb +48 -0
- data/lib/hanami/middleware/render_errors.rb +2 -2
- data/lib/hanami/providers/db.rb +7 -2
- data/lib/hanami/providers/db_logging.rb +4 -7
- data/lib/hanami/providers/i18n/backend.rb +369 -0
- data/lib/hanami/providers/i18n/locale/en.yml +57 -0
- data/lib/hanami/providers/i18n.rb +114 -0
- data/lib/hanami/providers/mailers.rb +101 -0
- data/lib/hanami/routes.rb +1 -0
- data/lib/hanami/settings/composite_store.rb +53 -0
- data/lib/hanami/settings.rb +4 -4
- data/lib/hanami/slice/router.rb +15 -10
- data/lib/hanami/slice.rb +71 -11
- data/lib/hanami/slice_registrar.rb +2 -2
- data/lib/hanami/universal_logger.rb +250 -0
- data/lib/hanami/version.rb +1 -1
- data/lib/hanami/web/rack_logger.rb +2 -80
- data/lib/hanami/web/welcome.html.erb +443 -58
- data/lib/hanami.rb +4 -2
- metadata +28 -276
- data/CODE_OF_CONDUCT.md +0 -74
- data/FEATURES.md +0 -269
- data/LICENSE.md +0 -22
- data/spec/integration/action/cookies_spec.rb +0 -58
- data/spec/integration/action/csrf_protection_spec.rb +0 -54
- data/spec/integration/action/format_config_spec.rb +0 -129
- data/spec/integration/action/routes_spec.rb +0 -71
- data/spec/integration/action/sessions_spec.rb +0 -50
- data/spec/integration/action/slice_configuration_spec.rb +0 -284
- data/spec/integration/action/view_rendering/automatic_rendering_spec.rb +0 -247
- data/spec/integration/action/view_rendering/paired_view_inference_spec.rb +0 -115
- data/spec/integration/action/view_rendering/view_context_spec.rb +0 -221
- data/spec/integration/action/view_rendering_spec.rb +0 -89
- data/spec/integration/assets/assets_spec.rb +0 -155
- data/spec/integration/assets/cross_slice_assets_helpers_spec.rb +0 -129
- data/spec/integration/assets/serve_static_assets_spec.rb +0 -152
- data/spec/integration/code_loading/loading_from_app_spec.rb +0 -152
- data/spec/integration/code_loading/loading_from_lib_spec.rb +0 -242
- data/spec/integration/code_loading/loading_from_slice_spec.rb +0 -165
- data/spec/integration/container/application_routes_helper_spec.rb +0 -48
- data/spec/integration/container/auto_injection_spec.rb +0 -53
- data/spec/integration/container/auto_registration_spec.rb +0 -86
- data/spec/integration/container/autoloader_spec.rb +0 -82
- data/spec/integration/container/imports_spec.rb +0 -253
- data/spec/integration/container/prepare_container_spec.rb +0 -125
- data/spec/integration/container/provider_environment_spec.rb +0 -52
- data/spec/integration/container/provider_lifecycle_spec.rb +0 -61
- data/spec/integration/container/shutdown_spec.rb +0 -91
- data/spec/integration/container/standard_providers/rack_provider_spec.rb +0 -44
- data/spec/integration/container/standard_providers_spec.rb +0 -124
- data/spec/integration/db/auto_registration_spec.rb +0 -39
- data/spec/integration/db/commands_spec.rb +0 -80
- data/spec/integration/db/db_inflector_spec.rb +0 -57
- data/spec/integration/db/db_slices_spec.rb +0 -398
- data/spec/integration/db/db_spec.rb +0 -245
- data/spec/integration/db/gateways_spec.rb +0 -361
- data/spec/integration/db/logging_spec.rb +0 -301
- data/spec/integration/db/mappers_spec.rb +0 -84
- data/spec/integration/db/provider_config_spec.rb +0 -88
- data/spec/integration/db/provider_spec.rb +0 -35
- data/spec/integration/db/relations_spec.rb +0 -60
- data/spec/integration/db/repo_spec.rb +0 -300
- data/spec/integration/db/slices_importing_from_parent.rb +0 -130
- data/spec/integration/dotenv_loading_spec.rb +0 -138
- data/spec/integration/logging/exception_logging_spec.rb +0 -120
- data/spec/integration/logging/notifications_spec.rb +0 -68
- data/spec/integration/logging/request_logging_spec.rb +0 -202
- data/spec/integration/operations/extension_spec.rb +0 -122
- data/spec/integration/rack_app/body_parser_spec.rb +0 -108
- data/spec/integration/rack_app/method_override_spec.rb +0 -97
- data/spec/integration/rack_app/middleware_spec.rb +0 -720
- data/spec/integration/rack_app/non_booted_rack_app_spec.rb +0 -104
- data/spec/integration/rack_app/rack_app_spec.rb +0 -442
- data/spec/integration/rake_tasks_spec.rb +0 -107
- data/spec/integration/router/resource_routes_spec.rb +0 -281
- data/spec/integration/settings/access_in_slice_class_body_spec.rb +0 -83
- data/spec/integration/settings/access_to_constants_spec.rb +0 -46
- data/spec/integration/settings/loading_from_env_spec.rb +0 -188
- data/spec/integration/settings/settings_component_loading_spec.rb +0 -113
- data/spec/integration/settings/slice_registration_spec.rb +0 -145
- data/spec/integration/settings/using_types_spec.rb +0 -80
- data/spec/integration/setup_spec.rb +0 -165
- data/spec/integration/slices/external_slice_spec.rb +0 -91
- data/spec/integration/slices/slice_configuration_spec.rb +0 -42
- data/spec/integration/slices/slice_loading_spec.rb +0 -171
- data/spec/integration/slices/slice_registrations_spec.rb +0 -80
- data/spec/integration/slices/slice_routing_spec.rb +0 -219
- data/spec/integration/slices_spec.rb +0 -471
- data/spec/integration/view/config/default_context_spec.rb +0 -149
- data/spec/integration/view/config/inflector_spec.rb +0 -57
- data/spec/integration/view/config/part_class_spec.rb +0 -147
- data/spec/integration/view/config/part_namespace_spec.rb +0 -103
- data/spec/integration/view/config/paths_spec.rb +0 -119
- data/spec/integration/view/config/scope_class_spec.rb +0 -147
- data/spec/integration/view/config/scope_namespace_spec.rb +0 -103
- data/spec/integration/view/config/template_spec.rb +0 -38
- data/spec/integration/view/context/assets_spec.rb +0 -79
- data/spec/integration/view/context/inflector_spec.rb +0 -40
- data/spec/integration/view/context/request_spec.rb +0 -57
- data/spec/integration/view/context/routes_spec.rb +0 -84
- data/spec/integration/view/helpers/form_helper_spec.rb +0 -174
- data/spec/integration/view/helpers/part_helpers_spec.rb +0 -124
- data/spec/integration/view/helpers/scope_helpers_spec.rb +0 -84
- data/spec/integration/view/helpers/user_defined_helpers/part_helpers_spec.rb +0 -162
- data/spec/integration/view/helpers/user_defined_helpers/scope_helpers_spec.rb +0 -119
- data/spec/integration/view/parts/default_rendering_spec.rb +0 -138
- data/spec/integration/view/slice_configuration_spec.rb +0 -289
- data/spec/integration/view/views_spec.rb +0 -103
- data/spec/integration/web/content_security_policy_nonce_spec.rb +0 -251
- data/spec/integration/web/render_detailed_errors_spec.rb +0 -107
- data/spec/integration/web/render_errors_spec.rb +0 -242
- data/spec/integration/web/welcome_view_spec.rb +0 -84
- data/spec/spec_helper.rb +0 -28
- data/spec/support/app_integration.rb +0 -157
- data/spec/support/coverage.rb +0 -1
- data/spec/support/matchers.rb +0 -32
- data/spec/support/rspec.rb +0 -27
- data/spec/unit/hanami/config/actions/content_security_policy_spec.rb +0 -96
- data/spec/unit/hanami/config/actions/cookies_spec.rb +0 -46
- data/spec/unit/hanami/config/actions/csrf_protection_spec.rb +0 -58
- data/spec/unit/hanami/config/actions/default_values_spec.rb +0 -43
- data/spec/unit/hanami/config/actions/sessions_spec.rb +0 -48
- data/spec/unit/hanami/config/actions_spec.rb +0 -52
- data/spec/unit/hanami/config/base_url_spec.rb +0 -25
- data/spec/unit/hanami/config/console_spec.rb +0 -22
- data/spec/unit/hanami/config/db_spec.rb +0 -38
- data/spec/unit/hanami/config/inflector_spec.rb +0 -35
- data/spec/unit/hanami/config/logger_spec.rb +0 -195
- data/spec/unit/hanami/config/render_detailed_errors_spec.rb +0 -25
- data/spec/unit/hanami/config/render_errors_spec.rb +0 -25
- data/spec/unit/hanami/config/router_spec.rb +0 -44
- data/spec/unit/hanami/config/slices_spec.rb +0 -34
- data/spec/unit/hanami/config/views_spec.rb +0 -80
- data/spec/unit/hanami/env_spec.rb +0 -37
- data/spec/unit/hanami/extensions/view/context_spec.rb +0 -59
- data/spec/unit/hanami/helpers/assets_helper/asset_url_spec.rb +0 -120
- data/spec/unit/hanami/helpers/assets_helper/audio_tag_spec.rb +0 -132
- data/spec/unit/hanami/helpers/assets_helper/favicon_tag_spec.rb +0 -87
- data/spec/unit/hanami/helpers/assets_helper/image_tag_spec.rb +0 -92
- data/spec/unit/hanami/helpers/assets_helper/javascript_tag_spec.rb +0 -143
- data/spec/unit/hanami/helpers/assets_helper/stylesheet_tag_spec.rb +0 -126
- data/spec/unit/hanami/helpers/assets_helper/video_tag_spec.rb +0 -136
- data/spec/unit/hanami/helpers/form_helper_spec.rb +0 -2857
- data/spec/unit/hanami/port_spec.rb +0 -117
- data/spec/unit/hanami/providers/db/config/default_config_spec.rb +0 -100
- data/spec/unit/hanami/providers/db/config/gateway_spec.rb +0 -73
- data/spec/unit/hanami/providers/db/config_spec.rb +0 -143
- data/spec/unit/hanami/router/errors/not_allowed_error_spec.rb +0 -27
- data/spec/unit/hanami/router/errors/not_found_error_spec.rb +0 -22
- data/spec/unit/hanami/settings/env_store_spec.rb +0 -52
- data/spec/unit/hanami/settings_spec.rb +0 -111
- data/spec/unit/hanami/slice_configurable_spec.rb +0 -141
- data/spec/unit/hanami/slice_name_spec.rb +0 -47
- data/spec/unit/hanami/slice_spec.rb +0 -99
- data/spec/unit/hanami/web/rack_logger_spec.rb +0 -99
data/FEATURES.md
DELETED
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
# Hanami
|
|
2
|
-
|
|
3
|
-
### The web, with simplicity.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
## v2.0.0 - 2021-11-22
|
|
8
|
-
|
|
9
|
-
- Renamed _apps_ into _slices_, and _project_ into _app_
|
|
10
|
-
- The core of new applications is going to be `app/`. Slices are now optional.
|
|
11
|
-
- App class built around a container for managing app components; code from `app/` is loaded into the app
|
|
12
|
-
- Apps may have multiple Slices; code from `slices/[slice_name]/` is loaded into the corresponding slice
|
|
13
|
-
- `MyApp::Deps` or `MySlice::Deps` mixin for auto-registering dependencies from the app or a slice
|
|
14
|
-
- Code autoloading using Zeitwerk
|
|
15
|
-
- Code reloading via Guard
|
|
16
|
-
- Providers for setting up and managing the lifecycle of your app's critical components and integrations
|
|
17
|
-
- Type-safe app settings
|
|
18
|
-
- Rebuilt high-performance router
|
|
19
|
-
- Redesigned stateless `Hamami::Action` classes supporting the Deps mixin; add your behavior to `#handle(request, response)`
|
|
20
|
-
- Simplified action format configuration via `config.format` and `config.formats`
|
|
21
|
-
- Rewritten CLI and console
|
|
22
|
-
|
|
23
|
-
## v1.3.3 - 2019-09-20
|
|
24
|
-
|
|
25
|
-
- Standardize file loading for `.env` files (see: https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use)
|
|
26
|
-
|
|
27
|
-
## v1.3.2 - 2019-07-26
|
|
28
|
-
|
|
29
|
-
## v1.3.1 - 2019-01-18
|
|
30
|
-
|
|
31
|
-
## v1.3.0 - 2018-10-24
|
|
32
|
-
|
|
33
|
-
- Default testing framework is RSpec
|
|
34
|
-
- Introduced `Hanami::Middleware::BodyParser` Rack middleware
|
|
35
|
-
- Log payload (body) for non-GET HTTP requests coming from body parsers
|
|
36
|
-
- Added support for `reply_to` in mailers
|
|
37
|
-
- Variadic arguments for `hanami-cli`
|
|
38
|
-
- Array as argument or option for `hanami-cli`
|
|
39
|
-
|
|
40
|
-
## v1.2.0 - 2018-04-11
|
|
41
|
-
|
|
42
|
-
- HTTP/2 Early Hints
|
|
43
|
-
- Unobtrusive JavaScript (UJS) (via `hanami-ujs` gem)
|
|
44
|
-
- Interactive console for development error page (via `hanami-webconsole` gem)
|
|
45
|
-
- CLI: register callbacks for `hanami` commands (`Hanami::CLI.after("db migrate", MyCallback.new)` or `Hanami::CLI.after("db migrate") { ... }`)
|
|
46
|
-
- Project level Rack middleware stack (`Hanami.configure { middleware.use MyRackMiddleware }`)
|
|
47
|
-
- Plugins can hook into project configuration (`Hanami.plugin { middleware.use AnotherRackMiddleware }`)
|
|
48
|
-
- Custom repository commands
|
|
49
|
-
- Coloured logging
|
|
50
|
-
|
|
51
|
-
## v1.1.1 - 2018-02-27
|
|
52
|
-
|
|
53
|
-
## v1.1.0 - 2017-10-25
|
|
54
|
-
|
|
55
|
-
- One-To-Many association (aka `belongs_to`)
|
|
56
|
-
- One-To-One association (aka `has_one`)
|
|
57
|
-
- Many-To-Many association (aka `has_many :through`)
|
|
58
|
-
- Allow third-party developers to register commands for CLI (eg `hanami generate webpack`)
|
|
59
|
-
- Initial support for plugins via `:plugins` group in `Gemfile`
|
|
60
|
-
- CLI: `hanami db rollback` to rollback database migrations
|
|
61
|
-
- Introduced new extra behaviors for entity manual schema: `:schema` (default), `:strict`, `:weak`, and `:permissive`
|
|
62
|
-
- Custom logger for `Hanami.logger`
|
|
63
|
-
- Selectively boot apps via `HANAMI_APPS=web` env var
|
|
64
|
-
- Log payload (params) for non-GET HTTP requests
|
|
65
|
-
- Filter sensitive data in logs
|
|
66
|
-
|
|
67
|
-
### v1.0.0 - 2017-04-06
|
|
68
|
-
|
|
69
|
-
- Logger rotation
|
|
70
|
-
- Added: `Action#unsafe_send_file` to send files outside of the public directory
|
|
71
|
-
- CLI: `hanami generate model` now also generates a migration
|
|
72
|
-
- Project logger `Hanami.logger`
|
|
73
|
-
- Automatic logging of HTTP requests, migrations, and SQL queries
|
|
74
|
-
|
|
75
|
-
### v0.9.2 - 2016-12-19
|
|
76
|
-
|
|
77
|
-
### v0.9.1 - 2016-11-18
|
|
78
|
-
|
|
79
|
-
### v0.9.0 - 2016-11-15
|
|
80
|
-
|
|
81
|
-
- Experimental repositories associations (only "has many")
|
|
82
|
-
- Database automapping for SQL databases
|
|
83
|
-
- Entities schema
|
|
84
|
-
- Immutable entities
|
|
85
|
-
- Removed dirty tracking for entities
|
|
86
|
-
- Repositories CRUD operations can accept both entities and/or data
|
|
87
|
-
- Removed Memory and File System adapters
|
|
88
|
-
- SQLite is the default adapter for new projects
|
|
89
|
-
- Native support for PostgreSQL types
|
|
90
|
-
- CLI: `hanami secret` to generate and print a new session secret for a single Hanami app
|
|
91
|
-
|
|
92
|
-
### v0.8.0 - 2016-07-22
|
|
93
|
-
|
|
94
|
-
- New validation syntax based on predicates
|
|
95
|
-
- Custom and shared predicates for validations
|
|
96
|
-
- High level rules for validations
|
|
97
|
-
- Validations error messages with I18n support (via optional `i18n` gem)
|
|
98
|
-
- Mount applications in subdomains
|
|
99
|
-
- Added support for Content Security Policy 1.1 and 2.0
|
|
100
|
-
- Subresurce Integrity
|
|
101
|
-
- Include `X-Content-Type-Options` and `X-XSS-Protection` in default response headers
|
|
102
|
-
- Support for several JSON engines (via optional `multi_json` gem)
|
|
103
|
-
- JSON Logging for production
|
|
104
|
-
- Per environment logging levels, stream (file, stdout), formatters
|
|
105
|
-
- Introduced `#local` for views, layouts and templates to safely access locals by avoiding `nil` values
|
|
106
|
-
- Added `datalist` form helper
|
|
107
|
-
- CC and BCC support for mailers
|
|
108
|
-
- Experimental code reloading via `entr(1)`
|
|
109
|
-
- CLI: `hanami new` can be used with `--template` argument to generate a new project with (`erb`/`haml`/`slim`) templates
|
|
110
|
-
|
|
111
|
-
### v0.7.3 - 2016-05-23
|
|
112
|
-
|
|
113
|
-
### v0.7.2 - 2016-02-09
|
|
114
|
-
|
|
115
|
-
### v0.7.1 - 2016-02-05
|
|
116
|
-
|
|
117
|
-
### v0.7.0 - 2016-01-22
|
|
118
|
-
|
|
119
|
-
- Renamed from Lotus to Hanami
|
|
120
|
-
|
|
121
|
-
### v0.6.1 - 2016-01-19
|
|
122
|
-
|
|
123
|
-
### v0.6.0 - 2016-01-12
|
|
124
|
-
|
|
125
|
-
- Assets preprocessors support (eg. Sass, ES6, Opal, Less, CoffeeScript..)
|
|
126
|
-
- Assets compressors (eg. YUI, UglifyJS2, Google Closure Compiler, Sass..)
|
|
127
|
-
- Assets helpers:
|
|
128
|
-
- `javascript`
|
|
129
|
-
- `stylesheet`
|
|
130
|
-
- `favicon`
|
|
131
|
-
- `image`
|
|
132
|
-
- `video`
|
|
133
|
-
- `audio`
|
|
134
|
-
- `asset_path`
|
|
135
|
-
- `asset_url`
|
|
136
|
-
- Content Delivery Network (CDN) support for static assets (CDN mode)
|
|
137
|
-
- Checksum suffix for static assets in production mode (Digest mode)
|
|
138
|
-
- Support for third party gems as assets distribution channel (eg. `lotus-jquery`)
|
|
139
|
-
- CLI: `lotus assets` command `precompile`: preprocess, minify and append checksum suffix
|
|
140
|
-
- CLI: `lotus destroy` destroy apps, models, actions, migrations and mailers
|
|
141
|
-
- Custom initializers (`apps/web/config/initializers`)
|
|
142
|
-
- Rake tasks `:preload` and `:environment`
|
|
143
|
-
|
|
144
|
-
### v0.5.0 - 2015-09-30
|
|
145
|
-
|
|
146
|
-
- Mailers
|
|
147
|
-
- CLI: `lotus generate mailer`
|
|
148
|
-
- SQL joins
|
|
149
|
-
- Custom coercers for data mapper
|
|
150
|
-
|
|
151
|
-
### v0.4.1 - 2015-07-10
|
|
152
|
-
|
|
153
|
-
### v0.4.0 - 2015-06-23
|
|
154
|
-
|
|
155
|
-
- Application architecture
|
|
156
|
-
- Database migrations
|
|
157
|
-
- CLI: `lotus db` commands: `create`, `drop`, `prepare`, `migrate`, `version`, `apply`.
|
|
158
|
-
- HTML5 Form helpers
|
|
159
|
-
- Cross Site Request Forgery (CSRF) protection
|
|
160
|
-
- Force SSL
|
|
161
|
-
- Number formatting helper
|
|
162
|
-
|
|
163
|
-
### v0.3.2 - 2015-05-22
|
|
164
|
-
|
|
165
|
-
- Automatic secure cookies
|
|
166
|
-
- Routing helpers for actions
|
|
167
|
-
- Send files from actions
|
|
168
|
-
- `Lotus.root` returns top level directory of the project.
|
|
169
|
-
|
|
170
|
-
### v0.3.1 - 2015-05-15
|
|
171
|
-
|
|
172
|
-
- CLI: `lotus generate app admin` creates a new application (`apps/admin`).
|
|
173
|
-
- CLI: `lotus generate model user`. It generates entity, repository and related unit test files.
|
|
174
|
-
- `Lotus.env` and `Lotus.env?` for current environment introspection (eg. `Lotus.env?(:test)` or `Lotus.env?(:staging, :production)`)
|
|
175
|
-
- Allow repositories to execute raw query/commands against database
|
|
176
|
-
- Automatic timestamps update for entities
|
|
177
|
-
– Dirty Tracking for entities (via `Lotus::Entity::DirtyTracking`)
|
|
178
|
-
- Nested RESTful resource(s)
|
|
179
|
-
- String pluralization and singularization
|
|
180
|
-
|
|
181
|
-
### v0.3.0 - 2015-03-23
|
|
182
|
-
|
|
183
|
-
- CLI: `lotus generate action web dashboard#index`. It generates an action, a view, a template, a route and related unit test files.
|
|
184
|
-
- CLI: `lotus db console`. It starts a database REPL.
|
|
185
|
-
- Full featured HTML5 markup generator for views (Eg. `html.div { p "Hello World" }`)
|
|
186
|
-
- Routing helpers in views and templates (Eg. `routes.home_path`).
|
|
187
|
-
- `lotus new` supports `--database` (Eg. `lotus new bookshelf --database=postgresql`).
|
|
188
|
-
- Initialize a Git repository when generate a new application
|
|
189
|
-
- Security: XSS (Cross Site Scripting) protections
|
|
190
|
-
- Security: Clickhijacking protection
|
|
191
|
-
- Security: Cookies are set as `HttpOnly` by default.
|
|
192
|
-
- Security: enable by default `X-Frame-Options` and `Content-Security-Policy` HTTP headers for new generated applications.
|
|
193
|
-
- Security: auto-escape output of presenters.
|
|
194
|
-
- Security: auto-escape output of virtual an concrete view methods.
|
|
195
|
-
- Security: view and template helpers for HTML, HTML attributes and URL escape. It's based on OWASP/ESAPI recommendations.
|
|
196
|
-
- Access nested action params with a safe API (`params.get('address.city')`).
|
|
197
|
-
- Interactors (aka Service Objects)
|
|
198
|
-
- Database transactions
|
|
199
|
-
|
|
200
|
-
### v0.2.1 - 2015-02-06
|
|
201
|
-
|
|
202
|
-
- Allow entities to include validations.
|
|
203
|
-
- `lotus new .` to generate a Lotus project for an existing code base (Eg. a gem that needs a web UI).
|
|
204
|
-
- `lotus new` supports `--path` (for destination directory), `--test` (to generate Minitest or RSpec boilerplate).
|
|
205
|
-
- Lotus logger
|
|
206
|
-
|
|
207
|
-
### v0.2.0 - 2014-12-23
|
|
208
|
-
|
|
209
|
-
- Support Minitest as default testing framework (`bundle exec rake` runs the entire test suite of an application).
|
|
210
|
-
- Support for _Method Override_ technique.
|
|
211
|
-
- Custom templates for non successful responses (Eg. `404.html.erb`).
|
|
212
|
-
- Support distinct `.env` files for each Lotus environment.
|
|
213
|
-
- Allow to configure multiple applications and handle Lotus environments accordingly.
|
|
214
|
-
- Allow to configure middleware stack, routes, database mapping and adapter for each application.
|
|
215
|
-
- Show a welcome page with instructions for new generated apps.
|
|
216
|
-
- CLI: `lotus routes`. It prints all the routes available for all the applications.
|
|
217
|
-
- CLI: `lotus new`. It generates a new application which can run multiple Lotus applications (_Container_ architecture).
|
|
218
|
-
- CLI: `lotus console`. It starts a Ruby REPL. It supports IRB (default), Pry and Ripl.
|
|
219
|
-
- CLI: `lotus server`. It starts a web server that supports code reloading. It supports all the Rack web servers (default: WEBRick).
|
|
220
|
-
- Database adapters: File system (default for new apps)
|
|
221
|
-
- Allow to share code for all the views and actions of an application
|
|
222
|
-
- Reusable validations framework (mixin). It supports: coercions and presence, format, acceptance, size, inclusion, exclusion, confirmation validations.
|
|
223
|
-
- Default Content-Type and Charset for responses
|
|
224
|
-
- Whitelist accepted MIME Types
|
|
225
|
-
- Custom exception handlers for actions
|
|
226
|
-
- Unique identifier for incoming HTTP requests
|
|
227
|
-
- Nested action params
|
|
228
|
-
- Action params _indifferent access_, whitelisting, validations and coercions
|
|
229
|
-
- HTTP caching (`Cache-Control`, `Last-Modified`, ETAG, Conditional GET, expires)
|
|
230
|
-
- JSON body parser for non-GET HTTP requests
|
|
231
|
-
- Routes inspector for CLI
|
|
232
|
-
|
|
233
|
-
### v0.1.0 - 2014-06-23
|
|
234
|
-
|
|
235
|
-
- Run multiple Lotus applications in the same Ruby process
|
|
236
|
-
- Serve static files
|
|
237
|
-
- Render default pages for non successful responses (404, 500, etc.)
|
|
238
|
-
- Support multiple Lotus environments (development, test and production)
|
|
239
|
-
- Full stack applications
|
|
240
|
-
- Data mapper
|
|
241
|
-
- Database adapters: Memory and SQL
|
|
242
|
-
- Reusable scopes for repositories
|
|
243
|
-
- Repositories
|
|
244
|
-
- Entities
|
|
245
|
-
- Custom rendering implementation via `#render` override in views
|
|
246
|
-
- Render partials and templates
|
|
247
|
-
- Presenters
|
|
248
|
-
- Layouts
|
|
249
|
-
- Views are able to handle multiple MIME Types according to the defined templates
|
|
250
|
-
- Support for all the most common template engines for Ruby. Including ERb, Slim, HAML, etc.
|
|
251
|
-
- Basic view rendering with templates
|
|
252
|
-
- Bypass rendering by setting a response body in actions (`self.body = "Hello"`)
|
|
253
|
-
- Single actions are able to mount Rack middleware
|
|
254
|
-
- Automatic MIME Type handling for request and responses
|
|
255
|
-
- HTTP sessions
|
|
256
|
-
- HTTP cookies
|
|
257
|
-
- HTTP redirect
|
|
258
|
-
- Action before/after callbacks
|
|
259
|
-
- Handle exceptions with HTTP statuses
|
|
260
|
-
- Action exposures, to expose a payload to pass to the other application layers
|
|
261
|
-
- Actions compatible with Rack
|
|
262
|
-
- Mount Rack applications
|
|
263
|
-
- Nested route namespaces
|
|
264
|
-
- RESTful resource(s), including collection and member actions
|
|
265
|
-
- Named routes, routes constraints, variables, catch-all
|
|
266
|
-
- Compatibility with Lotus::Controller
|
|
267
|
-
- HTTP redirect from the router
|
|
268
|
-
- HTTP routing compatible with Rack
|
|
269
|
-
- Thread safety
|
data/LICENSE.md
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
Copyright © 2014 Hanami Team
|
|
2
|
-
|
|
3
|
-
MIT License
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
-
a copy of this software and associated documentation files (the
|
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
-
the following conditions:
|
|
12
|
-
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
|
14
|
-
included in all copies or substantial portions of the Software.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe "App action / Cookies", :app_integration do
|
|
4
|
-
before do
|
|
5
|
-
module TestApp
|
|
6
|
-
class App < Hanami::App
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
Hanami.app.instance_eval(&app_hook) if respond_to?(:app_hook)
|
|
11
|
-
Hanami.app.prepare
|
|
12
|
-
|
|
13
|
-
module TestApp
|
|
14
|
-
class Action < Hanami::Action
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
subject(:action_class) { TestApp::Action }
|
|
20
|
-
|
|
21
|
-
context "default configuration" do
|
|
22
|
-
it "has cookie support enabled" do
|
|
23
|
-
expect(action_class.ancestors).to include Hanami::Action::Cookies
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
context "custom cookie options given in app-level config" do
|
|
28
|
-
subject(:app_hook) {
|
|
29
|
-
proc do
|
|
30
|
-
config.actions.cookies = {max_age: 300}
|
|
31
|
-
end
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
it "has cookie support enabled" do
|
|
35
|
-
expect(action_class.ancestors).to include Hanami::Action::Cookies
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it "has the cookie options configured" do
|
|
39
|
-
expect(action_class.config.cookies).to eq(max_age: 300)
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
context "cookies disabled in app-level config" do
|
|
44
|
-
subject(:app_hook) {
|
|
45
|
-
proc do
|
|
46
|
-
config.actions.cookies = nil
|
|
47
|
-
end
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
it "does not have cookie support enabled" do
|
|
51
|
-
expect(action_class.ancestors.map(&:to_s)).not_to include "Hanami::Action::Cookies"
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
it "has no cookie options configured" do
|
|
55
|
-
expect(action_class.config.cookies).to eq({})
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe "App action / CSRF protection", :app_integration do
|
|
4
|
-
before do
|
|
5
|
-
module TestApp
|
|
6
|
-
class App < Hanami::App
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
Hanami.app.instance_eval(&app_hook) if respond_to?(:app_hook)
|
|
11
|
-
Hanami.app.register_slice :main
|
|
12
|
-
Hanami.app.prepare
|
|
13
|
-
|
|
14
|
-
module TestApp
|
|
15
|
-
class Action < Hanami::Action
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
subject(:action_class) { TestApp::Action }
|
|
21
|
-
|
|
22
|
-
context "app sessions enabled" do
|
|
23
|
-
context "CSRF protection not explicitly configured" do
|
|
24
|
-
let(:app_hook) {
|
|
25
|
-
proc do
|
|
26
|
-
config.actions.sessions = :cookie, {secret: "abc123"}
|
|
27
|
-
end
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
it "has CSRF protection enabled" do
|
|
31
|
-
expect(action_class.ancestors).to include Hanami::Action::CSRFProtection
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
context "CSRF protection explicitly disabled" do
|
|
36
|
-
let(:app_hook) {
|
|
37
|
-
proc do
|
|
38
|
-
config.actions.sessions = :cookie, {secret: "abc123"}
|
|
39
|
-
config.actions.csrf_protection = false
|
|
40
|
-
end
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
it "does not have CSRF protection enabled" do
|
|
44
|
-
expect(action_class.ancestors.map(&:to_s)).not_to include "Hanami::Action::CSRFProtection"
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
context "app sessions not enabled" do
|
|
50
|
-
it "does not have CSRF protection enabled" do
|
|
51
|
-
expect(action_class.ancestors.map(&:to_s)).not_to include "Hanami::Action::CSRFProtection"
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "json"
|
|
4
|
-
require "rack/test"
|
|
5
|
-
|
|
6
|
-
RSpec.describe "App action / Format config", :app_integration do
|
|
7
|
-
include Rack::Test::Methods
|
|
8
|
-
|
|
9
|
-
let(:app) { Hanami.app }
|
|
10
|
-
|
|
11
|
-
around do |example|
|
|
12
|
-
with_tmp_directory(Dir.mktmpdir, &example)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it "adds a body parser middleware for the accepted formats from the action config" do
|
|
16
|
-
write "config/app.rb", <<~RUBY
|
|
17
|
-
require "hanami"
|
|
18
|
-
|
|
19
|
-
module TestApp
|
|
20
|
-
class App < Hanami::App
|
|
21
|
-
config.logger.stream = StringIO.new
|
|
22
|
-
|
|
23
|
-
config.actions.formats.accept :json
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
RUBY
|
|
27
|
-
|
|
28
|
-
write "config/routes.rb", <<~RUBY
|
|
29
|
-
module TestApp
|
|
30
|
-
class Routes < Hanami::Routes
|
|
31
|
-
post "/users", to: "users.create"
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
RUBY
|
|
35
|
-
|
|
36
|
-
write "app/action.rb", <<~RUBY
|
|
37
|
-
# auto_register: false
|
|
38
|
-
|
|
39
|
-
module TestApp
|
|
40
|
-
class Action < Hanami::Action
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
RUBY
|
|
44
|
-
|
|
45
|
-
write "app/actions/users/create.rb", <<~RUBY
|
|
46
|
-
module TestApp
|
|
47
|
-
module Actions
|
|
48
|
-
module Users
|
|
49
|
-
class Create < TestApp::Action
|
|
50
|
-
def handle(req, res)
|
|
51
|
-
res.body = req.params[:users].join("-")
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
RUBY
|
|
58
|
-
|
|
59
|
-
require "hanami/boot"
|
|
60
|
-
|
|
61
|
-
post(
|
|
62
|
-
"/users",
|
|
63
|
-
JSON.generate("users" => %w[jane john jade joe]),
|
|
64
|
-
"CONTENT_TYPE" => "application/json"
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
expect(last_response).to be_successful
|
|
68
|
-
expect(last_response.body).to eql("jane-john-jade-joe")
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it "does not add a body parser middleware if one is already added" do
|
|
72
|
-
write "config/app.rb", <<~RUBY
|
|
73
|
-
require "hanami"
|
|
74
|
-
|
|
75
|
-
module TestApp
|
|
76
|
-
class App < Hanami::App
|
|
77
|
-
config.logger.stream = StringIO.new
|
|
78
|
-
|
|
79
|
-
config.actions.formats.accept :json
|
|
80
|
-
config.middleware.use :body_parser, [json: "application/json+custom"]
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
RUBY
|
|
84
|
-
|
|
85
|
-
write "config/routes.rb", <<~RUBY
|
|
86
|
-
module TestApp
|
|
87
|
-
class Routes < Hanami::Routes
|
|
88
|
-
post "/users", to: "users.create"
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
RUBY
|
|
92
|
-
|
|
93
|
-
write "app/action.rb", <<~RUBY
|
|
94
|
-
# auto_register: false
|
|
95
|
-
|
|
96
|
-
module TestApp
|
|
97
|
-
class Action < Hanami::Action
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
RUBY
|
|
101
|
-
|
|
102
|
-
write "app/actions/users/create.rb", <<~RUBY
|
|
103
|
-
module TestApp
|
|
104
|
-
module Actions
|
|
105
|
-
module Users
|
|
106
|
-
class Create < TestApp::Action
|
|
107
|
-
config.formats.clear
|
|
108
|
-
|
|
109
|
-
def handle(req, res)
|
|
110
|
-
res.body = req.params[:users].join("-")
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
RUBY
|
|
117
|
-
|
|
118
|
-
require "hanami/boot"
|
|
119
|
-
|
|
120
|
-
post(
|
|
121
|
-
"/users",
|
|
122
|
-
JSON.generate("users" => %w[jane john jade joe]),
|
|
123
|
-
"CONTENT_TYPE" => "application/json+custom"
|
|
124
|
-
)
|
|
125
|
-
|
|
126
|
-
expect(last_response).to be_successful
|
|
127
|
-
expect(last_response.body).to eql("jane-john-jade-joe")
|
|
128
|
-
end
|
|
129
|
-
end
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe "App action / Routes", :app_integration do
|
|
4
|
-
specify "Access app routes from an action" do
|
|
5
|
-
with_tmp_directory(Dir.mktmpdir) do
|
|
6
|
-
write "config/app.rb", <<~RUBY
|
|
7
|
-
require "hanami"
|
|
8
|
-
|
|
9
|
-
module TestApp
|
|
10
|
-
class App < Hanami::App; end
|
|
11
|
-
end
|
|
12
|
-
RUBY
|
|
13
|
-
|
|
14
|
-
write "config/routes.rb", <<~RUBY
|
|
15
|
-
module TestApp
|
|
16
|
-
class Routes < Hanami::Routes
|
|
17
|
-
root to: "home.index"
|
|
18
|
-
|
|
19
|
-
slice :admin, at: "/admin" do
|
|
20
|
-
root to: "dashboard.index"
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
RUBY
|
|
25
|
-
|
|
26
|
-
write "app/action.rb", <<~RUBY
|
|
27
|
-
# auto_register: false
|
|
28
|
-
|
|
29
|
-
module TestApp
|
|
30
|
-
class Action < Hanami::Action; end
|
|
31
|
-
end
|
|
32
|
-
RUBY
|
|
33
|
-
|
|
34
|
-
write "app/actions/home/index.rb", <<~RUBY
|
|
35
|
-
module TestApp
|
|
36
|
-
module Actions
|
|
37
|
-
module Home
|
|
38
|
-
class Index < TestApp::Action
|
|
39
|
-
def handle(req, res)
|
|
40
|
-
res.body = routes.path(:root)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
RUBY
|
|
47
|
-
|
|
48
|
-
write "slices/admin/actions/dashboard/index.rb", <<~RUBY
|
|
49
|
-
module Admin
|
|
50
|
-
module Actions
|
|
51
|
-
module Dashboard
|
|
52
|
-
class Index < TestApp::Action
|
|
53
|
-
def handle(req, res)
|
|
54
|
-
res.body = routes.path(:admin_root)
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
RUBY
|
|
61
|
-
|
|
62
|
-
require "hanami/prepare"
|
|
63
|
-
|
|
64
|
-
response = TestApp::App["actions.home.index"].call({})
|
|
65
|
-
expect(response.body).to eq ["/"]
|
|
66
|
-
|
|
67
|
-
response = Admin::Slice["actions.dashboard.index"].call({})
|
|
68
|
-
expect(response.body).to eq ["/admin"]
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
end
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe "App action / Sessions", :app_integration do
|
|
4
|
-
before do
|
|
5
|
-
module TestApp
|
|
6
|
-
class App < Hanami::App
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
Hanami.app.instance_eval(&app_hook) if respond_to?(:app_hook)
|
|
11
|
-
Hanami.app.prepare
|
|
12
|
-
|
|
13
|
-
module TestApp
|
|
14
|
-
class Action < Hanami::Action
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
subject(:action_class) { TestApp::Action }
|
|
20
|
-
|
|
21
|
-
context "HTTP sessions enabled" do
|
|
22
|
-
let(:app_hook) {
|
|
23
|
-
proc do
|
|
24
|
-
config.actions.sessions = :cookie, {secret: "abc123"}
|
|
25
|
-
end
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
it "has HTTP sessions enabled" do
|
|
29
|
-
expect(action_class.ancestors).to include(Hanami::Action::Session)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
context "HTTP sessions explicitly disabled" do
|
|
34
|
-
let(:app_hook) {
|
|
35
|
-
proc do
|
|
36
|
-
config.actions.sessions = nil
|
|
37
|
-
end
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
it "does not have HTTP sessions enabled" do
|
|
41
|
-
expect(action_class.ancestors.map(&:to_s)).not_to include("Hanami::Action::Session")
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
context "HTTP sessions not enabled" do
|
|
46
|
-
it "does not have HTTP session enabled" do
|
|
47
|
-
expect(action_class.ancestors.map(&:to_s)).not_to include("Hanami::Action::Session")
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|