hanami 1.0.0 → 1.1.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/FEATURES.md +12 -0
- data/README.md +3 -0
- data/bin/hanami +3 -3
- data/hanami.gemspec +9 -9
- data/lib/hanami.rb +27 -0
- data/lib/hanami/action/routing_helpers.rb +1 -1
- data/lib/hanami/application_configuration.rb +0 -8
- data/lib/hanami/application_name.rb +1 -3
- data/lib/hanami/application_namespace.rb +1 -1
- data/lib/hanami/cli/commands.rb +101 -0
- data/lib/hanami/cli/commands/assets.rb +16 -0
- data/lib/hanami/cli/commands/assets/precompile.rb +42 -0
- data/lib/hanami/cli/commands/command.rb +180 -0
- data/lib/hanami/cli/commands/console.rb +95 -0
- data/lib/hanami/cli/commands/db.rb +30 -0
- data/lib/hanami/cli/commands/db/apply.rb +32 -0
- data/lib/hanami/cli/commands/db/console.rb +44 -0
- data/lib/hanami/cli/commands/db/create.rb +32 -0
- data/lib/hanami/cli/commands/db/drop.rb +32 -0
- data/lib/hanami/cli/commands/db/migrate.rb +39 -0
- data/lib/hanami/cli/commands/db/prepare.rb +32 -0
- data/lib/hanami/cli/commands/db/version.rb +32 -0
- data/lib/hanami/cli/commands/destroy.rb +26 -0
- data/lib/hanami/cli/commands/destroy/action.rb +131 -0
- data/lib/hanami/cli/commands/destroy/app.rb +159 -0
- data/lib/hanami/cli/commands/destroy/mailer.rb +74 -0
- data/lib/hanami/cli/commands/destroy/migration.rb +51 -0
- data/lib/hanami/cli/commands/destroy/model.rb +84 -0
- data/lib/hanami/cli/commands/generate.rb +28 -0
- data/lib/hanami/cli/commands/generate/action.rb +224 -0
- data/lib/hanami/cli/commands/generate/action/action.erb +8 -0
- data/lib/hanami/cli/commands/generate/action/action_spec.minitest.erb +11 -0
- data/lib/hanami/{generators/action/action_spec.rspec.tt → cli/commands/generate/action/action_spec.rspec.erb} +1 -3
- data/lib/hanami/cli/commands/generate/action/action_without_view.erb +9 -0
- data/lib/hanami/cli/commands/generate/action/view.erb +5 -0
- data/lib/hanami/cli/commands/generate/action/view_spec.minitest.erb +15 -0
- data/lib/hanami/{generators/action/view_spec.rspec.tt → cli/commands/generate/action/view_spec.rspec.erb} +2 -4
- data/lib/hanami/cli/commands/generate/app.rb +231 -0
- data/lib/hanami/{generators/app/application.rb.tt → cli/commands/generate/app/application.erb} +6 -6
- data/lib/hanami/{generators → cli/commands/generate}/app/favicon.ico +0 -0
- data/lib/hanami/{generators/action/template.tt → cli/commands/generate/app/gitkeep.erb} +0 -0
- data/lib/hanami/cli/commands/generate/app/layout.erb +7 -0
- data/lib/hanami/cli/commands/generate/app/layout_spec.minitest.erb +11 -0
- data/lib/hanami/cli/commands/generate/app/layout_spec.rspec.erb +11 -0
- data/lib/hanami/{generators/app/config/routes.rb.tt → cli/commands/generate/app/routes.erb} +0 -0
- data/lib/hanami/{generators/app/templates/application.html.erb.tt → cli/commands/generate/app/template.erb.erb} +1 -1
- data/lib/hanami/{generators/app/templates/application.html.haml.tt → cli/commands/generate/app/template.haml.erb} +1 -1
- data/lib/hanami/{generators/app/templates/application.html.slim.tt → cli/commands/generate/app/template.slim.erb} +1 -1
- data/lib/hanami/cli/commands/generate/mailer.rb +94 -0
- data/lib/hanami/cli/commands/generate/mailer/mailer.erb +7 -0
- data/lib/hanami/cli/commands/generate/mailer/mailer_spec.minitest.erb +7 -0
- data/lib/hanami/cli/commands/generate/mailer/mailer_spec.rspec.erb +5 -0
- data/lib/hanami/cli/commands/generate/migration.rb +41 -0
- data/lib/hanami/{generators/migration/migration.rb.tt → cli/commands/generate/migration/migration.erb} +0 -0
- data/lib/hanami/cli/commands/generate/model.rb +98 -0
- data/lib/hanami/cli/commands/generate/model/entity.erb +2 -0
- data/lib/hanami/cli/commands/generate/model/entity_spec.minitest.erb +5 -0
- data/lib/hanami/cli/commands/generate/model/entity_spec.rspec.erb +3 -0
- data/lib/hanami/{generators/model/migration.rb.tt → cli/commands/generate/model/migration.erb} +1 -1
- data/lib/hanami/cli/commands/generate/model/repository.erb +2 -0
- data/lib/hanami/cli/commands/generate/model/repository_spec.minitest.erb +5 -0
- data/lib/hanami/cli/commands/generate/model/repository_spec.rspec.erb +3 -0
- data/lib/hanami/cli/commands/generate/secret.rb +48 -0
- data/lib/hanami/cli/commands/new.rb +575 -0
- data/lib/hanami/{generators/application/container/.env.development.tt → cli/commands/new/.env.development.erb} +1 -1
- data/lib/hanami/{generators/application/container/.env.test.tt → cli/commands/new/.env.test.erb} +1 -1
- data/lib/hanami/{generators/app/config/initializers/.gitkeep → cli/commands/new/.gitkeep.erb} +0 -0
- data/lib/hanami/cli/commands/new/Gemfile.erb +57 -0
- data/lib/hanami/cli/commands/new/README.md.erb +35 -0
- data/lib/hanami/{generators/application/container/config.ru.tt → cli/commands/new/config.ru.erb} +0 -0
- data/lib/hanami/{generators/application/container/config/boot.rb.tt → cli/commands/new/config/boot.erb} +0 -0
- data/lib/hanami/{generators/application/container/config/environment.rb.tt → cli/commands/new/config/environment.erb} +8 -8
- data/lib/hanami/{generators/application/container/gitignore.tt → cli/commands/new/gitignore.erb} +0 -0
- data/lib/hanami/{generators/application/container/gitignore_with_sqlite.tt → cli/commands/new/gitignore_with_sqlite.erb} +0 -0
- data/lib/hanami/cli/commands/new/hanamirc.erb +3 -0
- data/lib/hanami/cli/commands/new/lib/project.erb +2 -0
- data/lib/hanami/{generators/application/container/Rakefile.minitest.tt → cli/commands/new/minitest/Rakefile.erb} +0 -0
- data/lib/hanami/{generators/application/container/features_helper.rb.minitest.tt → cli/commands/new/minitest/features_helper.erb} +0 -0
- data/lib/hanami/{generators/application/container/spec_helper.rb.minitest.tt → cli/commands/new/minitest/spec_helper.erb} +0 -0
- data/lib/hanami/{generators/application/container/Rakefile.rspec.tt → cli/commands/new/rspec/Rakefile.erb} +0 -0
- data/lib/hanami/{generators/application/container/capybara.rb.rspec.tt → cli/commands/new/rspec/capybara.erb} +0 -0
- data/lib/hanami/{generators/application/container/features_helper.rb.rspec.tt → cli/commands/new/rspec/features_helper.erb} +0 -0
- data/lib/hanami/{generators/application/container/rspec.rspec.tt → cli/commands/new/rspec/rspec.erb} +0 -0
- data/lib/hanami/{generators/application/container/spec_helper.rb.rspec.tt → cli/commands/new/rspec/spec_helper.erb} +0 -0
- data/lib/hanami/{generators/application/container/.gitignore → cli/commands/new/schema.sql.erb} +0 -0
- data/lib/hanami/cli/commands/project.rb +421 -0
- data/lib/hanami/cli/commands/routes.rb +21 -0
- data/lib/hanami/cli/commands/server.rb +39 -0
- data/lib/hanami/cli/commands/templates.rb +31 -0
- data/lib/hanami/cli/commands/version.rb +19 -0
- data/lib/hanami/common_logger.rb +14 -4
- data/lib/hanami/components.rb +39 -1
- data/lib/hanami/components/components.rb +36 -1
- data/lib/hanami/config/sessions.rb +1 -1
- data/lib/hanami/environment.rb +20 -50
- data/lib/hanami/hanamirc.rb +7 -30
- data/lib/hanami/middleware.rb +0 -26
- data/lib/hanami/static.rb +1 -1
- data/lib/hanami/templates/welcome.html.erb +1 -1
- data/lib/hanami/version.rb +1 -1
- data/lib/hanami/welcome.rb +1 -11
- metadata +125 -135
- data/lib/hanami/cli.rb +0 -154
- data/lib/hanami/cli_base.rb +0 -49
- data/lib/hanami/cli_sub_commands/assets.rb +0 -24
- data/lib/hanami/cli_sub_commands/db.rb +0 -138
- data/lib/hanami/cli_sub_commands/destroy.rb +0 -115
- data/lib/hanami/cli_sub_commands/generate.rb +0 -150
- data/lib/hanami/commands/apps.rb +0 -4
- data/lib/hanami/commands/assets/precompile.rb +0 -26
- data/lib/hanami/commands/command.rb +0 -77
- data/lib/hanami/commands/console.rb +0 -107
- data/lib/hanami/commands/db/apply.rb +0 -19
- data/lib/hanami/commands/db/console.rb +0 -41
- data/lib/hanami/commands/db/create.rb +0 -19
- data/lib/hanami/commands/db/drop.rb +0 -19
- data/lib/hanami/commands/db/migrate.rb +0 -30
- data/lib/hanami/commands/db/prepare.rb +0 -19
- data/lib/hanami/commands/db/version.rb +0 -19
- data/lib/hanami/commands/generate/abstract.rb +0 -76
- data/lib/hanami/commands/generate/action.rb +0 -322
- data/lib/hanami/commands/generate/app.rb +0 -154
- data/lib/hanami/commands/generate/mailer.rb +0 -131
- data/lib/hanami/commands/generate/migration.rb +0 -75
- data/lib/hanami/commands/generate/model.rb +0 -132
- data/lib/hanami/commands/generate/secret_token.rb +0 -37
- data/lib/hanami/commands/new/abstract.rb +0 -178
- data/lib/hanami/commands/new/app.rb +0 -129
- data/lib/hanami/commands/new/container.rb +0 -119
- data/lib/hanami/commands/routes.rb +0 -26
- data/lib/hanami/commands/server.rb +0 -32
- data/lib/hanami/generators/action/action.rb.tt +0 -8
- data/lib/hanami/generators/action/action_spec.minitest.tt +0 -12
- data/lib/hanami/generators/action/action_without_view.rb.tt +0 -9
- data/lib/hanami/generators/action/view.rb.tt +0 -5
- data/lib/hanami/generators/action/view_spec.minitest.tt +0 -16
- data/lib/hanami/generators/app/.gitkeep.tt +0 -1
- data/lib/hanami/generators/app/views/application_layout.rb.tt +0 -7
- data/lib/hanami/generators/application/container/.gitkeep +0 -1
- data/lib/hanami/generators/application/container/Gemfile.tt +0 -56
- data/lib/hanami/generators/application/container/config/initializers/.gitkeep +0 -0
- data/lib/hanami/generators/application/container/db/.gitkeep +0 -1
- data/lib/hanami/generators/application/container/hanamirc.tt +0 -4
- data/lib/hanami/generators/application/container/lib/chirp/entities/.gitkeep +0 -1
- data/lib/hanami/generators/application/container/lib/chirp/mailers/.gitkeep +0 -0
- data/lib/hanami/generators/application/container/lib/chirp/mailers/templates/.gitkeep +0 -0
- data/lib/hanami/generators/application/container/lib/chirp/repositories/.gitkeep +0 -1
- data/lib/hanami/generators/application/container/lib/project.rb.tt +0 -2
- data/lib/hanami/generators/application/container/schema.sql.tt +0 -0
- data/lib/hanami/generators/database_config.rb +0 -114
- data/lib/hanami/generators/generatable.rb +0 -69
- data/lib/hanami/generators/generator.rb +0 -52
- data/lib/hanami/generators/mailer/mailer.rb.tt +0 -7
- data/lib/hanami/generators/mailer/mailer_spec.rb.minitest.tt +0 -7
- data/lib/hanami/generators/mailer/mailer_spec.rb.rspec.tt +0 -5
- data/lib/hanami/generators/mailer/template.html.tt +0 -0
- data/lib/hanami/generators/mailer/template.txt.tt +0 -0
- data/lib/hanami/generators/model/entity.rb.tt +0 -2
- data/lib/hanami/generators/model/entity_spec.minitest.tt +0 -5
- data/lib/hanami/generators/model/entity_spec.rspec.tt +0 -3
- data/lib/hanami/generators/model/repository.rb.tt +0 -2
- data/lib/hanami/generators/model/repository_spec.minitest.tt +0 -5
- data/lib/hanami/generators/model/repository_spec.rspec.tt +0 -3
- data/lib/hanami/generators/template_engine.rb +0 -44
- data/lib/hanami/generators/test_framework.rb +0 -55
data/lib/hanami/{generators/app/config/initializers/.gitkeep → cli/commands/new/.gitkeep.erb}
RENAMED
File without changes
|
@@ -0,0 +1,57 @@
|
|
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'
|
39
|
+
end
|
40
|
+
|
41
|
+
<%- end -%>
|
42
|
+
group :test, :development do
|
43
|
+
gem 'dotenv', '~> 2.0'
|
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
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# <%= 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 create and migrate DB for development and test ENVs:
|
26
|
+
|
27
|
+
```
|
28
|
+
% bundle exec hanami db create
|
29
|
+
% bundle exec hanami db migrate
|
30
|
+
|
31
|
+
% HANAMI_ENV=test bundle exec hanami db create
|
32
|
+
% HANAMI_ENV=test bundle exec hanami db migrate
|
33
|
+
```
|
34
|
+
|
35
|
+
Explore Hanami [guides](http://hanamirb.org/guides/), [API docs](http://hanamirb.org/docs/1.0.0/), or jump in [chat](http://chat.hanamirb.org) for help. Enjoy! 🌸
|
data/lib/hanami/{generators/application/container/config.ru.tt → cli/commands/new/config.ru.erb}
RENAMED
File without changes
|
File without changes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'bundler/setup'
|
2
2
|
require 'hanami/setup'
|
3
3
|
require 'hanami/model'
|
4
|
-
require_relative '../lib/<%=
|
4
|
+
require_relative '../lib/<%= project %>'
|
5
5
|
|
6
6
|
Hanami.configure do
|
7
7
|
|
@@ -12,13 +12,13 @@ Hanami.configure do
|
|
12
12
|
# Available options:
|
13
13
|
#
|
14
14
|
# * SQL adapter
|
15
|
-
# adapter :sql, 'sqlite://db/<%=
|
16
|
-
# adapter :sql, 'postgresql://localhost/<%=
|
17
|
-
# adapter :sql, 'mysql://localhost/<%=
|
15
|
+
# adapter :sql, 'sqlite://db/<%= project %>_development.sqlite3'
|
16
|
+
# adapter :sql, 'postgresql://localhost/<%= project %>_development'
|
17
|
+
# adapter :sql, 'mysql://localhost/<%= project %>_development'
|
18
18
|
#
|
19
|
-
adapter :<%=
|
19
|
+
adapter :<%= database_config_hash[:type] %>, ENV['DATABASE_URL']
|
20
20
|
|
21
|
-
<%- if
|
21
|
+
<%- if database_config.sql? -%>
|
22
22
|
##
|
23
23
|
# Migrations
|
24
24
|
#
|
@@ -28,7 +28,7 @@ Hanami.configure do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
mailer do
|
31
|
-
root 'lib/<%=
|
31
|
+
root 'lib/<%= project %>/mailers'
|
32
32
|
|
33
33
|
# See http://hanamirb.org/guides/mailers/delivery
|
34
34
|
delivery :test
|
@@ -40,7 +40,7 @@ Hanami.configure do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
environment :production do
|
43
|
-
logger level: :info, formatter: :json
|
43
|
+
logger level: :info, formatter: :json, filter: []
|
44
44
|
|
45
45
|
mailer do
|
46
46
|
delivery :smtp, address: ENV['SMTP_HOST'], port: ENV['SMTP_PORT']
|
data/lib/hanami/{generators/application/container/gitignore.tt → cli/commands/new/gitignore.erb}
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/hanami/{generators/application/container/rspec.rspec.tt → cli/commands/new/rspec/rspec.erb}
RENAMED
File without changes
|
File without changes
|
data/lib/hanami/{generators/application/container/.gitignore → cli/commands/new/schema.sql.erb}
RENAMED
File without changes
|
@@ -0,0 +1,421 @@
|
|
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
|