dry-rb / dry-web-roda Goto Github PK
View Code? Open in Web Editor NEWRoda integration for dry-web apps
License: MIT License
Roda integration for dry-web apps
License: MIT License
dry-web-roda: 0.11.0
ruby: 2.5.3 and 2.4.5
steps:
i've been trying to get a freshly generated project going but instantly ran into this:
rake aborted!
NameError: uninitialized constant Dry::Monitor::Rack
Did you mean? Rake
/home/user/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/dry-web-0.8.0/lib/dry/web/container.rb:25:in `register_rack_monitor'
/home/user/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/dry-web-0.8.0/lib/dry/web/container.rb:16:in `block in inherited'
/home/user/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/dry-system-0.9.2/lib/dry/system/container.rb:105:in `instance_eval'
/home/user/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/dry-system-0.9.2/lib/dry/system/container.rb:105:in `block in configure'
/home/user/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/dry-system-0.9.2/lib/dry/system/container.rb:105:in `each'
/home/user/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/dry-system-0.9.2/lib/dry/system/container.rb:105:in `configure'
/home/user/projects/dry-rb/wellpress-crm/system/wellpress_crm/container.rb:6:in `<class:Container>'
/home/user/projects/dry-rb/wellpress-crm/system/wellpress_crm/container.rb:5:in `<module:WellpressCrm>'
/home/user/projects/dry-rb/wellpress-crm/system/wellpress_crm/container.rb:4:in `<top (required)>'
/home/user/projects/dry-rb/wellpress-crm/Rakefile:5:in `require_relative'
/home/user/projects/dry-rb/wellpress-crm/Rakefile:5:in `<top (required)>'
/home/user/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/rake_module.rb:29:in `load'
/home/user/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/rake_module.rb:29:in `load_rakefile'
/home/user/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:703:in `raw_load_rakefile'
/home/user/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:104:in `block in load_rakefile'
/home/user/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:186:in `standard_exception_handling'
/home/user/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:103:in `load_rakefile'
/home/user/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:82:in `block in run'
/home/user/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:186:in `standard_exception_handling'
/home/user/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:80:in `run'
/home/user/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
bin/rake:29:in `load'
bin/rake:29:in `<main>'
We don't need to use master
there anymore.
This happens with new freshly generated application. It looks a bug to me.
How to reproduce:
dry-web-roda new test_app
cd test_app
bundle install
rake db:create
rackup
I got:
Traceback (most recent call last):
42: from ~/.gem/ruby/2.5.0/bin/rackup:23:in `<main>'
41: from ~/.gem/ruby/2.5.0/bin/rackup:23:in `load'
40: from ~/.gem/ruby/2.5.0/gems/rack-2.0.4/bin/rackup:4:in `<top (required)>'
39: from ~/.gem/ruby/2.5.0/gems/rack-2.0.4/lib/rack/server.rb:148:in `start'
38: from ~/.gem/ruby/2.5.0/gems/rack-2.0.4/lib/rack/server.rb:283:in `start'
37: from ~/.gem/ruby/2.5.0/gems/rack-2.0.4/lib/rack/server.rb:354:in `wrapped_app'
36: from ~/.gem/ruby/2.5.0/gems/rack-2.0.4/lib/rack/server.rb:219:in `app'
35: from ~/.gem/ruby/2.5.0/gems/rack-2.0.4/lib/rack/server.rb:319:in `build_app_and_options_from_config'
34: from ~/.gem/ruby/2.5.0/gems/rack-2.0.4/lib/rack/builder.rb:40:in `parse_file'
33: from ~/.gem/ruby/2.5.0/gems/rack-2.0.4/lib/rack/builder.rb:49:in `new_from_string'
32: from ~/.gem/ruby/2.5.0/gems/rack-2.0.4/lib/rack/builder.rb:49:in `eval'
31: from ~/dev/pokus/test_app/config.ru:in `<main>'
30: from ~/dev/pokus/test_app/config.ru:in `new'
29: from ~/.gem/ruby/2.5.0/gems/rack-2.0.4/lib/rack/builder.rb:55:in `initialize'
28: from ~/.gem/ruby/2.5.0/gems/rack-2.0.4/lib/rack/builder.rb:55:in `instance_eval'
27: from ~/dev/pokus/test_app/config.ru:1:in `block in <main>'
26: from ~/dev/pokus/test_app/config.ru:1:in `require_relative'
25: from ~/dev/pokus/test_app/system/boot.rb:8:in `<top (required)>'
24: from ~/.gem/ruby/2.5.0/gems/dry-system-0.9.2/lib/dry/system/container.rb:298:in `finalize!'
23: from ~/.gem/ruby/2.5.0/gems/dry-system-0.9.2/lib/dry/system/booter.rb:65:in `finalize!'
22: from ~/.gem/ruby/2.5.0/gems/dry-system-0.9.2/lib/dry/system/booter/component_registry.rb:14:in `each'
21: from ~/.gem/ruby/2.5.0/gems/dry-system-0.9.2/lib/dry/system/booter/component_registry.rb:14:in `each'
20: from ~/.gem/ruby/2.5.0/gems/dry-system-0.9.2/lib/dry/system/booter.rb:66:in `block in finalize!'
19: from ~/.gem/ruby/2.5.0/gems/dry-system-0.9.2/lib/dry/system/booter.rb:86:in `start'
18: from ~/.gem/ruby/2.5.0/gems/dry-system-0.9.2/lib/dry/system/booter.rb:130:in `with_component'
17: from ~/.gem/ruby/2.5.0/gems/dry-system-0.9.2/lib/dry/system/booter.rb:89:in `block in start'
16: from ~/.gem/ruby/2.5.0/gems/dry-system-0.9.2/lib/dry/system/booter.rb:74:in `init'
15: from ~/.gem/ruby/2.5.0/gems/dry-system-0.9.2/lib/dry/system/booter.rb:130:in `with_component'
14: from ~/.gem/ruby/2.5.0/gems/dry-system-0.9.2/lib/dry/system/booter.rb:75:in `block in init'
13: from ~/.gem/ruby/2.5.0/gems/dry-system-0.9.2/lib/dry/system/booter.rb:101:in `call'
12: from ~/.gem/ruby/2.5.0/gems/dry-system-0.9.2/lib/dry/system/booter.rb:130:in `with_component'
11: from ~/.gem/ruby/2.5.0/gems/dry-system-0.9.2/lib/dry/system/booter.rb:106:in `block in call'
10: from ~/.gem/ruby/2.5.0/gems/dry-system-0.9.2/lib/dry/system/booter.rb:76:in `block (2 levels) in init'
9: from ~/.gem/ruby/2.5.0/gems/dry-system-0.9.2/lib/dry/system/components/bootable.rb:85:in `init'
8: from ~/.gem/ruby/2.5.0/gems/dry-system-0.9.2/lib/dry/system/lifecycle.rb:54:in `call'
7: from ~/.gem/ruby/2.5.0/gems/dry-system-0.9.2/lib/dry/system/lifecycle.rb:54:in `each'
6: from ~/.gem/ruby/2.5.0/gems/dry-system-0.9.2/lib/dry/system/lifecycle.rb:56:in `block in call'
5: from ~/.gem/ruby/2.5.0/gems/dry-system-0.9.2/lib/dry/system/lifecycle.rb:79:in `init'
4: from ~/.gem/ruby/2.5.0/gems/dry-system-0.9.2/lib/dry/system/lifecycle.rb:119:in `trigger!'
3: from ~/dev/pokus/test_app/system/boot/persistence.rb:3:in `block (2 levels) in <top (required)>'
2: from ~/.gem/ruby/2.5.0/gems/dry-system-0.9.2/lib/dry/system/lifecycle.rb:132:in `method_missing'
1: from ~/.gem/ruby/2.5.0/gems/dry-system-0.9.2/lib/dry/system/lifecycle.rb:132:in `public_send'
~/.gem/ruby/2.5.0/gems/dry-system-0.9.2/lib/dry/system/lifecycle.rb:132:in `require': cannot load such file -- sequel (LoadError)
sequel
is in Gemfile
btw.
I would expect I can run the application with rackup
command without throwing exceptions.
I have installed dry-web-roda (0.9.1)
when i run dry-web-roda new new_project
it generates gem file with an older version of some gems
gem "dry-web", "~> 0.7"
gem "dry-web-roda", "~> 0.7"
We need rtomayko/shotgun#61 to be released before shotgun will work with the 2.0.x versions of Rack.
Hey guys,
while using rake db:migrate
task (which uses dump
rake task) I encountered the following error:
pg_dump: invalid option -- i
Try "pg_dump --help" for more information.
After removing -i
option from https://github.com/dry-rb/dry-web-roda/blob/master/lib/dry/web/roda/skeletons/umbrella/Rakefile.tt#L40 everything works as expected. Not sure if that option was opened on purpose or its just a bug.
Postgres Version:
postgres (PostgreSQL) 9.5.2 on MacOSx installed via brew
As new user I would like to read some introduction which learn me key concepts behind generated directory tree. Some simple example like super-simple todolist application will be very helpful for newbie.
Hi guys, I was trying to use dry-web-roda and I run into an issue that files inside the folder component/boot
were not being initialized. I think it is because either we should change the config inside the container file, or we should rename the folder name to system.
Steps to reproduce the issue:
dry-web-roda new issue
Add a breaking point before Issue::Container::finalize!
# component/boot.rb
binding.pry
Issue::Container.finalize! do |container|
end
# ...
back to bash:
bin/console
At break point:
[2] pry(main)> Issue::Container.boot :logger
TypeError: no implicit conversion of Pathname into String
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dry-system-0.5.1/lib/dry/system/booter.rb:43:in `require'
[3] pry(main)> Issue::Container.finalize!
=> Issue::Container
[4] pry(main)> Issue::Container["logger"]
Dry::Container::Error: Nothing registered with the key "logger"
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dry-container-0.5.0/lib/dry/container/resolver.rb:22:in `block in call'
Adding config.system_dir = "component"
to the container seems to fix the issue.
Maybe the folder should be named system
because that is the default value from Dry::System::Container
https://github.com/dry-rb/dry-system/blob/master/lib/dry/system/container.rb#L69
If you guys need some help, I would be glad to help fix this issue, I just need some guidance since I never made a contribution to an open source project before and I don't know the code base here.
Regards
It'd be nice not to have to duplicate everything across the arch types for new projects. I did this just to get the flat one released quickly. Now they're present, we should look at a way of sharing as much code/templates between them as possible.
Calling dry-web-roda
from a fresh install immediately gives this load error. It looks like it's the require "bundler/setup"
-- I'm not sure why that's there in an executable to begin with.
(Maybe you folks only ever run it from local source with bundle exec so you never noticed?)
In any case, I've included what little I've got below, in case something else rings a bell.
# Starting from scratch:
13:51 $ ruby -v
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
13:51 $ gem list dry-web* roda*
*** LOCAL GEMS ***
*** LOCAL GEMS ***
13:52 $ gem install dry-web-roda
Fetching: roda-2.29.0.gem (100%)
Successfully installed roda-2.29.0
Fetching: roda-flow-0.3.1.gem (100%)
Successfully installed roda-flow-0.3.1
Fetching: dry-web-roda-0.9.1.gem (100%)
Successfully installed dry-web-roda-0.9.1
3 gems installed
13:52 $ dry-web-roda -h
/Users/dueberb/.gem/ruby/2.4.1/gems/dry-web-roda-0.9.1/exe/dry-web-roda:4:in `require': cannot load such file -- dry/web/roda/cli (LoadError)
from /Users/dueberb/.gem/ruby/2.4.1/gems/dry-web-roda-0.9.1/exe/dry-web-roda:4:in `<top (required)>'
from /Users/dueberb/.gem/ruby/2.4.1/bin/dry-web-roda:22:in `load'
from /Users/dueberb/.gem/ruby/2.4.1/bin/dry-web-roda:22:in `<main>'
Rakefile.tt should require 'pry-byebug'
.
dry-web-roda
's dry_view roda plugin has a dependency on rack_csrf
gem. When using dry-web-roda
as an API server, csrf is not needed. Better if this csrf dependency is removed.
ruby -v
ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-linux]
Install dry-web-roda
gem install dry-web-roda
Fetching thor-0.20.3.gem
Fetching rack-2.0.6.gem
Fetching concurrent-ruby-1.1.5.gem
Fetching dry-core-0.4.7.gem
Fetching roda-flow-0.4.0.gem
Fetching inflecto-0.0.2.gem
Fetching dry-configurable-0.8.2.gem
Fetching roda-3.18.0.gem
Fetching dry-web-roda-0.11.0.gem
Successfully installed concurrent-ruby-1.1.5
Successfully installed dry-core-0.4.7
Successfully installed dry-configurable-0.8.2
Successfully installed inflecto-0.0.2
Successfully installed rack-2.0.6
Successfully installed roda-3.18.0
Successfully installed roda-flow-0.4.0
Successfully installed thor-0.20.3
Successfully installed dry-web-roda-0.11.0
9 gems installed
Create app
dry-web-roda new demo01 --arch=flat
create demo01/bin/console
create demo01/bin/setup
create demo01/.env
create demo01/.env.test
create demo01/db/sample_data.rb
create demo01/db/seed.rb
create demo01/log/.keep
create demo01/.rspec
create demo01/spec/web_spec_helper.rb
create demo01/spec/db_spec_helper.rb
create demo01/spec/spec_helper.rb
create demo01/spec/support/db/factory.rb
create demo01/spec/support/db/helpers.rb
create demo01/spec/factories/example.rb
create demo01/spec/support/web/helpers.rb
create demo01/lib/types.rb
create demo01/lib/demo01/operation.rb
create demo01/lib/demo01/repository.rb
create demo01/lib/persistence/relations/.keep
create demo01/lib/persistence/commands/.keep
create demo01/lib/demo01/view/context.rb
create demo01/lib/demo01/view/controller.rb
create demo01/system/demo01/container.rb
create demo01/system/demo01/import.rb
create demo01/system/boot/monitor.rb
create demo01/system/boot/persistence.rb
create demo01/system/boot/settings.rb
create demo01/system/boot.rb
create demo01/system/demo01/web.rb
create demo01/.gitignore
create demo01/Gemfile
create demo01/Rakefile
create demo01/config.ru
create demo01/README.md
create demo01/lib/demo01/views/welcome.rb
create demo01/web/routes/example.rb
create demo01/web/templates/layouts/application.html.slim
create demo01/web/templates/welcome.html.slim
cd demo111
bundle install
Start application
puma -C config.ru
Traceback (most recent call last):
24: from /home/sena/.rbenv/versions/2.6.1/bin/puma:23:in '<main>'
23: from /home/sena/.rbenv/versions/2.6.1/bin/puma:23:in 'load'
22: from /home/sena/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/puma-3.12.1/bin/puma:8:in '<top (required)>'
21: from /home/sena/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/puma-3.12.1/bin/puma:8:in 'new'
20: from /home/sena/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/puma-3.12.1/lib/puma/cli.rb:71:in 'initialize'
19: from /home/sena/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/puma-3.12.1/lib/puma/cli.rb:71:in 'new'
18: from /home/sena/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/puma-3.12.1/lib/puma/launcher.rb:61:in 'initialize'
17: from /home/sena/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/puma-3.12.1/lib/puma/configuration.rb:194:in 'load'
16: from /home/sena/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/puma-3.12.1/lib/puma/configuration.rb:194:in 'each'
15: from /home/sena/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/puma-3.12.1/lib/puma/configuration.rb:194:in 'block in load'
14: from /home/sena/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/puma-3.12.1/lib/puma/dsl.rb:43:in '_load_from'
13: from /home/sena/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/puma-3.12.1/lib/puma/dsl.rb:43:in 'instance_eval'
12: from config.ru:1:in '_load_from'
11: from config.ru:1:in 'require_relative'
10: from /home/sena/Projects/dry-demo/demo01/system/boot.rb:8:in '<top (required)>'
9: from /home/sena/Projects/dry-demo/demo01/system/boot.rb:8:in 'require_relative'
8: from /home/sena/Projects/dry-demo/demo01/system/demo01/container.rb:4:in '<top (required)>'
7: from /home/sena/Projects/dry-demo/demo01/system/demo01/container.rb:5:in '<module:Demo01>'
6: from /home/sena/Projects/dry-demo/demo01/system/demo01/container.rb:6:in '<class:Container>'
5: from /home/sena/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/dry-system-0.9.2/lib/dry/system/container.rb:105:in 'configure'
4: from /home/sena/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/dry-system-0.9.2/lib/dry/system/container.rb:105:in 'each'
3: from /home/sena/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/dry-system-0.9.2/lib/dry/system/container.rb:105:in 'block in configure'
2: from /home/sena/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/dry-system-0.9.2/lib/dry/system/container.rb:105:in 'instance_eval'
1: from /home/sena/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/dry-web-0.8.0/lib/dry/web/container.rb:16:in 'block in inherited'
/home/sena/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/dry-web-0.8.0/lib/dry/web/container.rb:25:in 'register_rack_monitor': uninitialized constant Dry::Monitor::Rack (NameError)
Is it okay when a newly-generated application does not work?
Right now, Gemfile is declaring all the dependencies that generated application has (which are also declared in Gemfile template).
Is this duplication really needed? dry-web-roda
is just a skeleton generator, so it doesn't need all that stuff to do its work.
settings.rb
with no corresponding ENV
var and a default valuedry-web-roda new foo --arch=flat
Foo::Container.boot :settings, from: :system do
before :init do
require "types"
end
settings do
key :session_secret, Types::Strict::String.constrained(filled: true)
key :database_url, Types::Strict::String.constrained(filled: true)
key :bar, Types::Coercible::String.default("bar")
end
end
[1] pry(main)> Foo::Container[:settings].bar
=> ""
Steps to reproduce
Run generator dry-web-roda new my_app --arch=flat
Per #54, fix gem incompatibility issue
# Gemfile
gem 'rouge', '2.1.1'
# ...
$ bundle
$ bundle exec shotgun -p 3001 -o 0.0.0.0 config.ru
$ open http://localhost:3001
This is because 'view.context'
is not registered with the Container. The key is referenced during boot
Controller.config.context and during response rendering Roda::RodaPlugins::DryView
Boot Error
Dry::System::InvalidComponentError: Tried to create an invalid "view.context" component - namespace +my_app+ not found in path
gems/dry-system-0.7.3/lib/dry/system/component.rb:70:in `remove_namespace_from_path'
gems/dry-system-0.7.3/lib/dry/system/component.rb:62:in `extract_identifier'
gems/dry-system-0.7.3/lib/dry/system/component.rb:50:in `block in new'
gems/concurrent-ruby-1.0.5/lib/concurrent/map.rb:133:in `block in fetch_or_store'
gems/concurrent-ruby-1.0.5/lib/concurrent/map.rb:122:in `fetch'
gems/concurrent-ruby-1.0.5/lib/concurrent/map.rb:132:in `fetch_or_store'
gems/dry-system-0.7.3/lib/dry/system/component.rb:45:in `new'
gems/dry-system-0.7.3/lib/dry/system/container.rb:480:in `component'
gems/dry-system-0.7.3/lib/dry/system/container.rb:506:in `load_component'
gems/dry-system-0.7.3/lib/dry/system/container.rb:448:in `resolve'
gems/dry-container-0.6.0/lib/dry/container/mixin.rb:125:in `[]'
my_app/lib/my_app/view/controller.rb:13:in `block in <class:Controller>'
gems/dry-configurable-0.7.0/lib/dry/configurable.rb:70:in `configure'
my_app/lib/my_app/view/controller.rb:11:in `<class:Controller>'
my_app/lib/my_app/view/controller.rb:10:in `<module:View>'
my_app/lib/my_app/view/controller.rb:9:in `<module:MyApp>'
my_app/lib/my_app/view/controller.rb:8:in `<top (required)>'
my_app/lib/my_app/views/welcome.rb:1:in `require'
my_app/lib/my_app/views/welcome.rb:1:in `<top (required)>'
gems/dry-system-0.7.3/lib/dry/system/container.rb:497:in `require'
gems/dry-system-0.7.3/lib/dry/system/container.rb:497:in `require_component'
gems/dry-system-0.7.3/lib/dry/system/auto_registrar.rb:37:in `block in call'
gems/dry-system-0.7.3/lib/dry/system/auto_registrar.rb:34:in `each'
gems/dry-system-0.7.3/lib/dry/system/auto_registrar.rb:34:in `call'
gems/dry-system-0.7.3/lib/dry/system/auto_registrar.rb:27:in `block in finalize!'
gems/dry-system-0.7.3/lib/dry/system/auto_registrar.rb:27:in `each'
gems/dry-system-0.7.3/lib/dry/system/auto_registrar.rb:27:in `finalize!'
gems/dry-system-0.7.3/lib/dry/system/container.rb:263:in `finalize!'
my_app/system/boot.rb:8:in `<top (required)>'
config.ru:1:in `require_relative'
config.ru:1:in `block in inner_app'
gems/rack-2.0.3/lib/rack/builder.rb:55:in `instance_eval'
gems/rack-2.0.3/lib/rack/builder.rb:55:in `initialize'
config.ru:1:in `new'
config.ru:1:in `inner_app'
gems/shotgun-0.9.2/lib/shotgun/loader.rb:113:in `eval'
gems/shotgun-0.9.2/lib/shotgun/loader.rb:113:in `inner_app'
gems/shotgun-0.9.2/lib/shotgun/loader.rb:103:in `assemble_app'
gems/shotgun-0.9.2/lib/shotgun/loader.rb:86:in `proceed_as_child'
gems/shotgun-0.9.2/lib/shotgun/loader.rb:31:in `call!'
gems/shotgun-0.9.2/lib/shotgun/loader.rb:18:in `call'
gems/shotgun-0.9.2/lib/shotgun/favicon.rb:12:in `call'
gems/rack-2.0.3/lib/rack/urlmap.rb:68:in `block in call'
gems/rack-2.0.3/lib/rack/urlmap.rb:53:in `each'
gems/rack-2.0.3/lib/rack/urlmap.rb:53:in `call'
gems/rack-2.0.3/lib/rack/builder.rb:153:in `call'
gems/puma-3.10.0/lib/puma/configuration.rb:225:in `call'
gems/puma-3.10.0/lib/puma/server.rb:605:in `handle_request'
gems/puma-3.10.0/lib/puma/server.rb:437:in `process_client'
gems/puma-3.10.0/lib/puma/server.rb:301:in `block in run'
gems/puma-3.10.0/lib/puma/thread_pool.rb:120:in `block in spawn_thread'
Registering the namespace resolves the issue
# system/boot/view.rb
MyApp::Container.namespace 'view' do |container|
container.finalize :view do
init do
require 'my_app/view/context'
end
start do
container.register 'context', MyApp::View::Context.new
end
end
end
Is dry-web-roda
ready for use?
Replace calls to boot
with start
per deprecation warning.
Right now we generate Rakefile that has postgres support only. It'd be nice to have a system that allows people to work with their favourite databases.
This should probably be provide by another gem.
After using the following procedure to generate and start a new application, I received some errors that were difficult to diagnose and fix for newcomers:
dry-web-roda new APP_NAME
rake db:create
rerun -- rackup --port 4000 config.ru
The first issue was that the event sql
had not been registered. After some digging, and with help from @solnic on Zulip, I discovered that the issue lay in the system/boot/monitor.rb
file. After fixing this, I received a validation error saying that a password was not supplied when initialising the PostgreSQL connection. A fix for this is to specify the username and password as part of the DATABASE_URL
variable in the top-level .env
created when dry-web-roda new APP_NAME
is run. Alternatively, a user could pre-pend the variable declaration to step 3 above. Either way, I think this set-up step could be better explained in the README for first time use?
As discussed with @solnic yesterday, I will make a pull-request for this issue with some fixes and submit for review. Thanks again for all your hard work on this project!
The default skeleton for the import.rb
file causes an exception to occur with the initial setup, namely NoMethodError: undefined method 'Import' for Main:Module
Changing it to
module Main
Import = Main::Container::Inject.args
def self.Import(*args)
Import[*args]
end
end
Seems to work ok, but not sure if that's the "old" way of doing it
Would be good to have something equivalent to Hanami's instructions: https://github.com/MiniProfiler/rack-mini-profiler#hanami
I don't think lib folder is the place for roda_plugins or page.rb. Maybe I am wrong.
The auto-generated app configures a context
for the dry-view base class, however, this never gets used as the roda view plugin just calls roda_app['view.context']
, resolving from the container directly. The only way around this is to resolve the view in the plugin and get the context from the classes config, which feels very hacky.
https://github.com/dry-rb/dry-web-roda/blob/master/lib/roda/plugins/dry_view.rb#L10
People can set up their own testing tools like this
Reporting issue with default SQL logger configuration.
Steps to reproduce
$ dry-web-roda new app
$ bundle exec shotgun -p 3001 -o 0.0.0.0 config.ru
$ open http://localhost:3001
Visiting localhost:3001 renders Boot Error
Boot Error
Something went wrong while loading config.ru
ArgumentError: invalid theme: Rouge::Themes::Gruvbox
rouge-2.2.1/lib/rouge/formatters/terminal256.rb:20:in `initialize'
dry-monitor-0.0.2/lib/dry/monitor/sql/logger.rb:23:in `new'
dry-monitor-0.0.2/lib/dry/monitor/sql/logger.rb:23:in `initialize'
app/system/boot/monitor.rb:7:in `new'
app/system/boot/monitor.rb:7:in `block (2 levels) in <top (required)>'
dry-system-0.7.3/lib/dry/system/lifecycle.rb:88:in `trigger!'
dry-system-0.7.3/lib/dry/system/lifecycle.rb:63:in `start'
dry-system-0.7.3/lib/dry/system/lifecycle.rb:50:in `block in call'
dry-system-0.7.3/lib/dry/system/lifecycle.rb:48:in `each'
dry-system-0.7.3/lib/dry/system/lifecycle.rb:48:in `call'
dry-system-0.7.3/lib/dry/system/booter.rb:59:in `block in start'
dry-system-0.7.3/lib/dry/system/booter.rb:47:in `block in init'
dry-system-0.7.3/lib/dry/system/booter.rb:72:in `call'
dry-system-0.7.3/lib/dry/system/booter.rb:45:in `init'
dry-system-0.7.3/lib/dry/system/booter.rb:59:in `start'
dry-system-0.7.3/lib/dry/system/booter.rb:36:in `block in finalize!'
dry-system-0.7.3/lib/dry/system/booter.rb:35:in `each'
dry-system-0.7.3/lib/dry/system/booter.rb:35:in `finalize!'
dry-system-0.7.3/lib/dry/system/container.rb:261:in `finalize!'
app/system/boot.rb:8:in `<top (required)>'
config.ru:1:in `require_relative'
config.ru:1:in `block in inner_app'
rack-2.0.3/lib/rack/builder.rb:55:in `instance_eval'
rack-2.0.3/lib/rack/builder.rb:55:in `initialize'
config.ru:1:in `new'
config.ru:1:in `inner_app'
shotgun-0.9.2/lib/shotgun/loader.rb:113:in `eval'
shotgun-0.9.2/lib/shotgun/loader.rb:113:in `inner_app'
shotgun-0.9.2/lib/shotgun/loader.rb:103:in `assemble_app'
shotgun-0.9.2/lib/shotgun/loader.rb:86:in `proceed_as_child'
shotgun-0.9.2/lib/shotgun/loader.rb:31:in `call!'
shotgun-0.9.2/lib/shotgun/loader.rb:18:in `call'
shotgun-0.9.2/lib/shotgun/favicon.rb:12:in `call'
rack-2.0.3/lib/rack/urlmap.rb:68:in `block in call'
rack-2.0.3/lib/rack/urlmap.rb:53:in `each'
rack-2.0.3/lib/rack/urlmap.rb:53:in `call'
rack-2.0.3/lib/rack/builder.rb:153:in `call'
puma-3.10.0/lib/puma/configuration.rb:225:in `call'
puma-3.10.0/lib/puma/server.rb:605:in `handle_request'
puma-3.10.0/lib/puma/server.rb:437:in `process_client'
puma-3.10.0/lib/puma/server.rb:301:in `block in run'
puma-3.10.0/lib/puma/thread_pool.rb:120:in `block in spawn_thread'
As of Rouge #b9f7262 Rouge::Formatters::Terminal256#initialize
expects theme
param to be an instance of Rouge::Theme
. Instead it receives ::config.theme
, a Class
, from Dry::Monitor::SQL::Logger#initialize
.
Suggesting gem restraint gem 'rouge', '2.2.0'
or adjustments to constructor.
This issue is about the jruby-9.2.6.0 tests, which currently fail in bundle install
.
The pg
gem (which has C extensions) does not install.
If I created a new umbrella app, started the server and visited localhost:3000
. Then I got this output:
Something went wrong while loading config.ru
Dry::System::InvalidComponentError: Tried to create an invalid "view.context" component - namespace +main+ not found in path
/home/alejandro/.rvm/gems/ruby-2.3.3@dwr75/gems/dry-system-0.7.3/lib/dry/system/component.rb:70:in `remove_namespace_from_path'
/home/alejandro/.rvm/gems/ruby-2.3.3@dwr75/gems/dry-system-0.7.3/lib/dry/system/component.rb:62:in `extract_identifier'
/home/alejandro/.rvm/gems/ruby-2.3.3@dwr75/gems/dry-system-0.7.3/lib/dry/system/component.rb:50:in `block in new'
/home/alejandro/.rvm/gems/ruby-2.3.3@dwr75/gems/concurrent-ruby-1.0.5/lib/concurrent/map.rb:133:in `block in fetch_or_store'
/home/alejandro/.rvm/gems/ruby-2.3.3@dwr75/gems/concurrent-ruby-1.0.5/lib/concurrent/map.rb:122:in `fetch'
/home/alejandro/.rvm/gems/ruby-2.3.3@dwr75/gems/concurrent-ruby-1.0.5/lib/concurrent/map.rb:132:in `fetch_or_store'
/home/alejandro/.rvm/gems/ruby-2.3.3@dwr75/gems/dry-system-0.7.3/lib/dry/system/component.rb:45:in `new'
/home/alejandro/.rvm/gems/ruby-2.3.3@dwr75/gems/dry-system-0.7.3/lib/dry/system/container.rb:480:in `component'
/home/alejandro/.rvm/gems/ruby-2.3.3@dwr75/gems/dry-system-0.7.3/lib/dry/system/container.rb:506:in `load_component'
/home/alejandro/.rvm/gems/ruby-2.3.3@dwr75/gems/dry-system-0.7.3/lib/dry/system/container.rb:448:in `resolve'
/home/alejandro/.rvm/gems/ruby-2.3.3@dwr75/gems/dry-container-0.6.0/lib/dry/container/mixin.rb:125:in `[]'
/home/alejandro/source/learn/dry-rb/todo/apps/main/lib/main/view/controller.rb:12:in `block in <class:Controller>'
/home/alejandro/.rvm/gems/ruby-2.3.3@dwr75/gems/dry-configurable-0.7.0/lib/dry/configurable.rb:70:in `configure'
/home/alejandro/source/learn/dry-rb/todo/apps/main/lib/main/view/controller.rb:10:in `<class:Controller>'
/home/alejandro/source/learn/dry-rb/todo/apps/main/lib/main/view/controller.rb:9:in `<module:View>'
/home/alejandro/source/learn/dry-rb/todo/apps/main/lib/main/view/controller.rb:8:in `<module:Main>'
/home/alejandro/source/learn/dry-rb/todo/apps/main/lib/main/view/controller.rb:7:in `<top (required)>'
/home/alejandro/source/learn/dry-rb/todo/apps/main/lib/main/views/welcome.rb:1:in `require'
/home/alejandro/source/learn/dry-rb/todo/apps/main/lib/main/views/welcome.rb:1:in `<top (required)>'
/home/alejandro/.rvm/gems/ruby-2.3.3@dwr75/gems/dry-system-0.7.3/lib/dry/system/container.rb:497:in `require'
/home/alejandro/.rvm/gems/ruby-2.3.3@dwr75/gems/dry-system-0.7.3/lib/dry/system/container.rb:497:in `require_component'
/home/alejandro/.rvm/gems/ruby-2.3.3@dwr75/gems/dry-system-0.7.3/lib/dry/system/auto_registrar.rb:37:in `block in call'
/home/alejandro/.rvm/gems/ruby-2.3.3@dwr75/gems/dry-system-0.7.3/lib/dry/system/auto_registrar.rb:34:in `each'
/home/alejandro/.rvm/gems/ruby-2.3.3@dwr75/gems/dry-system-0.7.3/lib/dry/system/auto_registrar.rb:34:in `call'
/home/alejandro/.rvm/gems/ruby-2.3.3@dwr75/gems/dry-system-0.7.3/lib/dry/system/auto_registrar.rb:27:in `block in finalize!'
/home/alejandro/.rvm/gems/ruby-2.3.3@dwr75/gems/dry-system-0.7.3/lib/dry/system/auto_registrar.rb:27:in `each'
/home/alejandro/.rvm/gems/ruby-2.3.3@dwr75/gems/dry-system-0.7.3/lib/dry/system/auto_registrar.rb:27:in `finalize!'
/home/alejandro/.rvm/gems/ruby-2.3.3@dwr75/gems/dry-system-0.7.3/lib/dry/system/container.rb:263:in `finalize!'
/home/alejandro/source/learn/dry-rb/todo/apps/main/system/boot.rb:3:in `<top (required)>'
In the app in apps/main/system/boot.rb:3
calls Main::Container.finalize!
and after that in apps/main/lib/main/view/controller.rb:12
it sets the config.context
.
# auto_register: false
require "slim"
require "dry-view"
require "main/container"
module Main
module View
class Controller < Dry::View::Controller
configure do |config|
config.paths = [Container.root.join("web/templates")]
config.context = Container["view.context"]
config.layout = "application"
end
end
end
end
I found 2 workarounds in order to make the app work.
Change in the Gemfile gem "dry-system", ">= 0.7.1"
with gem "dry-system", "0.7.1"
and bundle update dry-system
Change the Main::View::Controller
and setting the context
as an injected dependency instead as a config value. This way:
# auto_register: false
require "slim"
require "dry-view"
require "main/container"
require "main/import"
module Main
module View
class Controller < Dry::View::Controller
include Import["view.context"]
configure do |config|
config.paths = [Container.root.join("web/templates")]
config.layout = "application"
end
end
end
end
I guess the first one could be a fix for that and the second something to think about.
Thank you for the awesome job that you are doing with the dry-rb gems.
Calling it "umbrella" instead of "component" would make it clearer that this is a special-case container.
I think rom-support is causing problems when rom-sql is required during boot process.
Steps to reproduce the issue:
# Gemfile
source "https://rubygems.org"
gem "rom", github: "rom-rb/rom"
gem "rom-sql", github: "rom-rb/rom-sql"
gem "rom-support", github: "rom-rb/rom-support"
at bash:
pry
[1] pry(main)> require "bundler/setup"
=> true
[2] pry(main)> require "rom"
=> true
[3] pry(main)> require "rom-sql"
NoMethodError: undefined method `define' for nil:NilClass
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-support-e76854b0dbd7/lib/rom/support/options.rb:165:in `option'
Removing rom-support
from the Gemfile
seems to fix the issue.
This is causing problems during boot process after the container tries to boot component/boot/rom.rb
when this line is executed
config = ROM::Configuration.new(:sql, container.settings.database_url, extensions: [:error_sql])
Here is the stacktrace
/home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-support-e76854b0dbd7/lib/rom/support/options.rb:165:in `option': undefined method `define' for nil:NilClass (NoMethodError)
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-sql-be9248512a7b/lib/rom/sql/association/many_to_many.rb:9:in `<class:ManyToMany>'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-sql-be9248512a7b/lib/rom/sql/association/many_to_many.rb:4:in `<class:Association>'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-sql-be9248512a7b/lib/rom/sql/association/many_to_many.rb:3:in `<module:SQL>'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-sql-be9248512a7b/lib/rom/sql/association/many_to_many.rb:2:in `<module:ROM>'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-sql-be9248512a7b/lib/rom/sql/association/many_to_many.rb:1:in `<top (required)>'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-sql-be9248512a7b/lib/rom/sql/association.rb:73:in `require'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-sql-be9248512a7b/lib/rom/sql/association.rb:73:in `<top (required)>'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-sql-be9248512a7b/lib/rom/sql/schema/associations_dsl.rb:1:in `require'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-sql-be9248512a7b/lib/rom/sql/schema/associations_dsl.rb:1:in `<top (required)>'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-sql-be9248512a7b/lib/rom/sql/schema/dsl.rb:2:in `require'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-sql-be9248512a7b/lib/rom/sql/schema/dsl.rb:2:in `<top (required)>'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-sql-be9248512a7b/lib/rom/sql/schema.rb:35:in `require'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-sql-be9248512a7b/lib/rom/sql/schema.rb:35:in `<top (required)>'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-sql-be9248512a7b/lib/rom/sql/relation.rb:4:in `require'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-sql-be9248512a7b/lib/rom/sql/relation.rb:4:in `<top (required)>'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-sql-be9248512a7b/lib/rom/sql.rb:11:in `require'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-sql-be9248512a7b/lib/rom/sql.rb:11:in `<top (required)>'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-179772b11bd3/lib/rom/gateway.rb:83:in `require'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-179772b11bd3/lib/rom/gateway.rb:83:in `block in class_from_symbol'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-179772b11bd3/lib/rom/gateway.rb:81:in `fetch'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-179772b11bd3/lib/rom/gateway.rb:81:in `class_from_symbol'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-179772b11bd3/lib/rom/gateway.rb:57:in `setup'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-179772b11bd3/lib/rom/environment.rb:51:in `block in normalize_gateways'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-179772b11bd3/lib/rom/environment.rb:45:in `each'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-179772b11bd3/lib/rom/environment.rb:45:in `each_with_object'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-179772b11bd3/lib/rom/environment.rb:45:in `normalize_gateways'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-179772b11bd3/lib/rom/environment.rb:25:in `configure_gateways'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-179772b11bd3/lib/rom/environment.rb:18:in `initialize'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-179772b11bd3/lib/rom/configuration.rb:22:in `new'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/rom-179772b11bd3/lib/rom/configuration.rb:22:in `initialize'
from /home/gabriel/Workspace/projects/issue/component/boot/rom.rb:8:in `new'
from /home/gabriel/Workspace/projects/issue/component/boot/rom.rb:8:in `block in <top (required)>'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dry-container-0.5.0/lib/dry/container/namespace_dsl.rb:28:in `initialize'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dry-container-0.5.0/lib/dry/container/mixin.rb:191:in `new'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dry-container-0.5.0/lib/dry/container/mixin.rb:191:in `namespace'
from /home/gabriel/Workspace/projects/issue/component/boot/rom.rb:7:in `<top (required)>'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dry-system-0.5.1/lib/dry/system/booter.rb:43:in `require'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dry-system-0.5.1/lib/dry/system/booter.rb:43:in `boot'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dry-system-0.5.1/lib/dry/system/booter.rb:59:in `boot!'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dry-system-0.5.1/lib/dry/system/booter.rb:36:in `block in finalize!'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dry-system-0.5.1/lib/dry/system/booter.rb:35:in `each'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dry-system-0.5.1/lib/dry/system/booter.rb:35:in `finalize!'
from /home/gabriel/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dry-system-0.5.1/lib/dry/system/container.rb:249:in `finalize!'
from /home/gabriel/Workspace/projects/issue/component/boot.rb:6:in `<top (required)>'
from bin/console:5:in `require_relative'
from bin/console:5:in `<main>'
The exception seems to be coming from here
https://github.com/rom-rb/rom/blob/master/lib/rom/gateway.rb#L83
After removing the rom-support from the Gemfile ROM seems to boot just fine.
If you guys need, I'm glad to give some help.
Regards
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.