hanami 0.9.2 → 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -0
  3. data/FEATURES.md +5 -0
  4. data/hanami.gemspec +8 -8
  5. data/lib/hanami.rb +25 -1
  6. data/lib/hanami/app.rb +4 -0
  7. data/lib/hanami/application.rb +1 -14
  8. data/lib/hanami/application_configuration.rb +2 -37
  9. data/lib/hanami/cli_base.rb +15 -0
  10. data/lib/hanami/cli_sub_commands/destroy.rb +2 -2
  11. data/lib/hanami/cli_sub_commands/generate.rb +2 -1
  12. data/lib/hanami/commands/generate/abstract.rb +5 -0
  13. data/lib/hanami/commands/generate/mailer.rb +2 -2
  14. data/lib/hanami/commands/generate/model.rb +24 -8
  15. data/lib/hanami/commands/new/abstract.rb +1 -1
  16. data/lib/hanami/commands/new/container.rb +1 -0
  17. data/lib/hanami/common_logger.rb +73 -0
  18. data/lib/hanami/components.rb +11 -0
  19. data/lib/hanami/components/app/controller.rb +1 -0
  20. data/lib/hanami/components/components.rb +73 -20
  21. data/lib/hanami/configuration.rb +12 -0
  22. data/lib/hanami/env.rb +2 -0
  23. data/lib/hanami/environment.rb +5 -1
  24. data/lib/hanami/generators/app/application.rb.tt +0 -30
  25. data/lib/hanami/generators/application/container/Gemfile.tt +0 -1
  26. data/lib/hanami/generators/application/container/config/boot.rb.tt +2 -0
  27. data/lib/hanami/generators/application/container/config/environment.rb.tt +14 -5
  28. data/lib/hanami/generators/database_config.rb +1 -1
  29. data/lib/hanami/generators/mailer/{mailer_spec.rb.tt → mailer_spec.rb.minitest.tt} +0 -0
  30. data/lib/hanami/generators/mailer/mailer_spec.rb.rspec.tt +5 -0
  31. data/lib/hanami/generators/model/migration.rb.tt +10 -0
  32. data/lib/hanami/mailer/glue.rb +4 -46
  33. data/lib/hanami/server.rb +4 -12
  34. data/lib/hanami/static.rb +4 -8
  35. data/lib/hanami/version.rb +1 -1
  36. metadata +25 -62
  37. data/lib/hanami/components/app/logger.rb +0 -30
  38. data/lib/hanami/config/logger.rb +0 -200
  39. data/lib/hanami/generators/application/app/.env.development.tt +0 -4
  40. data/lib/hanami/generators/application/app/.env.test.tt +0 -4
  41. data/lib/hanami/generators/application/app/.gitignore +0 -0
  42. data/lib/hanami/generators/application/app/.gitkeep +0 -1
  43. data/lib/hanami/generators/application/app/Gemfile.tt +0 -57
  44. data/lib/hanami/generators/application/app/Rakefile.minitest.tt +0 -12
  45. data/lib/hanami/generators/application/app/Rakefile.rspec.tt +0 -9
  46. data/lib/hanami/generators/application/app/apps/.gitkeep.tt +0 -1
  47. data/lib/hanami/generators/application/app/capybara.rb.rspec.tt +0 -8
  48. data/lib/hanami/generators/application/app/config.ru.tt +0 -3
  49. data/lib/hanami/generators/application/app/config/application.rb.tt +0 -347
  50. data/lib/hanami/generators/application/app/config/environment.rb.tt +0 -4
  51. data/lib/hanami/generators/application/app/config/initializers/.gitkeep +0 -0
  52. data/lib/hanami/generators/application/app/config/routes.rb.tt +0 -5
  53. data/lib/hanami/generators/application/app/db/.gitkeep +0 -1
  54. data/lib/hanami/generators/application/app/favicon.ico +0 -0
  55. data/lib/hanami/generators/application/app/features_helper.rb.minitest.tt +0 -11
  56. data/lib/hanami/generators/application/app/features_helper.rb.rspec.tt +0 -12
  57. data/lib/hanami/generators/application/app/gitignore.tt +0 -2
  58. data/lib/hanami/generators/application/app/gitignore_with_db.tt +0 -4
  59. data/lib/hanami/generators/application/app/gitignore_with_sqlite.tt +0 -3
  60. data/lib/hanami/generators/application/app/hanamirc.tt +0 -4
  61. data/lib/hanami/generators/application/app/lib/app_name.rb.tt +0 -35
  62. data/lib/hanami/generators/application/app/lib/chirp/entities/.gitkeep +0 -1
  63. data/lib/hanami/generators/application/app/lib/chirp/repositories/.gitkeep +0 -1
  64. data/lib/hanami/generators/application/app/rspec.rspec.tt +0 -2
  65. data/lib/hanami/generators/application/app/schema.sql.tt +0 -0
  66. data/lib/hanami/generators/application/app/spec_helper.rb.minitest.tt +0 -7
  67. data/lib/hanami/generators/application/app/spec_helper.rb.rspec.tt +0 -104
  68. data/lib/hanami/generators/application/app/templates/application.html.erb.tt +0 -10
  69. data/lib/hanami/generators/application/app/templates/application.html.haml.tt +0 -7
  70. data/lib/hanami/generators/application/app/templates/application.html.slim.tt +0 -8
  71. data/lib/hanami/generators/application/app/views/application_layout.rb.tt +0 -7
