hanami 0.7.0 → 0.7.1
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 +5 -0
- data/lib/hanami/application.rb +119 -116
- data/lib/hanami/commands/console.rb +1 -1
- data/lib/hanami/commands/new/abstract.rb +3 -6
- data/lib/hanami/rendering_policy.rb +2 -2
- data/lib/hanami/static.rb +9 -4
- data/lib/hanami/version.rb +1 -1
- data/lib/hanami/views/null_view.rb +1 -1
- data/lib/hanami/welcome.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b7009c4b87b140d19b16be7a2dcf3b7809c1519
|
4
|
+
data.tar.gz: 2593b7fce5f032a478e6977ff407e33237189c6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b718475924f9d0af9892d412cef58cf97e8eb24a54f7977be6d0061ece7703082cdca2f77a1ca7eaf9d05b9c32bd1fc6d01f3ff290bf60d6f4a300cbde8fc12
|
7
|
+
data.tar.gz: 754321b70b997b1416732336de62a5822e675e879475e994572d5b616161ee40844292415b5b68b4176bae25ec211c48695b83e060046a8d632e3d4624e69734
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# Hanami
|
2
2
|
The web, with simplicity.
|
3
3
|
|
4
|
+
## v0.7.1 - 2016-02-05
|
5
|
+
### Fixed
|
6
|
+
- [Anton Davydov] Fixed routing issue when static assets server tried to hijiack requests belonging to dynamic endpoints
|
7
|
+
- [Anatolii Didukh] Ensure to fallback to default engine for `hanami console`
|
8
|
+
|
4
9
|
## v0.7.0 - 2016-01-22
|
5
10
|
### Changed
|
6
11
|
- [Luca Guidi] Renamed the project
|
data/lib/hanami/application.rb
CHANGED
@@ -40,42 +40,6 @@ module Hanami
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
# Registry of Hanami applications in the current Ruby process
|
44
|
-
#
|
45
|
-
# @return [Set] a set of all the registered applications
|
46
|
-
#
|
47
|
-
# @since 0.2.0
|
48
|
-
# @api private
|
49
|
-
def self.applications
|
50
|
-
synchronize do
|
51
|
-
@@applications ||= Set.new
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
# Configure the application.
|
56
|
-
# It yields the given block in the context of the configuration
|
57
|
-
#
|
58
|
-
# @param environment [Symbol,nil] the configuration environment name
|
59
|
-
# @param blk [Proc] the configuration block
|
60
|
-
#
|
61
|
-
# @since 0.1.0
|
62
|
-
#
|
63
|
-
# @see Hanami::Configuration
|
64
|
-
#
|
65
|
-
# @example
|
66
|
-
# require 'hanami'
|
67
|
-
#
|
68
|
-
# module Bookshelf
|
69
|
-
# Application < Hanami::Application
|
70
|
-
# configure do
|
71
|
-
# # ...
|
72
|
-
# end
|
73
|
-
# end
|
74
|
-
# end
|
75
|
-
def self.configure(environment = nil, &blk)
|
76
|
-
configuration.configure(environment, &blk)
|
77
|
-
end
|
78
|
-
|
79
43
|
# Return the routes for this application
|
80
44
|
#
|
81
45
|
# @return [Hanami::Router] a route set
|
@@ -111,78 +75,6 @@ module Hanami
|
|
111
75
|
self.class.load!(self)
|
112
76
|
end
|
113
77
|
|
114
|
-
# Eager load the application configuration, by activating the framework
|
115
|
-
# duplication mechanisms.
|
116
|
-
#
|
117
|
-
# @param application [Hanami::Application, Class<Hanami::Application>]
|
118
|
-
# @return void
|
119
|
-
#
|
120
|
-
# @since 0.1.1
|
121
|
-
#
|
122
|
-
# @example
|
123
|
-
# require 'hanami'
|
124
|
-
#
|
125
|
-
# module OneFile
|
126
|
-
# class Application < Hanami::Application
|
127
|
-
# configure do
|
128
|
-
# routes do
|
129
|
-
# get '/', to: 'dashboard#index'
|
130
|
-
# end
|
131
|
-
# end
|
132
|
-
#
|
133
|
-
# load!
|
134
|
-
# end
|
135
|
-
#
|
136
|
-
# module Controllers::Dashboard
|
137
|
-
# class Index
|
138
|
-
# include OneFile::Action
|
139
|
-
#
|
140
|
-
# def call(params)
|
141
|
-
# self.body = 'Hello!'
|
142
|
-
# end
|
143
|
-
# end
|
144
|
-
# end
|
145
|
-
# end
|
146
|
-
def self.load!(application = self)
|
147
|
-
Hanami::Loader.new(application).load!
|
148
|
-
end
|
149
|
-
|
150
|
-
# Preload all the registered applications, by yielding their configurations
|
151
|
-
# and preparing the frameworks.
|
152
|
-
#
|
153
|
-
# This is useful for testing suites, where we want to make Hanami frameworks
|
154
|
-
# ready, but not preload applications code.
|
155
|
-
#
|
156
|
-
# This allows to test components such as views or actions in isolation and
|
157
|
-
# to have faster boot times.
|
158
|
-
#
|
159
|
-
# @return [void]
|
160
|
-
#
|
161
|
-
# @since 0.2.0
|
162
|
-
def self.preload!
|
163
|
-
synchronize do
|
164
|
-
applications.each(&:load!)
|
165
|
-
end
|
166
|
-
|
167
|
-
nil
|
168
|
-
end
|
169
|
-
|
170
|
-
# Full preload for all the registered applications.
|
171
|
-
#
|
172
|
-
# This is useful in console where we want all the application code available.
|
173
|
-
#
|
174
|
-
# @return [void]
|
175
|
-
#
|
176
|
-
# @since 0.2.1
|
177
|
-
# @api private
|
178
|
-
def self.preload_applications!
|
179
|
-
synchronize do
|
180
|
-
applications.each { |app| app.new }
|
181
|
-
end
|
182
|
-
|
183
|
-
nil
|
184
|
-
end
|
185
|
-
|
186
78
|
# Return the configuration for this application
|
187
79
|
#
|
188
80
|
# @since 0.1.0
|
@@ -229,15 +121,126 @@ module Hanami
|
|
229
121
|
@middleware ||= configuration.middleware
|
230
122
|
end
|
231
123
|
|
232
|
-
|
124
|
+
class << self
|
125
|
+
|
126
|
+
# Registry of Hanami applications in the current Ruby process
|
127
|
+
#
|
128
|
+
# @return [Set] a set of all the registered applications
|
129
|
+
#
|
130
|
+
# @since 0.2.0
|
131
|
+
# @api private
|
132
|
+
def applications
|
133
|
+
synchronize do
|
134
|
+
@@applications ||= Set.new
|
135
|
+
end
|
136
|
+
end
|
233
137
|
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
138
|
+
# Configure the application.
|
139
|
+
# It yields the given block in the context of the configuration
|
140
|
+
#
|
141
|
+
# @param environment [Symbol,nil] the configuration environment name
|
142
|
+
# @param blk [Proc] the configuration block
|
143
|
+
#
|
144
|
+
# @since 0.1.0
|
145
|
+
#
|
146
|
+
# @see Hanami::Configuration
|
147
|
+
#
|
148
|
+
# @example
|
149
|
+
# require 'hanami'
|
150
|
+
#
|
151
|
+
# module Bookshelf
|
152
|
+
# Application < Hanami::Application
|
153
|
+
# configure do
|
154
|
+
# # ...
|
155
|
+
# end
|
156
|
+
# end
|
157
|
+
# end
|
158
|
+
def configure(environment = nil, &blk)
|
159
|
+
configuration.configure(environment, &blk)
|
160
|
+
end
|
161
|
+
|
162
|
+
# Eager load the application configuration, by activating the framework
|
163
|
+
# duplication mechanisms.
|
164
|
+
#
|
165
|
+
# @param application [Hanami::Application, Class<Hanami::Application>]
|
166
|
+
# @return void
|
167
|
+
#
|
168
|
+
# @since 0.1.1
|
169
|
+
#
|
170
|
+
# @example
|
171
|
+
# require 'hanami'
|
172
|
+
#
|
173
|
+
# module OneFile
|
174
|
+
# class Application < Hanami::Application
|
175
|
+
# configure do
|
176
|
+
# routes do
|
177
|
+
# get '/', to: 'dashboard#index'
|
178
|
+
# end
|
179
|
+
# end
|
180
|
+
#
|
181
|
+
# load!
|
182
|
+
# end
|
183
|
+
#
|
184
|
+
# module Controllers::Dashboard
|
185
|
+
# class Index
|
186
|
+
# include OneFile::Action
|
187
|
+
#
|
188
|
+
# def call(params)
|
189
|
+
# self.body = 'Hello!'
|
190
|
+
# end
|
191
|
+
# end
|
192
|
+
# end
|
193
|
+
# end
|
194
|
+
def load!(application = self)
|
195
|
+
Hanami::Loader.new(application).load!
|
196
|
+
end
|
197
|
+
|
198
|
+
# Preload all the registered applications, by yielding their configurations
|
199
|
+
# and preparing the frameworks.
|
200
|
+
#
|
201
|
+
# This is useful for testing suites, where we want to make Hanami frameworks
|
202
|
+
# ready, but not preload applications code.
|
203
|
+
#
|
204
|
+
# This allows to test components such as views or actions in isolation and
|
205
|
+
# to have faster boot times.
|
206
|
+
#
|
207
|
+
# @return [void]
|
208
|
+
#
|
209
|
+
# @since 0.2.0
|
210
|
+
def preload!
|
211
|
+
synchronize do
|
212
|
+
applications.each(&:load!)
|
213
|
+
end
|
214
|
+
|
215
|
+
nil
|
216
|
+
end
|
217
|
+
|
218
|
+
# Full preload for all the registered applications.
|
219
|
+
#
|
220
|
+
# This is useful in console where we want all the application code available.
|
221
|
+
#
|
222
|
+
# @return [void]
|
223
|
+
#
|
224
|
+
# @since 0.2.1
|
225
|
+
# @api private
|
226
|
+
def preload_applications!
|
227
|
+
synchronize do
|
228
|
+
applications.each { |app| app.new }
|
229
|
+
end
|
230
|
+
|
231
|
+
nil
|
232
|
+
end
|
233
|
+
|
234
|
+
private
|
235
|
+
|
236
|
+
# Yields the given block in a critical section
|
237
|
+
#
|
238
|
+
# @since 0.2.0
|
239
|
+
# @api private
|
240
|
+
def synchronize
|
241
|
+
Mutex.new.synchronize do
|
242
|
+
yield
|
243
|
+
end
|
241
244
|
end
|
242
245
|
end
|
243
246
|
end
|
@@ -15,7 +15,7 @@ module Hanami
|
|
15
15
|
DEFAULT_ARCHITECTURE = 'container'.freeze
|
16
16
|
DEFAULT_APPLICATION_BASE_URL = '/'.freeze
|
17
17
|
|
18
|
-
attr_reader :options, :target_path, :database_config
|
18
|
+
attr_reader :options, :target_path, :database_config, :test_framework
|
19
19
|
|
20
20
|
def initialize(options, name)
|
21
21
|
@options = Hanami::Utils::Hash.new(options).symbolize!
|
@@ -28,6 +28,7 @@ module Hanami
|
|
28
28
|
|
29
29
|
@hanami_model_version = '~> 0.5'
|
30
30
|
@database_config = Hanami::Generators::DatabaseConfig.new(options[:database], app_name)
|
31
|
+
@test_framework = Hanami::Generators::TestFramework.new(hanamirc, @options[:test])
|
31
32
|
end
|
32
33
|
|
33
34
|
def start
|
@@ -41,10 +42,6 @@ module Hanami
|
|
41
42
|
|
42
43
|
private
|
43
44
|
|
44
|
-
def test_framework
|
45
|
-
@test_framework ||= Hanami::Generators::TestFramework.new(hanamirc, options[:test])
|
46
|
-
end
|
47
|
-
|
48
45
|
def hanamirc
|
49
46
|
@hanamirc ||= Hanamirc.new(Pathname.new('.'))
|
50
47
|
end
|
@@ -103,7 +100,7 @@ module Hanami
|
|
103
100
|
|
104
101
|
def assert_name!
|
105
102
|
if @name.nil? || @name.strip == '' || @name.include?(File::SEPARATOR)
|
106
|
-
raise ArgumentError.new("APPLICATION_NAME is
|
103
|
+
raise ArgumentError.new("APPLICATION_NAME is required and must not contain #{File::SEPARATOR}.")
|
107
104
|
end
|
108
105
|
end
|
109
106
|
|
@@ -48,7 +48,7 @@ module Hanami
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def _render_status_page(action, response)
|
51
|
-
if render_status_page?(action
|
51
|
+
if render_status_page?(action)
|
52
52
|
Hanami::Views::Default.render(@templates, response[STATUS], response: response, format: :html)
|
53
53
|
end
|
54
54
|
end
|
@@ -61,7 +61,7 @@ module Hanami
|
|
61
61
|
SUCCESSFUL_STATUSES.include?(response[STATUS])
|
62
62
|
end
|
63
63
|
|
64
|
-
def render_status_page?(action
|
64
|
+
def render_status_page?(action)
|
65
65
|
RENDERABLE_FORMATS.include?(action.format)
|
66
66
|
end
|
67
67
|
|
data/lib/hanami/static.rb
CHANGED
@@ -6,6 +6,10 @@ module Hanami
|
|
6
6
|
PATH_INFO = 'PATH_INFO'.freeze
|
7
7
|
PUBLIC_DIRECTORY = Hanami.public_directory.join('**', '*').to_s.freeze
|
8
8
|
|
9
|
+
# @since x.x.x
|
10
|
+
# @api private
|
11
|
+
URL_SEPARATOR = '/'.freeze
|
12
|
+
|
9
13
|
def initialize(app)
|
10
14
|
super(app, root: Hanami.public_directory, header_rules: _header_rules)
|
11
15
|
@sources = _sources_from_applications
|
@@ -14,9 +18,9 @@ module Hanami
|
|
14
18
|
def call(env)
|
15
19
|
path = env[PATH_INFO]
|
16
20
|
|
17
|
-
prefix, config = @sources.find {|p, _| path.start_with?(p) }
|
18
|
-
|
19
|
-
config.sources.find(path.sub(prefix, ''))
|
21
|
+
prefix, config = @sources.find { |p, _| path.start_with?(p) }
|
22
|
+
if prefix && config
|
23
|
+
original = config.sources.find(path.sub(prefix, ''))
|
20
24
|
end
|
21
25
|
|
22
26
|
if can_serve(path, original)
|
@@ -31,8 +35,9 @@ module Hanami
|
|
31
35
|
private
|
32
36
|
|
33
37
|
def can_serve(path, original = nil)
|
38
|
+
file_path = path.gsub(URL_SEPARATOR, ::File::SEPARATOR)
|
34
39
|
destination = Dir[PUBLIC_DIRECTORY].find do |file|
|
35
|
-
file.
|
40
|
+
file.end_with?(file_path)
|
36
41
|
end
|
37
42
|
|
38
43
|
(super(path) || !!destination) && _fresh?(original, destination)
|
data/lib/hanami/version.rb
CHANGED
data/lib/hanami/welcome.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hanami
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-02-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: hanami-utils
|