hanami 1.3.1 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +35 -6
- data/FEATURES.md +11 -1
- data/LICENSE.md +1 -1
- data/README.md +7 -4
- data/bin/hanami +2 -2
- data/hanami.gemspec +7 -7
- data/lib/hanami/app.rb +1 -1
- data/lib/hanami/cli/commands/command.rb +4 -6
- data/lib/hanami/cli/commands/generate/action/action_spec.minitest.erb +1 -1
- data/lib/hanami/cli/commands/generate/action/view_spec.minitest.erb +1 -1
- data/lib/hanami/cli/commands/generate/app/application.erb +5 -5
- data/lib/hanami/cli/commands/generate/app/layout_spec.minitest.erb +1 -1
- data/lib/hanami/cli/commands/generate/app/routes.erb +1 -1
- data/lib/hanami/cli/commands/new/Gemfile.erb +1 -2
- data/lib/hanami/cli/commands/new/README.md.erb +1 -1
- data/lib/hanami/cli/commands/new/config/environment.erb +2 -2
- data/lib/hanami/cli/commands/new/config.ru.erb +1 -1
- data/lib/hanami/cli/commands/new/gitignore.erb +2 -0
- data/lib/hanami/cli/commands/new/gitignore_with_sqlite.erb +2 -0
- data/lib/hanami/cli/commands/new.rb +3 -3
- data/lib/hanami/cli/commands.rb +2 -2
- data/lib/hanami/common_logger.rb +17 -1
- data/lib/hanami/components/app/assets.rb +1 -1
- data/lib/hanami/components/app/controller.rb +1 -1
- data/lib/hanami/components/app/routes.rb +1 -1
- data/lib/hanami/components/app/view.rb +1 -1
- data/lib/hanami/config/sessions.rb +17 -1
- data/lib/hanami/configuration/app.rb +5 -2
- data/lib/hanami/configuration.rb +6 -3
- data/lib/hanami/early_hints.rb +1 -1
- data/lib/hanami/environment.rb +38 -10
- data/lib/hanami/rake_helper.rb +1 -1
- data/lib/hanami/rake_tasks.rb +1 -0
- data/lib/hanami/rendering_policy.rb +2 -3
- data/lib/hanami/routes.rb +1 -1
- data/lib/hanami/setup.rb +1 -1
- data/lib/hanami/templates/welcome.html.erb +2 -2
- data/lib/hanami/version.rb +1 -1
- data/lib/hanami/welcome.rb +6 -1
- data/lib/hanami.rb +1 -1
- metadata +25 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92d8362c387abfc24cda9234c81c671d544f03a2ae2680c9f71d492c7172410a
|
4
|
+
data.tar.gz: 57643cd0ca74fd851e800edbe62c18464dc5ca0dcd09c66189ed53b256beb5f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6570e1184cc95fe719bbb366f59f082ccafdc55dddae70496c98579cd53f4d46a31bd740030b500e5d2b7ed03e2df8f42148344170c1a90453209b2575960441
|
7
|
+
data.tar.gz: f2409cb5bc4d8bf3c7fe4bfa026eb03a9315fb6ccb80e95aa2b44e9b94600427cab0814a00d32035128a3ace49b42ed35644e1d0652ffc584be2ac5ea6564db5
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,35 @@
|
|
1
1
|
# Hanami
|
2
2
|
The web, with simplicity.
|
3
3
|
|
4
|
+
## v1.3.5 - 2021-10-18
|
5
|
+
### Fixed
|
6
|
+
- [Ivan Kabluchkov] Ensure to properly store exceptions in Rack environment
|
7
|
+
- [Sean Collins] Explicitly limit in gemspec the supported rubies (>= 2.3 and < 3) for Hanami 1
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
- [Luca Guidi] Use JSON as default HTTP session serializer for cookie session storage
|
11
|
+
|
12
|
+
## v1.3.4 - 2021-05-02
|
13
|
+
### Fixed
|
14
|
+
- [Slava Kardakov] Fix generated `config.ru` `require_relative` statement
|
15
|
+
- [Armin] Fix `Hanami::CommonLogger` elapsed time compatibility with `rack` 2.1.0+
|
16
|
+
- [Adam Daniels] Fix generated tests compatibility with `minitest` 6.0+
|
17
|
+
|
18
|
+
## v1.3.3 - 2019-09-20
|
19
|
+
### Added
|
20
|
+
- [Gray Manley] Standardize file loading for `.env` files (see: https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use)
|
21
|
+
|
22
|
+
### Fixed
|
23
|
+
- [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"`)
|
24
|
+
|
25
|
+
## v1.3.2 - 2019-07-26
|
26
|
+
### Added
|
27
|
+
- [Luca Guidi] Support both `hanami-validations` 1 and 2
|
28
|
+
|
29
|
+
### Fixed
|
30
|
+
- [Wisnu Adi Nurcahyo] Ensure `hanami generate` syntax for Welcome page is compatible with ZSH
|
31
|
+
- [Luca Guidi] Don't let `hanami` to crash when called without `bundle exec`
|
32
|
+
|
4
33
|
## v1.3.1 - 2019-01-18
|
5
34
|
### Added
|
6
35
|
- [Luca Guidi] Official support for Ruby: MRI 2.6
|
@@ -9,7 +38,7 @@ The web, with simplicity.
|
|
9
38
|
### Fixed
|
10
39
|
- [Aidan Coyle] Remove from app generator support for deprecated `force_ssl` setting
|
11
40
|
- [Alessandro Caporrini] Remove from app generator support for deprecated `body_parsers` setting
|
12
|
-
- [Daphne Rouw & Sean Collins] Make app generator to work when code in `config/
|
41
|
+
- [Daphne Rouw & Sean Collins] Make app generator to work when code in `config/environment.rb` uses double quotes
|
13
42
|
|
14
43
|
## v1.3.0 - 2018-10-24
|
15
44
|
### Added
|
@@ -26,7 +55,7 @@ The web, with simplicity.
|
|
26
55
|
|
27
56
|
### Fixed
|
28
57
|
- [Anton Davydov] Make possible to pass extra settings for custom logger instances (eg. `logger SemanticLogger.new, :foo, :bar`)
|
29
|
-
- [graywolf] Ensure `hanami generate app` to work without `require_relative` entries in `config/
|
58
|
+
- [graywolf] Ensure `hanami generate app` to work without `require_relative` entries in `config/environment.rb`
|
30
59
|
- [Makoto Tajitsu & Luca Guidi] Fixed regression for `hanami new .` that used to generate a broken project
|
31
60
|
|
32
61
|
### Fixed
|
@@ -143,7 +172,7 @@ The web, with simplicity.
|
|
143
172
|
- [Luca Guidi] Make compatible with Rack 2.0 only
|
144
173
|
- [Luca Guidi] Removed `logger` settings from Hanami applications
|
145
174
|
- [Luca Guidi] Removed logger for Hanami applications (eg `Web.logger`)
|
146
|
-
- [Luca Guidi] Changed mailer syntax in `config/
|
175
|
+
- [Luca Guidi] Changed mailer syntax in `config/environment.rb`
|
147
176
|
|
148
177
|
## v0.9.2 - 2016-12-19
|
149
178
|
## Added
|
@@ -232,11 +261,11 @@ The web, with simplicity.
|
|
232
261
|
|
233
262
|
## v0.7.2 - 2016-02-09
|
234
263
|
### Fixed
|
235
|
-
- [Alfonso Uceda Pompa] Fixed routing issue when static assets server tried to
|
264
|
+
- [Alfonso Uceda Pompa] Fixed routing issue when static assets server tried to hijack paths that are matching directories in public directory
|
236
265
|
|
237
266
|
## v0.7.1 - 2016-02-05
|
238
267
|
### Fixed
|
239
|
-
- [Anton Davydov] Fixed routing issue when static assets server tried to
|
268
|
+
- [Anton Davydov] Fixed routing issue when static assets server tried to hijack requests belonging to dynamic endpoints
|
240
269
|
- [Anatolii Didukh] Ensure to fallback to default engine for `hanami console`
|
241
270
|
|
242
271
|
## v0.7.0 - 2016-01-22
|
@@ -371,7 +400,7 @@ The web, with simplicity.
|
|
371
400
|
## v0.3.0 - 2015-03-23
|
372
401
|
### Added
|
373
402
|
- [Luca Guidi] Introduced action generator. Eg. `bundle exec lotus generate action web dashboard#index`
|
374
|
-
- [Alfonso Uceda Pompa] Allow to specify default
|
403
|
+
- [Alfonso Uceda Pompa] Allow to specify default cookies options in application configuration. Eg. `cookies true, { domain: 'lotusrb.org' }`
|
375
404
|
- [Tom Kadwill] Include `Lotus::Helpers` in views.
|
376
405
|
- [Linus Pettersson] Allow to specify `--database` CLI option when generate a new project. Eg. `lotus new bookshelf --database=postgresql`
|
377
406
|
- [Linus Pettersson] Initialize a Git repository when generating a new project
|
data/FEATURES.md
CHANGED
@@ -3,6 +3,16 @@
|
|
3
3
|
|
4
4
|
## Features
|
5
5
|
|
6
|
+
## v1.3.5 - 2021-10-18
|
7
|
+
|
8
|
+
## v1.3.4 - 2021-05-02
|
9
|
+
|
10
|
+
## v1.3.3 - 2019-09-20
|
11
|
+
|
12
|
+
- Standardize file loading for `.env` files (see: https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use)
|
13
|
+
|
14
|
+
## v1.3.2 - 2019-07-26
|
15
|
+
|
6
16
|
## v1.3.1 - 2019-01-18
|
7
17
|
|
8
18
|
## v1.3.0 - 2018-10-24
|
@@ -20,7 +30,7 @@
|
|
20
30
|
- Unobtrusive JavaScript (UJS) (via `hanami-ujs` gem)
|
21
31
|
- Interactive console for development error page (via `hanami-webconsole` gem)
|
22
32
|
- CLI: register callbacks for `hanami` commands (`Hanami::CLI.after("db migrate", MyCallback.new)` or `Hanami::CLI.after("db migrate") { ... }`)
|
23
|
-
- Project level Rack middleware stack (`Hanami.configure { middleware.use
|
33
|
+
- Project level Rack middleware stack (`Hanami.configure { middleware.use MyRackMiddleware }`)
|
24
34
|
- Plugins can hook into project configuration (`Hanami.plugin { middleware.use AnotherRackMiddleware }`)
|
25
35
|
- Custom repository commands
|
26
36
|
- Coloured logging
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
The web, with simplicity.
|
4
4
|
|
5
|
+
## Version
|
6
|
+
|
7
|
+
**This branch contains the code for `hanami` 1.3.x.**
|
8
|
+
|
5
9
|
## Frameworks
|
6
10
|
|
7
11
|
Hanami is a **full-stack** Ruby web framework.
|
@@ -18,7 +22,6 @@ which provides the glue that ties all the parts together:
|
|
18
22
|
* [**Hanami::Helpers**](https://github.com/hanami/helpers) - View helpers for Ruby applications
|
19
23
|
* [**Hanami::Mailer**](https://github.com/hanami/mailer) - Mail for Ruby applications
|
20
24
|
* [**Hanami::Assets**](https://github.com/hanami/assets) - Assets management for Ruby
|
21
|
-
* [**Hanami::CLI**](https://github.com/hanami/cli) - Ruby command line interface
|
22
25
|
* [**Hanami::Utils**](https://github.com/hanami/utils) - Ruby core extensions and class utilities
|
23
26
|
|
24
27
|
These components are designed to be used independently or together in a Hanami application.
|
@@ -26,8 +29,8 @@ These components are designed to be used independently or together in a Hanami a
|
|
26
29
|
## Status
|
27
30
|
|
28
31
|
[![Gem Version](https://badge.fury.io/rb/hanami.svg)](https://badge.fury.io/rb/hanami)
|
29
|
-
[![
|
30
|
-
[![Test Coverage](https://codecov.io/gh/hanami/hanami/branch/
|
32
|
+
[![CI](https://github.com/hanami/hanami/workflows/ci/badge.svg?branch=1.3.x)](https://github.com/hanami/hanami/actions?query=workflow%3Aci+branch%3A1.3.x)
|
33
|
+
[![Test Coverage](https://codecov.io/gh/hanami/hanami/branch/1.3.x/graph/badge.svg)](https://codecov.io/gh/hanami/hanami)
|
31
34
|
[![Depfu](https://badges.depfu.com/badges/ba000e0f69e6ef1c44cd3038caaa1841/overview.svg)](https://depfu.com/github/hanami/hanami?project=Bundler)
|
32
35
|
[![Inline Docs](http://inch-ci.org/github/hanami/hanami.svg)](http://inch-ci.org/github/hanami/hanami)
|
33
36
|
|
@@ -137,4 +140,4 @@ Released under MIT License.
|
|
137
140
|
|
138
141
|
This project was formerly known as Lotus (`lotusrb`).
|
139
142
|
|
140
|
-
Copyright © 2014-
|
143
|
+
Copyright © 2014-2021 Luca Guidi.
|
data/bin/hanami
CHANGED
@@ -2,5 +2,5 @@
|
|
2
2
|
require 'bundler'
|
3
3
|
require 'hanami/cli/commands'
|
4
4
|
|
5
|
-
Bundler.require(:plugins) if File.exist?(ENV["BUNDLE_GEMFILE"] || "Gemfile")
|
6
|
-
|
5
|
+
::Bundler.require(:plugins) if File.exist?(ENV["BUNDLE_GEMFILE"] || "Gemfile")
|
6
|
+
Dry::CLI.new(Hanami::CLI::Commands).call
|
data/hanami.gemspec
CHANGED
@@ -17,24 +17,24 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
|
-
spec.required_ruby_version = '>= 2.3.0'
|
20
|
+
spec.required_ruby_version = '>= 2.3.0', '< 3'
|
21
21
|
|
22
22
|
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
23
23
|
|
24
24
|
spec.add_dependency 'hanami-utils', '~> 1.3'
|
25
|
-
spec.add_dependency 'hanami-validations', '
|
25
|
+
spec.add_dependency 'hanami-validations', '>= 1.3', '< 3'
|
26
26
|
spec.add_dependency 'hanami-router', '~> 1.3'
|
27
|
-
spec.add_dependency 'hanami-controller', '~> 1.3'
|
27
|
+
spec.add_dependency 'hanami-controller', '~> 1.3', '>= 1.3.3'
|
28
28
|
spec.add_dependency 'hanami-view', '~> 1.3'
|
29
29
|
spec.add_dependency 'hanami-helpers', '~> 1.3'
|
30
30
|
spec.add_dependency 'hanami-mailer', '~> 1.3'
|
31
31
|
spec.add_dependency 'hanami-assets', '~> 1.3'
|
32
|
-
spec.add_dependency '
|
32
|
+
spec.add_dependency 'dry-cli', '~> 0.5'
|
33
33
|
spec.add_dependency 'concurrent-ruby', '~> 1.0'
|
34
34
|
spec.add_dependency 'bundler', '>= 1.6', '< 3'
|
35
35
|
|
36
|
-
spec.add_development_dependency 'rspec', '~>
|
36
|
+
spec.add_development_dependency 'rspec', '~> 3.7'
|
37
37
|
spec.add_development_dependency 'rack-test', '~> 1.1'
|
38
|
-
spec.add_development_dependency 'aruba', '~>
|
39
|
-
spec.add_development_dependency 'rake', '~>
|
38
|
+
spec.add_development_dependency 'aruba', '~> 0.14'
|
39
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
40
40
|
end
|
data/lib/hanami/app.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'hanami'
|
2
2
|
require 'hanami/environment'
|
3
3
|
require 'hanami/components'
|
4
|
-
require '
|
4
|
+
require 'dry/cli/command'
|
5
5
|
require 'hanami/cli/commands/project'
|
6
6
|
require 'hanami/cli/commands/templates'
|
7
7
|
require 'concurrent'
|
@@ -17,7 +17,7 @@ module Hanami
|
|
17
17
|
# Abstract command
|
18
18
|
#
|
19
19
|
# @since 1.1.0
|
20
|
-
class Command <
|
20
|
+
class Command < Dry::CLI::Command
|
21
21
|
# @since 1.1.0
|
22
22
|
# @api private
|
23
23
|
def self.inherited(component)
|
@@ -82,7 +82,7 @@ module Hanami
|
|
82
82
|
options = environment.to_options.merge(options)
|
83
83
|
end
|
84
84
|
|
85
|
-
super(options)
|
85
|
+
super(**options)
|
86
86
|
rescue StandardError => e
|
87
87
|
warn e.message
|
88
88
|
warn e.backtrace.join("\n\t")
|
@@ -92,9 +92,7 @@ module Hanami
|
|
92
92
|
|
93
93
|
# @since 1.1.0
|
94
94
|
# @api private
|
95
|
-
def initialize(
|
96
|
-
super(command_name: command_name)
|
97
|
-
|
95
|
+
def initialize(out: $stdout, files: Utils::Files)
|
98
96
|
@out = out
|
99
97
|
@files = files
|
100
98
|
@templates = Templates.new(self.class)
|
@@ -122,7 +122,7 @@ module <%= app.classify %>
|
|
122
122
|
# * :yui
|
123
123
|
# * :closure
|
124
124
|
#
|
125
|
-
# See:
|
125
|
+
# See: https://guides.hanamirb.org/assets/compressors
|
126
126
|
#
|
127
127
|
# In order to skip JavaScript compression comment the following line
|
128
128
|
javascript_compressor :builtin
|
@@ -135,7 +135,7 @@ module <%= app.classify %>
|
|
135
135
|
# * :yui
|
136
136
|
# * :sass
|
137
137
|
#
|
138
|
-
# See:
|
138
|
+
# See: https://guides.hanamirb.org/assets/compressors
|
139
139
|
#
|
140
140
|
# In order to skip stylesheet compression comment the following line
|
141
141
|
stylesheet_compressor :builtin
|
@@ -292,12 +292,12 @@ module <%= app.classify %>
|
|
292
292
|
|
293
293
|
# Use fingerprint file name for asset paths
|
294
294
|
#
|
295
|
-
# See:
|
295
|
+
# See: https://guides.hanamirb.org/assets/overview
|
296
296
|
fingerprint true
|
297
297
|
|
298
298
|
# Content Delivery Network (CDN)
|
299
299
|
#
|
300
|
-
# See:
|
300
|
+
# See: https://guides.hanamirb.org/assets/content-delivery-network
|
301
301
|
#
|
302
302
|
# scheme 'https'
|
303
303
|
# host 'cdn.example.org'
|
@@ -305,7 +305,7 @@ module <%= app.classify %>
|
|
305
305
|
|
306
306
|
# Subresource Integrity
|
307
307
|
#
|
308
|
-
# See:
|
308
|
+
# See: https://guides.hanamirb.org/assets/content-delivery-network/#subresource-integrity
|
309
309
|
subresource_integrity :sha256
|
310
310
|
end
|
311
311
|
end
|
@@ -10,7 +10,6 @@ gem 'hanami-controller', require: false, git: 'https://github.com/hanami/contro
|
|
10
10
|
gem 'hanami-view', require: false, git: 'https://github.com/hanami/view.git', branch: 'develop'
|
11
11
|
gem 'hanami-helpers', require: false, git: 'https://github.com/hanami/helpers.git', branch: 'develop'
|
12
12
|
gem 'hanami-mailer', require: false, git: 'https://github.com/hanami/mailer.git', branch: 'develop'
|
13
|
-
gem 'hanami-cli', require: false, git: 'https://github.com/hanami/cli.git', branch: 'develop'
|
14
13
|
gem 'hanami-assets', require: false, git: 'https://github.com/hanami/assets.git', branch: 'develop'
|
15
14
|
gem 'hanami-model', require: false, git: 'https://github.com/hanami/model.git', branch: 'develop'
|
16
15
|
gem 'hanami', git: 'https://github.com/hanami/hanami.git', branch: 'develop'
|
@@ -34,7 +33,7 @@ gem 'haml'
|
|
34
33
|
<%- if code_reloading -%>
|
35
34
|
group :development do
|
36
35
|
# Code reloading
|
37
|
-
# See:
|
36
|
+
# See: https://guides.hanamirb.org/projects/code-reloading
|
38
37
|
gem 'shotgun', platforms: :ruby
|
39
38
|
gem 'hanami-webconsole'
|
40
39
|
end
|
@@ -30,4 +30,4 @@ How to prepare (create and migrate) DB for `development` and `test` environments
|
|
30
30
|
% HANAMI_ENV=test bundle exec hanami db prepare
|
31
31
|
```
|
32
32
|
|
33
|
-
Explore Hanami [guides](
|
33
|
+
Explore Hanami [guides](https://guides.hanamirb.org/), [API docs](http://docs.hanamirb.org/<%= Hanami::VERSION %>/), or jump in [chat](http://chat.hanamirb.org) for help. Enjoy! 🌸
|
@@ -30,12 +30,12 @@ Hanami.configure do
|
|
30
30
|
mailer do
|
31
31
|
root 'lib/<%= project %>/mailers'
|
32
32
|
|
33
|
-
# See
|
33
|
+
# See https://guides.hanamirb.org/mailers/delivery
|
34
34
|
delivery :test
|
35
35
|
end
|
36
36
|
|
37
37
|
environment :development do
|
38
|
-
# See:
|
38
|
+
# See: https://guides.hanamirb.org/projects/logging
|
39
39
|
logger level: :debug
|
40
40
|
end
|
41
41
|
|
@@ -502,7 +502,7 @@ module Hanami
|
|
502
502
|
# @since 1.1.0
|
503
503
|
# @api private
|
504
504
|
def generate_app(context)
|
505
|
-
Hanami::CLI::Commands::New::App.new(
|
505
|
+
Hanami::CLI::Commands::New::App.new(out: @out, files: @files).call(app: context.application_name, application_base_url: context.application_base_url, **context.options)
|
506
506
|
end
|
507
507
|
|
508
508
|
# @since 1.1.0
|
@@ -565,8 +565,8 @@ module Hanami
|
|
565
565
|
|
566
566
|
# @since 1.1.0
|
567
567
|
# @api private
|
568
|
-
def initialize(*)
|
569
|
-
super
|
568
|
+
def initialize(*args, **kwargs)
|
569
|
+
super(*args, **kwargs)
|
570
570
|
@templates = Templates.new(self.class.superclass)
|
571
571
|
end
|
572
572
|
end
|
data/lib/hanami/cli/commands.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'dry/cli'
|
2
2
|
require 'ostruct'
|
3
3
|
|
4
4
|
module Hanami
|
@@ -54,7 +54,7 @@ module Hanami
|
|
54
54
|
# @since 1.1.0
|
55
55
|
# @api private
|
56
56
|
module Commands
|
57
|
-
extend
|
57
|
+
extend Dry::CLI::Registry
|
58
58
|
|
59
59
|
# CLI command context
|
60
60
|
#
|
data/lib/hanami/common_logger.rb
CHANGED
@@ -55,7 +55,7 @@ module Hanami
|
|
55
55
|
# rubocop:disable Metrics/AbcSize
|
56
56
|
# rubocop:disable Metrics/MethodLength
|
57
57
|
def log(env, status, header, began_at)
|
58
|
-
now =
|
58
|
+
now = ElapsedTime.call
|
59
59
|
length = extract_content_length(header)
|
60
60
|
|
61
61
|
msg = Hash[
|
@@ -89,5 +89,21 @@ module Hanami
|
|
89
89
|
result.merge!(Utils::Hash.deep_stringify(env.fetch(ROUTER_PARAMS, {})))
|
90
90
|
result
|
91
91
|
end
|
92
|
+
|
93
|
+
# Wrapper which uses Rack's monotonic clock_time (used for began_at since Rack 2.1.0)
|
94
|
+
#
|
95
|
+
# @since 1.3.4
|
96
|
+
# @api private
|
97
|
+
class ElapsedTime
|
98
|
+
@clock = if Gem::Version.new(Rack::RELEASE) >= Gem::Version.new('2.1.0')
|
99
|
+
-> { Rack::Utils.clock_time }
|
100
|
+
else
|
101
|
+
-> { Time.now }
|
102
|
+
end.freeze
|
103
|
+
|
104
|
+
def self.call
|
105
|
+
@clock.call
|
106
|
+
end
|
107
|
+
end
|
92
108
|
end
|
93
109
|
end
|
@@ -8,7 +8,7 @@ module Hanami
|
|
8
8
|
# @since 0.9.0
|
9
9
|
# @api private
|
10
10
|
module App
|
11
|
-
# hanami-controller configuration for a
|
11
|
+
# hanami-controller configuration for a single Hanami application in the project.
|
12
12
|
#
|
13
13
|
# @since 0.9.0
|
14
14
|
# @api private
|
@@ -33,6 +33,7 @@ module Hanami
|
|
33
33
|
# @api private
|
34
34
|
#
|
35
35
|
# @see http://www.rubydoc.info/github/rack/rack/Rack/Session/Abstract/ID
|
36
|
+
# @see https://www.rubydoc.info/github/rack/rack/Rack/Session/Cookie
|
36
37
|
def initialize(adapter = nil, options = {}, configuration = nil)
|
37
38
|
@adapter = adapter
|
38
39
|
@options = options
|
@@ -77,11 +78,17 @@ module Hanami
|
|
77
78
|
# @since 0.2.0
|
78
79
|
# @api private
|
79
80
|
def default_options
|
80
|
-
if @configuration
|
81
|
+
result = if @configuration
|
81
82
|
{ domain: domain, secure: @configuration.ssl? }
|
82
83
|
else
|
83
84
|
{}
|
84
85
|
end
|
86
|
+
|
87
|
+
if s = cookies_adapter_serializer
|
88
|
+
result[:coder] = s
|
89
|
+
end
|
90
|
+
|
91
|
+
result
|
85
92
|
end
|
86
93
|
|
87
94
|
# @since 0.2.0
|
@@ -98,6 +105,15 @@ module Hanami
|
|
98
105
|
def ip_address?(string)
|
99
106
|
!!IPAddr.new(string) rescue false
|
100
107
|
end
|
108
|
+
|
109
|
+
# @since 1.3.5
|
110
|
+
# @api private
|
111
|
+
def cookies_adapter_serializer
|
112
|
+
return nil unless @adapter == :cookie
|
113
|
+
|
114
|
+
require "rack/session/cookie"
|
115
|
+
Rack::Session::Cookie::Base64::JSON.new
|
116
|
+
end
|
101
117
|
end
|
102
118
|
end
|
103
119
|
end
|
@@ -7,11 +7,14 @@ module Hanami
|
|
7
7
|
class App < SimpleDelegator
|
8
8
|
# @api private
|
9
9
|
attr_reader :path_prefix
|
10
|
+
# @api private
|
11
|
+
attr_reader :host
|
10
12
|
|
11
13
|
# @api private
|
12
|
-
def initialize(app,
|
14
|
+
def initialize(app, options = {})
|
13
15
|
super(app)
|
14
|
-
@path_prefix =
|
16
|
+
@path_prefix = options[:at]
|
17
|
+
@host = options[:host]
|
15
18
|
end
|
16
19
|
end
|
17
20
|
end
|
data/lib/hanami/configuration.rb
CHANGED
@@ -20,6 +20,7 @@ module Hanami
|
|
20
20
|
# @param app [#call] an application compatible with Rack SPEC
|
21
21
|
# @param options [Hash] a set of options
|
22
22
|
# @option :at [String] options the mount point
|
23
|
+
# @option :host [String] options the mount point
|
23
24
|
#
|
24
25
|
# @since 0.9.0
|
25
26
|
#
|
@@ -27,12 +28,14 @@ module Hanami
|
|
27
28
|
# # config/environment.rb
|
28
29
|
# # ...
|
29
30
|
# Hanami.configure do
|
31
|
+
# mount Beta::Application, at: '/', host: 'beta.bookshelf.com'
|
32
|
+
# mount Admin::Application, at: '/api'
|
30
33
|
# mount Web::Application, at: '/'
|
31
34
|
#
|
32
35
|
# # ...
|
33
36
|
# end
|
34
37
|
def mount(app, options)
|
35
|
-
mounted[app] = App.new(app, options
|
38
|
+
mounted[app] = App.new(app, options)
|
36
39
|
end
|
37
40
|
|
38
41
|
# Configure database
|
@@ -75,7 +78,7 @@ module Hanami
|
|
75
78
|
# mailer do
|
76
79
|
# root 'lib/bookshelf/mailers'
|
77
80
|
#
|
78
|
-
# # See
|
81
|
+
# # See https://guides.hanamirb.org/mailers/delivery
|
79
82
|
# delivery :test
|
80
83
|
# end
|
81
84
|
#
|
@@ -151,7 +154,7 @@ module Hanami
|
|
151
154
|
# @see Hanami.logger
|
152
155
|
# @see Hanami::Logger
|
153
156
|
#
|
154
|
-
# @see
|
157
|
+
# @see https://guides.hanamirb.org/projects/logging
|
155
158
|
#
|
156
159
|
# @example Basic Usage
|
157
160
|
# # config/environment.rb
|
data/lib/hanami/early_hints.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Hanami
|
4
4
|
# HTTP/2 Early Hints Rack middleware
|
5
5
|
#
|
6
|
-
# It sends extra responses **before** the main
|
6
|
+
# It sends extra responses **before** the main response is sent.
|
7
7
|
# These extra responses are HTTP/2 Early Hints (103).
|
8
8
|
# They specify the web assets (javascripts, stylesheets, etc..) to be "pushed",
|
9
9
|
# so modern browsers pre-fetch them in parallel with the main HTTP response.
|
data/lib/hanami/environment.rb
CHANGED
@@ -36,6 +36,12 @@ module Hanami
|
|
36
36
|
# @api private
|
37
37
|
DEFAULT_ENV = 'development'.freeze
|
38
38
|
|
39
|
+
# Test environment
|
40
|
+
#
|
41
|
+
# @since 1.3.3
|
42
|
+
# @api private
|
43
|
+
TEST_ENV = 'test'.freeze
|
44
|
+
|
39
45
|
# Production environment
|
40
46
|
#
|
41
47
|
# @since 0.6.0
|
@@ -48,11 +54,21 @@ module Hanami
|
|
48
54
|
# @api private
|
49
55
|
RACK_ENV_DEPLOYMENT = 'deployment'.freeze
|
50
56
|
|
51
|
-
#
|
57
|
+
# @since 1.3.3
|
58
|
+
# @api private
|
59
|
+
DOTENV_LOCAL_FILE = '.env.local'.freeze
|
60
|
+
|
61
|
+
# Default `.env` files that are loaded. The entries are ordered from highest
|
62
|
+
# to lowest priority.
|
52
63
|
#
|
53
|
-
# @since
|
64
|
+
# @since 1.3.3
|
54
65
|
# @api private
|
55
|
-
|
66
|
+
DOTENV_FILES = [
|
67
|
+
'.env.%{environment}.local'.freeze,
|
68
|
+
DOTENV_LOCAL_FILE,
|
69
|
+
'.env.%{environment}'.freeze,
|
70
|
+
'.env'.freeze
|
71
|
+
].freeze
|
56
72
|
|
57
73
|
# Default configuration directory under application root
|
58
74
|
#
|
@@ -132,9 +148,8 @@ module Hanami
|
|
132
148
|
# located under the config directory. All the settings in those files will
|
133
149
|
# be exported as `ENV` variables.
|
134
150
|
#
|
135
|
-
#
|
136
|
-
#
|
137
|
-
# control.
|
151
|
+
# This table: https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
|
152
|
+
# has more info on the priority of the .env files.
|
138
153
|
#
|
139
154
|
# The format of those `.env.<environment>` files follows UNIX and UNIX-like
|
140
155
|
# operating system environment variable declaration format and compatible
|
@@ -391,7 +406,7 @@ module Hanami
|
|
391
406
|
# @since 0.4.0
|
392
407
|
# @api private
|
393
408
|
def require_application_environment
|
394
|
-
Bundler.setup(*bundler_groups)
|
409
|
+
::Bundler.setup(*bundler_groups)
|
395
410
|
require project_environment_configuration.to_s # if project_environment_configuration.exist?
|
396
411
|
end
|
397
412
|
|
@@ -487,10 +502,13 @@ module Hanami
|
|
487
502
|
# @since 0.2.0
|
488
503
|
# @api private
|
489
504
|
def set_application_env_vars!
|
490
|
-
|
491
|
-
|
505
|
+
DOTENV_FILES.each do |filename_format|
|
506
|
+
file = filename_format % { environment: environment }
|
507
|
+
next unless dotenv_applicable?(file)
|
492
508
|
|
493
|
-
|
509
|
+
path = root.join(file)
|
510
|
+
env.load!(path) if path.exist?
|
511
|
+
end
|
494
512
|
end
|
495
513
|
|
496
514
|
# @since 0.1.0
|
@@ -509,5 +527,15 @@ module Hanami
|
|
509
527
|
env[RACK_ENV]
|
510
528
|
end
|
511
529
|
end
|
530
|
+
|
531
|
+
# @api private
|
532
|
+
# @since 1.3.3
|
533
|
+
#
|
534
|
+
# @see https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
|
535
|
+
def dotenv_applicable?(file)
|
536
|
+
return false if file == DOTENV_LOCAL_FILE && environment == TEST_ENV
|
537
|
+
|
538
|
+
true
|
539
|
+
end
|
512
540
|
end
|
513
541
|
end
|
data/lib/hanami/rake_helper.rb
CHANGED
@@ -71,7 +71,7 @@ module Hanami
|
|
71
71
|
# @api private
|
72
72
|
def run_hanami_command(command)
|
73
73
|
require "hanami/cli/commands"
|
74
|
-
|
74
|
+
Dry::CLI.new(Hanami::CLI::Commands).call(arguments: command.split(/[[:space:]]/))
|
75
75
|
end
|
76
76
|
# rubocop:enable Metrics/MethodLength
|
77
77
|
end
|
data/lib/hanami/rake_tasks.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'hanami/utils/class'
|
2
2
|
require 'hanami/views/default'
|
3
3
|
require 'hanami/views/null_view'
|
4
|
+
require 'hanami/action/rack/errors'
|
4
5
|
|
5
6
|
module Hanami
|
6
7
|
# Rendering policy
|
@@ -17,8 +18,6 @@ module Hanami
|
|
17
18
|
|
18
19
|
# @api private
|
19
20
|
HANAMI_ACTION = 'hanami.action'.freeze
|
20
|
-
# @api private
|
21
|
-
RACK_EXCEPTION = 'rack.exception'.freeze
|
22
21
|
|
23
22
|
# @api private
|
24
23
|
SUCCESSFUL_STATUSES = (200..201).freeze
|
@@ -57,7 +56,7 @@ module Hanami
|
|
57
56
|
action.exposures
|
58
57
|
)
|
59
58
|
rescue StandardError => e
|
60
|
-
env
|
59
|
+
Hanami::Action::Rack::Errors.set(env, e)
|
61
60
|
raise e unless @configuration.handle_exceptions
|
62
61
|
|
63
62
|
response[STATUS] = ERROR_STATUS
|
data/lib/hanami/routes.rb
CHANGED
data/lib/hanami/setup.rb
CHANGED
@@ -32,13 +32,13 @@
|
|
32
32
|
|
33
33
|
<h3>Hanami is Open Source Software for MVC web development with Ruby.</h3>
|
34
34
|
|
35
|
-
<p>Please generate a new action with:<br><code>bundle exec hanami generate action <%= application_name %> home#index --url=/</code></p>
|
35
|
+
<p>Please generate a new action with:<br><code>bundle exec hanami generate action <%= application_name %> 'home#index' --url=/</code></p>
|
36
36
|
|
37
37
|
<hr style="margin-top: 4em;"/>
|
38
38
|
<div id="content">
|
39
39
|
<ul>
|
40
40
|
<li><a href="http://hanamirb.org">Website</a></li>
|
41
|
-
<li><a href="
|
41
|
+
<li><a href="https://guides.hanamirb.org/">Guides</a></li>
|
42
42
|
<li><a href="http://www.rubydoc.info/gems/hanami">API docs</a></li>
|
43
43
|
<li><a href="https://github.com/hanami/hanami">Source code</a></li>
|
44
44
|
<li><a href="https://gitter.im/hanami/chat">Chat</a></li>
|
data/lib/hanami/version.rb
CHANGED
data/lib/hanami/welcome.rb
CHANGED
@@ -14,6 +14,7 @@ module Hanami
|
|
14
14
|
# @api private
|
15
15
|
def call(env)
|
16
16
|
@request_path = env['REQUEST_PATH'] || ''
|
17
|
+
@request_host = env['HTTP_HOST'] || ''
|
17
18
|
@body = [ERB.new(@root.join('welcome.html.erb').read).result(binding)]
|
18
19
|
|
19
20
|
[200, {}, @body]
|
@@ -29,7 +30,11 @@ module Hanami
|
|
29
30
|
# @api private
|
30
31
|
def application_class
|
31
32
|
Hanami.configuration.apps do |app|
|
32
|
-
|
33
|
+
if app.host.nil?
|
34
|
+
return app if @request_path.include?(app.path_prefix)
|
35
|
+
else
|
36
|
+
return app if @request_host == app.host
|
37
|
+
end
|
33
38
|
end
|
34
39
|
end
|
35
40
|
end
|
data/lib/hanami.rb
CHANGED
@@ -264,7 +264,7 @@ module Hanami
|
|
264
264
|
# @since 1.0.0
|
265
265
|
# @api private
|
266
266
|
#
|
267
|
-
# @see
|
267
|
+
# @see https://guides.hanamirb.org/projects/code-reloading
|
268
268
|
def self.code_reloading?
|
269
269
|
environment
|
270
270
|
Components.resolve('code_reloading')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hanami
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hanami-utils
|
@@ -28,16 +28,22 @@ dependencies:
|
|
28
28
|
name: hanami-validations
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.3'
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '3'
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
|
-
- - "
|
41
|
+
- - ">="
|
39
42
|
- !ruby/object:Gem::Version
|
40
43
|
version: '1.3'
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '3'
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: hanami-router
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,6 +65,9 @@ dependencies:
|
|
59
65
|
- - "~>"
|
60
66
|
- !ruby/object:Gem::Version
|
61
67
|
version: '1.3'
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.3.3
|
62
71
|
type: :runtime
|
63
72
|
prerelease: false
|
64
73
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -66,6 +75,9 @@ dependencies:
|
|
66
75
|
- - "~>"
|
67
76
|
- !ruby/object:Gem::Version
|
68
77
|
version: '1.3'
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 1.3.3
|
69
81
|
- !ruby/object:Gem::Dependency
|
70
82
|
name: hanami-view
|
71
83
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,19 +135,19 @@ dependencies:
|
|
123
135
|
- !ruby/object:Gem::Version
|
124
136
|
version: '1.3'
|
125
137
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
138
|
+
name: dry-cli
|
127
139
|
requirement: !ruby/object:Gem::Requirement
|
128
140
|
requirements:
|
129
141
|
- - "~>"
|
130
142
|
- !ruby/object:Gem::Version
|
131
|
-
version: '0.
|
143
|
+
version: '0.5'
|
132
144
|
type: :runtime
|
133
145
|
prerelease: false
|
134
146
|
version_requirements: !ruby/object:Gem::Requirement
|
135
147
|
requirements:
|
136
148
|
- - "~>"
|
137
149
|
- !ruby/object:Gem::Version
|
138
|
-
version: '0.
|
150
|
+
version: '0.5'
|
139
151
|
- !ruby/object:Gem::Dependency
|
140
152
|
name: concurrent-ruby
|
141
153
|
requirement: !ruby/object:Gem::Requirement
|
@@ -218,14 +230,14 @@ dependencies:
|
|
218
230
|
requirements:
|
219
231
|
- - "~>"
|
220
232
|
- !ruby/object:Gem::Version
|
221
|
-
version: '
|
233
|
+
version: '13.0'
|
222
234
|
type: :development
|
223
235
|
prerelease: false
|
224
236
|
version_requirements: !ruby/object:Gem::Requirement
|
225
237
|
requirements:
|
226
238
|
- - "~>"
|
227
239
|
- !ruby/object:Gem::Version
|
228
|
-
version: '
|
240
|
+
version: '13.0'
|
229
241
|
description: Hanami is a web framework for Ruby
|
230
242
|
email:
|
231
243
|
- me@lucaguidi.com
|
@@ -389,13 +401,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
389
401
|
- - ">="
|
390
402
|
- !ruby/object:Gem::Version
|
391
403
|
version: 2.3.0
|
404
|
+
- - "<"
|
405
|
+
- !ruby/object:Gem::Version
|
406
|
+
version: '3'
|
392
407
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
393
408
|
requirements:
|
394
409
|
- - ">="
|
395
410
|
- !ruby/object:Gem::Version
|
396
411
|
version: '0'
|
397
412
|
requirements: []
|
398
|
-
rubygems_version: 3.
|
413
|
+
rubygems_version: 3.2.2
|
399
414
|
signing_key:
|
400
415
|
specification_version: 4
|
401
416
|
summary: The web, with simplicity
|