hanami 0.0.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +214 -0
  3. data/FEATURES.md +156 -0
  4. data/LICENSE.md +22 -0
  5. data/README.md +80 -15
  6. data/bin/hanami +5 -0
  7. data/hanami.gemspec +27 -12
  8. data/lib/hanami.rb +78 -2
  9. data/lib/hanami/action/csrf_protection.rb +167 -0
  10. data/lib/hanami/action/routing_helpers.rb +40 -0
  11. data/lib/hanami/application.rb +244 -0
  12. data/lib/hanami/application_name.rb +101 -0
  13. data/lib/hanami/cli.rb +119 -0
  14. data/lib/hanami/cli_sub_commands/assets.rb +29 -0
  15. data/lib/hanami/cli_sub_commands/db.rb +124 -0
  16. data/lib/hanami/cli_sub_commands/destroy.rb +102 -0
  17. data/lib/hanami/cli_sub_commands/generate.rb +127 -0
  18. data/lib/hanami/commands/assets/precompile.rb +35 -0
  19. data/lib/hanami/commands/console.rb +90 -0
  20. data/lib/hanami/commands/db/abstract.rb +19 -0
  21. data/lib/hanami/commands/db/apply.rb +14 -0
  22. data/lib/hanami/commands/db/console.rb +50 -0
  23. data/lib/hanami/commands/db/create.rb +14 -0
  24. data/lib/hanami/commands/db/drop.rb +14 -0
  25. data/lib/hanami/commands/db/migrate.rb +19 -0
  26. data/lib/hanami/commands/db/prepare.rb +14 -0
  27. data/lib/hanami/commands/db/version.rb +14 -0
  28. data/lib/hanami/commands/generate/abstract.rb +63 -0
  29. data/lib/hanami/commands/generate/action.rb +262 -0
  30. data/lib/hanami/commands/generate/app.rb +116 -0
  31. data/lib/hanami/commands/generate/mailer.rb +118 -0
  32. data/lib/hanami/commands/generate/migration.rb +63 -0
  33. data/lib/hanami/commands/generate/model.rb +96 -0
  34. data/lib/hanami/commands/new/abstract.rb +128 -0
  35. data/lib/hanami/commands/new/app.rb +116 -0
  36. data/lib/hanami/commands/new/container.rb +102 -0
  37. data/lib/hanami/commands/routes.rb +41 -0
  38. data/lib/hanami/commands/server.rb +79 -0
  39. data/lib/hanami/config/configure.rb +17 -0
  40. data/lib/hanami/config/cookies.rb +68 -0
  41. data/lib/hanami/config/framework_configuration.rb +42 -0
  42. data/lib/hanami/config/load_paths.rb +27 -0
  43. data/lib/hanami/config/mapper.rb +36 -0
  44. data/lib/hanami/config/mapping.rb +12 -0
  45. data/lib/hanami/config/routes.rb +16 -0
  46. data/lib/hanami/config/security.rb +58 -0
  47. data/lib/hanami/config/sessions.rb +97 -0
  48. data/lib/hanami/configuration.rb +1728 -0
  49. data/lib/hanami/container.rb +59 -0
  50. data/lib/hanami/environment.rb +485 -0
  51. data/lib/hanami/frameworks.rb +14 -0
  52. data/lib/hanami/generators/action/action.rb.tt +8 -0
  53. data/lib/hanami/generators/action/action_spec.minitest.tt +12 -0
  54. data/lib/hanami/generators/action/action_spec.rspec.tt +11 -0
  55. data/lib/hanami/generators/action/action_without_view.rb.tt +9 -0
  56. data/lib/hanami/generators/action/template.tt +0 -0
  57. data/lib/hanami/generators/action/view.rb.tt +5 -0
  58. data/lib/hanami/generators/action/view_spec.minitest.tt +13 -0
  59. data/lib/hanami/generators/action/view_spec.rspec.tt +12 -0
  60. data/lib/hanami/generators/app/.gitkeep.tt +1 -0
  61. data/lib/hanami/generators/app/application.rb.tt +273 -0
  62. data/lib/hanami/generators/app/config/initializers/.gitkeep +0 -0
  63. data/lib/hanami/generators/app/config/routes.rb.tt +2 -0
  64. data/lib/hanami/generators/app/favicon.ico +0 -0
  65. data/lib/hanami/generators/app/templates/application.html.erb.tt +10 -0
  66. data/lib/hanami/generators/app/views/application_layout.rb.tt +7 -0
  67. data/lib/hanami/generators/application/app/.env.development.tt +4 -0
  68. data/lib/hanami/generators/application/app/.env.test.tt +4 -0
  69. data/lib/hanami/generators/application/app/.env.tt +1 -0
  70. data/lib/hanami/generators/application/app/.gitignore +0 -0
  71. data/lib/hanami/generators/application/app/.gitkeep +1 -0
  72. data/lib/hanami/generators/application/app/Gemfile.tt +37 -0
  73. data/lib/hanami/generators/application/app/Rakefile.minitest.tt +11 -0
  74. data/lib/hanami/generators/application/app/Rakefile.rspec.tt +6 -0
  75. data/lib/hanami/generators/application/app/apps/.gitkeep.tt +1 -0
  76. data/lib/hanami/generators/application/app/capybara.rb.rspec.tt +8 -0
  77. data/lib/hanami/generators/application/app/config.ru.tt +3 -0
  78. data/lib/hanami/generators/application/app/config/application.rb.tt +270 -0
  79. data/lib/hanami/generators/application/app/config/environment.rb.tt +5 -0
  80. data/lib/hanami/generators/application/app/config/initializers/.gitkeep +0 -0
  81. data/lib/hanami/generators/application/app/config/routes.rb.tt +2 -0
  82. data/lib/hanami/generators/application/app/db/.gitkeep +1 -0
  83. data/lib/hanami/generators/application/app/favicon.ico +0 -0
  84. data/lib/hanami/generators/application/app/features_helper.rb.minitest.tt +11 -0
  85. data/lib/hanami/generators/application/app/features_helper.rb.rspec.tt +12 -0
  86. data/lib/hanami/generators/application/app/gitignore.tt +2 -0
  87. data/lib/hanami/generators/application/app/gitignore_with_db.tt +4 -0
  88. data/lib/hanami/generators/application/app/hanamirc.tt +3 -0
  89. data/lib/hanami/generators/application/app/lib/app_name.rb.tt +59 -0
  90. data/lib/hanami/generators/application/app/lib/chirp/entities/.gitkeep +1 -0
  91. data/lib/hanami/generators/application/app/lib/chirp/repositories/.gitkeep +1 -0
  92. data/lib/hanami/generators/application/app/lib/config/mapping.rb.tt +7 -0
  93. data/lib/hanami/generators/application/app/rspec.rspec.tt +2 -0
  94. data/lib/hanami/generators/application/app/schema.sql.tt +0 -0
  95. data/lib/hanami/generators/application/app/spec_helper.rb.minitest.tt +7 -0
  96. data/lib/hanami/generators/application/app/spec_helper.rb.rspec.tt +104 -0
  97. data/lib/hanami/generators/application/app/templates/application.html.erb.tt +10 -0
  98. data/lib/hanami/generators/application/app/views/application_layout.rb.tt +7 -0
  99. data/lib/hanami/generators/application/container/.env.development.tt +3 -0
  100. data/lib/hanami/generators/application/container/.env.test.tt +3 -0
  101. data/lib/hanami/generators/application/container/.env.tt +1 -0
  102. data/lib/hanami/generators/application/container/.gitignore +0 -0
  103. data/lib/hanami/generators/application/container/.gitkeep +1 -0
  104. data/lib/hanami/generators/application/container/Gemfile.tt +36 -0
  105. data/lib/hanami/generators/application/container/Rakefile.minitest.tt +11 -0
  106. data/lib/hanami/generators/application/container/Rakefile.rspec.tt +6 -0
  107. data/lib/hanami/generators/application/container/capybara.rb.rspec.tt +8 -0
  108. data/lib/hanami/generators/application/container/config.ru.tt +3 -0
  109. data/lib/hanami/generators/application/container/config/environment.rb.tt +7 -0
  110. data/lib/hanami/generators/application/container/config/initializers/.gitkeep +0 -0
  111. data/lib/hanami/generators/application/container/db/.gitkeep +1 -0
  112. data/lib/hanami/generators/application/container/features_helper.rb.minitest.tt +11 -0
  113. data/lib/hanami/generators/application/container/features_helper.rb.rspec.tt +12 -0
  114. data/lib/hanami/generators/application/container/gitignore.tt +2 -0
  115. data/lib/hanami/generators/application/container/gitignore_with_db.tt +4 -0
  116. data/lib/hanami/generators/application/container/hanamirc.tt +3 -0
  117. data/lib/hanami/generators/application/container/lib/app_name.rb.tt +60 -0
  118. data/lib/hanami/generators/application/container/lib/chirp/entities/.gitkeep +1 -0
  119. data/lib/hanami/generators/application/container/lib/chirp/mailers/.gitkeep +0 -0
  120. data/lib/hanami/generators/application/container/lib/chirp/mailers/templates/.gitkeep +0 -0
  121. data/lib/hanami/generators/application/container/lib/chirp/repositories/.gitkeep +1 -0
  122. data/lib/hanami/generators/application/container/lib/config/mapping.rb.tt +7 -0
  123. data/lib/hanami/generators/application/container/rspec.rspec.tt +2 -0
  124. data/lib/hanami/generators/application/container/schema.sql.tt +0 -0
  125. data/lib/hanami/generators/application/container/spec_helper.rb.minitest.tt +7 -0
  126. data/lib/hanami/generators/application/container/spec_helper.rb.rspec.tt +104 -0
  127. data/lib/hanami/generators/database_config.rb +99 -0
  128. data/lib/hanami/generators/generatable.rb +51 -0
  129. data/lib/hanami/generators/generator.rb +35 -0
  130. data/lib/hanami/generators/mailer/mailer.rb.tt +7 -0
  131. data/lib/hanami/generators/mailer/mailer_spec.rb.tt +7 -0
  132. data/lib/hanami/generators/mailer/template.html.tt +0 -0
  133. data/lib/hanami/generators/mailer/template.txt.tt +0 -0
  134. data/lib/hanami/generators/migration/migration.rb.tt +4 -0
  135. data/lib/hanami/generators/model/entity.rb.tt +3 -0
  136. data/lib/hanami/generators/model/entity_spec.minitest.tt +5 -0
  137. data/lib/hanami/generators/model/entity_spec.rspec.tt +3 -0
  138. data/lib/hanami/generators/model/repository.rb.tt +3 -0
  139. data/lib/hanami/generators/model/repository_spec.minitest.tt +5 -0
  140. data/lib/hanami/generators/model/repository_spec.rspec.tt +3 -0
  141. data/lib/hanami/generators/test_framework.rb +42 -0
  142. data/lib/hanami/hanamirc.rb +152 -0
  143. data/lib/hanami/loader.rb +258 -0
  144. data/lib/hanami/mailer/glue.rb +68 -0
  145. data/lib/hanami/middleware.rb +143 -0
  146. data/lib/hanami/rake_helper.rb +68 -0
  147. data/lib/hanami/rake_tasks.rb +2 -0
  148. data/lib/hanami/rendering_policy.rb +77 -0
  149. data/lib/hanami/repositories/car_repository.rb +3 -0
  150. data/lib/hanami/repositories/name_repository.rb +3 -0
  151. data/lib/hanami/root.rb +7 -0
  152. data/lib/hanami/routes.rb +151 -0
  153. data/lib/hanami/routing/default.rb +25 -0
  154. data/lib/hanami/setup.rb +3 -0
  155. data/lib/hanami/static.rb +77 -0
  156. data/lib/hanami/templates/default.html.erb +9 -0
  157. data/lib/hanami/templates/welcome.html.erb +52 -0
  158. data/lib/hanami/version.rb +4 -1
  159. data/lib/hanami/views/default.rb +34 -0
  160. data/lib/hanami/views/default_template_finder.rb +20 -0
  161. data/lib/hanami/views/null_view.rb +17 -0
  162. data/lib/hanami/welcome.rb +40 -0
  163. metadata +357 -16
  164. data/.gitignore +0 -9
  165. data/Gemfile +0 -4
  166. data/Rakefile +0 -2
  167. data/bin/console +0 -14
  168. data/bin/setup +0 -8
