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
@@ -1,28 +0,0 @@
1
- module Hanami
2
- # Hanami CLI
3
- #
4
- # @since 1.1.0
5
- class CLI
6
- module Commands
7
- # @since 1.1.0
8
- # @api private
9
- module Generate
10
- require "hanami/cli/commands/generate/app"
11
- require "hanami/cli/commands/generate/action"
12
- require "hanami/cli/commands/generate/mailer"
13
- require "hanami/cli/commands/generate/migration"
14
- require "hanami/cli/commands/generate/model"
15
- require "hanami/cli/commands/generate/secret"
16
- end
17
- end
18
-
19
- register "generate", aliases: ["g"] do |prefix|
20
- prefix.register "app", Commands::Generate::App
21
- prefix.register "action", Commands::Generate::Action
22
- prefix.register "mailer", Commands::Generate::Mailer
23
- prefix.register "migration", Commands::Generate::Migration
24
- prefix.register "model", Commands::Generate::Model
25
- prefix.register "secret", Commands::Generate::Secret
26
- end
27
- end
28
- end
@@ -1,3 +0,0 @@
1
- # Define ENV variables for development environment
2
- DATABASE_URL="<%= database_config_hash[:uri][:development] %>"
3
- SERVE_STATIC_ASSETS="true"
@@ -1,3 +0,0 @@
1
- # Define ENV variables for test environment
2
- DATABASE_URL="<%= database_config_hash[:uri][:test] %>"
3
- SERVE_STATIC_ASSETS="true"
File without changes
@@ -1,57 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'rake'
4
- <%- if hanami_head -%>
5
-
6
- gem 'hanami-utils', require: false, git: 'https://github.com/hanami/utils.git', branch: 'develop'
7
- gem 'hanami-validations', require: false, git: 'https://github.com/hanami/validations.git', branch: 'develop'
8
- gem 'hanami-router', require: false, git: 'https://github.com/hanami/router.git', branch: 'develop'
9
- gem 'hanami-controller', require: false, git: 'https://github.com/hanami/controller.git', branch: 'develop'
10
- gem 'hanami-view', require: false, git: 'https://github.com/hanami/view.git', branch: 'develop'
11
- gem 'hanami-helpers', require: false, git: 'https://github.com/hanami/helpers.git', branch: 'develop'
12
- gem 'hanami-mailer', require: false, git: 'https://github.com/hanami/mailer.git', branch: 'develop'
13
- gem 'hanami-assets', require: false, git: 'https://github.com/hanami/assets.git', branch: 'develop'
14
- gem 'hanami-model', require: false, git: 'https://github.com/hanami/model.git', branch: 'develop'
15
- gem 'hanami', git: 'https://github.com/hanami/hanami.git', branch: 'develop'
16
- <%- else -%>
17
- gem 'hanami', '<%= hanami_version %>'
18
- gem 'hanami-model', '<%= hanami_model_version %>'
19
- <%- end -%>
20
- <%- if database_config_hash[:gem] -%>
21
-
22
- gem '<%= database_config_hash[:gem] %>'
23
- <%- end -%>
24
- <%- case template_engine.name
25
- when 'slim' -%>
26
-
27
- gem 'slim'
28
- <%- when 'haml' -%>
29
-
30
- gem 'haml'
31
- <%- end -%>
32
-
33
- <%- if code_reloading -%>
34
- group :development do
35
- # Code reloading
36
- # See: https://guides.hanamirb.org/projects/code-reloading
37
- gem 'shotgun', platforms: :ruby
38
- gem 'hanami-webconsole'
39
- end
40
-
41
- <%- end -%>
42
- group :test, :development do
43
- gem 'dotenv', '~> 2.4'
44
- end
45
-
46
- group :test do
47
- <%- if test_framework.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,33 +0,0 @@
1
- # <%= Hanami::Utils::String.titleize(project) %>
2
-
3
- Welcome to your new Hanami project!
4
-
5
- ## Setup
6
-
7
- How to run tests:
8
-
9
- ```
10
- % bundle exec rake
11
- ```
12
-
13
- How to run the development console:
14
-
15
- ```
16
- % bundle exec hanami console
17
- ```
18
-
19
- How to run the development server:
20
-
21
- ```
22
- % bundle exec hanami server
23
- ```
24
-
25
- How to prepare (create and migrate) DB for `development` and `test` environments:
26
-
27
- ```
28
- % bundle exec hanami db prepare
29
-
30
- % HANAMI_ENV=test bundle exec hanami db prepare
31
- ```
32
-
33
- Explore Hanami [guides](https://guides.hanamirb.org/), [API docs](http://docs.hanamirb.org/<%= Hanami::VERSION %>/), or jump in [chat](http://chat.hanamirb.org) for help. Enjoy! 🌸
@@ -1,2 +0,0 @@
1
- require_relative './environment'
2
- Hanami.boot
@@ -1,49 +0,0 @@
1
- require 'bundler/setup'
2
- require 'hanami/setup'
3
- require 'hanami/model'
4
- require_relative '../lib/<%= project %>'
5
-
6
- Hanami.configure do
7
-
8
- model do
9
- ##
10
- # Database adapter
11
- #
12
- # Available options:
13
- #
14
- # * SQL adapter
15
- # adapter :sql, 'sqlite://db/<%= project %>_development.sqlite3'
16
- # adapter :sql, 'postgresql://localhost/<%= project %>_development'
17
- # adapter :sql, 'mysql://localhost/<%= project %>_development'
18
- #
19
- adapter :<%= database_config_hash[:type] %>, ENV.fetch('DATABASE_URL')
20
-
21
- <%- if database_config.sql? -%>
22
- ##
23
- # Migrations
24
- #
25
- migrations 'db/migrations'
26
- schema 'db/schema.sql'
27
- <%- end -%>
28
- end
29
-
30
- mailer do
31
- root 'lib/<%= project %>/mailers'
32
-
33
- # See https://guides.hanamirb.org/mailers/delivery
34
- delivery :test
35
- end
36
-
37
- environment :development do
38
- # See: https://guides.hanamirb.org/projects/logging
39
- logger level: :debug
40
- end
41
-
42
- environment :production do
43
- logger level: :info, formatter: :json, filter: []
44
-
45
- mailer do
46
- delivery :smtp, address: ENV.fetch('SMTP_HOST'), port: ENV.fetch('SMTP_PORT')
47
- end
48
- end
49
- end
@@ -1,3 +0,0 @@
1
- require_relative 'config/environment'
2
-
3
- run Hanami.app
@@ -1,4 +0,0 @@
1
- /public/assets*
2
- /tmp
3
- .env.local
4
- .env.*.local
@@ -1,5 +0,0 @@
1
- /db/*.sqlite
2
- /public/assets*
3
- /tmp
4
- .env.local
5
- .env.*.local
@@ -1,3 +0,0 @@
1
- <%= Hanami::Hanamirc::PROJECT_NAME %>=<%= project %>
2
- <%= Hanami::Hanamirc::TEST_KEY %>=<%= test %>
3
- <%= Hanami::Hanamirc::TEMPLATE_KEY %>=<%= template_engine.name %>
@@ -1,2 +0,0 @@
1
- module <%= project_module %>
2
- 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,11 +0,0 @@
1
- # Require this file for feature tests
2
- require_relative './spec_helper'
3
-
4
- require 'capybara'
5
- require 'capybara/dsl'
6
-
7
- Capybara.app = Hanami.app
8
-
9
- class MiniTest::Spec
10
- include Capybara::DSL
11
- end
@@ -1,7 +0,0 @@
1
- # Require this file for unit tests
2
- ENV['HANAMI_ENV'] ||= 'test'
3
-
4
- require_relative '../config/environment'
5
- require 'minitest/autorun'
6
-
7
- Hanami.boot
@@ -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 = Hanami.app
6
- end
7
- end
8
- end
@@ -1,12 +0,0 @@
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
@@ -1,2 +0,0 @@
1
- --color
2
- --require spec_helper
@@ -1,103 +0,0 @@
1
- # Require this file for unit tests
2
- ENV['HANAMI_ENV'] ||= 'test'
3
-
4
- require_relative '../config/environment'
5
- Hanami.boot
6
- Hanami::Utils.require!("#{__dir__}/support")
7
-
8
- # This file was generated by the `rspec --init` command. Conventionally, all
9
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
10
- # The generated `.rspec` file contains `--require spec_helper` which will cause
11
- # this file to always be loaded, without a need to explicitly require it in any
12
- # files.
13
- #
14
- # Given that it is always loaded, you are encouraged to keep this file as
15
- # light-weight as possible. Requiring heavyweight dependencies from this file
16
- # will add to the boot time of your test suite on EVERY test run, even for an
17
- # individual file that may not need all of that loaded. Instead, consider making
18
- # a separate helper file that requires the additional dependencies and performs
19
- # the additional setup, and require it from the spec files that actually need
20
- # it.
21
- #
22
- # The `.rspec` file also contains a few flags that are not defaults but that
23
- # users commonly want.
24
- #
25
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
26
- RSpec.configure do |config|
27
- # rspec-expectations config goes here. You can use an alternate
28
- # assertion/expectation library such as wrong or the stdlib/minitest
29
- # assertions if you prefer.
30
- config.expect_with :rspec do |expectations|
31
- # This option will default to `true` in RSpec 4. It makes the `description`
32
- # and `failure_message` of custom matchers include text for helper methods
33
- # defined using `chain`, e.g.:
34
- # be_bigger_than(2).and_smaller_than(4).description
35
- # # => "be bigger than 2 and smaller than 4"
36
- # ...rather than:
37
- # # => "be bigger than 2"
38
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
39
- end
40
-
41
- # rspec-mocks config goes here. You can use an alternate test double
42
- # library (such as bogus or mocha) by changing the `mock_with` option here.
43
- config.mock_with :rspec do |mocks|
44
- # Prevents you from mocking or stubbing a method that does not exist on
45
- # a real object. This is generally recommended, and will default to
46
- # `true` in RSpec 4.
47
- mocks.verify_partial_doubles = true
48
- end
49
-
50
- # The settings below are suggested to provide a good initial experience
51
- # with RSpec, but feel free to customize to your heart's content.
52
- =begin
53
- # These two settings work together to allow you to limit a spec run
54
- # to individual examples or groups you care about by tagging them with
55
- # `:focus` metadata. When nothing is tagged with `:focus`, all examples
56
- # get run.
57
- config.filter_run :focus
58
- config.run_all_when_everything_filtered = true
59
-
60
- # Allows RSpec to persist some state between runs in order to support
61
- # the `--only-failures` and `--next-failure` CLI options. We recommend
62
- # you configure your source control system to ignore this file.
63
- config.example_status_persistence_file_path = "spec/examples.txt"
64
-
65
- # Limits the available syntax to the non-monkey patched syntax that is
66
- # recommended. For more details, see:
67
- # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
68
- # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
69
- # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
70
- config.disable_monkey_patching!
71
-
72
- # This setting enables warnings. It's recommended, but in many cases may
73
- # be too noisy due to issues in dependencies.
74
- config.warnings = false
75
-
76
- # Many RSpec users commonly either run the entire suite or an individual
77
- # file, and it's useful to allow more verbose output when running an
78
- # individual spec file.
79
- if config.files_to_run.one?
80
- # Use the documentation formatter for detailed output,
81
- # unless a formatter has already been configured
82
- # (e.g. via a command-line flag).
83
- config.default_formatter = 'doc'
84
- end
85
-
86
- # Print the 10 slowest examples and example groups at the
87
- # end of the spec run, to help surface which specs are running
88
- # particularly slow.
89
- config.profile_examples = 10
90
-
91
- # Run specs in random order to surface order dependencies. If you find an
92
- # order dependency and want to debug it, you can fix the order by providing
93
- # the seed, which is printed after each run.
94
- # --seed 1234
95
- config.order = :random
96
-
97
- # Seed global randomization in this process using the `--seed` CLI option.
98
- # Setting this allows you to use `--seed` to deterministically reproduce
99
- # test failures related to randomization by passing the same `--seed` value
100
- # as the one that triggered the failure.
101
- Kernel.srand config.seed
102
- =end
103
- end
File without changes