dry-web 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +34 -0
- data/.rspec +3 -0
- data/.travis.yml +30 -0
- data/CHANGELOG.md +16 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +21 -0
- data/LICENSE +22 -0
- data/LICENSE.txt +22 -0
- data/README.md +46 -0
- data/Rakefile +6 -0
- data/lib/dry-web.rb +8 -0
- data/lib/dry/web/application.rb +34 -0
- data/lib/dry/web/cli.rb +17 -0
- data/lib/dry/web/container.rb +9 -0
- data/lib/dry/web/transaction.rb +19 -0
- data/lib/dry/web/version.rb +5 -0
- data/lib/roda/plugins/flow.rb +71 -0
- data/rodakase.gemspec +34 -0
- data/skeletons/simple/.ruby-version +1 -0
- data/skeletons/simple/Gemfile +11 -0
- data/skeletons/simple/README.md +21 -0
- data/skeletons/simple/Rakefile +4 -0
- data/skeletons/simple/bin/console +6 -0
- data/skeletons/simple/config.ru +3 -0
- data/skeletons/simple/config/application.yml +4 -0
- data/skeletons/simple/core/boot.rb +12 -0
- data/skeletons/simple/core/simple/application.rb +16 -0
- data/skeletons/simple/core/simple/container.rb +11 -0
- data/skeletons/simple/core/simple/import.rb +9 -0
- data/skeletons/simple/lib/entities/user.rb +3 -0
- data/skeletons/simple/log/.gitkeep +0 -0
- data/skeletons/simple/spec/routes/heartbeat_spec.rb +9 -0
- data/skeletons/simple/spec/spec_helper.rb +12 -0
- data/skeletons/simple/spec/unit/user_spec.rb +17 -0
- data/skeletons/simple/spec/web_helper.rb +20 -0
- data/skeletons/simple/web/routes/root.rb +3 -0
- data/spec/dummy/apps/main/core/boot.rb +15 -0
- data/spec/dummy/apps/main/core/main/application.rb +17 -0
- data/spec/dummy/apps/main/core/main/container.rb +16 -0
- data/spec/dummy/apps/main/core/main/import.rb +9 -0
- data/spec/dummy/apps/main/core/main/requests.rb +21 -0
- data/spec/dummy/apps/main/core/main/view.rb +21 -0
- data/spec/dummy/apps/main/lib/main/entities/user.rb +5 -0
- data/spec/dummy/apps/main/lib/main/persistence/repositories/users.rb +16 -0
- data/spec/dummy/apps/main/lib/main/transactions/register_user.rb +19 -0
- data/spec/dummy/apps/main/lib/main/views/users/index.rb +17 -0
- data/spec/dummy/apps/main/log/.gitkeep +0 -0
- data/spec/dummy/apps/main/requests/users.rb +5 -0
- data/spec/dummy/apps/main/web/routes/users.rb +19 -0
- data/spec/dummy/apps/main/web/templates/layouts/app.html.slim +6 -0
- data/spec/dummy/apps/main/web/templates/users/index.html.slim +3 -0
- data/spec/dummy/apps/main/web/templates/users/index/_list.html.slim +3 -0
- data/spec/dummy/apps/main/web/templates/users/index/_list_item.html.slim +1 -0
- data/spec/dummy/bin/console +6 -0
- data/spec/dummy/config.ru +3 -0
- data/spec/dummy/config/application.yml +4 -0
- data/spec/dummy/core/boot.rb +8 -0
- data/spec/dummy/core/dummy/application.rb +7 -0
- data/spec/dummy/core/dummy/container.rb +14 -0
- data/spec/dummy/core/dummy/import.rb +9 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/shared/persistence.rb +12 -0
- data/spec/dummy/shared/persistence/db.rb +9 -0
- data/spec/fixtures/test/core/boot/bar.rb +11 -0
- data/spec/fixtures/test/lib/test/dep.rb +4 -0
- data/spec/fixtures/test/lib/test/foo.rb +5 -0
- data/spec/fixtures/test/lib/test/models.rb +4 -0
- data/spec/fixtures/test/lib/test/models/book.rb +6 -0
- data/spec/fixtures/test/lib/test/models/user.rb +6 -0
- data/spec/integration/application_spec.rb +21 -0
- data/spec/request/users_spec.rb +35 -0
- data/spec/spec_helper.rb +44 -0
- data/spec/support/helpers.rb +15 -0
- metadata +322 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d5ba8f9faeb0a3e0595de3e686095a683896f0f1
|
4
|
+
data.tar.gz: a6f025dc1d9c67824dba13a537112172f08b07f4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: afd37f9bdc809c044d5a54c04a1c61de7dd34d2cfbea6a7e302a39f79213cf70d7c2189150a1b742e65d2408abc61d81cbbba47674254585cb2ae889f2f7f87d
|
7
|
+
data.tar.gz: 29d78e836e947ada5becdf6f94feb2731c5eef916951689d30b4fcb44107edd484510eefa808900b8f1b794ae87b4dd19525d5a317b99591e886e9da06979b8e
|
data/.gitignore
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
Gemfile.lock
|
30
|
+
# .ruby-version
|
31
|
+
# .ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
language: ruby
|
2
|
+
sudo: false
|
3
|
+
cache: bundler
|
4
|
+
bundler_args: --without tools
|
5
|
+
script:
|
6
|
+
- bundle exec rake spec
|
7
|
+
rvm:
|
8
|
+
- 2.0
|
9
|
+
- 2.1
|
10
|
+
- 2.2
|
11
|
+
- 2.3.0
|
12
|
+
- rbx-2
|
13
|
+
- jruby-9000
|
14
|
+
- ruby-head
|
15
|
+
- jruby-head
|
16
|
+
env:
|
17
|
+
global:
|
18
|
+
- JRUBY_OPTS='--dev -J-Xmx1024M'
|
19
|
+
matrix:
|
20
|
+
allow_failures:
|
21
|
+
- rvm: ruby-head
|
22
|
+
- rvm: jruby-head
|
23
|
+
notifications:
|
24
|
+
email: false
|
25
|
+
webhooks:
|
26
|
+
urls:
|
27
|
+
- https://webhooks.gitter.im/e/19098b4253a72c9796db
|
28
|
+
on_success: change # options: [always|never|change] default: always
|
29
|
+
on_failure: always # options: [always|never|change] default: always
|
30
|
+
on_start: false # default: false
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# v0.1.0 / 2016-04-21
|
2
|
+
|
3
|
+
### Changed
|
4
|
+
|
5
|
+
– Renamed from rodakase to dry-web
|
6
|
+
– Dependency management features were extracted into [dry-component](https://github.com/dry-rb/dry-component)
|
7
|
+
– `Rodakase::View` was extracted into the [dry-view](https://github.com/dry-rb/dry-view) gem
|
8
|
+
|
9
|
+
# v0.0.1 / 2015-11-13
|
10
|
+
|
11
|
+
Awesome, first release on Friday 13th. Let's be optimistic. This release ships with:
|
12
|
+
|
13
|
+
- `Rodakase::Container` API for dependency management and component loading
|
14
|
+
- `Rodakase::Application` customized `Roda::Application` API for web part
|
15
|
+
- `Rodakase::Transaction` for composing processing pipelines
|
16
|
+
- `Rodakase::View` an experimental, helper-less, template-as-data view layer
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in rodakase.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem 'dry-component', github: 'dryrb/dry-component', branch: 'master'
|
7
|
+
|
8
|
+
group :test do
|
9
|
+
gem 'byebug', platform: :mri
|
10
|
+
gem 'rack-test'
|
11
|
+
gem 'slim'
|
12
|
+
gem 'anima', '~> 0.2.0' # >= 0.3.0 requires MRI >= 2.2
|
13
|
+
|
14
|
+
gem 'dry-data'
|
15
|
+
|
16
|
+
gem 'codeclimate-test-reporter', platform: :rbx
|
17
|
+
end
|
18
|
+
|
19
|
+
group :tools do
|
20
|
+
gem 'pry'
|
21
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Piotr Solnica
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Piotr Solnica
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
[gem]: https://rubygems.org/gems/dry-web
|
2
|
+
[travis]: https://travis-ci.org/dry-rb/dry-web
|
3
|
+
[codeclimate]: https://codeclimate.com/github/dry-rb/dry-web
|
4
|
+
[inchpages]: http://inch-ci.org/github/dry-rb/dry-web/
|
5
|
+
|
6
|
+
# dry-web [![Join the chat at https://gitter.im/dry-rb/chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/dry-rb/chat?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
7
|
+
|
8
|
+
[![Gem Version](https://badge.fury.io/rb/dry-web.svg)][gem]
|
9
|
+
[![Build Status](https://travis-ci.org/dry-rb/dry-web.svg?branch=master)][travis]
|
10
|
+
[![Code Climate](https://codeclimate.com/github/dry-rb/dry-web/badges/gpa.svg)][codeclimate]
|
11
|
+
[![Test Coverage](https://codeclimate.com/github/dry-rb/dry-web/badges/coverage.svg)][codeclimate]
|
12
|
+
[![Inline docs](http://inch-ci.org/github/dry-rb/dry-web.svg?branch=master&style=flat)][inchpages]
|
13
|
+
|
14
|
+
## Tools
|
15
|
+
|
16
|
+
dry-web is composed from the following libraries:
|
17
|
+
|
18
|
+
* [roda](http://roda.jeremyevans.net)
|
19
|
+
* [dry-component](https://github.com/dry-rb/dry-component)
|
20
|
+
* [dry-view](https://github.com/dry-rb/dry-view)
|
21
|
+
* [dry-transaction](https://github.com/dry-rb/dry-transaction)
|
22
|
+
|
23
|
+
## LICENSE
|
24
|
+
|
25
|
+
See `LICENSE.txt` file.
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
To run the specs make sure the dummy app uses proper db configuration `spec/dummy/config/application.yml`.
|
30
|
+
Also you need to run the migrations, do following:
|
31
|
+
|
32
|
+
```
|
33
|
+
$ cd spec/dummy
|
34
|
+
$ bundle install
|
35
|
+
$ rake db:migrate
|
36
|
+
```
|
37
|
+
|
38
|
+
After that you can run the specs from dry-web root:
|
39
|
+
|
40
|
+
```
|
41
|
+
$ bundle exec rspec
|
42
|
+
```
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/dry-rb/dry-web.
|
data/Rakefile
ADDED
data/lib/dry-web.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'roda'
|
2
|
+
require 'dry-configurable'
|
3
|
+
|
4
|
+
module Dry
|
5
|
+
module Web
|
6
|
+
class Application < Roda
|
7
|
+
extend Dry::Configurable
|
8
|
+
|
9
|
+
setting :container
|
10
|
+
setting :routes
|
11
|
+
|
12
|
+
plugin :multi_route
|
13
|
+
plugin :all_verbs
|
14
|
+
|
15
|
+
plugin :flow
|
16
|
+
|
17
|
+
def self.resolve(name)
|
18
|
+
config.container[name]
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.[](name)
|
22
|
+
resolve(name)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.load_routes!
|
26
|
+
Dir[root.join("#{config.routes}/**/*.rb")].each { |f| require f }
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.root
|
30
|
+
config.container.config.root
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/dry/web/cli.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'dry-transaction'
|
2
|
+
|
3
|
+
module Dry
|
4
|
+
module Web
|
5
|
+
module Transaction
|
6
|
+
class Composer
|
7
|
+
attr_reader :container
|
8
|
+
|
9
|
+
def initialize(container)
|
10
|
+
@container = container
|
11
|
+
end
|
12
|
+
|
13
|
+
def define(&block)
|
14
|
+
Dry.Transaction(container: container, &block)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# this is taken from roda-flow plugin but it drops dependency on roda-container
|
2
|
+
class Roda
|
3
|
+
module RodaPlugins
|
4
|
+
module Flow
|
5
|
+
module RequestMethods
|
6
|
+
def resolve(*args, &block)
|
7
|
+
on(resolve: args, &block)
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def match_resolve(resolve)
|
13
|
+
Array(resolve).flatten.each do |key|
|
14
|
+
@captures << roda_class.resolve(key)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def match_to(to)
|
19
|
+
container_key, @block_method = to.to_s.split('#')
|
20
|
+
@block_arg = roda_class.resolve(container_key)
|
21
|
+
end
|
22
|
+
|
23
|
+
def match_inject(inject)
|
24
|
+
@block_arg = @block_arg.call(*inject) if @block_arg
|
25
|
+
end
|
26
|
+
|
27
|
+
def match_call_with(call_with)
|
28
|
+
@captures.concat(call_with)
|
29
|
+
end
|
30
|
+
|
31
|
+
def if_match(*args, &block)
|
32
|
+
path = @remaining_path
|
33
|
+
# For every block, we make sure to reset captures so that
|
34
|
+
# nesting matchers won't mess with each other's captures.
|
35
|
+
@captures.clear
|
36
|
+
|
37
|
+
return unless match_all(args)
|
38
|
+
block_result(get_block(&block).call(*captures))
|
39
|
+
throw :halt, response.finish
|
40
|
+
ensure
|
41
|
+
@remaining_path = path
|
42
|
+
end
|
43
|
+
|
44
|
+
def always(&block)
|
45
|
+
super(&get_block(&block))
|
46
|
+
end
|
47
|
+
|
48
|
+
def get_block(&block)
|
49
|
+
if block_given?
|
50
|
+
block
|
51
|
+
elsif @block_arg
|
52
|
+
if @block_method
|
53
|
+
block_arg = @block_arg.method(@block_method)
|
54
|
+
else
|
55
|
+
block_arg = @block_arg
|
56
|
+
end
|
57
|
+
clear_block_args
|
58
|
+
block_arg
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def clear_block_args
|
63
|
+
@block_arg = nil
|
64
|
+
@block_method = nil
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
register_plugin(:flow, Flow)
|
70
|
+
end
|
71
|
+
end
|
data/rodakase.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'dry/web/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "dry-web"
|
8
|
+
spec.version = Dry::Web::VERSION
|
9
|
+
spec.authors = ["Piotr Solnica"]
|
10
|
+
spec.email = ["piotr.solnica@gmail.com"]
|
11
|
+
spec.summary = "Lightweight web application stack on top of Roda"
|
12
|
+
spec.description = spec.summary
|
13
|
+
spec.homepage = "https://github.com/solnic/rodakase"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "inflecto", "~> 0"
|
22
|
+
spec.add_runtime_dependency "roda", "~> 2.7"
|
23
|
+
spec.add_runtime_dependency "tilt", "~> 2.0"
|
24
|
+
spec.add_runtime_dependency "dry-component", "~> 0"
|
25
|
+
spec.add_runtime_dependency "dry-configurable", "~> 0.1"
|
26
|
+
spec.add_runtime_dependency "dry-equalizer", "~> 0.2"
|
27
|
+
spec.add_runtime_dependency "dry-transaction", "~> 0.5"
|
28
|
+
spec.add_runtime_dependency "dry-view", "~> 0.1"
|
29
|
+
|
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
|
+
end
|