@@ -0,0 +1,11 @@
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
+ end
9
+
10
+ task default: :test
11
+ task spec: :test
@@ -0,0 +1,6 @@
1
+ require 'rake'
2
+ require 'hanami/rake_tasks'
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ task default: :spec
@@ -0,0 +1,8 @@
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
@@ -0,0 +1,3 @@
1
+ require './config/environment'
2
+
3
+ run <%= config[:classified_app_name] %>::Application.new
@@ -0,0 +1,270 @@
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 currenlty 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
+ # Content-Security-Policy (CSP) is a HTTP header supported by modern browsers.
170
+ # It determines trusted sources of execution for dynamic contents
171
+ # (JavaScript) or other web related assets: stylesheets, images, fonts,
172
+ # plugins, etc.
173
+ #
174
+ # Web applications can send this header to mitigate Cross Site Scripting
175
+ # (XSS) attacks.
176
+ #
177
+ # The default value allows images, scripts, AJAX, fonts and CSS from the same
178
+ # origin, and does not allow any other resources to load (eg object,
179
+ # frame, media, etc).
180
+ #
181
+ # Inline JavaScript is NOT allowed. To enable it, please use:
182
+ # "script-src 'unsafe-inline'".
183
+ #
184
+ # Content Security Policy introduction:
185
+ #
186
+ # * http://www.html5rocks.com/en/tutorials/security/content-security-policy/
187
+ # * https://www.owasp.org/index.php/Content_Security_Policy
188
+ # * https://www.owasp.org/index.php/Cross-site_Scripting_%28XSS%29
189
+ #
190
+ # Inline and eval JavaScript risks:
191
+ #
192
+ # * http://www.html5rocks.com/en/tutorials/security/content-security-policy/#inline-code-considered-harmful
193
+ # * http://www.html5rocks.com/en/tutorials/security/content-security-policy/#eval-too
194
+ #
195
+ # Content Security Policy usage:
196
+ #
197
+ # * http://content-security-policy.com/
198
+ # * https://developer.mozilla.org/en-US/docs/Web/Security/CSP/Using_Content_Security_Policy
199
+ #
200
+ security.content_security_policy "default-src 'none'; script-src 'self'; connect-src 'self'; img-src 'self'; style-src 'self'; font-src 'self';"
201
+
202
+ ##
203
+ # FRAMEWORKS
204
+ #
205
+
206
+ # Configure the code that will yield each time <%= config[:classified_app_name] %>::Action is included
207
+ # This is useful for sharing common functionality
208
+ #
209
+ # See: http://www.rubydoc.info/gems/hanami-controller#Configuration
210
+ controller.prepare do
211
+ # include MyAuthentication # included in all the actions
212
+ # before :authenticate! # run an authentication before callback
213
+ end
214
+
215
+ # Configure the code that will yield each time <%= config[:classified_app_name] %>::View is included
216
+ # This is useful for sharing common functionality
217
+ #
218
+ # See: http://www.rubydoc.info/gems/hanami-view#Configuration
219
+ view.prepare do
220
+ include Hanami::Helpers
221
+ include <%= config[:classified_app_name] %>::Assets::Helpers
222
+ end
223
+ end
224
+
225
+ ##
226
+ # DEVELOPMENT
227
+ #
228
+ configure :development do
229
+ # Don't handle exceptions, render the stack trace
230
+ handle_exceptions false
231
+ end
232
+
233
+ ##
234
+ # TEST
235
+ #
236
+ configure :test do
237
+ # Don't handle exceptions, render the stack trace
238
+ handle_exceptions false
239
+ end
240
+
241
+ ##
242
+ # PRODUCTION
243
+ #
244
+ configure :production do
245
+ # scheme 'https'
246
+ # host 'example.org'
247
+ # port 443
248
+
249
+ assets do
250
+ # Don't compile static assets in production mode (eg. Sass, ES6)
251
+ #
252
+ # See: http://www.rubydoc.info/gems/hanami-assets#Configuration
253
+ compile false
254
+
255
+ # Use digest file name for asset paths
256
+ #
257
+ # See: http://hanamirb.org/guides/assets/digest
258
+ digest true
259
+
260
+ # Content Delivery Network (CDN)
261
+ #
262
+ # See: http://hanamirb.org/guides/assets/content-delivery-network
263
+ #
264
+ # scheme 'https'
265
+ # host 'cdn.example.org'
266
+ # port 443
267
+ end
268
+ end
269
+ end
270
+ end
@@ -0,0 +1,5 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'hanami/setup'
4
+ require_relative '../lib/<%= config[:app_name] %>'
5
+ require_relative '../config/application'
@@ -0,0 +1,2 @@
1
+ # Configure your routes here
2
+ # See: http://www.rubydoc.info/gems/hanami-router/#Usage
@@ -0,0 +1,11 @@
1
+ # Require this file for feature tests
2
+ require_relative './spec_helper'
3
+
4
+ require 'capybara'
5
+ require 'capybara/dsl'
6
+
7
+ Capybara.app = <%= config[:classified_app_name] %>::Application.new
8
+
9
+ class MiniTest::Spec
10
+ include Capybara::DSL
11
+ end
@@ -0,0 +1,12 @@
1
+ # Require this file for feature tests
2
+ require_relative './spec_helper'
3
+
4
+ require 'capybara'
5
+ require 'capybara/rspec'
6
+
7
+ RSpec.configure do |config|
8
+ config.include RSpec::FeatureExampleGroup
9
+
10
+ config.include Capybara::DSL, feature: true
11
+ config.include Capybara::RSpecMatchers, feature: true
12
+ end
@@ -0,0 +1,2 @@
1
+ /public/assets*
2
+ /tmp
@@ -0,0 +1,4 @@
1
+ /db/<%= config[:app_name] %>_development
2
+ /db/<%= config[:app_name] %>_test
3
+ /public/assets*
4
+ /tmp
@@ -0,0 +1,3 @@
1
+ <%= Hanami::Hanamirc::ARCHITECTURE_KEY %>=<%= Hanami::Hanamirc::APP_ARCHITECTURE %>
2
+ <%= Hanami::Hanamirc::TEST_KEY %>=<%= config[:test] %>
3
+ <%= Hanami::Hanamirc::TEMPLATE_KEY %>=<%= Hanami::Hanamirc::DEFAULT_TEMPLATE %>
@@ -0,0 +1,59 @@
1
+ require 'hanami/model'
2
+ require 'hanami/mailer'
3
+ Dir["#{ __dir__ }/<%= config[:app_name] %>/**/*.rb"].each { |file| require_relative file }
4
+
5
+ Hanami::Model.configure do
6
+ # Database adapter
7
+ #
8
+ # Available options:
9
+ #
10
+ # * Memory adapter
11
+ # adapter type: :memory, uri: 'memory://localhost/<%= config[:app_name] %>_development'
12
+ #
13
+ # * SQL adapter
14
+ # adapter type: :sql, uri: 'sqlite://db/<%= config[:app_name] %>_development.sqlite3'
15
+ # adapter type: :sql, uri: 'postgres://localhost/<%= config[:app_name] %>_development'
16
+ # adapter type: :sql, uri: 'mysql://localhost/<%= config[:app_name] %>_development'
17
+ #
18
+ adapter type: :<%= config[:database_config][:type] %>, uri: ENV['<%= config[:app_name].to_env_s %>_DATABASE_URL']
19
+
20
+ <%- if config[:database_config][:type] == :sql -%>
21
+ ##
22
+ # Migrations
23
+ #
24
+ migrations 'db/migrations'
25
+ schema 'db/schema.sql'
26
+
27
+ <%- end -%>
28
+ ##
29
+ # Database mapping
30
+ #
31
+ # Intended for specifying application wide mappings.
32
+ #
33
+ # You can specify mapping file to load with:
34
+ #
35
+ # mapping "#{__dir__}/config/mapping"
36
+ #
37
+ # Alternatively, you can use a block syntax like the following:
38
+ #
39
+ mapping do
40
+ # collection :users do
41
+ # entity User
42
+ # repository UserRepository
43
+ #
44
+ # attribute :id, Integer
45
+ # attribute :name, String
46
+ # end
47
+ end
48
+ end.load!
49
+
50
+ Hanami::Mailer.configure do
51
+ root "#{ __dir__ }/<%= config[:app_name] %>/mailers"
52
+
53
+ # See http://hanamirb.org/guides/mailers/delivery
54
+ delivery do
55
+ development :test
56
+ test :test
57
+ # production :stmp, address: ENV['SMTP_PORT'], port: 1025
58
+ end
59
+ end.load!
@@ -0,0 +1,7 @@
1
+ # collection :users do
2
+ # entity User
3
+ # repository UserRepository
4
+ #
5
+ # attribute :id, Integer
6
+ # attribute :name, String
7
+ # end
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper