dry-web-roda 0.10.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +179 -41
  3. data/LICENSE +16 -18
  4. data/README.md +16 -42
  5. data/{exe → bin}/dry-web-roda +0 -0
  6. data/dry-web-roda.gemspec +24 -23
  7. data/lib/dry/web/roda/generators/abstract_project.rb +2 -2
  8. data/lib/dry/web/roda/generators/inflections.rb +3 -3
  9. data/lib/dry/web/roda/generators/sub_app.rb +2 -2
  10. data/lib/dry/web/roda/inflector.rb +9 -0
  11. data/lib/dry/web/roda/templates/Gemfile +19 -14
  12. data/lib/dry/web/roda/templates/README.md.tt +8 -5
  13. data/lib/dry/web/roda/templates/container.rb.tt +2 -0
  14. data/lib/dry/web/roda/templates/flat_project/boot.rb.tt +2 -0
  15. data/lib/dry/web/roda/templates/flat_project/web.rb.tt +3 -1
  16. data/lib/dry/web/roda/templates/monitor.rb.tt +2 -1
  17. data/lib/dry/web/roda/templates/subapp/container.rb.tt +3 -3
  18. data/lib/dry/web/roda/templates/subapp/view.rb.tt +17 -0
  19. data/lib/dry/web/roda/templates/subapp/view_context.rb.tt +8 -0
  20. data/lib/dry/web/roda/templates/subapp/web.rb.tt +3 -1
  21. data/lib/dry/web/roda/templates/subapp/welcome.rb.tt +2 -2
  22. data/lib/dry/web/roda/templates/types.rb +3 -3
  23. data/lib/dry/web/roda/templates/umbrella_project/boot.rb.tt +2 -0
  24. data/lib/dry/web/roda/templates/view.rb.tt +15 -0
  25. data/lib/dry/web/roda/templates/view_context.rb.tt +31 -0
  26. data/lib/dry/web/roda/templates/welcome.rb.tt +2 -2
  27. data/lib/dry/web/roda/version.rb +1 -1
  28. data/lib/roda/plugins/dry_view.rb +6 -3
  29. metadata +30 -148
  30. data/.gitignore +0 -37
  31. data/.rspec +0 -2
  32. data/.travis.yml +0 -32
  33. data/CONTRIBUTING.md +0 -29
  34. data/Gemfile +0 -33
  35. data/Rakefile +0 -6
  36. data/lib/dry/web/roda/templates/.gitignore +0 -11
  37. data/lib/dry/web/roda/templates/.keep +0 -0
  38. data/lib/dry/web/roda/templates/.rspec +0 -2
  39. data/lib/dry/web/roda/templates/subapp/view__context.rb.tt +0 -10
  40. data/lib/dry/web/roda/templates/subapp/view__controller.rb.tt +0 -19
  41. data/lib/dry/web/roda/templates/view__context.rb.tt +0 -41
  42. data/lib/dry/web/roda/templates/view__controller.rb.tt +0 -17
  43. data/script/ci +0 -67
  44. data/script/setup +0 -47
  45. data/script/teardown +0 -42
  46. data/spec/integration/new_app_spec.rb +0 -21
  47. data/spec/spec_helper.rb +0 -22
  48. data/spec/support/app.rb +0 -64
  49. data/spec/support/bundler.rb +0 -113
  50. data/spec/support/cli.rb +0 -47
  51. data/spec/support/directories.rb +0 -37
  52. data/spec/support/env.rb +0 -84
  53. data/spec/support/files.rb +0 -59
  54. data/spec/support/project.rb +0 -60
  55. data/spec/support/requests.rb +0 -5
  56. data/spec/support/silently.rb +0 -28
  57. data/spec/unit/generators/inflections_spec.rb +0 -33
File without changes
data/dry-web-roda.gemspec CHANGED
@@ -1,35 +1,36 @@
1
- lib = File.expand_path("../lib", __FILE__)
1
+ # frozen_string_literal: true
2
+ # this file is managed by dry-rb/devtools project
3
+
4
+ lib = File.expand_path('lib', __dir__)
2
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require "dry/web/roda/version"
6
+ require 'dry/web/roda/version'
4
7
 
5
8
  Gem::Specification.new do |spec|
