hanami 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d78ad0596470f8b250d8338f0699027536b75f5e2d831e8d5de80c015752cb1
4
- data.tar.gz: 2e2ccb278a4650be97af8cf4a82f744392de01e2ba0bf4e2722894aae428f08e
3
+ metadata.gz: 9ec1be46fff34a0e6278e8c08a20742d87622bb24ef82b5320c7f71c9900bc6d
4
+ data.tar.gz: b88a1a45b04427a79a7c7d828353bca49df12de456815d35ff84c18ff09dcda0
5
5
  SHA512:
6
- metadata.gz: 8cfcdad6be7609b696cb5a9361431e1905efdef079edbdb9a6d1cf16ffa25524d1621b6611906b15d1749651c40921795eb43a4bbf90b638d8a129f3761dc7f3
7
- data.tar.gz: 400732666b45a462880bbd56fdddffc96f10420ecca3d031aeacadf87d3c473a3962092de36b88dd1eba713e31cf4908c32974d6c90c0b9f550f876ea87b2a38
6
+ metadata.gz: 97ff7cbc39b2dca8623431ff84024f854d504618742035242f3ee6ca84af419ba6126812e2e7316f4cb1025f1b5be1b0f383ea7c9acc4947a726c4012e301ec0
7
+ data.tar.gz: 53c4e2fe586a644adc84a32fa8f19ea41553796e0aeb33d40e0d60185a99bb225a6809b618693e0663569acd7bd040c402928629d8a54cdc63ee9e0a55bc5df2
@@ -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
@@ -3,6 +3,10 @@
3
3
 
4
4
  ## Features
5
5
 
6
+ ## v1.3.3 - 2019-09-20
7
+
8
+ - Standardize file loading for `.env` files (see: https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use)
9
+
6
10
  ## v1.3.2 - 2019-07-26
7
11
 
8
12
  ## v1.3.1 - 2019-01-18
@@ -62,7 +62,7 @@ module Hanami
62
62
  # @api private
63
63
  def mount(configuration)
64
64
  configuration.mounted.each do |klass, app|
65
- routes.mount(klass, at: app.path_prefix)
65
+ routes.mount(klass, at: app.path_prefix, host: app.host)
66
66
  end
67
67
  end
68
68
 
@@ -1,2 +1,4 @@
1
1
  /public/assets*
2
2
  /tmp
3
+ .env.local
4
+ .env.*.local
@@ -1,3 +1,5 @@
1
1
  /db/*.sqlite
2
2
  /public/assets*
3
3
  /tmp
4
+ .env.local
5
+ .env.*.local
@@ -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.fetch(:at))
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, path_prefix)
14
+ def initialize(app, options = {})
13
15
  super(app)
14
- @path_prefix = path_prefix
16
+ @path_prefix = options[:at]
17
+ @host = options[:host]
15
18
  end
16
19
  end
17
20
  end
@@ -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
- # Default `.env` per environment file name
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 0.2.0
64
+ # @since 1.3.3
54
65
  # @api private
55
- DEFAULT_DOTENV_ENV = '.env.%s'.freeze
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
- # Master .env file is ignored to suggest clear separation of environment
136
- # configurations and discourage putting sensitive information into source
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
- dotenv = root.join(DEFAULT_DOTENV_ENV % environment)
491
- return unless dotenv.exist?
505
+ DOTENV_FILES.each do |filename_format|
506
+ file = filename_format % { environment: environment }
507
+ next unless dotenv_applicable?(file)
492
508
 
493
- env.load!(dotenv)
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
@@ -6,7 +6,7 @@ module Hanami
6
6
  module Version
7
7
  # @since 0.9.0
8
8
  # @api private
9
- VERSION = '1.3.2'.freeze
9
+ VERSION = '1.3.3'.freeze
10
10
 
11
11
  # @since 0.9.0
12
12
  # @api private
@@ -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
- return app if @request_path.include?(app.path_prefix)
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.2
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-07-26 00:00:00.000000000 Z
11
+ date: 2019-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hanami-utils