dry-web 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/Gemfile +1 -10
  4. data/README.md +0 -3
  5. data/{rodakase.gemspec → dry-web.gemspec} +3 -10
  6. data/lib/dry-web.rb +0 -4
  7. data/lib/dry/web/version.rb +1 -1
  8. data/spec/spec_helper.rb +7 -16
  9. data/spec/unit/container_spec.rb +52 -0
  10. metadata +11 -200
  11. data/lib/dry/web/application.rb +0 -34
  12. data/lib/dry/web/transaction.rb +0 -19
  13. data/lib/roda/plugins/flow.rb +0 -71
  14. data/skeletons/simple/.ruby-version +0 -1
  15. data/skeletons/simple/Gemfile +0 -11
  16. data/skeletons/simple/README.md +0 -21
  17. data/skeletons/simple/Rakefile +0 -4
  18. data/skeletons/simple/bin/console +0 -6
  19. data/skeletons/simple/config.ru +0 -3
  20. data/skeletons/simple/config/application.yml +0 -4
  21. data/skeletons/simple/core/boot.rb +0 -12
  22. data/skeletons/simple/core/simple/application.rb +0 -16
  23. data/skeletons/simple/core/simple/container.rb +0 -11
  24. data/skeletons/simple/core/simple/import.rb +0 -9
  25. data/skeletons/simple/lib/entities/user.rb +0 -3
  26. data/skeletons/simple/log/.gitkeep +0 -0
  27. data/skeletons/simple/spec/routes/heartbeat_spec.rb +0 -9
  28. data/skeletons/simple/spec/spec_helper.rb +0 -12
  29. data/skeletons/simple/spec/unit/user_spec.rb +0 -17
  30. data/skeletons/simple/spec/web_helper.rb +0 -20
  31. data/skeletons/simple/web/routes/root.rb +0 -3
  32. data/spec/dummy/apps/main/core/boot.rb +0 -15
  33. data/spec/dummy/apps/main/core/main/application.rb +0 -17
  34. data/spec/dummy/apps/main/core/main/container.rb +0 -16
  35. data/spec/dummy/apps/main/core/main/import.rb +0 -9
  36. data/spec/dummy/apps/main/core/main/requests.rb +0 -21
  37. data/spec/dummy/apps/main/core/main/view.rb +0 -21
  38. data/spec/dummy/apps/main/lib/main/entities/user.rb +0 -5
  39. data/spec/dummy/apps/main/lib/main/persistence/repositories/users.rb +0 -16
  40. data/spec/dummy/apps/main/lib/main/transactions/register_user.rb +0 -19
  41. data/spec/dummy/apps/main/lib/main/views/users/index.rb +0 -17
  42. data/spec/dummy/apps/main/log/.gitkeep +0 -0
  43. data/spec/dummy/apps/main/requests/users.rb +0 -5
  44. data/spec/dummy/apps/main/web/routes/users.rb +0 -19
  45. data/spec/dummy/apps/main/web/templates/layouts/app.html.slim +0 -6
  46. data/spec/dummy/apps/main/web/templates/users/index.html.slim +0 -3
  47. data/spec/dummy/apps/main/web/templates/users/index/_list.html.slim +0 -3
  48. data/spec/dummy/apps/main/web/templates/users/index/_list_item.html.slim +0 -1
  49. data/spec/dummy/bin/console +0 -6
  50. data/spec/dummy/config.ru +0 -3
  51. data/spec/dummy/config/application.yml +0 -4
  52. data/spec/dummy/core/boot.rb +0 -8
  53. data/spec/dummy/core/dummy/application.rb +0 -7
  54. data/spec/dummy/core/dummy/container.rb +0 -14
  55. data/spec/dummy/core/dummy/import.rb +0 -9
  56. data/spec/dummy/log/.gitkeep +0 -0
  57. data/spec/dummy/shared/persistence.rb +0 -12
  58. data/spec/dummy/shared/persistence/db.rb +0 -9
  59. data/spec/fixtures/test/core/boot/bar.rb +0 -11
  60. data/spec/fixtures/test/lib/test/dep.rb +0 -4
  61. data/spec/fixtures/test/lib/test/foo.rb +0 -5
  62. data/spec/fixtures/test/lib/test/models.rb +0 -4
  63. data/spec/fixtures/test/lib/test/models/book.rb +0 -6
  64. data/spec/fixtures/test/lib/test/models/user.rb +0 -6
  65. data/spec/integration/application_spec.rb +0 -21
  66. data/spec/request/users_spec.rb +0 -35
  67. data/spec/support/helpers.rb +0 -15