@@ -1,4 +0,0 @@
1
- # Define ENV variables for development environment
2
- DATABASE_URL="<%= config[:database_config][:uri][:development] %>"
3
- <%= config[:upcase_app_name] %>_SESSIONS_SECRET="<%= SecureRandom.hex(32) %>"
4
- SERVE_STATIC_ASSETS="true"
@@ -1,4 +0,0 @@
1
- # Define ENV variables for test environment
2
- DATABASE_URL="<%= config[:database_config][:uri][:test] %>"
3
- <%= config[:upcase_app_name] %>_SESSIONS_SECRET="<%= SecureRandom.hex(32) %>"
4
- SERVE_STATIC_ASSETS="true"
@@ -1,57 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'bundler'
4
- gem 'rake'
5
- <%- if config[:hanami_head] -%>
6
-
7
- gem 'hanami-utils', require: false, github: 'hanami/utils'
8
- gem 'hanami-router', require: false, github: 'hanami/router'
9
- gem 'hanami-validations', require: false, github: 'hanami/validations'
10
- gem 'hanami-helpers', require: false, github: 'hanami/helpers'
11
- gem 'hanami-controller', require: false, github: 'hanami/controller'
12
- gem 'hanami-view', require: false, github: 'hanami/view'
13
- gem 'hanami-model', require: false, github: 'hanami/model'
14
- gem 'hanami-mailer', require: false, github: 'hanami/mailer'
15
- gem 'hanami-assets', require: false, github: 'hanami/assets'
16
- gem 'hanami', github: 'hanami/hanami'
17
- <%- else -%>
18
- gem 'hanami', '<%= config[:hanami_version] %>'
19
- gem 'hanami-model', '<%= config[:hanami_model_version] %>'
20
- <%- end -%>
21
- <%- if config[:database_config][:gem] -%>
22
-
23
- gem '<%= config[:database_config][:gem] %>'
24
- <%- end -%>
25
- <%- case config[:template] -%>
26
- <%- when 'slim' -%>
27
-
28
- gem 'slim'
29
- <%- when 'haml' -%>
30
-
31
- gem 'haml'
32
- <%- end -%>
33
-
34
- <%- unless Hanami::Utils.jruby? -%>
35
- group :development do
36
- # Code reloading
37
- # See: http://hanamirb.org/guides/projects/code-reloading
38
- gem 'shotgun'
39
- end
40
-
41
- <%- end -%>
42
- group :test, :development do
43
- gem 'dotenv', '~> 2.0'
44
- end
45
-
46
- group :test do
47
- <%- if config[:test] == 'rspec' -%>
48
- gem 'rspec'
49
- <%- else -%>
50
- gem 'minitest'
51
- <%- end -%>
52
- gem 'capybara'
53
- end
54
-
55
- group :production do
56
- # gem 'puma'
57
- end
@@ -1,12 +0,0 @@
1
- require 'rake'
2
- require 'hanami/rake_tasks'
3
- require 'rake/testtask'
4
-
5
- Rake::TestTask.new do |t|
6
- t.pattern = 'spec/**/*_spec.rb'
7
- t.libs << 'spec'
8
- t.warning = false
9
- end
10
-
11
- task default: :test
12
- task spec: :test
@@ -1,9 +0,0 @@
1
- require 'rake'
2
- require 'hanami/rake_tasks'
3
-
4
- begin
5
- require 'rspec/core/rake_task'
6
- RSpec::Core::RakeTask.new(:spec)
7
- task default: :spec
8
- rescue LoadError
9
- end
@@ -1,8 +0,0 @@
1
- module RSpec
2
- module FeatureExampleGroup
3
- def self.included(group)
4
- group.metadata[:type] = :feature
5
- Capybara.app = <%= config[:classified_app_name] %>::Application.new
6
- end
7
- end
8
- end
@@ -1,3 +0,0 @@
1
- require './config/environment'
2
-
3
- run <%= config[:classified_app_name] %>::Application.new
@@ -1,347 +0,0 @@
1
- require 'hanami/helpers'
2
- require 'hanami/assets'
3
-
4
- module <%= config[:classified_app_name] %>
5
- class Application < Hanami::Application
6
- configure do
7
- ##
8
- # BASIC
9
- #
10
-
11
- # Define the root path of this application.
12
- # All paths specified in this configuration are relative to path below.
13
- #
14
- root "#{ __dir__ }/.."
15
-
16
- # Relative load paths where this application will recursively load the code.
17
- # When you add new directories, remember to add them here.
18
- #
19
- load_paths << [
20
- 'app/controllers',
21
- 'app/views'
22
- ]
23
-
24
- # Handle exceptions with HTTP statuses (true) or don't catch them (false).
25
- # Defaults to true.
26
- # See: http://www.rubydoc.info/gems/hanami-controller/
27
-
28
- # Exceptions_management
29
- #
30
- # handle_exceptions true
31
-
32
- ##
33
- # HTTP
34
- #
35
-
36
- # Routes definitions for this application
37
- # See: http://www.rubydoc.info/gems/hanami-router#Usage
38
- #
39
- routes 'config/routes'
40
-
41
- # URI scheme used by the routing system to generate absolute URLs
42
- # Defaults to "http"
43
- #
44
- # scheme 'https'
45
-
46
- # URI host used by the routing system to generate absolute URLs
47
- # Defaults to "localhost"
48
- #
49
- # host 'example.org'
50
-
51
- # URI port used by the routing system to generate absolute URLs
52
- # Argument: An object coercible to integer, default to 80 if the scheme is http and 443 if it's https
53
- # This SHOULD be configured only in case the application listens to that non standard ports
54
- #
55
- # port 443
56
-
57
- # Enable cookies
58
- # Argument: boolean to toggle the feature
59
- # A Hash with options
60
- #
61
- # Options: :domain - The domain (String - nil by default, not required)
62
- # :path - Restrict cookies to a relative URI (String - nil by default)
63
- # :max_age - Cookies expiration expressed in seconds (Integer - nil by default)
64
- # :secure - Restrict cookies to secure connections
65
- # (Boolean - Automatically set on true if currently using a secure connection)
66
- # See #scheme and #ssl?
67
- # :httponly - Prevent JavaScript access (Boolean - true by default)
68
- #
69
- # cookies true
70
- # or
71
- # cookies max_age: 300
72
-
73
- # Enable sessions
74
- # Argument: Symbol the Rack session adapter
75
- # A Hash with options
76
- #
77
- # See: http://www.rubydoc.info/gems/rack/Rack/Session/Cookie
78
- #
79
- # sessions :cookie, secret: ENV['<%= config[:upcase_app_name] %>_SESSIONS_SECRET']
80
-
81
- # Configure Rack middleware for this application
82
- #
83
- # middleware.use Rack::Protection
84
-
85
- # Default format for the requests that don't specify an HTTP_ACCEPT header
86
- # Argument: A symbol representation of a mime type, default to :html
87
- #
88
- # default_request_format :html
89
-
90
- # Default format for responses that doesn't take into account the request format
91
- # Argument: A symbol representation of a mime type, default to :html
92
- #
93
- # default_response_format :html
94
-
95
- # HTTP Body parsers
96
- # Parse non GET responses body for a specific mime type
97
- # Argument: Symbol, which represent the format of the mime type (only `:json` is supported)
98
- # Object, the parser
99
- #
100
- # body_parsers :json
101
-
102
- ##
103
- # TEMPLATES
104
- #
105
-
106
- # The layout to be used by all views
107
- #
108
- layout :application # It will load <%= config[:classified_app_name] %>::Views::ApplicationLayout
109
-
110
- # The relative path to templates
111
- #
112
- templates 'app/templates'
113
-
114
- ##
115
- # ASSETS
116
- #
117
- assets do
118
- # JavaScript compressor
119
- #
120
- # Supported engines:
121
- #
122
- # * :builtin
123
- # * :uglifier
124
- # * :yui
125
- # * :closure
126
- #
127
- # See: http://hanamirb.org/guides/assets/compressors
128
- #
129
- # In order to skip JavaScript compression comment the following line
130
- javascript_compressor :builtin
131
-
132
- # Stylesheet compressor
133
- #
134
- # Supported engines:
135
- #
136
- # * :builtin
137
- # * :yui
138
- # * :sass
139
- #
140
- # See: http://hanamirb.org/guides/assets/compressors
141
- #
142
- # In order to skip stylesheet compression comment the following line
143
- stylesheet_compressor :builtin
144
-
145
- # Specify sources for assets
146
- #
147
- sources << [
148
- 'app/assets'
149
- ]
150
- end
151
-
152
- ##
153
- # SECURITY
154
- #
155
-
156
- # X-Frame-Options is a HTTP header supported by modern browsers.
157
- # It determines if a web page can or cannot be included via <frame> and
158
- # <iframe> tags by untrusted domains.
159
- #
160
- # Web applications can send this header to prevent Clickjacking attacks.
161
- #
162
- # Read more at:
163
- #
164
- # * https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options
165
- # * https://www.owasp.org/index.php/Clickjacking
166
- #
167
- security.x_frame_options 'DENY'
168
-
169
- # X-Content-Type-Options prevents browsers from interpreting files as
170
- # something else than declared by the content type in the HTTP headers.
171
- #
172
- # Read more at:
173
- #
174
- # * https://www.owasp.org/index.php/OWASP_Secure_Headers_Project#X-Content-Type-Options
175
- # * https://msdn.microsoft.com/en-us/library/gg622941%28v=vs.85%29.aspx
176
- # * https://blogs.msdn.microsoft.com/ie/2008/09/02/ie8-security-part-vi-beta-2-update
177
- #
178
- security.x_content_type_options 'nosniff'
179
-
180
- # X-XSS-Protection is a HTTP header to determine the behavior of the browser
181
- # in case an XSS attack is detected.
182
- #
183
- # Read more at:
184
- #
185
- # * https://www.owasp.org/index.php/Cross-site_Scripting_(XSS)
186
- # * https://www.owasp.org/index.php/OWASP_Secure_Headers_Project#X-XSS-Protection
187
- #
188
- security.x_xss_protection '1; mode=block'
189
-
190
- # Content-Security-Policy (CSP) is a HTTP header supported by modern browsers.
191
- # It determines trusted sources of execution for dynamic contents
192
- # (JavaScript) or other web related assets: stylesheets, images, fonts,
193
- # plugins, etc.
194
- #
195
- # Web applications can send this header to mitigate Cross Site Scripting
196
- # (XSS) attacks.
197
- #
198
- # The default value allows images, scripts, AJAX, fonts and CSS from the same
199
- # origin, and does not allow any other resources to load (eg object,
200
- # frame, media, etc).
201
- #
202
- # Inline JavaScript is NOT allowed. To enable it, please use:
203
- # "script-src 'unsafe-inline'".
204
- #
205
- # Content Security Policy introduction:
206
- #
207
- # * http://www.html5rocks.com/en/tutorials/security/content-security-policy/
208
- # * https://www.owasp.org/index.php/Content_Security_Policy
209
- # * https://www.owasp.org/index.php/Cross-site_Scripting_%28XSS%29
210
- #
211
- # Inline and eval JavaScript risks:
212
- #
213
- # * http://www.html5rocks.com/en/tutorials/security/content-security-policy/#inline-code-considered-harmful
214
- # * http://www.html5rocks.com/en/tutorials/security/content-security-policy/#eval-too
215
- #
216
- # Content Security Policy usage:
217
- #
218
- # * http://content-security-policy.com/
219
- # * https://developer.mozilla.org/en-US/docs/Web/Security/CSP/Using_Content_Security_Policy
220
- #
221
- # Content Security Policy references:
222
- #
223
- # * https://developer.mozilla.org/en-US/docs/Web/Security/CSP/CSP_policy_directives
224
- #
225
- security.content_security_policy %{
226
- form-action 'self';
227
- referrer origin-when-cross-origin;
228
- reflected-xss block;
229
- frame-ancestors 'self';
230
- base-uri 'self';
231
- default-src 'none';
232
- script-src 'self';
233
- connect-src 'self';
234
- img-src 'self';
235
- style-src 'self';
236
- font-src 'self';
237
- object-src 'self';
238
- plugin-types application/pdf;
239
- child-src 'self';
240
- frame-src 'self';
241
- media-src 'self'
242
- }
243
-
244
- ##
245
- # FRAMEWORKS
246
- #
247
-
248
- # Configure the code that will yield each time <%= config[:classified_app_name] %>::Action is included
249
- # This is useful for sharing common functionality
250
- #
251
- # See: http://www.rubydoc.info/gems/hanami-controller#Configuration
252
- controller.prepare do
253
- # include MyAuthentication # included in all the actions
254
- # before :authenticate! # run an authentication before callback
255
- end
256
-
257
- # Configure the code that will yield each time <%= config[:classified_app_name] %>::View is included
258
- # This is useful for sharing common functionality
259
- #
260
- # See: http://www.rubydoc.info/gems/hanami-view#Configuration
261
- view.prepare do
262
- include Hanami::Helpers
263
- include <%= config[:classified_app_name] %>::Assets::Helpers
264
- end
265
- end
266
-
267
- ##
268
- # DEVELOPMENT
269
- #
270
- configure :development do
271
- # Don't handle exceptions, render the stack trace
272
- handle_exceptions false
273
-
274
- # Logger
275
- # See: http://hanamirb.org/guides/projects/logging
276
- #
277
- # Logger stream. It defaults to STDOUT.
278
- # logger.stream "log/development.log"
279
- #
280
- # Logger level. It defaults to DEBUG
281
- # logger.level :debug
282
- #
283
- # Logger format. It defaults to DEFAULT
284
- # logger.format :default
285
- end
286
-
287
- ##
288
- # TEST
289
- #
290
- configure :test do
291
- # Don't handle exceptions, render the stack trace
292
- handle_exceptions false
293
-
294
- # Logger
295
- # See: http://hanamirb.org/guides/projects/logging
296
- #
297
- # Logger level. It defaults to ERROR
298
- logger.level :error
299
- end
300
-
301
- ##
302
- # PRODUCTION
303
- #
304
- configure :production do
305
- # scheme 'https'
306
- # host 'example.org'
307
- # port 443
308
-
309
- # Logger
310
- # See: http://hanamirb.org/guides/projects/logging
311
- #
312
- # Logger stream. It defaults to STDOUT.
313
- # logger.stream "log/production.log"
314
- #
315
- # Logger level. It defaults to INFO
316
- logger.level :info
317
-
318
- # Logger format.
319
- logger.format :json
320
-
321
- assets do
322
- # Don't compile static assets in production mode (eg. Sass, ES6)
323
- #
324
- # See: http://www.rubydoc.info/gems/hanami-assets#Configuration
325
- compile false
326
-
327
- # Use fingerprint file name for asset paths
328
- #
329
- # See: http://hanamirb.org/guides/assets/overview
330
- fingerprint true
331
-
332
- # Content Delivery Network (CDN)
333
- #
334
- # See: http://hanamirb.org/guides/assets/content-delivery-network
335
- #
336
- # scheme 'https'
337
- # host 'cdn.example.org'
338
- # port 443
339
-
340
- # Subresource Integrity
341
- #
342
- # See: http://hanamirb.org/guides/assets/content-delivery-network/#subresource-integrity
343
- subresource_integrity :sha256
344
- end
345
- end
346
- end
347
- end