dry-web-roda 0.6.3 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/CONTRIBUTING.md +29 -0
- data/Gemfile +4 -3
- data/README.md +1 -1
- data/dry-web-roda.gemspec +0 -2
- data/lib/dry/web/roda/cli.rb +2 -2
- data/lib/dry/web/roda/cli/generate.rb +1 -1
- data/lib/dry/web/roda/generate.rb +32 -34
- data/lib/dry/web/roda/generators/abstract_generator.rb +54 -0
- data/lib/dry/web/roda/generators/abstract_project.rb +118 -0
- data/lib/dry/web/roda/generators/flat_project.rb +20 -14
- data/lib/dry/web/roda/generators/sub_app.rb +34 -13
- data/lib/dry/web/roda/generators/umbrella_project.rb +10 -19
- data/lib/dry/web/roda/templates/.env.test.tt +1 -0
- data/lib/dry/web/roda/templates/.env.tt +2 -0
- data/lib/dry/web/roda/templates/.gitignore +8 -0
- data/lib/dry/web/roda/{skeletons/flat_project/lib/__underscored_app_name__ → templates}/.keep +0 -0
- data/lib/dry/web/roda/templates/.rspec +2 -0
- data/lib/dry/web/roda/{skeletons/flat_project → templates}/Gemfile +4 -3
- data/lib/dry/web/roda/{skeletons/umbrella_project → templates}/README.md.tt +2 -2
- data/lib/dry/web/roda/templates/Rakefile.tt +66 -0
- data/lib/dry/web/roda/{skeletons/flat_project/web/templates/layouts → templates}/application.html.slim +0 -0
- data/lib/dry/web/roda/templates/boot__settings.rb.tt +10 -0
- data/lib/dry/web/roda/{skeletons/flat_project → templates}/config.ru.tt +0 -0
- data/lib/dry/web/roda/{skeletons/flat_project/bin → templates}/console.tt +0 -0
- data/lib/dry/web/roda/templates/container.rb.tt +14 -0
- data/lib/dry/web/roda/{skeletons/flat_project/web/routes/example.rb.tt → templates/example_routes.rb.tt} +0 -0
- data/lib/dry/web/roda/{skeletons/flat_project/system/__underscored_app_name__ → templates/flat_project}/application.rb.tt +6 -1
- data/lib/dry/web/roda/templates/flat_project/boot.rb.tt +10 -0
- data/lib/dry/web/roda/{skeletons/flat_project/system/__underscored_app_name__ → templates}/import.rb.tt +0 -0
- data/lib/dry/web/roda/{skeletons/flat_project/system/boot → templates}/monitor.rb.tt +0 -0
- data/lib/dry/web/roda/templates/operation.rb.tt +9 -0
- data/lib/dry/web/roda/{skeletons/flat_project/system/__underscored_app_name__ → templates}/repository.rb.tt +4 -2
- data/lib/dry/web/roda/templates/rom.rb.tt +39 -0
- data/lib/dry/web/roda/{skeletons/flat_project/db → templates}/sample_data.rb +0 -0
- data/lib/dry/web/roda/{skeletons/flat_project/db → templates}/seed.rb +0 -0
- data/lib/dry/web/roda/templates/settings.rb.tt +9 -0
- data/lib/dry/web/roda/{skeletons/flat_project/bin → templates}/setup +0 -0
- data/lib/dry/web/roda/{skeletons/umbrella_project/spec/db_helper.rb.tt → templates/spec/db_spec_helper.rb.tt} +2 -3
- data/lib/dry/web/roda/templates/spec/factories/example.rb +9 -0
- data/lib/dry/web/roda/{skeletons/flat_project → templates}/spec/spec_helper.rb.tt +1 -1
- data/lib/dry/web/roda/templates/spec/support/db/factory.rb +8 -0
- data/lib/dry/web/roda/templates/spec/support/db/helpers.rb.tt +13 -0
- data/lib/dry/web/roda/templates/spec/support/web/helpers.rb.tt +9 -0
- data/lib/dry/web/roda/{skeletons/umbrella_project/spec/app_helper.rb → templates/spec/web_spec_helper.rb} +8 -6
- data/lib/dry/web/roda/{skeletons/sub_app/system/__underscored_app_name__ → templates/subapp}/application.rb.tt +6 -1
- data/lib/dry/web/roda/templates/subapp/boot.rb.tt +5 -0
- data/lib/dry/web/roda/{skeletons/sub_app/system/__underscored_app_name__ → templates/subapp}/container.rb.tt +6 -9
- data/lib/dry/web/roda/{skeletons/sub_app/system/__underscored_app_name__ → templates/subapp}/transactions.rb.tt +2 -3
- data/lib/dry/web/roda/templates/subapp/view_context.rb.tt +8 -0
- data/lib/dry/web/roda/templates/subapp/view_controller.rb.tt +17 -0
- data/lib/dry/web/roda/{skeletons/flat_project/lib → templates}/types.rb +0 -0
- data/lib/dry/web/roda/{skeletons/umbrella_project/system/__underscored_app_name__ → templates/umbrella_project}/application.rb.tt +6 -1
- data/lib/dry/web/roda/templates/umbrella_project/boot.rb.tt +16 -0
- data/lib/dry/web/roda/templates/view_context.rb.tt +43 -0
- data/lib/dry/web/roda/templates/view_controller.rb.tt +17 -0
- data/lib/dry/web/roda/{skeletons/flat_project/web/templates → templates}/welcome.html.slim +0 -0
- data/lib/dry/web/roda/{skeletons/flat_project/lib/__underscored_app_name__/views → templates}/welcome.rb.tt +2 -2
- data/lib/dry/web/roda/version.rb +1 -1
- data/lib/roda/plugins/dry_view.rb +1 -1
- data/spec/support/project.rb +1 -1
- metadata +51 -116
- data/lib/dry/web/roda/skeletons/flat_project/README.md.tt +0 -12
- data/lib/dry/web/roda/skeletons/flat_project/Rakefile.tt +0 -81
- data/lib/dry/web/roda/skeletons/flat_project/config/settings.yml.tt +0 -8
- data/lib/dry/web/roda/skeletons/flat_project/lib/persistence/commands/.keep +0 -0
- data/lib/dry/web/roda/skeletons/flat_project/lib/persistence/relations/.keep +0 -0
- data/lib/dry/web/roda/skeletons/flat_project/log/.keep +0 -0
- data/lib/dry/web/roda/skeletons/flat_project/spec/app_helper.rb +0 -35
- data/lib/dry/web/roda/skeletons/flat_project/spec/db_helper.rb.tt +0 -24
- data/lib/dry/web/roda/skeletons/flat_project/spec/support/db/test_factories.rb +0 -3
- data/lib/dry/web/roda/skeletons/flat_project/spec/support/test_helpers.rb.tt +0 -15
- data/lib/dry/web/roda/skeletons/flat_project/system/__underscored_app_name__/container.rb.tt +0 -23
- data/lib/dry/web/roda/skeletons/flat_project/system/__underscored_app_name__/settings.rb.tt +0 -17
- data/lib/dry/web/roda/skeletons/flat_project/system/__underscored_app_name__/transactions.rb.tt +0 -34
- data/lib/dry/web/roda/skeletons/flat_project/system/__underscored_app_name__/view_context.rb.tt +0 -39
- data/lib/dry/web/roda/skeletons/flat_project/system/__underscored_app_name__/view_controller.rb.tt +0 -13
- data/lib/dry/web/roda/skeletons/flat_project/system/boot.rb.tt +0 -11
- data/lib/dry/web/roda/skeletons/flat_project/system/boot/rom.rb.tt +0 -32
- data/lib/dry/web/roda/skeletons/flat_project/system/boot/view.rb.tt +0 -3
- data/lib/dry/web/roda/skeletons/flat_project/transactions/example.rb.tt +0 -10
- data/lib/dry/web/roda/skeletons/sub_app/lib/__underscored_app_name__/.keep +0 -0
- data/lib/dry/web/roda/skeletons/sub_app/lib/__underscored_app_name__/views/welcome.rb.tt +0 -11
- data/lib/dry/web/roda/skeletons/sub_app/system/__underscored_app_name__/import.rb.tt +0 -5
- data/lib/dry/web/roda/skeletons/sub_app/system/__underscored_app_name__/view_context.rb.tt +0 -6
- data/lib/dry/web/roda/skeletons/sub_app/system/__underscored_app_name__/view_controller.rb.tt +0 -13
- data/lib/dry/web/roda/skeletons/sub_app/system/boot.rb.tt +0 -8
- data/lib/dry/web/roda/skeletons/sub_app/system/boot/view.rb.tt +0 -3
- data/lib/dry/web/roda/skeletons/sub_app/transactions/example.rb.tt +0 -9
- data/lib/dry/web/roda/skeletons/sub_app/web/routes/example.rb.tt +0 -7
- data/lib/dry/web/roda/skeletons/sub_app/web/templates/layouts/application.html.slim +0 -3
- data/lib/dry/web/roda/skeletons/sub_app/web/templates/welcome.html.slim +0 -1
- data/lib/dry/web/roda/skeletons/umbrella_project/.gitignore +0 -8
- data/lib/dry/web/roda/skeletons/umbrella_project/Gemfile +0 -40
- data/lib/dry/web/roda/skeletons/umbrella_project/Rakefile.tt +0 -81
- data/lib/dry/web/roda/skeletons/umbrella_project/bin/console.tt +0 -7
- data/lib/dry/web/roda/skeletons/umbrella_project/bin/setup +0 -7
- data/lib/dry/web/roda/skeletons/umbrella_project/config.ru.tt +0 -2
- data/lib/dry/web/roda/skeletons/umbrella_project/config/settings.yml.tt +0 -8
- data/lib/dry/web/roda/skeletons/umbrella_project/db/sample_data.rb +0 -1
- data/lib/dry/web/roda/skeletons/umbrella_project/db/seed.rb +0 -1
- data/lib/dry/web/roda/skeletons/umbrella_project/lib/__underscored_app_name__/repository.rb.tt +0 -11
- data/lib/dry/web/roda/skeletons/umbrella_project/lib/__underscored_app_name__/transactions.rb.tt +0 -33
- data/lib/dry/web/roda/skeletons/umbrella_project/lib/__underscored_app_name__/view_context.rb.tt +0 -39
- data/lib/dry/web/roda/skeletons/umbrella_project/lib/persistence/commands/.keep +0 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/lib/persistence/relations/.keep +0 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/lib/types.rb +0 -6
- data/lib/dry/web/roda/skeletons/umbrella_project/log/.keep +0 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/spec/spec_helper.rb.tt +0 -61
- data/lib/dry/web/roda/skeletons/umbrella_project/spec/support/db/test_factories.rb +0 -3
- data/lib/dry/web/roda/skeletons/umbrella_project/spec/support/test_helpers.rb.tt +0 -15
- data/lib/dry/web/roda/skeletons/umbrella_project/system/__underscored_app_name__/container.rb.tt +0 -18
- data/lib/dry/web/roda/skeletons/umbrella_project/system/__underscored_app_name__/import.rb.tt +0 -5
- data/lib/dry/web/roda/skeletons/umbrella_project/system/__underscored_app_name__/settings.rb.tt +0 -17
- data/lib/dry/web/roda/skeletons/umbrella_project/system/boot.rb.tt +0 -12
- data/lib/dry/web/roda/skeletons/umbrella_project/system/boot/monitor.rb.tt +0 -9
- data/lib/dry/web/roda/skeletons/umbrella_project/system/boot/rom.rb.tt +0 -32
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 33b31bfd006852b040b770a7ca5b7967af9b3686
|
|
4
|
+
data.tar.gz: de42647467c74034df0503398cac8d7d25f3dbe1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a4b4caae50823f09588968a7027f88e4b1e5dfe1df21b70c5bccb749c9c753db05f2e7656248f4f54aa31ebf0789dea1415fac4ff24c47df7f7049129b56f413
|
|
7
|
+
data.tar.gz: b76fe02ea98f0399ed6a4fb4606ebfe18700ec60d6eb2f2aaf3f8fcef95cca4ed700fa2cb3dbf860c2088c11231e82e7aee566d082cb79f891ea444f8965c933
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
# 0.7.0 - 2017-06-16
|
|
2
|
+
|
|
3
|
+
### Added
|
|
4
|
+
|
|
5
|
+
In generated app:
|
|
6
|
+
|
|
7
|
+
- Shared `Operation` class for all application operations to inherit from (timriley)
|
|
8
|
+
- Enable `auto_restrictions` relation plugin for ROM (timriley)
|
|
9
|
+
- Register low-level database connection object as "persistence.db" in core container (timriley)
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
In generated app:
|
|
14
|
+
|
|
15
|
+
- Use full database URL to include credentials in pg_dump (lukkor)
|
|
16
|
+
- Move view controller and context classes into main lib/ dirs (timriley)
|
|
17
|
+
- Use dry-system 0.7.0 magic comments to prevent auto-registration of base repository, view controller and view context classes (timriley)
|
|
18
|
+
- Update dry-system dependency to support string paths for container root configs (timriley)
|
|
19
|
+
- [BREAKING] Use Dry::Web::Settings from dry-web 0.7.0, which loads settings from .env files instead of .yml files (timriley)
|
|
20
|
+
- [BREAKING] Provide settings object via a bootable component
|
|
21
|
+
- [BREAKING] Remove special transactions setup harness, since dry-transaction 0.10.0 supports class-based transactions
|
|
22
|
+
|
|
1
23
|
# 0.6.3 - 2017-03-02
|
|
2
24
|
|
|
3
25
|
### Changed
|
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Issue Guidelines
|
|
2
|
+
|
|
3
|
+
## Reporting bugs
|
|
4
|
+
|
|
5
|
+
If you found a bug, report an issue and describe what's the expected behavior versus what actually happens. If the bug causes a crash, attach a full backtrace. If possible, a reproduction script showing the problem is highly appreciated.
|
|
6
|
+
|
|
7
|
+
## Reporting feature requests
|
|
8
|
+
|
|
9
|
+
Report a feature request **only after discussing it first on [discuss.dry-rb.org](https://discuss.dry-rb.org)** where it was accepted. Please provide a concise description of the feature, don't link to a discussion thread, and instead summarize what was discussed.
|
|
10
|
+
|
|
11
|
+
## Reporting questions, support requests, ideas, concerns etc.
|
|
12
|
+
|
|
13
|
+
**PLEASE DON'T** - use [discuss.dry-rb.org](http://discuss.dry-rb.org) instead.
|
|
14
|
+
|
|
15
|
+
# Pull Request Guidelines
|
|
16
|
+
|
|
17
|
+
A Pull Request will only be accepted if it addresses a specific issue that was reported previously, or fixes typos, mistakes in documentation etc.
|
|
18
|
+
|
|
19
|
+
Other requirements:
|
|
20
|
+
|
|
21
|
+
1) Do not open a pull request if you can't provide tests along with it. If you have problems writing tests, ask for help in the related issue.
|
|
22
|
+
2) Follow the style conventions of the surrounding code. In most cases, this is standard ruby style.
|
|
23
|
+
3) Add API documentation if it's a new feature
|
|
24
|
+
4) Update API documentation if it changes an existing feature
|
|
25
|
+
5) Bonus points for sending a PR to [github.com/dry-rb/dry-rb.org](github.com/dry-rb/dry-rb.org) which updates user documentation and guides
|
|
26
|
+
|
|
27
|
+
# Asking for help
|
|
28
|
+
|
|
29
|
+
If these guidelines aren't helpful, and you're stuck, please post a message on [discuss.dry-rb.org](https://discuss.dry-rb.org).
|
data/Gemfile
CHANGED
|
@@ -7,7 +7,8 @@ gem 'byebug', platform: :mri
|
|
|
7
7
|
gem 'codeclimate-test-reporter', platform: :rbx
|
|
8
8
|
|
|
9
9
|
# Generated application dependencies
|
|
10
|
-
gem "dry-
|
|
10
|
+
gem "dry-system", ">= 0.7.1"
|
|
11
|
+
gem "dry-web", ">= 0.7.0"
|
|
11
12
|
gem "puma"
|
|
12
13
|
gem "rack_csrf"
|
|
13
14
|
gem "rack", ">= 2.0"
|
|
@@ -18,10 +19,10 @@ gem "rom-sql"
|
|
|
18
19
|
gem "dry-matcher"
|
|
19
20
|
gem "dry-monads"
|
|
20
21
|
gem "dry-struct"
|
|
21
|
-
gem "dry-transaction"
|
|
22
|
+
gem "dry-transaction", ">= 0.10.0"
|
|
22
23
|
gem "dry-types"
|
|
23
24
|
gem "dry-validation"
|
|
24
|
-
gem "dry-view", ">= 0.
|
|
25
|
+
gem "dry-view", ">= 0.3.0"
|
|
25
26
|
gem "slim"
|
|
26
27
|
gem "pry-byebug", platform: :mri
|
|
27
28
|
gem "capybara"
|
data/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
[][codeclimate]
|
|
12
12
|
[][inchpages]
|
|
13
13
|
|
|
14
|
-
Integration between dry-web and roda.
|
|
14
|
+
Integration between [dry-web](https://github.com/dry-rb/dry-web) and [roda](https://github.com/jeremyevans/roda).
|
|
15
15
|
|
|
16
16
|
dry-web-roda offers a CLI for generating new projects.
|
|
17
17
|
|
data/dry-web-roda.gemspec
CHANGED
|
@@ -20,8 +20,6 @@ Gem::Specification.new do |spec|
|
|
|
20
20
|
|
|
21
21
|
spec.required_ruby_version = '>= 2.2.0'
|
|
22
22
|
|
|
23
|
-
spec.add_runtime_dependency "dry-web", "~> 0.6", ">= 0.6.0"
|
|
24
|
-
spec.add_runtime_dependency "dry-monitor"
|
|
25
23
|
spec.add_runtime_dependency "dry-configurable", "~> 0.2"
|
|
26
24
|
spec.add_runtime_dependency "inflecto", "~> 0.0"
|
|
27
25
|
spec.add_runtime_dependency "roda", "~> 2.14"
|
data/lib/dry/web/roda/cli.rb
CHANGED
|
@@ -10,10 +10,10 @@ module Dry
|
|
|
10
10
|
case options[:arch]
|
|
11
11
|
when "umbrella"
|
|
12
12
|
require "dry/web/roda/generators/umbrella_project"
|
|
13
|
-
Generators::UmbrellaProject.new
|
|
13
|
+
Generators::UmbrellaProject.new(app_name).call
|
|
14
14
|
when "flat"
|
|
15
15
|
require "dry/web/roda/generators/flat_project"
|
|
16
|
-
Generators::FlatProject.new
|
|
16
|
+
Generators::FlatProject.new(app_name).call
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
@@ -9,7 +9,7 @@ module Dry
|
|
|
9
9
|
option :umbrella, required: true, banner: "UMBRELLA_NAME", desc: "Provide the name of the umbrella app, e.g. my_project"
|
|
10
10
|
def sub_app(app_name)
|
|
11
11
|
require "dry/web/roda/generators/sub_app"
|
|
12
|
-
Dry::Web::Roda::Generators::SubApp.new
|
|
12
|
+
Dry::Web::Roda::Generators::SubApp.new(app_name, umbrella: options[:umbrella]).call
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
end
|
|
@@ -5,48 +5,46 @@ module Dry
|
|
|
5
5
|
module Web
|
|
6
6
|
module Roda
|
|
7
7
|
class Generate
|
|
8
|
-
|
|
8
|
+
TEMPLATES_DIR = "templates".freeze
|
|
9
|
+
SOURCE_DIR = Pathname(__FILE__).dirname.join(TEMPLATES_DIR)
|
|
9
10
|
|
|
10
|
-
attr_reader :
|
|
11
|
-
attr_reader :processor
|
|
11
|
+
attr_reader :target_dir, :template_scope, :template_files, :processor
|
|
12
12
|
|
|
13
|
-
def initialize(
|
|
14
|
-
@
|
|
13
|
+
def initialize(target_dir, template_scope)
|
|
14
|
+
@target_dir = target_dir
|
|
15
|
+
@template_scope = template_scope
|
|
16
|
+
@template_files = Dir[SOURCE_DIR.join('**/{.,}*')]
|
|
15
17
|
|
|
16
18
|
@processor = Class.new(Thor) do
|
|
17
19
|
include Thor::Actions
|
|
18
20
|
end.new
|
|
19
|
-
@processor.class.source_root
|
|
21
|
+
@processor.class.source_root SOURCE_DIR
|
|
20
22
|
end
|
|
21
23
|
|
|
22
|
-
def call(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if source_file.file? && source_file.executable?
|
|
47
|
-
FileUtils.chmod "a+x", target_file
|
|
48
|
-
end
|
|
49
|
-
end
|
|
24
|
+
def call(source, target)
|
|
25
|
+
source = Pathname(source)
|
|
26
|
+
aboslute_source_path = source.expand_path(SOURCE_DIR)
|
|
27
|
+
target_file = get_target_file(target)
|
|
28
|
+
template_file = template_files.find { |f| f == aboslute_source_path.to_s } or raise "missing template file +#{source}+"
|
|
29
|
+
template_file = Pathname(template_file)
|
|
30
|
+
|
|
31
|
+
processor.template template_file, target_file, template_scope
|
|
32
|
+
|
|
33
|
+
create_executable(target_file) if executable?(template_file)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
def get_target_file(target)
|
|
39
|
+
Pathname.getwd.join(target_dir, target)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def create_executable(file)
|
|
43
|
+
FileUtils.chmod "a+x", file
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def executable?(file)
|
|
47
|
+
file.file? && file.executable?
|
|
50
48
|
end
|
|
51
49
|
end
|
|
52
50
|
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
require "dry/web/roda/generate"
|
|
2
|
+
require "dry/web/roda/generators/inflections"
|
|
3
|
+
|
|
4
|
+
module Dry
|
|
5
|
+
module Web
|
|
6
|
+
module Roda
|
|
7
|
+
module Generators
|
|
8
|
+
class AbstractGenerator
|
|
9
|
+
attr_reader :target_dir, :options
|
|
10
|
+
|
|
11
|
+
def initialize(target_dir, options = {})
|
|
12
|
+
@target_dir = target_dir
|
|
13
|
+
@options = options
|
|
14
|
+
@templates = []
|
|
15
|
+
populate_templates
|
|
16
|
+
@templates.freeze
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def call
|
|
20
|
+
templates.each do |source, target|
|
|
21
|
+
generator.(source, target)
|
|
22
|
+
end
|
|
23
|
+
post_process_callback
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
attr_reader :templates
|
|
28
|
+
|
|
29
|
+
def add_template(source, target)
|
|
30
|
+
templates << [source, target]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def generator
|
|
34
|
+
@generator ||= Generate.new(destination, template_scope)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def post_process_callback; end
|
|
38
|
+
|
|
39
|
+
def underscored_project_name
|
|
40
|
+
@underscored_project_name ||= Inflections.underscored_name(target_dir)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def template_scope
|
|
44
|
+
fail NotImplementedError
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def destination
|
|
48
|
+
fail NotImplementedError
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
require "securerandom"
|
|
2
|
+
require "dry/web/roda/generators/abstract_generator"
|
|
3
|
+
|
|
4
|
+
module Dry
|
|
5
|
+
module Web
|
|
6
|
+
module Roda
|
|
7
|
+
module Generators
|
|
8
|
+
class AbstractProject < AbstractGenerator
|
|
9
|
+
def populate_templates
|
|
10
|
+
add_bin
|
|
11
|
+
add_config
|
|
12
|
+
add_db
|
|
13
|
+
add_log
|
|
14
|
+
add_spec
|
|
15
|
+
add_lib
|
|
16
|
+
add_system
|
|
17
|
+
add_boot
|
|
18
|
+
add_application
|
|
19
|
+
add_config_files
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def destination
|
|
25
|
+
target_dir
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def template_scope
|
|
29
|
+
{
|
|
30
|
+
underscored_project_name: underscored_project_name,
|
|
31
|
+
camel_cased_app_name: Inflections.camel_cased_name(target_dir)
|
|
32
|
+
}
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def add_bin
|
|
36
|
+
add_template('console.tt', 'bin/console')
|
|
37
|
+
add_template('setup', 'bin/setup')
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def add_config
|
|
41
|
+
add_template('.env.tt', '.env')
|
|
42
|
+
add_template('.env.test.tt', '.env.test')
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def add_db
|
|
46
|
+
add_template('sample_data.rb', 'db/sample_data.rb')
|
|
47
|
+
add_template('seed.rb', 'db/seed.rb')
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def add_lib
|
|
51
|
+
add_template('types.rb', 'lib/types.rb')
|
|
52
|
+
add_template('operation.rb.tt', "lib/#{underscored_project_name}/operation.rb")
|
|
53
|
+
add_template('repository.rb.tt', "lib/#{underscored_project_name}/repository.rb")
|
|
54
|
+
add_template('.keep', 'lib/persistance/relations/.keep')
|
|
55
|
+
add_template('.keep', 'lib/persistance/commands/.keep')
|
|
56
|
+
add_template('view_context.rb.tt', "lib/#{underscored_project_name}/view/context.rb")
|
|
57
|
+
add_template('view_controller.rb.tt', "lib/#{underscored_project_name}/view/controller.rb")
|
|
58
|
+
add_template('welcome.rb.tt', "lib/#{underscored_project_name}/views/welcome.rb")
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def add_log
|
|
62
|
+
add_template('.keep', 'log/.keep')
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def add_spec
|
|
66
|
+
add_template('.rspec', '.rspec')
|
|
67
|
+
|
|
68
|
+
# Base spec helpers
|
|
69
|
+
add_template('spec/web_spec_helper.rb', 'spec/web_spec_helper.rb')
|
|
70
|
+
add_template('spec/db_spec_helper.rb.tt', 'spec/db_spec_helper.rb')
|
|
71
|
+
add_template('spec/spec_helper.rb.tt', 'spec/spec_helper.rb')
|
|
72
|
+
|
|
73
|
+
# DB support
|
|
74
|
+
add_template('spec/support/db/factory.rb', 'spec/support/db/factory.rb')
|
|
75
|
+
add_template('spec/support/db/helpers.rb.tt', 'spec/support/db/helpers.rb')
|
|
76
|
+
add_template('spec/factories/example.rb', 'spec/factories/example.rb')
|
|
77
|
+
|
|
78
|
+
# Web support
|
|
79
|
+
add_template('spec/support/web/helpers.rb.tt', 'spec/support/web/helpers.rb')
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def add_system
|
|
83
|
+
add_system_lib
|
|
84
|
+
add_system_boot
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def add_boot
|
|
88
|
+
raise NotImplementedError
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def add_application
|
|
92
|
+
raise NotImplementedError
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def add_system_lib
|
|
96
|
+
add_template("container.rb.tt", "system/#{underscored_project_name}/container.rb")
|
|
97
|
+
add_template("import.rb.tt", "system/#{underscored_project_name}/import.rb")
|
|
98
|
+
add_template("settings.rb.tt", "system/#{underscored_project_name}/settings.rb")
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def add_system_boot
|
|
102
|
+
add_template("monitor.rb.tt", "system/boot/monitor.rb")
|
|
103
|
+
add_template("rom.rb.tt", "system/boot/rom.rb")
|
|
104
|
+
add_template("boot__settings.rb.tt", "system/boot/settings.rb")
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def add_config_files
|
|
108
|
+
add_template('.gitignore', '.gitignore')
|
|
109
|
+
add_template('Gemfile', 'Gemfile')
|
|
110
|
+
add_template('Rakefile.tt', 'Rakefile')
|
|
111
|
+
add_template('config.ru.tt', 'config.ru')
|
|
112
|
+
add_template('README.md.tt', 'README.md')
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
require "securerandom"
|
|
2
|
-
require "dry/web/roda/
|
|
3
|
-
require "dry/web/roda/generators/inflections"
|
|
2
|
+
require "dry/web/roda/generators/abstract_project"
|
|
4
3
|
|
|
5
4
|
module Dry
|
|
6
5
|
module Web
|
|
7
6
|
module Roda
|
|
8
7
|
module Generators
|
|
9
|
-
class FlatProject
|
|
10
|
-
|
|
8
|
+
class FlatProject < AbstractProject
|
|
9
|
+
def populate_templates
|
|
10
|
+
super
|
|
11
|
+
add_views
|
|
12
|
+
add_web
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
private
|
|
11
16
|
|
|
12
|
-
def
|
|
13
|
-
|
|
17
|
+
def add_boot
|
|
18
|
+
add_template("flat_project/boot.rb.tt", "system/boot.rb")
|
|
14
19
|
end
|
|
15
20
|
|
|
16
|
-
def
|
|
17
|
-
|
|
21
|
+
def add_application
|
|
22
|
+
add_template("flat_project/application.rb.tt", "system/#{underscored_project_name}/application.rb")
|
|
18
23
|
end
|
|
19
24
|
|
|
20
|
-
|
|
25
|
+
def add_views
|
|
26
|
+
add_template('welcome.rb.tt', "lib/#{underscored_project_name}/views/welcome.rb")
|
|
27
|
+
end
|
|
21
28
|
|
|
22
|
-
def
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
29
|
+
def add_web
|
|
30
|
+
add_template('example_routes.rb.tt', 'web/routes/example.rb')
|
|
31
|
+
add_template('application.html.slim', 'web/templates/layouts/application.html.slim')
|
|
32
|
+
add_template('welcome.html.slim', 'web/templates/welcome.html.slim')
|
|
27
33
|
end
|
|
28
34
|
end
|
|
29
35
|
end
|
|
@@ -1,29 +1,50 @@
|
|
|
1
|
-
require "dry/web/roda/
|
|
2
|
-
require "dry/web/roda/generators/inflections"
|
|
1
|
+
require "dry/web/roda/generators/abstract_generator"
|
|
3
2
|
|
|
4
3
|
module Dry
|
|
5
4
|
module Web
|
|
6
5
|
module Roda
|
|
7
6
|
module Generators
|
|
8
|
-
class SubApp
|
|
9
|
-
|
|
7
|
+
class SubApp < AbstractGenerator
|
|
8
|
+
def populate_templates
|
|
9
|
+
add_lib
|
|
10
|
+
add_system
|
|
11
|
+
add_web
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def destination
|
|
17
|
+
options.fetch(:to) { File.join("apps", target_dir) }
|
|
18
|
+
end
|
|
10
19
|
|
|
11
|
-
def
|
|
12
|
-
|
|
20
|
+
def umbrella_name
|
|
21
|
+
options.fetch(:umbrella)
|
|
13
22
|
end
|
|
14
23
|
|
|
15
|
-
def
|
|
16
|
-
|
|
17
|
-
|
|
24
|
+
def add_lib
|
|
25
|
+
add_template('subapp/view_context.rb.tt', "lib/#{underscored_project_name}/view/context.rb")
|
|
26
|
+
add_template('subapp/view_controller.rb.tt', "lib/#{underscored_project_name}/view/controller.rb")
|
|
27
|
+
add_template('welcome.rb.tt', "lib/#{underscored_project_name}/views/welcome.rb")
|
|
28
|
+
add_template('.keep', "lib/#{underscored_project_name}/.keep")
|
|
29
|
+
end
|
|
18
30
|
|
|
19
|
-
|
|
31
|
+
def add_system
|
|
32
|
+
%w(application container).each do |file|
|
|
33
|
+
add_template("subapp/#{file}.rb.tt", "system/#{underscored_project_name}/#{file}.rb")
|
|
34
|
+
end
|
|
35
|
+
add_template('import.rb.tt', "system/#{underscored_project_name}/import.rb")
|
|
36
|
+
add_template('subapp/boot.rb.tt', 'system/boot.rb')
|
|
20
37
|
end
|
|
21
38
|
|
|
22
|
-
|
|
39
|
+
def add_web
|
|
40
|
+
add_template('example_routes.rb.tt', 'web/routes/example.rb')
|
|
41
|
+
add_template('application.html.slim', 'web/templates/layouts/application.html.slim')
|
|
42
|
+
add_template('welcome.html.slim', 'web/templates/welcome.html.slim')
|
|
43
|
+
end
|
|
23
44
|
|
|
24
|
-
def
|
|
45
|
+
def template_scope
|
|
25
46
|
{
|
|
26
|
-
|
|
47
|
+
underscored_project_name: underscored_project_name,
|
|
27
48
|
camel_cased_app_name: Inflections.camel_cased_name(target_dir),
|
|
28
49
|
underscored_umbrella_name: Inflections.underscored_name(umbrella_name),
|
|
29
50
|
camel_cased_umbrella_name: Inflections.camel_cased_name(umbrella_name),
|