dry-web-roda 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +7 -1
  3. data/.rspec +1 -2
  4. data/.travis.yml +14 -8
  5. data/CHANGELOG.md +22 -0
  6. data/Gemfile +26 -15
  7. data/README.md +22 -4
  8. data/dry-web-roda.gemspec +3 -1
  9. data/lib/dry/web/roda/application.rb +3 -3
  10. data/lib/dry/web/roda/cli.rb +9 -2
  11. data/lib/dry/web/roda/cli/generate.rb +4 -4
  12. data/lib/dry/web/roda/generators/flat_project.rb +31 -0
  13. data/lib/dry/web/roda/generators/{app.rb → sub_app.rb} +2 -2
  14. data/lib/dry/web/roda/generators/{umbrella.rb → umbrella_project.rb} +6 -6
  15. data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/Gemfile +3 -3
  16. data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/README.md.tt +0 -0
  17. data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/Rakefile.tt +0 -0
  18. data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/bin/console.tt +0 -0
  19. data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/bin/setup +0 -0
  20. data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/config.ru.tt +0 -0
  21. data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/config/settings.yml.tt +0 -0
  22. data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/db/sample_data.rb +0 -0
  23. data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/db/seed.rb +0 -0
  24. data/lib/dry/web/roda/skeletons/{app → flat_project}/lib/__underscored_app_name__/.keep +0 -0
  25. data/lib/dry/web/roda/skeletons/{app → flat_project}/lib/__underscored_app_name__/views/welcome.rb.tt +0 -0
  26. data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/lib/persistence/commands/.keep +0 -0
  27. data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/lib/persistence/relations/.keep +0 -0
  28. data/lib/dry/web/roda/skeletons/flat_project/lib/rom/instrumentation.rb.tt +22 -0
  29. data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/lib/types.rb +0 -0
  30. data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/log/.keep +0 -0
  31. data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/spec/app_helper.rb +0 -0
  32. data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/spec/db_helper.rb.tt +0 -0
  33. data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/spec/spec_helper.rb.tt +0 -0
  34. data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/spec/support/db/test_factories.rb +0 -0
  35. data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/spec/support/test_helpers.rb.tt +0 -0
  36. data/lib/dry/web/roda/skeletons/flat_project/system/__underscored_app_name__/application.rb.tt +29 -0
  37. data/lib/dry/web/roda/skeletons/flat_project/system/__underscored_app_name__/container.rb.tt +23 -0
  38. data/lib/dry/web/roda/skeletons/{app → flat_project}/system/__underscored_app_name__/import.rb.tt +0 -0
  39. data/lib/dry/web/roda/skeletons/{umbrella/lib → flat_project/system}/__underscored_app_name__/repository.rb.tt +0 -0
  40. data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/system/__underscored_app_name__/settings.rb.tt +0 -0
  41. data/lib/dry/web/roda/skeletons/flat_project/system/__underscored_app_name__/transactions.rb.tt +34 -0
  42. data/lib/dry/web/roda/skeletons/{umbrella/lib → flat_project/system}/__underscored_app_name__/view_context.rb.tt +0 -0
  43. data/lib/dry/web/roda/skeletons/{app → flat_project}/system/__underscored_app_name__/view_controller.rb.tt +0 -0
  44. data/lib/dry/web/roda/skeletons/flat_project/system/boot.rb.tt +11 -0
  45. data/lib/dry/web/roda/skeletons/flat_project/system/boot/monitor.rb.tt +10 -0
  46. data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/system/boot/rom.rb.tt +0 -0
  47. data/lib/dry/web/roda/skeletons/{app → flat_project}/system/boot/view.rb.tt +0 -0
  48. data/lib/dry/web/roda/skeletons/flat_project/transactions/example.rb.tt +10 -0
  49. data/lib/dry/web/roda/skeletons/{app → flat_project}/web/routes/example.rb.tt +0 -0
  50. data/lib/dry/web/roda/skeletons/{app → flat_project}/web/templates/layouts/application.html.slim +0 -0
  51. data/lib/dry/web/roda/skeletons/{app → flat_project}/web/templates/welcome.html.slim +0 -0
  52. data/lib/dry/web/roda/skeletons/sub_app/lib/__underscored_app_name__/.keep +0 -0
  53. data/lib/dry/web/roda/skeletons/sub_app/lib/__underscored_app_name__/views/welcome.rb.tt +11 -0
  54. data/lib/dry/web/roda/skeletons/{app → sub_app}/system/__underscored_app_name__/application.rb.tt +1 -1
  55. data/lib/dry/web/roda/skeletons/{app → sub_app}/system/__underscored_app_name__/container.rb.tt +2 -0
  56. data/lib/dry/web/roda/skeletons/{umbrella → sub_app}/system/__underscored_app_name__/import.rb.tt +0 -0
  57. data/lib/dry/web/roda/skeletons/{app → sub_app}/system/__underscored_app_name__/transactions.rb.tt +0 -0
  58. data/lib/dry/web/roda/skeletons/{app → sub_app}/system/__underscored_app_name__/view_context.rb.tt +0 -0
  59. data/lib/dry/web/roda/skeletons/sub_app/system/__underscored_app_name__/view_controller.rb.tt +13 -0
  60. data/lib/dry/web/roda/skeletons/{app → sub_app}/system/boot.rb.tt +1 -2
  61. data/lib/dry/web/roda/skeletons/sub_app/system/boot/view.rb.tt +3 -0
  62. data/lib/dry/web/roda/skeletons/{app → sub_app}/transactions/example.rb.tt +0 -0
  63. data/lib/dry/web/roda/skeletons/sub_app/web/routes/example.rb.tt +7 -0
  64. data/lib/dry/web/roda/skeletons/sub_app/web/templates/layouts/application.html.slim +3 -0
  65. data/lib/dry/web/roda/skeletons/sub_app/web/templates/welcome.html.slim +1 -0
  66. data/lib/dry/web/roda/skeletons/{umbrella → umbrella_project}/.gitignore +0 -0
  67. data/lib/dry/web/roda/skeletons/umbrella_project/Gemfile +39 -0
  68. data/lib/dry/web/roda/skeletons/umbrella_project/README.md.tt +12 -0
  69. data/lib/dry/web/roda/skeletons/umbrella_project/Rakefile.tt +81 -0
  70. data/lib/dry/web/roda/skeletons/umbrella_project/bin/console.tt +7 -0
  71. data/lib/dry/web/roda/skeletons/umbrella_project/bin/setup +7 -0
  72. data/lib/dry/web/roda/skeletons/umbrella_project/config.ru.tt +2 -0
  73. data/lib/dry/web/roda/skeletons/umbrella_project/config/settings.yml.tt +8 -0
  74. data/lib/dry/web/roda/skeletons/umbrella_project/db/sample_data.rb +1 -0
  75. data/lib/dry/web/roda/skeletons/umbrella_project/db/seed.rb +1 -0
  76. data/lib/dry/web/roda/skeletons/umbrella_project/lib/__underscored_app_name__/repository.rb.tt +11 -0
  77. data/lib/dry/web/roda/skeletons/{umbrella → umbrella_project}/lib/__underscored_app_name__/transactions.rb.tt +0 -0
  78. data/lib/dry/web/roda/skeletons/umbrella_project/lib/__underscored_app_name__/view_context.rb.tt +39 -0
  79. data/lib/dry/web/roda/skeletons/umbrella_project/lib/persistence/commands/.keep +0 -0
  80. data/lib/dry/web/roda/skeletons/umbrella_project/lib/persistence/relations/.keep +0 -0
  81. data/lib/dry/web/roda/skeletons/umbrella_project/lib/rom/instrumentation.rb.tt +22 -0
  82. data/lib/dry/web/roda/skeletons/umbrella_project/lib/types.rb +6 -0
  83. data/lib/dry/web/roda/skeletons/umbrella_project/log/.keep +0 -0
  84. data/lib/dry/web/roda/skeletons/umbrella_project/spec/app_helper.rb +35 -0
  85. data/lib/dry/web/roda/skeletons/umbrella_project/spec/db_helper.rb.tt +24 -0
  86. data/lib/dry/web/roda/skeletons/umbrella_project/spec/spec_helper.rb.tt +61 -0
  87. data/lib/dry/web/roda/skeletons/umbrella_project/spec/support/db/test_factories.rb +3 -0
  88. data/lib/dry/web/roda/skeletons/umbrella_project/spec/support/test_helpers.rb.tt +15 -0
  89. data/lib/dry/web/roda/skeletons/umbrella_project/system/__underscored_app_name__/application.rb.tt +14 -0
  90. data/lib/dry/web/roda/skeletons/{umbrella → umbrella_project}/system/__underscored_app_name__/container.rb.tt +1 -0
  91. data/lib/dry/web/roda/skeletons/umbrella_project/system/__underscored_app_name__/import.rb.tt +5 -0
  92. data/lib/dry/web/roda/skeletons/umbrella_project/system/__underscored_app_name__/settings.rb.tt +17 -0
  93. data/lib/dry/web/roda/skeletons/{umbrella → umbrella_project}/system/boot.rb.tt +0 -0
  94. data/lib/dry/web/roda/skeletons/umbrella_project/system/boot/monitor.rb.tt +10 -0
  95. data/lib/dry/web/roda/skeletons/umbrella_project/system/boot/rom.rb.tt +26 -0
  96. data/lib/dry/web/roda/version.rb +1 -1
  97. data/script/ci +67 -0
  98. data/script/setup +47 -0
  99. data/script/teardown +42 -0
  100. data/spec/integration/new_app_spec.rb +21 -0
  101. data/spec/spec_helper.rb +14 -16
  102. data/spec/support/app.rb +64 -0
  103. data/spec/support/bundler.rb +113 -0
  104. data/spec/support/cli.rb +47 -0
  105. data/spec/support/directories.rb +37 -0
  106. data/spec/support/env.rb +84 -0
  107. data/spec/support/files.rb +59 -0
  108. data/spec/support/project.rb +60 -0
  109. data/spec/support/requests.rb +5 -0
  110. data/spec/support/silently.rb +28 -0
  111. metadata +139 -49
  112. data/lib/dry/web/roda/skeletons/umbrella/system/__underscored_app_name__/application.rb.tt +0 -7
  113. data/lib/dry/web/roda/skeletons/umbrella/system/boot/logger.rb.tt +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae7be8dfee807179e26795b99b21373e09af8136
4
- data.tar.gz: b0617d0d7ead77a504ba4caa3487bb5c171814d0
3
+ metadata.gz: 2687d6c62fe47551a7f1d73de05dfbe8350e60a2
4
+ data.tar.gz: a94145d9896fa2ac5059f0aa372f3df86d0b1005
5
5
  SHA512:
6
- metadata.gz: 22456e206baab37dcb943358c5a4ccf99d85b1365b4d0a56756ac0eaa87a19f82ec1cf684c75df3a20b6da5245f7a255b1369d09c7bdafd92f92c532fb631e75
7
- data.tar.gz: 9b5832e568862fd71249c29f9580b0937a2157cacbdd0f25baa75a803dc73b30b550ca430baa86f3601c44ff23e0de3dff963a847464ed805ec223fbb6c4001e
6
+ metadata.gz: f32d05abe77ab8d0b687e091cfa0f4c0384bc5558ae76d909eaf4f6a6e2eeb0431f5b8c3af4b487537a71ad097ca68cdbfaa9a076e3cc7bd4aebcb00b90514a7
7
+ data.tar.gz: c8547744187747d7c505f8cb3f9ac294d52edd305ae428428683fff964b13e35adc8665865c7028feb7035fe0de56a9923bfee9b8a5f21cce50e5ad50589575c
data/.gitignore CHANGED
@@ -4,11 +4,14 @@
4
4
  /coverage/
5
5
  /InstalledFiles
6
6
  /pkg/
7
- /spec/reports/
8
7
  /test/tmp/
9
8
  /test/version_tmp/
10
9
  /tmp/
11
10
 
11
+ ## Testing
12
+ /spec/reports/
13
+ /spec/examples.txt
14
+
12
15
  ## Documentation cache and generated files:
13
16
  /.yardoc/
14
17
  /_yardoc/
@@ -27,3 +30,6 @@ Gemfile.lock
27
30
 
28
31
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
29
32
  .rvmrc
33
+
34
+ .byebug_history
35
+ /vendor/cache/
data/.rspec CHANGED
@@ -1,3 +1,2 @@
1
1
  --color
2
- --order random
3
- --require ./spec/spec_helper.rb
2
+ --require spec_helper
@@ -1,21 +1,27 @@
1
1
  language: ruby
2
+ dist: trusty
2
3
  sudo: false
4
+ services:
5
+ - postgresql
3
6
  cache: bundler
4
- bundler_args: --without tools
7
+ install: true
8
+ before_install:
9
+ - gem update --system
10
+ before_script:
11
+ - psql -c 'create database sandbox_test;' -U postgres
5
12
  script:
6
- - bundle exec rake spec
13
+ - ./script/ci
7
14
  rvm:
8
- - 2.1
9
- - 2.2
10
- - 2.3.0
11
- - rbx
12
- - jruby-9000
15
+ - 2.4.0
16
+ - 2.3.3
17
+ - 2.2.6
18
+ - jruby-9.1.6.0
13
19
  env:
14
20
  global:
15
21
  - JRUBY_OPTS='--dev -J-Xmx1024M'
16
22
  matrix:
17
23
  allow_failures:
18
- - rvm: rbx
24
+ - rvm: jruby-9.1.6.0
19
25
  notifications:
20
26
  email: false
21
27
  webhooks:
@@ -1,3 +1,25 @@
1
+ # 0.6.1 - 2017-02-08
2
+
3
+ ### Added
4
+
5
+ - In generated projects, set up dry-monitor for request logging (timriley)
6
+ - In generated projects, use dry-monitor to log SQL queries (timriley)
7
+ - Add new flat project generator: `dry-web-roda new <your_app> --arch=flat` (timriley)
8
+
9
+ ### Changed
10
+
11
+ - Renamed sub-app generator from `dry-web-roda generate app` to `dry-web-roda generate sub_app` (timriley)
12
+
13
+ ### Fixed
14
+
15
+ - Ensure dry-monitor is set up in `Application` regardless of the order in which the application's configs are applied (timriley)
16
+
17
+ # 0.6.1 - 2017-02-03
18
+
19
+ ### Added
20
+
21
+ - In generated projects, integrate with dry-monitor (via dry-web) for centralized application logging and error reporting (solnic)
22
+
1
23
  # 0.5.1 - 2016-12-27
2
24
 
3
25
  ### Fixed
data/Gemfile CHANGED
@@ -1,20 +1,31 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in rodakase.gemspec
4
3
  gemspec
5
4
 
6
- group :test do
7
- gem 'byebug', platform: :mri
8
- gem 'rack', '>= 1.0.0', '<= 2.0.0'
9
- gem 'rack-test'
10
- gem 'dry-monads'
11
- gem 'dry-transaction'
12
- gem 'dry-view'
13
- gem 'slim'
5
+ gem 'pry'
6
+ gem 'byebug', platform: :mri
7
+ gem 'codeclimate-test-reporter', platform: :rbx
14
8
 
15
- gem 'codeclimate-test-reporter', platform: :rbx
16
- end
17
-
18
- group :tools do
19
- gem 'pry'
20
- end
9
+ # Generated application dependencies
10
+ gem "dry-web", ">= 0.6.0"
11
+ gem "puma"
12
+ gem "rack_csrf"
13
+ gem "rack", ">= 2.0"
14
+ gem "shotgun", ">= 0.9.2"
15
+ gem "pg"
16
+ gem "rom-repository"
17
+ gem "rom-sql"
18
+ gem "dry-matcher"
19
+ gem "dry-monads"
20
+ gem "dry-struct"
21
+ gem "dry-transaction"
22
+ gem "dry-types"
23
+ gem "dry-validation"
24
+ gem "dry-view", ">= 0.2.2"
25
+ gem "slim"
26
+ gem "pry-byebug", platform: :mri
27
+ gem "capybara"
28
+ gem "capybara-screenshot"
29
+ gem "database_cleaner"
30
+ gem "poltergeist"
31
+ gem "rspec"
data/README.md CHANGED
@@ -13,16 +13,28 @@
13
13
 
14
14
  Integration between dry-web and roda.
15
15
 
16
- dry-web-roda offers a CLI for generating new projects:
16
+ dry-web-roda offers a CLI for generating new projects.
17
+
18
+ ### Umbrella projects
19
+
20
+ To generate a new _umbrella project_ (functionality divided into sub-apps):
17
21
 
18
22
  ```sh
19
- $ dry-web-roda new <project_name>
23
+ $ dry-web-roda new <your_project_name>
20
24
  ```
21
25
 
22
- And building apps within projects:
26
+ And to generate sub-apps within your project:
23
27
 
24
28
  ```sh
25
- $ dry-web-roda generate app <my_sub_app_name>
29
+ $ dry-web-roda generate sub_app <your_sub_app_name> --umbrella=<your_project_name>
30
+ ```
31
+
32
+ ### Flat projects
33
+
34
+ To generate a new _flat project_ (a simpler architecture, with a single module for your entire app):
35
+
36
+ ```sh
37
+ $ dry-web-roda new <your_project_name> --arch=flat
26
38
  ```
27
39
 
28
40
  ## LICENSE
@@ -32,3 +44,9 @@ See `LICENSE` file.
32
44
  ## Contributing
33
45
 
34
46
  Bug reports and pull requests are welcome on GitHub at https://github.com/dry-rb/dry-web-roda.
47
+
48
+ ## Acknowledgements
49
+
50
+ The support code for testing the CLI and generated app are derived from
51
+ [hanami/hanami](https://github.com/hanami/hanami). Thank you to Luca and the
52
+ Hanami team!
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.required_ruby_version = '>= 2.1.0'
21
+ spec.required_ruby_version = '>= 2.2.0'
22
22
 
23
23
  spec.add_runtime_dependency "dry-web", "~> 0.6", ">= 0.6.0"
24
24
  spec.add_runtime_dependency "dry-monitor"
@@ -28,8 +28,10 @@ Gem::Specification.new do |spec|
28
28
  spec.add_runtime_dependency "roda-flow", "~> 0.3"
29
29
  spec.add_runtime_dependency "thor", "~> 0.19"
30
30
 
31
+ spec.add_development_dependency "aruba"
31
32
  spec.add_development_dependency "bundler", "~> 1.7"
32
33
  spec.add_development_dependency "rake", "~> 11.0"
33
34
  spec.add_development_dependency "rspec", "~> 3.4"
34
35
  spec.add_development_dependency "capybara", "~> 2.5"
36
+ spec.add_development_dependency "waitutil"
35
37
  end
@@ -16,9 +16,9 @@ module Dry
16
16
  plugin :error_handler
17
17
 
18
18
  def self.configure(&block)
19
- container = super
20
- use(container[:rack_monitor])
21
- container
19
+ super.tap do
20
+ use(config.container[:rack_monitor])
21
+ end
22
22
  end
23
23
 
24
24
  def self.resolve(name)
@@ -5,9 +5,16 @@ module Dry
5
5
  module Roda
6
6
  class CLI < Thor
7
7
  desc "new APP", "Generate a new dry-web-roda project"
8
+ option :arch, required: false, default: "umbrella", enum: %w[umbrella flat], banner: "ARCH", desc: "Project architecture (umbrella/flat)"
8
9
  def new(app_name)
9
- require "dry/web/roda/generators/umbrella"
10
- Generators::Umbrella.new.(app_name)
10
+ case options[:arch]
11
+ when "umbrella"
12
+ require "dry/web/roda/generators/umbrella_project"
13
+ Generators::UmbrellaProject.new.(app_name)
14
+ when "flat"
15
+ require "dry/web/roda/generators/flat_project"
16
+ Generators::FlatProject.new.(app_name)
17
+ end
11
18
  end
12
19
 
13
20
  desc "generate GENERATOR", "Generate a new component for an existing dry-web-roda project"
@@ -5,11 +5,11 @@ module Dry
5
5
  module Roda
6
6
  class CLI
7
7
  class Generate < Thor
8
- desc "generate app APP", "Generate an app within a dry-web umbrella"
8
+ desc "generate sub_app APP", "Generate a sub-app within a dry-web umbrella app"
9
9
  option :umbrella, required: true, banner: "UMBRELLA_NAME", desc: "Provide the name of the umbrella app, e.g. my_project"
10
- def app(app_name)
11
- require "dry/web/roda/generators/app"
12
- Dry::Web::Roda::Generators::App.new.(app_name, umbrella: options[:umbrella])
10
+ def sub_app(app_name)
11
+ require "dry/web/roda/generators/sub_app"
12
+ Dry::Web::Roda::Generators::SubApp.new.(app_name, umbrella: options[:umbrella])
13
13
  end
14
14
  end
15
15
  end
@@ -0,0 +1,31 @@
1
+ require "inflecto"
2
+ require "dry/web/roda/generate"
3
+
4
+ module Dry
5
+ module Web
6
+ module Roda
7
+ module Generators
8
+ class FlatProject
9
+ attr_reader :generate
10
+
11
+ def initialize
12
+ @generate = Generate.new("flat_project")
13
+ end
14
+
15
+ def call(target_dir)
16
+ generate.(target_dir, prepare_scope(target_dir))
17
+ end
18
+
19
+ private
20
+
21
+ def prepare_scope(target_dir)
22
+ {
23
+ underscored_app_name: Inflecto.underscore(target_dir),
24
+ camel_cased_app_name: Inflecto.camelize(target_dir)
25
+ }
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -5,11 +5,11 @@ module Dry
5
5
  module Web
6
6
  module Roda
7
7
  module Generators
8
- class App
8
+ class SubApp
9
9
  attr_reader :generate
10
10
 
11
11
  def initialize
12
- @generate = Dry::Web::Roda::Generate.new("app")
12
+ @generate = Dry::Web::Roda::Generate.new("sub_app")
13
13
  end
14
14
 
15
15
  def call(target_dir, options = {})
@@ -1,25 +1,25 @@
1
1
  require "inflecto"
2
2
  require "securerandom"
3
3
  require "dry/web/roda/generate"
4
- require "dry/web/roda/generators/app"
4
+ require "dry/web/roda/generators/sub_app"
5
5
 
6
6
  module Dry
7
7
  module Web
8
8
  module Roda
9
9
  module Generators
10
- class Umbrella
11
- attr_reader :generate, :app_generator
10
+ class UmbrellaProject
11
+ attr_reader :generate, :sub_app_generator
12
12
 
13
13
  def initialize
14
- @generate = Generate.new("umbrella")
15
- @app_generator = Generators::App.new
14
+ @generate = Generate.new("umbrella_project")
15
+ @sub_app_generator = Generators::SubApp.new
16
16
  end
17
17
 
18
18
  def call(target_dir)
19
19
  generate.(target_dir, prepare_scope(target_dir))
20
20
 
21
21
  Dir.chdir(target_dir) do
22
- app_generator.("main", umbrella: target_dir)
22
+ sub_app_generator.("main", umbrella: target_dir)
23
23
  end
24
24
  end
25
25
 
@@ -3,8 +3,8 @@ source "https://rubygems.org"
3
3
  gem "rake"
4
4
 
5
5
  # Web framework
6
- gem "dry-web", ">= 0.5.0"
7
- gem "dry-web-roda", ">= 0.5.0"
6
+ gem "dry-web", ">= 0.6.0"
7
+ gem "dry-web-roda", ">= 0.6.0"
8
8
  gem "puma"
9
9
  gem "rack_csrf"
10
10
 
@@ -27,7 +27,7 @@ gem "dry-view", ">= 0.2.2"
27
27
  gem "slim"
28
28
 
29
29
  group :development, :test do
30
- gem "pry-byebug"
30
+ gem "pry-byebug", platform: :mri
31
31
  end
32
32
 
33
33
  group :test do
@@ -0,0 +1,22 @@
1
+ require "rom-sql"
2
+
3
+ module ROM
4
+ class Relation
5
+ # Monkey patch ROM::SQL to support query logs until an official API is available
6
+ module Instrumentation
7
+ def self.included(klass)
8
+ klass.option :notifications, reader: true, optional: false, default: proc {
9
+ <%= config[:camel_cased_app_name] %>::Container[:notifications]
10
+ }
11
+ end
12
+
13
+ def to_a
14
+ notifications.instrument(:sql, name: name.relation, query: dataset.sql) do
15
+ super
16
+ end
17
+ end
18
+ end
19
+
20
+ SQL::Relation.include(Instrumentation)
21
+ end
22
+ end
@@ -0,0 +1,29 @@
1
+ require "dry/web/roda/application"
2
+ require_relative "container"
3
+
4
+ module <%= config[:camel_cased_app_name] %>
5
+ class Application < Dry::Web::Roda::Application
6
+ configure do |config|
7
+ config.container = Container
8
+ config.routes = "web/routes".freeze
9
+ end
10
+
11
+ opts[:root] = Pathname(__FILE__).join("../..").realpath.dirname
12
+
13
+ use Rack::Session::Cookie, key: "<%= config[:underscored_app_name] %>.session", secret: <%= config[:camel_cased_app_name] %>::Container.settings.session_secret
14
+
15
+ plugin :csrf, raise: true
16
+ plugin :flash
17
+ plugin :dry_view
18
+
19
+ route do |r|
20
+ r.multi_route
21
+
22
+ r.root do
23
+ r.view "welcome"
24
+ end
25
+ end
26
+
27
+ load_routes!
28
+ end
29
+ end