6
- spec.name = "dry-web-roda"
7
- spec.version = Dry::Web::Roda::VERSION
9
+ spec.name = 'dry-web-roda'
8
10
  spec.authors = ["Piotr Solnica"]
9
11
  spec.email = ["piotr.solnica@gmail.com"]
12
+ spec.license = 'MIT'
13
+ spec.version = Dry::Web::Roda::VERSION.dup
14
+
10
15
  spec.summary = "Roda integration for dry-web apps"
11
16
  spec.description = spec.summary
12
- spec.homepage = "https://github.com/dry-rb/dry-web-roda"
13
- spec.license = "MIT"
17
+ spec.homepage = 'https://dry-rb.org/gems/dry-web-roda'
18
+ spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-web-roda.gemspec", "lib/**/*"]
19
+ spec.bindir = 'bin'
20
+ spec.executables = ["dry-web-roda"]
21
+ spec.require_paths = ['lib']
14
22
 
15
- spec.files = `git ls-files -z`.split("\x0")
16
- spec.bindir = "exe"
17
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
23
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
24
+ spec.metadata['changelog_uri'] = 'https://github.com/dry-rb/dry-web-roda/blob/master/CHANGELOG.md'
25
+ spec.metadata['source_code_uri'] = 'https://github.com/dry-rb/dry-web-roda'
26
+ spec.metadata['bug_tracker_uri'] = 'https://github.com/dry-rb/dry-web-roda/issues'
20
27
 
21
- spec.required_ruby_version = '>= 2.3.0'
28
+ spec.required_ruby_version = ">= 2.4.0"
22
29
 
30
+ # to update dependencies edit project.yml
23
31
  spec.add_runtime_dependency "dry-configurable", "~> 0.2"
24
- spec.add_runtime_dependency "inflecto", "~> 0.0"
25
- spec.add_runtime_dependency "roda", "~> 2.14"
26
- spec.add_runtime_dependency "roda-flow", "~> 0.3.1"
27
- spec.add_runtime_dependency "thor", "~> 0.19"
28
-
29
- spec.add_development_dependency "aruba"
30
- spec.add_development_dependency "bundler", "~> 1.7"
31
- spec.add_development_dependency "rake", "~> 11.0"
32
- spec.add_development_dependency "rspec", "~> 3.4"
33
- spec.add_development_dependency "capybara", "~> 2.5"
34
- spec.add_development_dependency "waitutil"
32
+ spec.add_runtime_dependency "dry-inflector", "~> 0.2"
33
+ spec.add_runtime_dependency "roda", "~> 3.0"
34
+ spec.add_runtime_dependency "roda-flow", "~> 0.4"
35
+ spec.add_runtime_dependency "thor", "~> 1.0"
35
36
  end
@@ -53,8 +53,8 @@ module Dry
53
53
  add_template('repository.rb.tt', "lib/#{underscored_project_name}/repository.rb")
54
54
  add_template('.keep', 'lib/persistence/relations/.keep')
