hanami 1.3.2 → 1.3.3
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 +7 -0
- data/FEATURES.md +4 -0
- data/lib/hanami/app.rb +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/configuration.rb +4 -1
- data/lib/hanami/configuration/app.rb +5 -2
- data/lib/hanami/environment.rb +37 -9
- data/lib/hanami/version.rb +1 -1
- data/lib/hanami/welcome.rb +6 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ec1be46fff34a0e6278e8c08a20742d87622bb24ef82b5320c7f71c9900bc6d
|
4
|
+
data.tar.gz: b88a1a45b04427a79a7c7d828353bca49df12de456815d35ff84c18ff09dcda0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97ff7cbc39b2dca8623431ff84024f854d504618742035242f3ee6ca84af419ba6126812e2e7316f4cb1025f1b5be1b0f383ea7c9acc4947a726c4012e301ec0
|
7
|
+
data.tar.gz: 53c4e2fe586a644adc84a32fa8f19ea41553796e0aeb33d40e0d60185a99bb225a6809b618693e0663569acd7bd040c402928629d8a54cdc63ee9e0a55bc5df2
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
# Hanami
|
2
2
|
The web, with simplicity.
|
3
3
|
|
4
|
+
## v1.3.3 - 2019-09-20
|
5
|
+
### Added
|
6
|
+
- [Gray Manley] Standardize file loading for `.env` files (see: https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use)
|
7
|
+
|
8
|
+
### Fixed
|
9
|
+
- [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"`)
|
10
|
+
|
4
11
|
## v1.3.2 - 2019-07-26
|
5
12
|
### Added
|
6
13
|
- [Luca Guidi] Support both `hanami-validations` 1 and 2
|
data/FEATURES.md
CHANGED
data/lib/hanami/app.rb
CHANGED
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
|
@@ -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/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
|
@@ -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/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
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hanami-utils
|