hanami 1.3.5 → 2.0.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +51 -41
  3. data/FEATURES.md +2 -12
  4. data/LICENSE.md +1 -1
  5. data/README.md +5 -8
  6. data/bin/hanami +6 -4
  7. data/hanami.gemspec +24 -28
  8. data/lib/hanami/application.rb +44 -176
  9. data/lib/hanami/boot.rb +6 -0
  10. data/lib/hanami/cli/commands/command.rb +21 -29
  11. data/lib/hanami/cli/commands/server.rb +63 -14
  12. data/lib/hanami/cli/commands.rb +5 -42
  13. data/lib/hanami/configuration/cookies.rb +24 -0
  14. data/lib/hanami/configuration/middleware.rb +8 -28
  15. data/lib/hanami/configuration/security.rb +141 -0
  16. data/lib/hanami/configuration/sessions.rb +50 -0
  17. data/lib/hanami/configuration.rb +181 -191
  18. data/lib/hanami/container.rb +107 -0
  19. data/lib/hanami/frameworks.rb +24 -18
  20. data/lib/hanami/routes.rb +17 -205
  21. data/lib/hanami/server.rb +5 -69
  22. data/lib/hanami/version.rb +3 -1
  23. data/lib/hanami.rb +39 -243
  24. metadata +36 -233
  25. data/lib/hanami/action/csrf_protection.rb +0 -211
  26. data/lib/hanami/action/routing_helpers.rb +0 -40
  27. data/lib/hanami/app.rb +0 -96
  28. data/lib/hanami/application_configuration.rb +0 -1495
  29. data/lib/hanami/application_name.rb +0 -108
  30. data/lib/hanami/application_namespace.rb +0 -14
  31. data/lib/hanami/assets/asset.rb +0 -72
  32. data/lib/hanami/assets/static.rb +0 -102
  33. data/lib/hanami/cli/commands/assets/precompile.rb +0 -42
  34. data/lib/hanami/cli/commands/assets.rb +0 -16
  35. data/lib/hanami/cli/commands/console.rb +0 -95
  36. data/lib/hanami/cli/commands/db/apply.rb +0 -32
  37. data/lib/hanami/cli/commands/db/console.rb +0 -44
  38. data/lib/hanami/cli/commands/db/create.rb +0 -32
  39. data/lib/hanami/cli/commands/db/drop.rb +0 -32
  40. data/lib/hanami/cli/commands/db/migrate.rb +0 -39
  41. data/lib/hanami/cli/commands/db/prepare.rb +0 -32
  42. data/lib/hanami/cli/commands/db/rollback.rb +0 -59
  43. data/lib/hanami/cli/commands/db/version.rb +0 -32
  44. data/lib/hanami/cli/commands/db.rb +0 -32
  45. data/lib/hanami/cli/commands/destroy/action.rb +0 -137
  46. data/lib/hanami/cli/commands/destroy/app.rb +0 -159
  47. data/lib/hanami/cli/commands/destroy/mailer.rb +0 -74
  48. data/lib/hanami/cli/commands/destroy/migration.rb +0 -51
  49. data/lib/hanami/cli/commands/destroy/model.rb +0 -84
  50. data/lib/hanami/cli/commands/destroy.rb +0 -26
  51. data/lib/hanami/cli/commands/generate/action/action.erb +0 -7
  52. data/lib/hanami/cli/commands/generate/action/action_spec.minitest.erb +0 -11
  53. data/lib/hanami/cli/commands/generate/action/action_spec.rspec.erb +0 -9
  54. data/lib/hanami/cli/commands/generate/action/action_without_view.erb +0 -7
  55. data/lib/hanami/cli/commands/generate/action/view.erb +0 -7
  56. data/lib/hanami/cli/commands/generate/action/view_spec.minitest.erb +0 -12
  57. data/lib/hanami/cli/commands/generate/action/view_spec.rspec.erb +0 -10
  58. data/lib/hanami/cli/commands/generate/action.rb +0 -321
  59. data/lib/hanami/cli/commands/generate/app/application.erb +0 -313
  60. data/lib/hanami/cli/commands/generate/app/favicon.ico +0 -0
  61. data/lib/hanami/cli/commands/generate/app/gitkeep.erb +0 -0
  62. data/lib/hanami/cli/commands/generate/app/layout.erb +0 -7
  63. data/lib/hanami/cli/commands/generate/app/layout_spec.minitest.erb +0 -10
  64. data/lib/hanami/cli/commands/generate/app/layout_spec.rspec.erb +0 -10
  65. data/lib/hanami/cli/commands/generate/app/routes.erb +0 -5
  66. data/lib/hanami/cli/commands/generate/app/template.erb.erb +0 -10
  67. data/lib/hanami/cli/commands/generate/app/template.haml.erb +0 -7
  68. data/lib/hanami/cli/commands/generate/app/template.slim.erb +0 -8
  69. data/lib/hanami/cli/commands/generate/app.rb +0 -243
  70. data/lib/hanami/cli/commands/generate/mailer/mailer.erb +0 -9
  71. data/lib/hanami/cli/commands/generate/mailer/mailer_spec.minitest.erb +0 -7
  72. data/lib/hanami/cli/commands/generate/mailer/mailer_spec.rspec.erb +0 -5
  73. data/lib/hanami/cli/commands/generate/mailer.rb +0 -104
  74. data/lib/hanami/cli/commands/generate/migration/migration.erb +0 -4
  75. data/lib/hanami/cli/commands/generate/migration.rb +0 -41
  76. data/lib/hanami/cli/commands/generate/model/entity.erb +0 -2
  77. data/lib/hanami/cli/commands/generate/model/entity_spec.minitest.erb +0 -5
  78. data/lib/hanami/cli/commands/generate/model/entity_spec.rspec.erb +0 -3
  79. data/lib/hanami/cli/commands/generate/model/migration.erb +0 -10
  80. data/lib/hanami/cli/commands/generate/model/repository.erb +0 -5
  81. data/lib/hanami/cli/commands/generate/model/repository_spec.minitest.erb +0 -5
  82. data/lib/hanami/cli/commands/generate/model/repository_spec.rspec.erb +0 -3
  83. data/lib/hanami/cli/commands/generate/model.rb +0 -125
  84. data/lib/hanami/cli/commands/generate/secret.rb +0 -48
  85. data/lib/hanami/cli/commands/generate.rb +0 -28
  86. data/lib/hanami/cli/commands/new/.env.development.erb +0 -3
  87. data/lib/hanami/cli/commands/new/.env.test.erb +0 -3
  88. data/lib/hanami/cli/commands/new/.gitkeep.erb +0 -0
  89. data/lib/hanami/cli/commands/new/Gemfile.erb +0 -57
  90. data/lib/hanami/cli/commands/new/README.md.erb +0 -33
  91. data/lib/hanami/cli/commands/new/config/boot.erb +0 -2
  92. data/lib/hanami/cli/commands/new/config/environment.erb +0 -49
  93. data/lib/hanami/cli/commands/new/config.ru.erb +0 -3
  94. data/lib/hanami/cli/commands/new/gitignore.erb +0 -4
  95. data/lib/hanami/cli/commands/new/gitignore_with_sqlite.erb +0 -5
  96. data/lib/hanami/cli/commands/new/hanamirc.erb +0 -3
  97. data/lib/hanami/cli/commands/new/lib/project.erb +0 -2
  98. data/lib/hanami/cli/commands/new/minitest/Rakefile.erb +0 -12
  99. data/lib/hanami/cli/commands/new/minitest/features_helper.erb +0 -11
  100. data/lib/hanami/cli/commands/new/minitest/spec_helper.erb +0 -7
  101. data/lib/hanami/cli/commands/new/rspec/Rakefile.erb +0 -9
  102. data/lib/hanami/cli/commands/new/rspec/capybara.erb +0 -8
  103. data/lib/hanami/cli/commands/new/rspec/features_helper.erb +0 -12
  104. data/lib/hanami/cli/commands/new/rspec/rspec.erb +0 -2
  105. data/lib/hanami/cli/commands/new/rspec/spec_helper.erb +0 -103
  106. data/lib/hanami/cli/commands/new/schema.sql.erb +0 -0
  107. data/lib/hanami/cli/commands/new.rb +0 -578
  108. data/lib/hanami/cli/commands/project.rb +0 -421
  109. data/lib/hanami/cli/commands/routes.rb +0 -21
  110. data/lib/hanami/cli/commands/templates.rb +0 -31
  111. data/lib/hanami/cli/commands/version.rb +0 -19
  112. data/lib/hanami/common_logger.rb +0 -109
  113. data/lib/hanami/components/app/assets.rb +0 -59
  114. data/lib/hanami/components/app/controller.rb +0 -74
  115. data/lib/hanami/components/app/routes.rb +0 -59
  116. data/lib/hanami/components/app/view.rb +0 -44
  117. data/lib/hanami/components/component.rb +0 -182
  118. data/lib/hanami/components/components.rb +0 -479
  119. data/lib/hanami/components/routes_inspector.rb +0 -72
  120. data/lib/hanami/components.rb +0 -156
  121. data/lib/hanami/config/cookies.rb +0 -69
  122. data/lib/hanami/config/framework_configuration.rb +0 -43
  123. data/lib/hanami/config/load_paths.rb +0 -46
  124. data/lib/hanami/config/mapper.rb +0 -47
  125. data/lib/hanami/config/routes.rb +0 -20
  126. data/lib/hanami/config/security.rb +0 -110
  127. data/lib/hanami/config/sessions.rb +0 -119
  128. data/lib/hanami/configuration/app.rb +0 -21
  129. data/lib/hanami/early_hints.rb +0 -129
  130. data/lib/hanami/env.rb +0 -69
  131. data/lib/hanami/environment.rb +0 -541
  132. data/lib/hanami/environment_application_configurations.rb +0 -37
  133. data/lib/hanami/hanamirc.rb +0 -169
  134. data/lib/hanami/mailer/glue.rb +0 -27
  135. data/lib/hanami/middleware_stack.rb +0 -172
  136. data/lib/hanami/rake_helper.rb +0 -78
  137. data/lib/hanami/rake_tasks.rb +0 -3
  138. data/lib/hanami/rendering_policy.rb +0 -94
  139. data/lib/hanami/routing/default.rb +0 -32
  140. data/lib/hanami/setup.rb +0 -3
  141. data/lib/hanami/static.rb +0 -63
  142. data/lib/hanami/templates/default.html.erb +0 -30
  143. data/lib/hanami/templates/welcome.html.erb +0 -52
  144. data/lib/hanami/views/default.rb +0 -37
  145. data/lib/hanami/views/default_template_finder.rb +0 -22
  146. data/lib/hanami/views/null_view.rb +0 -15
  147. data/lib/hanami/welcome.rb +0 -41
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92d8362c387abfc24cda9234c81c671d544f03a2ae2680c9f71d492c7172410a
4
- data.tar.gz: 57643cd0ca74fd851e800edbe62c18464dc5ca0dcd09c66189ed53b256beb5f0
3
+ metadata.gz: 1c197523a333228ef0596099b121a0f3a3e02c4a5a0da3f3f4fe837e794b7cf8
4
+ data.tar.gz: 5a7526ef47fc6f64ebffdae725d26a17944e390274dbc478ff52d593c7ba63b9
5
5
  SHA512:
6
- metadata.gz: 6570e1184cc95fe719bbb366f59f082ccafdc55dddae70496c98579cd53f4d46a31bd740030b500e5d2b7ed03e2df8f42148344170c1a90453209b2575960441
7
- data.tar.gz: f2409cb5bc4d8bf3c7fe4bfa026eb03a9315fb6ccb80e95aa2b44e9b94600427cab0814a00d32035128a3ace49b42ed35644e1d0652ffc584be2ac5ea6564db5
6
+ metadata.gz: dd55bf77935140473affae77676eae8afe042f385dee3288dd9d80729fb887899f89950f26b83e2b793161545347cdc3dab8a5f6e0915013aa333c2caf2e080d
7
+ data.tar.gz: d254599b55640e0e3a27b718c1ae7141a40662c7291e60463d9620383cc419d49f06f5c8d1712b484f50ba758b71bf3f0ae79729452243532a0769e00478af8b
data/CHANGELOG.md CHANGED
@@ -1,44 +1,54 @@
1
1
  # Hanami
2
2
  The web, with simplicity.
3
3
 
4
- ## v1.3.5 - 2021-10-18
5
- ### Fixed
6
- - [Ivan Kabluchkov] Ensure to properly store exceptions in Rack environment
7
- - [Sean Collins] Explicitly limit in gemspec the supported rubies (>= 2.3 and < 3) for Hanami 1
8
-
9
- ### Changed
10
- - [Luca Guidi] Use JSON as default HTTP session serializer for cookie session storage
11
-
12
- ## v1.3.4 - 2021-05-02
13
- ### Fixed
14
- - [Slava Kardakov] Fix generated `config.ru` `require_relative` statement
15
- - [Armin] Fix `Hanami::CommonLogger` elapsed time compatibility with `rack` 2.1.0+
16
- - [Adam Daniels] Fix generated tests compatibility with `minitest` 6.0+
17
-
18
- ## v1.3.3 - 2019-09-20
19
- ### Added
20
- - [Gray Manley] Standardize file loading for `.env` files (see: https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use)
21
-
22
- ### Fixed
23
- - [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"`)
24
-
25
- ## v1.3.2 - 2019-07-26
26
- ### Added
27
- - [Luca Guidi] Support both `hanami-validations` 1 and 2
28
-
29
- ### Fixed
30
- - [Wisnu Adi Nurcahyo] Ensure `hanami generate` syntax for Welcome page is compatible with ZSH
31
- - [Luca Guidi] Don't let `hanami` to crash when called without `bundle exec`
32
-
33
- ## v1.3.1 - 2019-01-18
4
+ ## v2.0.0.alpha1 - 2019-01-30
34
5
  ### Added
35
- - [Luca Guidi] Official support for Ruby: MRI 2.6
36
- - [Luca Guidi] Support `bundler` 2.0+
6
+ - [Luca Guidi] Implemented from scratch `hanami version`
7
+ - [Luca Guidi] Implemented from scratch `hanami server`
8
+ - [Luca Guidi] Main configuration is opinionated: when a setting is not specified in generated code, it uses a framework default.
9
+ - [Luca Guidi] Main configuration setting `environment`: to yield env based settings (e.g. `config.environment(:production) { |c| c.logger = {...} }`)
10
+ - [Luca Guidi] Main configuration setting `base_url`: to set the base URL of the app (e.g. `config.base_url = "https://example.com"`)
11
+ - [Luca Guidi] Main configuration setting `logger`: to set the logger options (e.g. `config.logger = { level: :info, format: :json }`)
12
+ - [Luca Guidi] Main configuration setting `routes`: to set the path to routes file (e.g. `config.routes = "path/to/routes"`)
13
+ - [Luca Guidi] Main configuration setting `cookies`: to set cookies options (e.g. `config.cookies = { max_age: 300 }`)
14
+ - [Luca Guidi] Main configuration setting `sessions`: to set session options (e.g. `config.sessions = :cookie, { secret: "abc" }`)
15
+ - [Luca Guidi] Main configuration setting `default_request_format`: to set the fallback for request format (aka MIME Type) (e.g. `config.default_request_format = :json`)
16
+ - [Luca Guidi] Main configuration setting `default_response_format`: to set the default response format (aka MIME Type) (e.g. `config.default_response_format = :json`)
17
+ - [Luca Guidi] Main configuration setting `middleware` to mount Rack middleware (e.g. `config.middleware.use MyMiddleware, "argument"`)
18
+ - [Luca Guidi] Main configuration setting `security` to set security settings (see below)
19
+ - [Luca Guidi] Main configuration setting `inflections` to configure inflections (e.g. `config.inflections { |i| i.plural "virus", "viruses" }`)
20
+ - [Luca Guidi] Main configuration security setting `x_frame_options`: defaults to `"deny"` (e.g. `config.security.x_frame_options = "sameorigin"`)
21
+ - [Luca Guidi] Main configuration security setting `x_content_type_options`: defaults to `"nosniff"` (e.g. `config.security.x_content_type_options = nil`)
22
+ - [Luca Guidi] Main configuration security setting `x_xss_protection`: defaults to `"1; mode=block"` (e.g. `config.security.x_xss_protection = "1"`)
23
+ - [Luca Guidi] Main configuration security setting `content_security_policy`: defaults to `"form-action 'self'; frame-ancestors 'self'; base-uri 'self'; default-src 'none'; script-src 'self'; connect-src 'self'; img-src 'self' https: data:; style-src 'self' 'unsafe-inline' https:; font-src 'self'; object-src 'none'; plugin-types application/pdf; child-src 'self'; frame-src 'self'; media-src 'self'"`
24
+ (e.g. `config.security.content_security_policy[:style_src] += " https://my.cdn.example"` to add another source)
25
+ (e.g. `config.security.content_security_policy[:plugin_types] = nil` to override the settings)
37
26
 
38
- ### Fixed
39
- - [Aidan Coyle] Remove from app generator support for deprecated `force_ssl` setting
40
- - [Alessandro Caporrini] Remove from app generator support for deprecated `body_parsers` setting
41
- - [Daphne Rouw & Sean Collins] Make app generator to work when code in `config/environment.rb` uses double quotes
27
+ ### Changed
28
+ - [Luca Guidi] Drop support for Ruby: MRI 2.3, and 2.4.
29
+ - [Luca Guidi] `Hanami::Application` must be used as superclass for main application under `config/application.rb` (e.g. `Bookshelf::Application`)
30
+ - [Luca Guidi] Main configuration is available at `config/application.rb` instead of `config/enviroment.rb`
31
+ - [Luca Guidi] Removed `Hanami.configure` in favor of main application configuration (e.g. `Bookshelf::Application.config`)
32
+ - [Luca Guidi] Removed DSL syntax for main configuration (from `cookies max_age: 600` to `config.cookies = { max_age: 600 }`)
33
+ - [Luca Guidi] Per enviroment settings must be wrapped in a block (e.g. `config.enviroment(:production) { |c| c.logger = {} }`)
34
+ - [Luca Guidi] Concrete applications are no longer supported (e.g. `Web::Application` in `apps/web/application.rb`)
35
+ - [Luca Guidi] Main routes must be configured at `config/routes.rb`:
36
+ ```ruby
37
+ # frozen_string_literal: true
38
+
39
+ Hanami.application.routes do
40
+ mount :web, at: "/" do
41
+ root to: "home#index"
42
+ end
43
+
44
+ mount :admin, at: "/admin" do
45
+ root to: "home#index"
46
+ end
47
+ end
48
+ ```
49
+ - [Luca Guidi] Per application routes are no longer supported (e.g. `apps/web/config/routes.rb`)
50
+ - [Luca Guidi] Removed `shotgun` and code reloading from the core. Code reloading is implemented by `hanami-reloader` gem.
51
+ - [Luca Guidi] Removed support for `.hanamirc`
42
52
 
43
53
  ## v1.3.0 - 2018-10-24
44
54
  ### Added
@@ -55,7 +65,7 @@ The web, with simplicity.
55
65
 
56
66
  ### Fixed
57
67
  - [Anton Davydov] Make possible to pass extra settings for custom logger instances (eg. `logger SemanticLogger.new, :foo, :bar`)
58
- - [graywolf] Ensure `hanami generate app` to work without `require_relative` entries in `config/environment.rb`
68
+ - [graywolf] Ensure `hanami generate app` to work without `require_relative` entries in `config/enviroment.rb`
59
69
  - [Makoto Tajitsu & Luca Guidi] Fixed regression for `hanami new .` that used to generate a broken project
60
70
 
61
71
  ### Fixed
@@ -172,7 +182,7 @@ The web, with simplicity.
172
182
  - [Luca Guidi] Make compatible with Rack 2.0 only
173
183
  - [Luca Guidi] Removed `logger` settings from Hanami applications
174
184
  - [Luca Guidi] Removed logger for Hanami applications (eg `Web.logger`)
175
- - [Luca Guidi] Changed mailer syntax in `config/environment.rb`
185
+ - [Luca Guidi] Changed mailer syntax in `config/enviroment.rb`
176
186
 
177
187
  ## v0.9.2 - 2016-12-19
178
188
  ## Added
@@ -261,11 +271,11 @@ The web, with simplicity.
261
271
 
262
272
  ## v0.7.2 - 2016-02-09
263
273
  ### Fixed
264
- - [Alfonso Uceda Pompa] Fixed routing issue when static assets server tried to hijack paths that are matching directories in public directory
274
+ - [Alfonso Uceda Pompa] Fixed routing issue when static assets server tried to hijiack paths that are matching directories in public directory
265
275
 
266
276
  ## v0.7.1 - 2016-02-05
267
277
  ### Fixed
268
- - [Anton Davydov] Fixed routing issue when static assets server tried to hijack requests belonging to dynamic endpoints
278
+ - [Anton Davydov] Fixed routing issue when static assets server tried to hijiack requests belonging to dynamic endpoints
269
279
  - [Anatolii Didukh] Ensure to fallback to default engine for `hanami console`
270
280
 
271
281
  ## v0.7.0 - 2016-01-22
@@ -400,7 +410,7 @@ The web, with simplicity.
400
410
  ## v0.3.0 - 2015-03-23
401
411
  ### Added
402
412
  - [Luca Guidi] Introduced action generator. Eg. `bundle exec lotus generate action web dashboard#index`
403
- - [Alfonso Uceda Pompa] Allow to specify default cookies options in application configuration. Eg. `cookies true, { domain: 'lotusrb.org' }`
413
+ - [Alfonso Uceda Pompa] Allow to specify default coookies options in application configuration. Eg. `cookies true, { domain: 'lotusrb.org' }`
404
414
  - [Tom Kadwill] Include `Lotus::Helpers` in views.
405
415
  - [Linus Pettersson] Allow to specify `--database` CLI option when generate a new project. Eg. `lotus new bookshelf --database=postgresql`
406
416
  - [Linus Pettersson] Initialize a Git repository when generating a new project
data/FEATURES.md CHANGED
@@ -3,17 +3,7 @@
3
3
 
4
4
  ## Features
5
5
 
6
- ## v1.3.5 - 2021-10-18
7
-
8
- ## v1.3.4 - 2021-05-02
9
-
10
- ## v1.3.3 - 2019-09-20
11
-
12
- - Standardize file loading for `.env` files (see: https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use)
13
-
14
- ## v1.3.2 - 2019-07-26
15
-
16
- ## v1.3.1 - 2019-01-18
6
+ ## v2.0.0.alpha1 - 2019-01-30
17
7
 
18
8
  ## v1.3.0 - 2018-10-24
19
9
 
@@ -30,7 +20,7 @@
30
20
  - Unobtrusive JavaScript (UJS) (via `hanami-ujs` gem)
31
21
  - Interactive console for development error page (via `hanami-webconsole` gem)
32
22
  - CLI: register callbacks for `hanami` commands (`Hanami::CLI.after("db migrate", MyCallback.new)` or `Hanami::CLI.after("db migrate") { ... }`)
33
- - Project level Rack middleware stack (`Hanami.configure { middleware.use MyRackMiddleware }`)
23
+ - Project level Rack middleware stack (`Hanami.configure { middleware.use MyRackMiddlewre }`)
34
24
  - Plugins can hook into project configuration (`Hanami.plugin { middleware.use AnotherRackMiddleware }`)
35
25
  - Custom repository commands
36
26
  - Coloured logging
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright © 2014-2021 Luca Guidi
1
+ Copyright © 2014-2017 Luca Guidi
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -2,10 +2,6 @@
2
2
 
3
3
  The web, with simplicity.
4
4
 
5
- ## Version
6
-
7
- **This branch contains the code for `hanami` 1.3.x.**
8
-
9
5
  ## Frameworks
10
6
 
11
7
  Hanami is a **full-stack** Ruby web framework.
@@ -22,6 +18,7 @@ which provides the glue that ties all the parts together:
22
18
  * [**Hanami::Helpers**](https://github.com/hanami/helpers) - View helpers for Ruby applications
23
19
  * [**Hanami::Mailer**](https://github.com/hanami/mailer) - Mail for Ruby applications
24
20
  * [**Hanami::Assets**](https://github.com/hanami/assets) - Assets management for Ruby
21
+ * [**Hanami::CLI**](https://github.com/hanami/cli) - Ruby command line interface
25
22
  * [**Hanami::Utils**](https://github.com/hanami/utils) - Ruby core extensions and class utilities
26
23
 
27
24
  These components are designed to be used independently or together in a Hanami application.
@@ -29,14 +26,14 @@ These components are designed to be used independently or together in a Hanami a
29
26
  ## Status
30
27
 
31
28
  [![Gem Version](https://badge.fury.io/rb/hanami.svg)](https://badge.fury.io/rb/hanami)
32
- [![CI](https://github.com/hanami/hanami/workflows/ci/badge.svg?branch=1.3.x)](https://github.com/hanami/hanami/actions?query=workflow%3Aci+branch%3A1.3.x)
33
- [![Test Coverage](https://codecov.io/gh/hanami/hanami/branch/1.3.x/graph/badge.svg)](https://codecov.io/gh/hanami/hanami)
29
+ [![TravisCI](https://travis-ci.org/hanami/hanami.svg?branch=master)](https://travis-ci.org/hanami/hanami)
30
+ [![Test Coverage](https://codecov.io/gh/hanami/hanami/branch/master/graph/badge.svg)](https://codecov.io/gh/hanami/hanami)
34
31
  [![Depfu](https://badges.depfu.com/badges/ba000e0f69e6ef1c44cd3038caaa1841/overview.svg)](https://depfu.com/github/hanami/hanami?project=Bundler)
35
32
  [![Inline Docs](http://inch-ci.org/github/hanami/hanami.svg)](http://inch-ci.org/github/hanami/hanami)
36
33
 
37
34
  ## Installation
38
35
 
39
- __Hanami__ supports Ruby (MRI) 2.3+
36
+ __Hanami__ supports Ruby (MRI) 2.5+
40
37
 
41
38
  ```shell
42
39
  gem install hanami
@@ -140,4 +137,4 @@ Released under MIT License.
140
137
 
141
138
  This project was formerly known as Lotus (`lotusrb`).
142
139
 
143
- Copyright © 2014-2021 Luca Guidi.
140
+ Copyright © 2014-2019 Luca Guidi.
data/bin/hanami CHANGED
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
- require 'bundler'
3
- require 'hanami/cli/commands'
2
+ # frozen_string_literal: true
4
3
 
5
- ::Bundler.require(:plugins) if File.exist?(ENV["BUNDLE_GEMFILE"] || "Gemfile")
6
- Dry::CLI.new(Hanami::CLI::Commands).call
4
+ require "bundler"
5
+ require "hanami/cli/commands"
6
+
7
+ Bundler.require(*Hanami.bundler_groups) if File.exist?(ENV["BUNDLE_GEMFILE"] || "Gemfile")
8
+ Hanami::CLI.new(Hanami::CLI::Commands).call
data/hanami.gemspec CHANGED
@@ -1,40 +1,36 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("../lib", __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'hanami/version'
5
+ require "hanami/version"
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = 'hanami'
8
+ spec.name = "hanami"
8
9
  spec.version = Hanami::VERSION
9
- spec.authors = ['Luca Guidi']
10
- spec.email = ['me@lucaguidi.com']
11
- spec.summary = 'The web, with simplicity'
12
- spec.description = 'Hanami is a web framework for Ruby'
13
- spec.homepage = 'http://hanamirb.org'
14
- spec.license = 'MIT'
10
+ spec.authors = ["Luca Guidi"]
11
+ spec.email = ["me@lucaguidi.com"]
12
+ spec.summary = "The web, with simplicity"
13
+ spec.description = "Hanami is a web framework for Ruby"
14
+ spec.homepage = "http://hanamirb.org"
15
+ spec.license = "MIT"
15
16
 
16
17
  spec.files = `git ls-files -c -o --exclude-standard -z -- lib/* bin/* LICENSE.md README.md CODE_OF_CONDUCT.md CHANGELOG.md FEATURES.md hanami.gemspec`.split("\x0")
17
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
19
  spec.test_files = spec.files.grep(%r{^(test)/})
19
- spec.require_paths = ['lib']
20
- spec.required_ruby_version = '>= 2.3.0', '< 3'
20
+ spec.require_paths = ["lib"]
21
+ spec.required_ruby_version = ">= 2.5.0"
21
22
 
22
- spec.metadata['allowed_push_host'] = 'https://rubygems.org'
23
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
23
24
 
24
- spec.add_dependency 'hanami-utils', '~> 1.3'
25
- spec.add_dependency 'hanami-validations', '>= 1.3', '< 3'
26
- spec.add_dependency 'hanami-router', '~> 1.3'
27
- spec.add_dependency 'hanami-controller', '~> 1.3', '>= 1.3.3'
28
- spec.add_dependency 'hanami-view', '~> 1.3'
29
- spec.add_dependency 'hanami-helpers', '~> 1.3'
30
- spec.add_dependency 'hanami-mailer', '~> 1.3'
31
- spec.add_dependency 'hanami-assets', '~> 1.3'
32
- spec.add_dependency 'dry-cli', '~> 0.5'
33
- spec.add_dependency 'concurrent-ruby', '~> 1.0'
34
- spec.add_dependency 'bundler', '>= 1.6', '< 3'
25
+ spec.add_dependency "hanami-utils", "~> 2.0.alpha"
26
+ spec.add_dependency "hanami-router", "~> 2.0.alpha"
27
+ spec.add_dependency "hanami-controller", "~> 2.0.alpha"
28
+ spec.add_dependency "hanami-cli", "~> 1.0.alpha"
29
+ spec.add_dependency "dry-system", "~> 0.10"
30
+ spec.add_dependency "dry-inflector", "~> 0.1", ">= 0.1.2"
31
+ spec.add_dependency "bundler", ">= 1.16", "< 3"
35
32
 
36
- spec.add_development_dependency 'rspec', '~> 3.7'
37
- spec.add_development_dependency 'rack-test', '~> 1.1'
38
- spec.add_development_dependency 'aruba', '~> 0.14'
39
- spec.add_development_dependency 'rake', '~> 13.0'
33
+ spec.add_development_dependency "rspec", "~> 3.8"
34
+ spec.add_development_dependency "rack-test", "~> 1.1"
35
+ spec.add_development_dependency "rake", "~> 12.0"
40
36
  end
@@ -1,202 +1,70 @@
1
- require 'thread'
2
- require 'concurrent'
3
- require 'hanami/application_name'
4
- require 'hanami/application_namespace'
5
- require 'hanami/application_configuration'
6
- require 'hanami/environment_application_configurations'
7
- require 'hanami/rendering_policy'
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami/configuration"
4
+ require "hanami/routes"
5
+ require "hanami/router"
8
6
 
9
7
  module Hanami
10
- # A full stack Hanami application
11
- #
12
- # @since 0.1.0
13
- #
14
- # @example
15
- # require 'hanami'
8
+ # Hanami application
16
9
  #
17
- # module Bookshelf
18
- # class Application < Hanami::Application
19
- # end
20
- # end
10
+ # @since 2.0.0
21
11
  class Application
22
- # Override Ruby's Class#inherited
23
- #
24
- # @since 0.2.0
25
- # @api private
26
- #
27
- # @see http://www.ruby-doc.org/core/Class.html#method-i-inherited
28
- def self.inherited(base)
29
- super
12
+ @_mutex = Mutex.new
30
13
 
31
- base.extend(ClassMethods)
32
- base.namespace.module_eval do
33
- class << self
34
- # Routes for this application
35
- #
36
- # @return [Hanami::Routes] the routes for this Hanami application
37
- #
38
- # @since 0.9.0
39
- # @api public
40
- #
41
- # @example
42
- #
43
- # Web.routes
44
- # Admin.routes
45
- attr_accessor :routes
14
+ def self.inherited(app)
15
+ @_mutex.synchronize do
16
+ app.class_eval do
17
+ @_mutex = Mutex.new
18
+ @_configuration = Hanami::Configuration.new(env: Hanami.env)
19
+
20
+ extend ClassMethods
21
+ include InstanceMethods
46
22
  end
23
+
24
+ Hanami.application = app
47
25
  end
48
26
  end
49
27
 
50
- # Class interface for Hanami applications
28
+ # Class method interface
51
29
  #
52
- # @since 0.9.0
53
- # @api private
30
+ # @since 2.0.0
54
31
  module ClassMethods
55
- # Override Ruby's Class#extended
56
- #
57
- # @since 0.9.0
58
- # @api private
59
- #
60
- # @see http://www.ruby-doc.org/core/Class.html#method-i-extended
61
- def self.extended(base) # rubocop:disable Metrics/MethodLength
62
- super
63
-
64
- base.class_eval do
65
- @namespace = ApplicationNamespace.resolve(name)
66
- @configurations = EnvironmentApplicationConfigurations.new
67
- @_lock = Mutex.new
32
+ def configuration
33
+ @_configuration
34
+ end
68
35
 
69
- class << self
70
- # @since 0.9.0
71
- # @api private
72
- attr_reader :namespace
36
+ alias config configuration
73
37
 
74
- # @since 0.9.0
75
- # @api private
76
- attr_reader :configurations
38
+ def routes(&blk)
39
+ @_mutex.synchronize do
40
+ if blk.nil?
41
+ raise "Hanami.application.routes not configured" unless defined?(@_routes)
77
42
 
78
- # @since 0.9.0
79
- # @api private
80
- attr_reader :configuration
43
+ @_routes
44
+ else
45
+ @_routes = Routes.new(&blk)
81
46
  end
82
47
  end
83
48
  end
49
+ end
84
50
 
85
- # Hanami application name
86
- #
87
- # @return [String] the Hanami application name
88
- #
89
- # @since 0.9.0
90
- # @api private
91
- #
92
- # @example
93
- # require 'hanami'
94
- #
95
- # module Web
96
- # class Application < Hanami::Application
97
- # end
98
- # end
99
- #
100
- # Web::Application.app_name # => "web"
101
- def app_name
102
- ApplicationName.new(name).to_s
103
- end
51
+ # Instance method interface
52
+ #
53
+ # @since 2.0.0
54
+ module InstanceMethods
55
+ def initialize(configuration: self.class.configuration, routes: self.class.routes)
56
+ @app = Rack::Builder.new do
57
+ configuration.for_each_middleware do |m, *args|
58
+ use m, *args
59
+ end
104
60
 
105
- # Set configuration
106
- #
107
- # @param configuration [Hanami::ApplicationConfiguration] the application configuration
108
- #
109
- # @raise [RuntimeError] if the configuration is assigned more than once
110
- #
111
- # @since 0.1.0
112
- # @api private
113
- def configuration=(configuration)
114
- @_lock.synchronize do
115
- # raise "Can't assign configuration more than once (#{app_name})" unless @configuration.nil?
116
- @configuration = configuration
61
+ run Hanami::Router.new(**configuration.router_settings, &routes)
117
62
  end
118
63
  end
119
64
 
120
- # Configure the application.
121
- # It yields the given block in the context of the configuration
122
- #
123
- # @param environment [Symbol,nil] the configuration environment name
124
- # @param blk [Proc] the configuration block
125
- #
126
- # @since 0.1.0
127
- #
128
- # @see Hanami::ApplicationConfiguration
129
- #
130
- # @example
131
- # require 'hanami'
132
- #
133
- # module Bookshelf
134
- # Application < Hanami::Application
135
- # configure do
136
- # # ...
137
- # end
138
- # end
139
- # end
140
- def configure(environment = nil, &blk)
141
- configurations.add(environment, &blk)
65
+ def call(env)
66
+ @app.call(env)
142
67
  end
143
68
  end
144
-
145
- # Initialize and load a new instance of the application
146
- #
147
- # @return [Hanami::Application] a new instance of the application
148
- #
149
- # @since 0.1.0
150
- # @api private
151
- def initialize
152
- @renderer = RenderingPolicy.new(configuration)
153
- @middleware = configuration.middleware
154
- end
155
-
156
- # Process a request.
157
- # This method makes Hanami applications compatible with the Rack protocol.
158
- #
159
- # @param env [Hash] a Rack env
160
- #
161
- # @return [Array] a serialized Rack response
162
- #
163
- # @since 0.1.0
164
- #
165
- # @see http://rack.github.io
166
- # @see Hanami::RenderingPolicy#render
167
- # @see Hanami::Application#middleware
168
- def call(env)
169
- renderer.render(env, middleware.call(env))
170
- end
171
-
172
- private
173
-
174
- # Return the configuration for this application
175
- #
176
- # @since 0.1.0
177
- # @api private
178
- #
179
- # @see Hanami::Application.configuration
180
- def configuration
181
- self.class.configuration
182
- end
183
-
184
- # Rendering policy
185
- #
186
- # @since 0.2.0
187
- # @api private
188
- #
189
- # @see Hanami::RenderingPolicy
190
- attr_reader :renderer
191
-
192
- # Rack middleware stack
193
- #
194
- # @return [Hanami::MiddlewareStack] the middleware stack
195
- #
196
- # @since 0.1.0
197
- # @api private
198
- #
199
- # @see Hanami::MiddlewareStack
200
- attr_reader :middleware
201
69
  end
202
70
  end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/setup"
4
+ require "hanami"
5
+
6
+ Hanami.boot
@@ -1,12 +1,10 @@
1
- require 'hanami'
2
- require 'hanami/environment'
3
- require 'hanami/components'
4
- require 'dry/cli/command'
5
- require 'hanami/cli/commands/project'
6
- require 'hanami/cli/commands/templates'
7
- require 'concurrent'
8
- require 'hanami/utils/files'
9
- require 'erb'
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami"
4
+ require "hanami/cli/command"
5
+ require "concurrent"
6
+ require "hanami/utils/files"
7
+ require "erb"
10
8
 
11
9
  module Hanami
12
10
  # Hanami CLI
@@ -17,7 +15,7 @@ module Hanami
17
15
  # Abstract command
18
16
  #
19
17
  # @since 1.1.0
20
- class Command < Dry::CLI::Command
18
+ class Command < Hanami::CLI::Command
21
19
  # @since 1.1.0
22
20
  # @api private
23
21
  def self.inherited(component)
@@ -72,17 +70,8 @@ module Hanami
72
70
  # @since 1.1.0
73
71
  # @api private
74
72
  def call(**options)
75
- if self.class.requirements.any?
76
- environment = Hanami::Environment.new(options)
77
- environment.require_project_environment
78
-
79
- requirements.resolved('environment', environment)
80
- requirements.resolve(self.class.requirements)
81
-
82
- options = environment.to_options.merge(options)
83
- end
84
-
85
- super(**options)
73
+ # FIXME: merge ENV vars (like HANAMI_ENV) into **options
74
+ super(options)
86
75
  rescue StandardError => e
87
76
  warn e.message
88
77
  warn e.backtrace.join("\n\t")
@@ -92,10 +81,11 @@ module Hanami
92
81
 
93
82
  # @since 1.1.0
94
83
  # @api private
95
- def initialize(out: $stdout, files: Utils::Files)
96
- @out = out
97
- @files = files
98
- @templates = Templates.new(self.class)
84
+ def initialize(command_name:, out: $stdout, files: Utils::Files)
85
+ super(command_name: command_name)
86
+
87
+ @out = out
88
+ @files = files
99
89
  end
100
90
 
101
91
  private
@@ -107,7 +97,7 @@ module Hanami
107
97
  class Renderer
108
98
  # @since 1.1.0
109
99
  # @api private
110
- TRIM_MODE = "-".freeze
100
+ TRIM_MODE = "-"
111
101
 
112
102
  # @since 1.1.0
113
103
  # @api private
@@ -124,7 +114,7 @@ module Hanami
124
114
 
125
115
  # @since 1.1.0
126
116
  # @api private
127
- SAY_FORMATTER = "%<operation>12s %<path>s\n".freeze
117
+ SAY_FORMATTER = "%<operation>12s %<path>s\n"
128
118
 
129
119
  # @since 1.1.0
130
120
  # @api private
@@ -165,13 +155,15 @@ module Hanami
165
155
  # @since 1.1.0
166
156
  # @api private
167
157
  def project
168
- Project
158
+ # FIXME: is this still useful?
159
+ raise "it used to be implemented as Project"
169
160
  end
170
161
 
171
162
  # @since 1.1.0
172
163
  # @api private
173
164
  def requirements
174
- Hanami::Components
165
+ # FIXME: require components via the new Hanami::Container
166
+ raise "it used to be implemented as Hanami::Components"
175
167
  end
176
168
  end
177
169
  end