55
55
  add_template('.keep', 'lib/persistence/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")
56
+ add_template('view_context.rb.tt', "lib/#{underscored_project_name}/view_context.rb")
57
+ add_template('view.rb.tt', "lib/#{underscored_project_name}/view.rb")
58
58
  end
59
59
 
60
60
  def add_log
@@ -1,4 +1,4 @@
1
- require "inflecto"
1
+ require 'dry/web/roda/inflector'
2
2
 
3
3
  module Dry
4
4
  module Web
@@ -8,11 +8,11 @@ module Dry
8
8
  module_function
9
9
 
10
10
  def underscored_name(name)
11
- Inflecto.underscore(name)
11
+ Inflector.underscore(name)
12
12
  end
13
13
 
14
14
  def camel_cased_name(name)
15
- Inflecto.camelize(underscored_name(name))
15
+ Inflector.camelize(underscored_name(name))
16
16
  end
17
17
  end
18
18
  end
@@ -34,8 +34,8 @@ module Dry
34
34
  end
35
35
 
36
36
  def add_lib
37
- add_template('subapp/view__context.rb.tt', "#{lib_path}/view/context.rb")
38
- add_template('subapp/view__controller.rb.tt', "#{lib_path}/view/controller.rb")
37
+ add_template('subapp/view_context.rb.tt', "#{lib_path}/view_context.rb")
38
+ add_template('subapp/view.rb.tt', "#{lib_path}/view.rb")
39
39
  add_template('subapp/welcome.rb.tt', "#{lib_path}/views/welcome.rb")
40
40
  end
41
41
 
@@ -0,0 +1,9 @@
1
+ require 'dry/inflector'
2
+
3
+ module Dry
4
+ module Web
5
+ module Roda
6
+ Inflector = Dry::Inflector.new
7
+ end
8
+ end
9
+ end
@@ -1,41 +1,46 @@
1
1
  source "https://rubygems.org"
2
2
 
3
+ # TODO: The original content of this Gemfile was generated by dry-web-roda.
4
+ # It is recommended to review the dependencies and define their version
5
+ # requirements for gems that miss them.
3
6
  gem "rake"
4
7
 
5
8
  # Web framework
6
- gem "dry-system", "~> 0.9"
7
- gem "dry-web", "~> 0.7"
8
- gem "dry-web-roda", "~> 0.7"
9
+ gem "dry-web-roda"
10
+ gem "dry-system"
11
+ gem "dry-web"
9
12
  gem "puma"
10
13
  gem "rack_csrf"
11
14
 
12
15
  gem "rack", ">= 2.0"
13
- gem "rerun"
14
16
 
15
17
  # Database persistence
16
18
  gem "pg"
17
- gem "rom", "~> 4.0"
18
- gem "rom-sql", "~> 2.1"
19
+ gem "rom", "~> 5.1"
20
+ gem "rom-sql", "~> 3.1"
19
21
 
20
22
  # Application dependencies
21
- gem "dry-matcher", "~> 0.6.0"
22
- gem "dry-monads", "~> 0.3"
23
- gem "dry-struct", "~> 0.3"
24
- gem "dry-transaction", "~> 0.10"
25
- gem "dry-types", "~> 0.12"
26
- gem "dry-validation", "~> 0.11"
27
- gem "dry-view", "~> 0.4"
23
+ gem "dry-matcher"
24
+ gem "dry-monads"
25
+ gem "dry-struct"
26
+ gem "dry-types"
27
+ gem "dry-validation"
28
+ gem "dry-view"
28
29
  gem "slim"
29
30
 
30
31
  group :development, :test do
31
32
  gem "pry-byebug", platform: :mri
32
33
  end
33
34
 
35
+ group :development do
36
+ gem "rerun"
37
+ end
38
+
34
39
  group :test do
35
40
  gem "capybara"
36
41
  gem "capybara-screenshot"
37
42
  gem "database_cleaner"
38
43
  gem "poltergeist"
39
44
  gem "rspec"
40
- gem "rom-factory", "~> 0.5"
45
+ gem "rom-factory", "~> 0.10"
41
46
  end
@@ -5,8 +5,11 @@ Welcome! You’ve generated an app using dry-web-roda.
5
5
  ## First steps
6
6
 
7
7
  1. Run `bundle`
8
- 2. Review `.env` & `.env.test` (and make a copy to e.g. `.example.env` if you want example settings checked in)
9
- 3. Run `bundle exec rake db:create`
10
- 4. Add your own steps to `bin/setup`
11
- 5. Run the app with `bundle exec rerun -- rackup --port 4000 config.ru`
12
- 6. Initialize git with `git init` and make your initial commit
8
+ 2. Review `.env` & `.env.test` (and make a copy to e.g. `.example.env` if you want example settings checked in). In
9
+ particular, ensure that your PostgreSQL username and password are specified in the `DATABASE_URL` variable as follows:
10
+ `postgres://username:password@your_host/...`.
11
+ 3. Run `bundle exec rake db:create` to create the development database.
12
+ 4. Run `RACK_ENV=test bundle exec rake db:create` to create the test database.
13
+ 5. Add your own steps to `bin/setup`
14
+ 6. Run the app with `bundle exec rerun -- rackup --port 4000 config.ru`
15
+ 7. Initialize git with `git init` and make your initial commit
@@ -1,5 +1,7 @@
1
1
  require "dry/web/container"
2
2
  require "dry/system/components"
3
+ require 'dry-monitor'
4
+ Dry::Monitor.load_extensions(:rack)
3
5
 
4
6
  module <%= config[:camel_cased_app_name] %>
5
7
  class Container < Dry::Web::Container
@@ -1,3 +1,5 @@
1
+ require "bundler/setup"
2
+
1
3
  begin
2
4
  require "pry-byebug"
3
5
  rescue LoadError
@@ -11,19 +11,21 @@ module <%= config[:camel_cased_app_name] %>
11
11
  opts[:root] = Pathname(__FILE__).join("../..").realpath.dirname
12
12
 
13
13
  use Rack::Session::Cookie, key: "<%= config[:underscored_project_name] %>.session", secret: self["settings"].session_secret
14
+ use Rack::MethodOverride
14
15
 
15
16
  plugin :csrf, raise: true
16
17
  plugin :dry_view
17
18
  plugin :error_handler
18
19
  plugin :flash
19
20
  plugin :multi_route
21
+ plugin :all_verbs
20
22
 
21
23
  route do |r|
22
24
  # Enable this after writing your first web/routes/ file
23
25
  # r.multi_route
24
26
 
25
27
  r.root do
26
- r.view "welcome"
28
+ r.view :welcome
27
29
  end
28
30
  end
29
31
 
@@ -1,9 +1,10 @@
1
1
  <%= config[:camel_cased_app_name] %>::Container.boot :monitor do
2
2
  init do
3
- require "dry/monitor"
3
+ require "dry/monitor/sql/logger"
4
4
  end
5
5
 
6
6
  start do
7
+ notifications.register_event(:sql)
7
8
  Dry::Monitor::SQL::Logger.new(logger).subscribe(notifications)
8
9
  end
9
10
  end
@@ -5,9 +5,6 @@ require "dry/system/components"
5
5
  module <%= config[:camel_cased_umbrella_name] %>
6
6
  module <%= config[:camel_cased_app_name] %>
7
7
  class Container < Dry::Web::Container
8
- require root.join("system/<%= config[:underscored_umbrella_name] %>/container")
9
- import core: <%= config[:camel_cased_umbrella_name] %>::Container
10
-
11
8
  configure do |config|
12
9
  config.root = Pathname(__FILE__).join("../../..").realpath.dirname.freeze
13
10
  config.logger = <%= config[:camel_cased_umbrella_name] %>::Container[:logger]
@@ -15,6 +12,9 @@ module <%= config[:camel_cased_umbrella_name] %>
15
12
  config.auto_register = %w[lib/<%= config[:underscored_umbrella_name] %>/<%= config[:underscored_project_name] %>]
16
13
  end
17
14
 
15
+ require root.join("../../system/<%= config[:underscored_umbrella_name] %>/container").to_s
16
+ import core: <%= config[:camel_cased_umbrella_name] %>::Container
17
+
18
18
  load_paths! "lib"
19
19
  end
20
20
  end
@@ -0,0 +1,17 @@
1
+ # auto_register: false
2
+
3
+ require "slim"
4
+ require "dry/view"
5
+ require "<%= config[:underscored_umbrella_name] %>/<%= config[:underscored_project_name] %>/container"
6
+
7
+ module <%= config[:camel_cased_umbrella_name] %>
8
+ module <%= config[:camel_cased_app_name] %>
9
+ class View < Dry::View
10
+ configure do |config|
11
+ config.paths = [Container.root.join("web/templates")]
12
+ config.default_context = Container["view_context"]
13
+ config.layout = "application"
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,8 @@
1
+ require "<%= config[:underscored_umbrella_name] %>/view_context"
2
+
3
+ module <%= config[:camel_cased_umbrella_name] %>
4
+ module <%= config[:camel_cased_app_name] %>
5
+ class ViewContext < <%= config[:camel_cased_umbrella_name] %>::ViewContext
6
+ end
7
+ end
8
+ end
@@ -12,19 +12,21 @@ module <%= config[:camel_cased_umbrella_name] %>
12
12
  opts[:root] = Pathname(__FILE__).join("../../..").realpath.dirname
13
13
 
14
14
  use Rack::Session::Cookie, key: "<%= config[:underscored_umbrella_name] %>.<%= config[:underscored_project_name] %>.session", secret: self["core.settings"].session_secret
15
+ use Rack::MethodOverride
15
16
 
16
17
  plugin :csrf, raise: true
17
18
  plugin :dry_view
18
19
  plugin :error_handler
19
20
  plugin :flash
20
21
  plugin :multi_route
22
+ plugin :all_verbs
21
23
 
22
24
  route do |r|
23
25
  # Enable this after writing your first web/routes/ file
24
26
  # r.multi_route
25
27
 
26
28
  r.root do
27
- r.view "welcome"
29
+ r.view :welcome
28
30
  end
29
31
  end
30
32
 
@@ -1,9 +1,9 @@
1
- require "<%= config[:underscored_umbrella_name] %>/<%= config[:underscored_project_name] %>/view/controller"
1
+ require "<%= config[:underscored_umbrella_name] %>/<%= config[:underscored_project_name] %>/view"
2
2
 
3
3
  module <%= config[:camel_cased_umbrella_name] %>
4
4
  module <%= config[:camel_cased_app_name] %>
5
5
  module Views
6
- class Welcome < View::Controller
6
+ class Welcome < View
7
7
  configure do |config|
8
8
  config.template = "welcome"
9
9
  end
@@ -1,6 +1,6 @@
1
- require "dry-struct"
2
- require "dry-types"
1
+ require "dry/struct"
2
+ require "dry/types"
3
3
 
4
4
  module Types
5
- include Dry::Types.module
5
+ include Dry.Types()
6
6
  end
@@ -1,3 +1,5 @@
1
+ require "bundler/setup"
2
+
1
3
  begin
2
4
  require "pry-byebug"
3
5
  rescue LoadError
@@ -0,0 +1,15 @@
1
+ # auto_register: false
2
+
3
+ require "slim"
4
+ require "dry/view"
5
+ require "<%= config[:underscored_project_name] %>/container"
6
+
7
+ module <%= config[:camel_cased_app_name] %>
8
+ class View < Dry::View
9
+ configure do |config|
10
+ config.paths = [Container.root.join("web/templates")]
11
+ config.default_context = Container["view_context"]
12
+ config.layout = "application"
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,31 @@
1
+ require "dry/view/context"
2
+
3
+ module <%= config[:camel_cased_app_name] %>
4
+ class ViewContext < Dry::View::Context
5
+ def csrf_token
6
+ self[:csrf_token]
7
+ end
8
+
9
+ def csrf_metatag
10
+ self[:csrf_metatag]
11
+ end
12
+
13
+ def csrf_tag
14
+ self[:csrf_tag]
15
+ end
16
+
17
+ def flash
18
+ self[:flash]
19
+ end
20
+
21
+ def flash?
22
+ %i[notice alert].any? { |type| flash[type] }
23
+ end
24
+
25
+ private
26
+
27
+ def [](name)
28
+ _options.fetch(name)
29
+ end
30
+ end
31
+ end
@@ -1,8 +1,8 @@
1
- require "<%= config[:underscored_project_name] %>/view/controller"
1
+ require "<%= config[:underscored_project_name] %>/view"
2
2
 
3
3
  module <%= config[:camel_cased_app_name] %>
4
4
  module Views
5
- class Welcome < <%= config[:camel_cased_app_name] %>::View::Controller
5
+ class Welcome < <%= config[:camel_cased_app_name] %>::View
6
6
  configure do |config|
7
7
  config.template = "welcome"
8
8
  end
@@ -1,7 +1,7 @@
1
1
  module Dry
2
2
  module Web
3
3
  module Roda
4
- VERSION = "0.10.0".freeze
4
+ VERSION = "0.14.0".freeze
5
5
  end
6
6
  end
7
7
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Roda
2
4
  module RodaPlugins
3
5
  module DryView
@@ -7,7 +9,7 @@ class Roda
7
9
 
8
10
  module InstanceMethods
9
11
  def view_context
10
- self.class["view.context"].with(view_context_options)
12
+ self.class["view_context"].with(view_context_options)
11
13
  end
12
14
 
13
15
  def view_context_options
@@ -21,8 +23,9 @@ class Roda
21
23
 
22
24
  module RequestMethods
23
25
  def view(name, options = {})
24
- options = {context: scope.view_context}.merge(options)
25
- is to: scope.view_key(name), call_with: [options]
26
+ resolve(scope.view_key(name)) do |renderer|
27
+ renderer.call({ context: scope.view_context }.merge(options)).to_s
28
+ end
26
29
  end
27
30
  end
28
31
  end