hanami 1.3.1 → 2.0.0.alpha2

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 +110 -6
  3. data/FEATURES.md +9 -1
  4. data/LICENSE.md +1 -1
  5. data/README.md +4 -5
  6. data/hanami.gemspec +26 -30
  7. data/lib/hanami.rb +40 -243
  8. data/lib/hanami/application.rb +338 -174
  9. data/lib/hanami/application/autoloader/inflector_adapter.rb +22 -0
  10. data/lib/hanami/application/container/boot/inflector.rb +7 -0
  11. data/lib/hanami/application/container/boot/logger.rb +8 -0
  12. data/lib/hanami/application/container/boot/rack_logger.rb +19 -0
  13. data/lib/hanami/application/container/boot/rack_monitor.rb +12 -0
  14. data/lib/hanami/application/container/boot/settings.rb +7 -0
  15. data/lib/hanami/application/router.rb +59 -0
  16. data/lib/hanami/application/routing/middleware/stack.rb +89 -0
  17. data/lib/hanami/application/routing/resolver.rb +82 -0
  18. data/lib/hanami/application/routing/resolver/node.rb +50 -0
  19. data/lib/hanami/application/routing/resolver/trie.rb +59 -0
  20. data/lib/hanami/application/settings.rb +23 -0
  21. data/lib/hanami/application/settings/definition.rb +26 -0
  22. data/lib/hanami/application/settings/loader.rb +97 -0
  23. data/lib/hanami/application/settings/struct.rb +65 -0
  24. data/lib/hanami/boot.rb +5 -0
  25. data/lib/hanami/cli/application/cli.rb +40 -0
  26. data/lib/hanami/cli/application/command.rb +47 -0
  27. data/lib/hanami/cli/application/commands.rb +16 -0
  28. data/lib/hanami/cli/application/commands/console.rb +81 -0
  29. data/lib/hanami/cli/base_command.rb +48 -0
  30. data/lib/hanami/cli/commands.rb +6 -42
  31. data/lib/hanami/cli/commands/command.rb +20 -30
  32. data/lib/hanami/cli/commands/server.rb +63 -14
  33. data/lib/hanami/configuration.rb +248 -190
  34. data/lib/hanami/configuration/middleware.rb +8 -28
  35. data/lib/hanami/configuration/router.rb +50 -0
  36. data/lib/hanami/configuration/sessions.rb +50 -0
  37. data/lib/hanami/init.rb +5 -0
  38. data/lib/hanami/server.rb +5 -69
  39. data/lib/hanami/setup.rb +8 -2
  40. data/lib/hanami/slice.rb +138 -0
  41. data/lib/hanami/version.rb +3 -1
  42. data/lib/hanami/web/rack_logger.rb +96 -0
  43. metadata +84 -228
  44. data/bin/hanami +0 -6
  45. data/lib/hanami/action/csrf_protection.rb +0 -211
  46. data/lib/hanami/action/routing_helpers.rb +0 -40
  47. data/lib/hanami/app.rb +0 -96
  48. data/lib/hanami/application_configuration.rb +0 -1495
  49. data/lib/hanami/application_name.rb +0 -108
  50. data/lib/hanami/application_namespace.rb +0 -14
  51. data/lib/hanami/assets/asset.rb +0 -72
  52. data/lib/hanami/assets/static.rb +0 -102
  53. data/lib/hanami/cli/commands/assets.rb +0 -16
  54. data/lib/hanami/cli/commands/assets/precompile.rb +0 -42
  55. data/lib/hanami/cli/commands/console.rb +0 -95
  56. data/lib/hanami/cli/commands/db.rb +0 -32
  57. data/lib/hanami/cli/commands/db/apply.rb +0 -32
  58. data/lib/hanami/cli/commands/db/console.rb +0 -44
  59. data/lib/hanami/cli/commands/db/create.rb +0 -32
  60. data/lib/hanami/cli/commands/db/drop.rb +0 -32
  61. data/lib/hanami/cli/commands/db/migrate.rb +0 -39
  62. data/lib/hanami/cli/commands/db/prepare.rb +0 -32
  63. data/lib/hanami/cli/commands/db/rollback.rb +0 -59
  64. data/lib/hanami/cli/commands/db/version.rb +0 -32
  65. data/lib/hanami/cli/commands/destroy.rb +0 -26
  66. data/lib/hanami/cli/commands/destroy/action.rb +0 -137
  67. data/lib/hanami/cli/commands/destroy/app.rb +0 -159
  68. data/lib/hanami/cli/commands/destroy/mailer.rb +0 -74
  69. data/lib/hanami/cli/commands/destroy/migration.rb +0 -51
  70. data/lib/hanami/cli/commands/destroy/model.rb +0 -84
  71. data/lib/hanami/cli/commands/generate.rb +0 -28
  72. data/lib/hanami/cli/commands/generate/action.rb +0 -321
  73. data/lib/hanami/cli/commands/generate/action/action.erb +0 -7
  74. data/lib/hanami/cli/commands/generate/action/action_spec.minitest.erb +0 -11
  75. data/lib/hanami/cli/commands/generate/action/action_spec.rspec.erb +0 -9
  76. data/lib/hanami/cli/commands/generate/action/action_without_view.erb +0 -7
  77. data/lib/hanami/cli/commands/generate/action/view.erb +0 -7
  78. data/lib/hanami/cli/commands/generate/action/view_spec.minitest.erb +0 -12
  79. data/lib/hanami/cli/commands/generate/action/view_spec.rspec.erb +0 -10
  80. data/lib/hanami/cli/commands/generate/app.rb +0 -243
  81. data/lib/hanami/cli/commands/generate/app/application.erb +0 -313
  82. data/lib/hanami/cli/commands/generate/app/favicon.ico +0 -0
  83. data/lib/hanami/cli/commands/generate/app/gitkeep.erb +0 -0
  84. data/lib/hanami/cli/commands/generate/app/layout.erb +0 -7
  85. data/lib/hanami/cli/commands/generate/app/layout_spec.minitest.erb +0 -10
  86. data/lib/hanami/cli/commands/generate/app/layout_spec.rspec.erb +0 -10
  87. data/lib/hanami/cli/commands/generate/app/routes.erb +0 -5
  88. data/lib/hanami/cli/commands/generate/app/template.erb.erb +0 -10
  89. data/lib/hanami/cli/commands/generate/app/template.haml.erb +0 -7
  90. data/lib/hanami/cli/commands/generate/app/template.slim.erb +0 -8
  91. data/lib/hanami/cli/commands/generate/mailer.rb +0 -104
  92. data/lib/hanami/cli/commands/generate/mailer/mailer.erb +0 -9
  93. data/lib/hanami/cli/commands/generate/mailer/mailer_spec.minitest.erb +0 -7
  94. data/lib/hanami/cli/commands/generate/mailer/mailer_spec.rspec.erb +0 -5
  95. data/lib/hanami/cli/commands/generate/migration.rb +0 -41
  96. data/lib/hanami/cli/commands/generate/migration/migration.erb +0 -4
  97. data/lib/hanami/cli/commands/generate/model.rb +0 -125
  98. data/lib/hanami/cli/commands/generate/model/entity.erb +0 -2
  99. data/lib/hanami/cli/commands/generate/model/entity_spec.minitest.erb +0 -5
  100. data/lib/hanami/cli/commands/generate/model/entity_spec.rspec.erb +0 -3
  101. data/lib/hanami/cli/commands/generate/model/migration.erb +0 -10
  102. data/lib/hanami/cli/commands/generate/model/repository.erb +0 -5
  103. data/lib/hanami/cli/commands/generate/model/repository_spec.minitest.erb +0 -5
  104. data/lib/hanami/cli/commands/generate/model/repository_spec.rspec.erb +0 -3
  105. data/lib/hanami/cli/commands/generate/secret.rb +0 -48
  106. data/lib/hanami/cli/commands/new.rb +0 -578
  107. data/lib/hanami/cli/commands/new/.env.development.erb +0 -3
  108. data/lib/hanami/cli/commands/new/.env.test.erb +0 -3
  109. data/lib/hanami/cli/commands/new/.gitkeep.erb +0 -0
  110. data/lib/hanami/cli/commands/new/Gemfile.erb +0 -58
  111. data/lib/hanami/cli/commands/new/README.md.erb +0 -33
  112. data/lib/hanami/cli/commands/new/config.ru.erb +0 -3
  113. data/lib/hanami/cli/commands/new/config/boot.erb +0 -2
  114. data/lib/hanami/cli/commands/new/config/environment.erb +0 -49
  115. data/lib/hanami/cli/commands/new/gitignore.erb +0 -2
  116. data/lib/hanami/cli/commands/new/gitignore_with_sqlite.erb +0 -3
  117. data/lib/hanami/cli/commands/new/hanamirc.erb +0 -3
  118. data/lib/hanami/cli/commands/new/lib/project.erb +0 -2
  119. data/lib/hanami/cli/commands/new/minitest/Rakefile.erb +0 -12
  120. data/lib/hanami/cli/commands/new/minitest/features_helper.erb +0 -11
  121. data/lib/hanami/cli/commands/new/minitest/spec_helper.erb +0 -7
  122. data/lib/hanami/cli/commands/new/rspec/Rakefile.erb +0 -9
  123. data/lib/hanami/cli/commands/new/rspec/capybara.erb +0 -8
  124. data/lib/hanami/cli/commands/new/rspec/features_helper.erb +0 -12
  125. data/lib/hanami/cli/commands/new/rspec/rspec.erb +0 -2
  126. data/lib/hanami/cli/commands/new/rspec/spec_helper.erb +0 -103
  127. data/lib/hanami/cli/commands/new/schema.sql.erb +0 -0
  128. data/lib/hanami/cli/commands/project.rb +0 -421
  129. data/lib/hanami/cli/commands/routes.rb +0 -21
  130. data/lib/hanami/cli/commands/templates.rb +0 -31
  131. data/lib/hanami/cli/commands/version.rb +0 -19
  132. data/lib/hanami/common_logger.rb +0 -93
  133. data/lib/hanami/components.rb +0 -156
  134. data/lib/hanami/components/app/assets.rb +0 -59
  135. data/lib/hanami/components/app/controller.rb +0 -74
  136. data/lib/hanami/components/app/routes.rb +0 -59
  137. data/lib/hanami/components/app/view.rb +0 -44
  138. data/lib/hanami/components/component.rb +0 -182
  139. data/lib/hanami/components/components.rb +0 -479
  140. data/lib/hanami/components/routes_inspector.rb +0 -72
  141. data/lib/hanami/config/cookies.rb +0 -69
  142. data/lib/hanami/config/framework_configuration.rb +0 -43
  143. data/lib/hanami/config/load_paths.rb +0 -46
  144. data/lib/hanami/config/mapper.rb +0 -47
  145. data/lib/hanami/config/routes.rb +0 -20
  146. data/lib/hanami/config/security.rb +0 -110
  147. data/lib/hanami/config/sessions.rb +0 -103
  148. data/lib/hanami/configuration/app.rb +0 -18
  149. data/lib/hanami/early_hints.rb +0 -129
  150. data/lib/hanami/env.rb +0 -69
  151. data/lib/hanami/environment.rb +0 -513
  152. data/lib/hanami/environment_application_configurations.rb +0 -37
  153. data/lib/hanami/frameworks.rb +0 -22
  154. data/lib/hanami/hanamirc.rb +0 -169
  155. data/lib/hanami/mailer/glue.rb +0 -27
  156. data/lib/hanami/middleware_stack.rb +0 -172
  157. data/lib/hanami/rake_helper.rb +0 -78
  158. data/lib/hanami/rake_tasks.rb +0 -2
  159. data/lib/hanami/rendering_policy.rb +0 -95
  160. data/lib/hanami/routes.rb +0 -219
  161. data/lib/hanami/routing/default.rb +0 -32
  162. data/lib/hanami/static.rb +0 -63
  163. data/lib/hanami/templates/default.html.erb +0 -30
  164. data/lib/hanami/templates/welcome.html.erb +0 -52
  165. data/lib/hanami/views/default.rb +0 -37
  166. data/lib/hanami/views/default_template_finder.rb +0 -22
  167. data/lib/hanami/views/null_view.rb +0 -15
  168. data/lib/hanami/welcome.rb +0 -36
@@ -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,58 +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-cli', require: false, git: 'https://github.com/hanami/cli.git', branch: 'develop'
14
- gem 'hanami-assets', require: false, git: 'https://github.com/hanami/assets.git', branch: 'develop'
15
- gem 'hanami-model', require: false, git: 'https://github.com/hanami/model.git', branch: 'develop'
16
- gem 'hanami', git: 'https://github.com/hanami/hanami.git', branch: 'develop'
17
- <%- else -%>
18
- gem 'hanami', '<%= hanami_version %>'
19
- gem 'hanami-model', '<%= hanami_model_version %>'
20
- <%- end -%>
21
- <%- if database_config_hash[:gem] -%>
22
-
23
- gem '<%= database_config_hash[:gem] %>'
24
- <%- end -%>
25
- <%- case template_engine.name
26
- when 'slim' -%>
27
-
28
- gem 'slim'
29
- <%- when 'haml' -%>
30
-
31
- gem 'haml'
32
- <%- end -%>
33
-
34
- <%- if code_reloading -%>
35
- group :development do
36
- # Code reloading
37
- # See: http://hanamirb.org/guides/projects/code-reloading
38
- gem 'shotgun', platforms: :ruby
39
- gem 'hanami-webconsole'
40
- end
41
-
42
- <%- end -%>
43
- group :test, :development do
44
- gem 'dotenv', '~> 2.4'
45
- end
46
-
47
- group :test do
48
- <%- if test_framework.rspec? -%>
49
- gem 'rspec'
50
- <%- else -%>
51
- gem 'minitest'
52
- <%- end -%>
53
- gem 'capybara'
54
- end
55
-
56
- group :production do
57
- # gem 'puma'
58
- 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](http://hanamirb.org/guides/), [API docs](http://docs.hanamirb.org/<%= Hanami::VERSION %>/), or jump in [chat](http://chat.hanamirb.org) for help. Enjoy! 🌸
@@ -1,3 +0,0 @@
1
- require './config/environment'
2
-
3
- run Hanami.app
@@ -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 http://hanamirb.org/guides/mailers/delivery
34
- delivery :test
35
- end
36
-
37
- environment :development do
38
- # See: http://hanamirb.org/guides/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,2 +0,0 @@
1
- /public/assets*
2
- /tmp
@@ -1,3 +0,0 @@
1
- /db/*.sqlite
2
- /public/assets*
3
- /tmp
@@ -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
@@ -1,421 +0,0 @@
1
- require "hanami/utils/file_list"
2
- require "securerandom"
3
-
4
- module Hanami
5
- # Hanami CLI
6
- #
7
- # @since 1.1.0
8
- class CLI
9
- module Commands
10
- # @since 1.1.0
11
- # @api private
12
- module Project # rubocop:disable Metrics/ModuleLength
13
- # @since 1.1.0
14
- # @api private
15
- def self.readme(*)
16
- root.join("README.md")
17
- end
18
-
19
- # @since 1.1.0
20
- # @api private
21
- def self.gemfile(*)
22
- root.join("Gemfile")
23
- end
24
-
25
- # @since 1.1.0
26
- # @api private
27
- def self.rakefile(*)
28
- root.join("Rakefile")
29
- end
30
-
31
- # @since 1.1.0
32
- # @api private
33
- def self.hanamirc(*)
34
- root.join(".hanamirc")
35
- end
36
-
37
- # @since 1.1.0
38
- # @api private
39
- def self.gitignore(*)
40
- root.join(".gitignore")
41
- end
42
-
43
- # @since 1.1.0
44
- # @api private
45
- def self.config_ru(*)
46
- root.join("config.ru")
47
- end
48
-
49
- # @since 1.1.0
50
- # @api private
51
- def self.environment(*)
52
- root.join("config", "environment.rb")
53
- end
54
-
55
- # @since 1.1.0
56
- # @api private
57
- def self.boot(*)
58
- root.join("config", "boot.rb")
59
- end
60
-
61
- # @since 1.1.0
62
- # @api private
63
- def self.initializers(*)
64
- root.join("config", "initializers")
65
- end
66
-
67
- # @since 1.1.0
68
- # @api private
69
- def self.env(*, environment)
70
- root.join(".env.#{environment}")
71
- end
72
-
73
- # @since 1.1.0
74
- # @api private
75
- def self.db(*)
76
- root.join("db")
77
- end
78
-
79
- # @since 1.1.0
80
- # @api private
81
- def self.db_schema(*)
82
- root.join("db", "schema.sql")
83
- end
84
-
85
- # @since 1.1.0
86
- # @api private
87
- def self.migrations(*)
88
- root.join("db", "migrations")
89
- end
90
-
91
- # @since 1.1.0
92
- # @api private
93
- def self.migration(context)
94
- filename = MIGRATION_FILENAME_PATTERN % { timestamp: migration_timestamp, name: context.migration }
95
-
96
- root.join("db", "migrations", "#{filename}.rb")
97
- end
98
-
99
- # @since 1.1.0
100
- # @api private
101
- def self.migration_timestamp
102
- Time.now.utc.strftime(MIGRATION_TIMESTAMP_FORMAT)
103
- end
104
-
105
- # @since 1.1.0
106
- # @api private
107
- def self.find_migration(context)
108
- list(root.join("db", "migrations", "*_#{context.migration}.rb")).first
109
- end
110
-
111
- # @since 1.1.0
112
- # @api private
113
- def self.project(context)
114
- root.join("lib", "#{context.options.fetch(:project)}.rb")
115
- end
116
-
117
- # @since 1.1.0
118
- # @api private
119
- def self.mailers(context)
120
- root.join("lib", context.options.fetch(:project), "mailers")
121
- end
122
-
123
- # @since 1.1.0
124
- # @api private
125
- def self.mailers_templates(context)
126
- root.join("lib", context.options.fetch(:project), "mailers", "templates")
127
- end
128
-
129
- # @since 1.1.0
130
- # @api private
131
- def self.mailer(context)
132
- root.join("lib", context.options.fetch(:project), "mailers", "#{context.mailer}.rb")
133
- end
134
-
135
- # @since 1.1.0
136
- # @api private
137
- def self.mailer_templates(context)
138
- list root.join("lib", context.options.fetch(:project), "mailers", "templates", "#{context.mailer}.*.*")
139
- end
140
-
141
- # @since 1.1.0
142
- # @api private
143
- def self.entities(context)
144
- root.join("lib", context.options.fetch(:project), "entities")
145
- end
146
-
147
- # @since 1.1.0
148
- # @api private
149
- def self.entity(context)
150
- root.join("lib", context.options.fetch(:project), "entities", "#{context.model}.rb")
151
- end
152
-
153
- # @since 1.1.0
154
- # @api private
155
- def self.repositories(context)
156
- root.join("lib", context.options.fetch(:project), "repositories")
157
- end
158
-
159
- # @since 1.1.0
160
- # @api private
161
- def self.repository(context)
162
- root.join("lib", context.options.fetch(:project), "repositories", "#{context.model}_repository.rb")
163
- end
164
-
165
- # @since 1.1.0
166
- # @api private
167
- def self.public_directory(*)
168
- root.join("public")
169
- end
170
-
171
- # @since 1.1.0
172
- # @api private
173
- def self.assets_manifest(*)
174
- root.join("public", "assets.json")
175
- end
176
-
177
- # @since 1.1.0
178
- # @api private
179
- def self.public_app_assets(context)
180
- # FIXME: extract this URL to path conversion into Hanami::Utils
181
- assets_directory = context.base_url.sub(/\A\//, "").split("/")
182
- root.join("public", "assets", *assets_directory)
183
- end
184
-
185
- # @since 1.1.0
186
- # @api private
187
- def self.mailer_template(context, format)
188
- root.join("lib", context.options.fetch(:project), "mailers", "templates", "#{context.mailer}.#{format}.#{context.options.fetch(:template)}")
189
- end
190
-
191
- # @since 1.1.0
192
- # @api private
193
- def self.app_application(context)
194
- root.join("apps", context.app, "application.rb")
195
- end
196
-
197
- # @since 1.1.0
198
- # @api private
199
- def self.app_sessions_secret
200
- SecureRandom.hex(32)
201
- end
202
-
203
- # @since 1.1.0
204
- # @api private
205
- def self.app_routes(context)
206
- root.join("apps", context.app, "config", "routes.rb")
207
- end
208
-
209
- # @since 1.1.0
210
- # @api private
211
- def self.app_layout(context)
212
- root.join("apps", context.app, "views", "application_layout.rb")
213
- end
214
-
215
- # @since 1.1.0
216
- # @api private
217
- def self.app_template(context)
218
- root.join("apps", context.app, "templates", "application.html.#{context.template}")
219
- end
220
-
221
- # @since 1.1.0
222
- # @api private
223
- def self.app_favicon(context)
224
- root.join("apps", context.app, "assets", "favicon.ico")
225
- end
226
-
227
- # @since 1.1.0
228
- # @api private
229
- def self.controllers(context)
230
- root.join("apps", context.app, "controllers")
231
- end
232
-
233
- # @since 1.1.0
234
- # @api private
235
- def self.images(context)
236
- root.join("apps", context.app, "assets", "images")
237
- end
238
-
239
- # @since 1.1.0
240
- # @api private
241
- def self.javascripts(context)
242
- root.join("apps", context.app, "assets", "javascripts")
243
- end
244
-
245
- # @since 1.1.0
246
- # @api private
247
- def self.stylesheets(context)
248
- root.join("apps", context.app, "assets", "stylesheets")
249
- end
250
-
251
- # @since 1.1.0
252
- # @api private
253
- def self.action(context)
254
- root.join("apps", context.app, "controllers", context.controller, "#{context.action}.rb")
255
- end
256
-
257
- # @since 1.1.0
258
- # @api private
259
- def self.view(context)
260
- root.join("apps", context.app, "views", context.controller, "#{context.action}.rb")
261
- end
262
-
263
- # @since 1.1.0
264
- # @api private
265
- def self.template(context)
266
- root.join("apps", context.app, "templates", context.controller, "#{context.action}.html.#{context.options.fetch(:template)}")
267
- end
268
-
269
- # @since 1.1.0
270
- # @api private
271
- def self.templates(context)
272
- list root.join("apps", context.app, "templates", context.controller, "#{context.action}.*.*")
273
- end
274
-
275
- # @since 1.1.0
276
- # @api private
277
- def self.entities_spec(context)
278
- root.join("spec", context.options.fetch(:project), "entities")
279
- end
280
-
281
- # @since 1.1.0
282
- # @api private
283
- def self.entity_spec(context)
284
- root.join("spec", context.options.fetch(:project), "entities", "#{context.model}_spec.rb")
285
- end
286
-
287
- # @since 1.1.0
288
- # @api private
289
- def self.repositories_spec(context)
290
- root.join("spec", context.options.fetch(:project), "repositories")
291
- end
292
-
293
- # @since 1.1.0
294
- # @api private
295
- def self.repository_spec(context)
296
- root.join("spec", context.options.fetch(:project), "repositories", "#{context.model}_repository_spec.rb")
297
- end
298
-
299
- # @since 1.1.0
300
- # @api private
301
- def self.mailers_spec(context)
302
- root.join("spec", context.options.fetch(:project), "mailers")
303
- end
304
-
305
- # @since 1.1.0
306
- # @api private
307
- def self.mailer_spec(context)
308
- root.join("spec", context.options.fetch(:project), "mailers", "#{context.mailer}_spec.rb")
309
- end
310
-
311
- # @since 1.1.0
312
- # @api private
313
- def self.app_spec(context)
314
- root.join("spec", context.app)
315
- end
316
-
317
- def self.app_layout_spec(context)
318
- root.join("spec", context.app, "views", "application_layout_spec.rb")
319
- end
320
-
321
- # @since 1.1.0
322
- # @api private
323
- def self.controllers_spec(context)
324
- root.join("spec", context.app, "controllers")
325
- end
326
-
327
- # @since 1.1.0
328
- # @api private
329
- def self.action_spec(context)
330
- root.join("spec", context.app, "controllers", context.controller, "#{context.action}_spec.rb")
331
- end
332
-
333
- # @since 1.1.0
334
- # @api private
335
- def self.view_spec(context)
336
- root.join("spec", context.app, "views", context.controller, "#{context.action}_spec.rb")
337
- end
338
-
339
- # @since 1.1.0
340
- # @api private
341
- def self.features_spec(context)
342
- root.join("spec", context.app, "features")
343
- end
344
-
345
- # @since 1.1.0
346
- # @api private
347
- def self.dotrspec(*)
348
- root.join(".rspec")
349
- end
350
-
351
- # @since 1.1.0
352
- # @api private
353
- def self.spec_helper(*)
354
- root.join("spec", "spec_helper.rb")
355
- end
356
-
357
- # @since 1.1.0
358
- # @api private
359
- def self.features_helper(*)
360
- root.join("spec", "features_helper.rb")
361
- end
362
-
363
- # @since 1.1.0
364
- # @api private
365
- def self.support_spec(*)
366
- root.join("spec", "support")
367
- end
368
-
369
- # @since 1.1.0
370
- # @api private
371
- def self.capybara(*)
372
- root.join("spec", "support", "capybara.rb")
373
- end
374
-
375
- # @since 1.1.0
376
- # @api private
377
- def self.app(context)
378
- root.join("apps", context.app)
379
- end
380
-
381
- # @since 1.1.0
382
- # @api private
383
- def self.app?(context)
384
- apps.include?(context.app)
385
- end
386
-
387
- # @since 1.1.0
388
- # @api private
389
- def self.apps
390
- Dir.glob(root.join("apps", "*")).map { |app| File.basename(app) }
391
- end
392
-
393
- # @since 1.1.0
394
- # @api private
395
- def self.keep(path)
396
- root.join(path, ".gitkeep")
397
- end
398
-
399
- # @since 1.1.0
400
- # @api private
401
- def self.list(pattern)
402
- Hanami::Utils::FileList[pattern]
403
- end
404
-
405
- # @since 1.1.0
406
- # @api private
407
- def self.root
408
- File
409
- end
410
-
411
- # @since 1.1.0
412
- # @api private
413
- MIGRATION_TIMESTAMP_FORMAT = "%Y%m%d%H%M%S".freeze
414
-
415
- # @since 1.1.0
416
- # @api private
417
- MIGRATION_FILENAME_PATTERN = "%{timestamp}_%{name}".freeze # rubocop:disable Style/FormatStringToken
418
- end
419
- end
420
- end
421
- end