@@ -1,16 +0,0 @@
1
- require 'main/import'
2
- require 'main/entities/user'
3
-
4
- module Main
5
- module Persistence
6
- module Repositories
7
- class Users
8
- include Main::Import('persistence.db')
9
-
10
- def all
11
- db[:users]
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,19 +0,0 @@
1
- require 'main/import'
2
- require 'main/entities/user'
3
- require 'kleisli'
4
-
5
- module Main
6
- module Transactions
7
- class RegisterUser
8
- include Main::Import('persistence.db')
9
-
10
- def call(params)
11
- if params['name']
12
- Right(db[:users] << Main::Entities::User.new(*params.values_at('id', 'name')))
13
- else
14
- Left(validation: 'name is missing')
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,17 +0,0 @@
1
- require 'main/view'
2
-
3
- module Main
4
- module Views
5
- module Users
6
- class Index < Main::View
7
- configure do |config|
8
- config.template = 'users/index'
9
- end
10
-
11
- def locals(options)
12
- { users: [{ name: 'Jane' }, { name: 'Joe' }] }
13
- end
14
- end
15
- end
16
- end
17
- end
File without changes
@@ -1,5 +0,0 @@
1
- Main::Requests.define do |r|
2
- r.define('main.requests.users.create') do
3
- step 'main.transactions.register_user'
4
- end
5
- end
@@ -1,19 +0,0 @@
1
- class Main::Application < Dry::Web::Application
2
- route('users') do |r|
3
- r.get(to: 'main.views.users.index')
4
-
5
- r.resolve('main.requests.users.create') do |t|
6
- r.post do
7
- t.(r[:user]) do |m|
8
- m.success do
9
- response.status = 201
10
- end
11
-
12
- m.failure do |err|
13
- r.redirect '/users'
14
- end
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,6 +0,0 @@
1
- doctype html
2
- html
3
- head
4
- title == page.title
5
- body
6
- == yield
@@ -1,3 +0,0 @@
1
- h1 Users
2
-
3
- .users == users.list
@@ -1,3 +0,0 @@
1
- ul
2
- - users.each do |user|
3
- == user.list_item
@@ -1 +0,0 @@
1
- li == user[:name]
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'dry/web/cli'
4
- # require_relative '../core/boot'
5
-
6
- Dry::Web::Cli.start
data/spec/dummy/config.ru DELETED
@@ -1,3 +0,0 @@
1
- require_relative 'core/boot'
2
-
3
- run Dummy::Application.freeze.app
@@ -1,4 +0,0 @@
1
- development:
2
- DATABASE_URL: 'postgres://localhost/rodakase'
3
- test:
4
- DATABASE_URL: 'postgres://localhost/rodakase'
@@ -1,8 +0,0 @@
1
- require_relative 'dummy/container'
2
-
3
- Dummy::Container.finalize!
4
-
5
- app_paths = Pathname(__FILE__).dirname.join('../apps').realpath.join('*')
6
- Dir[app_paths].each { |f| require "#{f}/core/boot" }
7
-
8
- require_relative "dummy/application"
@@ -1,7 +0,0 @@
1
- module Dummy
2
- class Application < Roda
3
- route do |r|
4
- r.run Main::Application.freeze.app
5
- end
6
- end
7
- end
@@ -1,14 +0,0 @@
1
- require 'dry/web/container'
2
-
3
- module Dummy
4
- class Container < Dry::Web::Container
5
- # we need to override default here because we run tests from within the
6
- # project root and our app is in spec/dummy
7
- configure do |config|
8
- config.root = Pathname(__FILE__).dirname.join('../..')
9
- config.auto_register = 'lib'
10
- end
11
-
12
- load_paths!('lib')
13
- end
14
- end
@@ -1,9 +0,0 @@
1
- require_relative 'container'
2
-
3
- module Dummy
4
- Import = Dummy::Container.import_module
5
-
6
- def self.Import(*args)
7
- Import[*args]
8
- end
9
- end
File without changes
@@ -1,12 +0,0 @@
1
- module Persistence
2
- class Container < Dry::Component::Container
3
- configure do |config|
4
- config.root = Pathname(__dir__).join('persistence')
5
- config.name = :persistence
6
- end
7
-
8
- require 'db'
9
-
10
- register(:db, Db.new)
11
- end
12
- end
@@ -1,9 +0,0 @@
1
- module Persistence
2
- class Db
3
- STORE = Hash.new { |k, v| k[v] = [] }
4
-
5
- def [](name)
6
- STORE[name]
7
- end
8
- end
9
- end
@@ -1,11 +0,0 @@
1
- Test::Container.namespace(:test) do |container|
2
- module Test
3
- module Bar
4
- # I shall be booted
5
- end
6
- end
7
-
8
- container.finalize(:bar) do
9
- container.register(:bar, "I was finalized")
10
- end
11
- end
@@ -1,4 +0,0 @@
1
- module Test
2
- class Dep
3
- end
4
- end
@@ -1,5 +0,0 @@
1
- module Test
2
- class Foo
3
- include Import['test.dep']
4
- end
5
- end
@@ -1,4 +0,0 @@
1
- module Test
2
- module Models
3
- end
4
- end
@@ -1,6 +0,0 @@
1
- module Test
2
- module Models
3
- class Book
4
- end
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- module Test
2
- module Models
3
- class User
4
- end
5
- end
6
- end
@@ -1,21 +0,0 @@
1
- require 'main/import'
2
-
3
- RSpec.describe 'Dry Web Application' do
4
- it 'sets env' do
5
- expect(Main::Application.config.container.config.env).to be(:test)
6
- end
7
-
8
- it 'loads container' do
9
- expect(Main::Application[:logger]).to be_instance_of(Logger)
10
- end
11
-
12
- it 'sets up namespaced dependencies' do
13
- expect(Main::Application['main.persistence.repositories.users']).to be_instance_of(Main::Persistence::Repositories::Users)
14
- end
15
-
16
- it 'sets up auto-injection mechanism' do
17
- klass = Class.new { include Main::Import(:logger) }
18
-
19
- expect(klass.new.logger).to be_instance_of(Logger)
20
- end
21
- end
@@ -1,35 +0,0 @@
1
- require 'main/entities/user'
2
-
3
- RSpec.describe '/users', type: :request do
4
- describe 'GET /users' do
5
- it 'renders hello template' do
6
- get '/users'
7
-
8
- expect(last_response).to be_ok
9
-
10
- expect(last_response.body).to eql(
11
- '<!DOCTYPE html><html><head><title>Woohaa</title></head><body><h1>Users</h1><div class="users"><ul><li>Jane</li><li>Joe</li></ul></div></body></html>'
12
- )
13
- end
14
- end
15
-
16
- describe 'POST /users' do
17
- it 'creates a user' do
18
- user = { id: '1', name: 'Jane' }
19
-
20
- post '/users', user: user
21
-
22
- expect(last_response).to be_created
23
-
24
- expect(container['main.persistence.repositories.users'].all).to eql([Main::Entities::User.new('1', 'Jane')])
25
- end
26
-
27
- it 'redirects when name is missing' do
28
- user = { id: '1' }
29
-
30
- post '/users', user: user
31
-
32
- expect(last_response).to be_redirect
33
- end
34
- end
35
- end
@@ -1,15 +0,0 @@
1
- module Helpers
2
- module_function
3
-
4
- def fixtures_path
5
- SPEC_ROOT.join('fixtures')
6
- end
7
-
8
- def container
9
- Main::Container
10
- end
11
-
12
- def app
13
- Dummy::Application.app
14
- end
15
- end