web_pipe 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile +2 -2
- data/README.md +1 -1
- data/docs/extensions/{dry_view.md → hanami_view.md} +16 -14
- data/docs/extensions/rails.md +3 -4
- data/docs/recipes/dry_rb_integration.md +2 -3
- data/lib/web_pipe/extensions/{dry_view/dry_view.rb → hanami_view/hanami_view.rb} +18 -18
- data/lib/web_pipe/extensions/rails/rails.rb +2 -6
- data/lib/web_pipe/version.rb +1 -1
- data/lib/web_pipe.rb +2 -2
- data/web_pipe.gemspec +0 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a8ebc7025774af2e5938efb5c76a0ff120bc386f449900781e3f05d35eb6a15
|
4
|
+
data.tar.gz: a6e03d72fb7cb3bd384cea1f51369f21a375b4a009b8409ef3a588600adc07b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 278d8402ec4ea79266eefd3ee558522af3923bb23232b3fcefd8574d73dc64c8106757f910a1c312ceed57889ee352e5955c19641601dfdcb47bcbbc63673bb8
|
7
|
+
data.tar.gz: 99ae42906946fbdda913bbf4f0cdd2cc1a6c3951ffb5972b52bb11b5caf882b6b6c286b68aca9d92ce0e6974d6168178860ae164d3d49af7bcb36556202b70dc
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
6
6
|
|
7
|
+
## [0.15.0] - 2021-09-12
|
8
|
+
- **BREAKING**. Switch `dry_view` extension with `hanami_view`.
|
9
|
+
[#45](https://github.com/waiting-for-dev/web_pipe/pull/45)
|
10
|
+
|
11
|
+
### Added
|
7
12
|
## [0.14.0] - 2021-04-14
|
8
13
|
### Added
|
9
14
|
- Inspecting operations
|
data/Gemfile
CHANGED
@@ -7,7 +7,7 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
|
7
7
|
# Specify your gem's dependencies in web_pipe.gemspec
|
8
8
|
gemspec
|
9
9
|
|
10
|
-
# TODO: Remove when dry-rb 0.8 is released (ruby 3.0 support)
|
11
10
|
group :development do
|
12
|
-
|
11
|
+
# TODO: Move to gemspec when hanami-view 2.0 is available
|
12
|
+
gem 'hanami-view', github: 'hanami/view', tag: 'v2.0.0.alpha2'
|
13
13
|
end
|
data/README.md
CHANGED
@@ -40,7 +40,7 @@ extension](docs/extensions/rails.md).
|
|
40
40
|
1. [Cookies](docs/extensions/cookies.md)
|
41
41
|
1. [Flash](docs/extensions/flash.md)
|
42
42
|
1. [Dry Schema](docs/extensions/dry_schema.md)
|
43
|
-
1. [
|
43
|
+
1. [Hanami View](docs/extensions/hanami_view.md)
|
44
44
|
1. [Params](docs/extensions/params.md)
|
45
45
|
1. [Rails](docs/extensions/rails.md)
|
46
46
|
1. [Redirect](docs/extensions/redirect.md)
|
@@ -1,8 +1,10 @@
|
|
1
|
-
#
|
1
|
+
# Hanami View
|
2
2
|
|
3
|
-
This
|
4
|
-
|
5
|
-
|
3
|
+
> This extension currently works with `hanami-view` v2.0.0.alpha2, which is not
|
4
|
+
still released but it's available on the gem repository.
|
5
|
+
|
6
|
+
This extensions integrates with [hanami-view](https://github.com/hanami/view)
|
7
|
+
rendering system to set a hanami-view output as response body.
|
6
8
|
|
7
9
|
`WebPipe::Conn#view` method is at the core of this extension. In its basic
|
8
10
|
behaviour, you provide to it a view instance you want to render and any
|
@@ -10,12 +12,12 @@ exposures or options it may need:
|
|
10
12
|
|
11
13
|
```ruby
|
12
14
|
require 'web_pipe'
|
13
|
-
require '
|
15
|
+
require 'hanami/view'
|
14
16
|
require 'my_context'
|
15
17
|
|
16
|
-
WebPipe.load_extensions(:
|
18
|
+
WebPipe.load_extensions(:hanami_view)
|
17
19
|
|
18
|
-
class SayHelloView <
|
20
|
+
class SayHelloView < Hanami::View
|
19
21
|
config.paths = [File.join(__dir__, '..', 'templates')]
|
20
22
|
config.template = 'say_hello'
|
21
23
|
config.default_context = MyContext
|
@@ -40,12 +42,12 @@ However, you can resolve a view from a container if you also use (`:container`
|
|
40
42
|
extension)[container.md]:
|
41
43
|
|
42
44
|
```ruby
|
43
|
-
require '
|
45
|
+
require 'hanami_view'
|
44
46
|
require 'my_container'
|
45
47
|
require 'web_pipe'
|
46
48
|
require 'web_pipe/plugs/config'
|
47
49
|
|
48
|
-
WebPipe.load_extensions(:
|
50
|
+
WebPipe.load_extensions(:hanami_view, :container)
|
49
51
|
|
50
52
|
class MyApp
|
51
53
|
include WebPipe
|
@@ -61,20 +63,20 @@ class MyApp
|
|
61
63
|
end
|
62
64
|
```
|
63
65
|
|
64
|
-
As in a standard call to `
|
65
|
-
(`
|
66
|
+
As in a standard call to `Hanami::View#call`, you can override the context
|
67
|
+
(`Hanami::View::Context`) to use through `context:` option. However, it is still
|
66
68
|
possible to leverage configured default context while being able to inject
|
67
69
|
request specific data to it.
|
68
70
|
|
69
71
|
For that to work, you have to specify required dependencies (in this case,
|
70
|
-
request specific data) to your
|
72
|
+
request specific data) to your hanami-view's context. A very convenient way to do
|
71
73
|
that is with [`dry-auto_inject`](https://dry-rb.org/gems/dry-auto_inject):
|
72
74
|
|
73
75
|
```ruby
|
74
|
-
require '
|
76
|
+
require 'hanami/view/context'
|
75
77
|
require 'my_import'
|
76
78
|
|
77
|
-
class MyContext <
|
79
|
+
class MyContext < Hanami::View::Context
|
78
80
|
include MyImport::Import[:current_path]
|
79
81
|
|
80
82
|
# Without `dry-auto_inject` you have to manually specify dependencies and
|
data/docs/extensions/rails.md
CHANGED
@@ -31,10 +31,9 @@ It's quite possible that you don't need more than that in terms of rails
|
|
31
31
|
integration. Of course, surely you want something more elaborate to generate
|
32
32
|
responses. For that, you can use the view or template system you like. One
|
33
33
|
option that will play specially well here is
|
34
|
-
[`
|
35
|
-
|
36
|
-
|
37
|
-
[extension](https://waiting-for-dev.github.io/web_pipe/docs/extensions/dry_view.html).
|
34
|
+
[`hanami-view`](https://github.com/hanami/view). Furthermore, we have a
|
35
|
+
tailored `hanami_view`
|
36
|
+
[extension](https://waiting-for-dev.github.io/web_pipe/docs/extensions/hanami_view.html).
|
38
37
|
|
39
38
|
You need to use `:rails` extension if:
|
40
39
|
|
@@ -3,9 +3,8 @@
|
|
3
3
|
`web_pipe` has been designed to integrate smoothly with
|
4
4
|
[dry-rb](https://dry-rb.org/) ecosystem. It shares same design
|
5
5
|
principles and it ships with some extensions which even make this
|
6
|
-
integration tighter (like
|
7
|
-
|
8
|
-
[`:dry-schema`](../extensions/dry_schema.md) extensions).
|
6
|
+
integration tighter (like [`:dry-schema`](../extensions/dry_schema.md)
|
7
|
+
extension).
|
9
8
|
|
10
9
|
If you want to use `web_pipe` with the rest of dry-rb libraries,
|
11
10
|
your best bet is to use
|
@@ -2,19 +2,19 @@
|
|
2
2
|
|
3
3
|
require 'web_pipe/types'
|
4
4
|
require 'web_pipe/conn'
|
5
|
-
require '
|
5
|
+
require 'hanami/view'
|
6
6
|
|
7
7
|
#:nodoc:
|
8
8
|
module WebPipe
|
9
|
-
# Integration with `
|
9
|
+
# Integration with `hanami-view` rendering system.
|
10
10
|
#
|
11
11
|
# This extensions adds a {#view} method to {WebPipe::Conn} which
|
12
|
-
# sets the string output of a `
|
12
|
+
# sets the string output of a `hanami-view` view as response body.
|
13
13
|
#
|
14
14
|
# @example
|
15
|
-
# WebPipe.load_extensions(:
|
15
|
+
# WebPipe.load_extensions(:hanami_view)
|
16
16
|
#
|
17
|
-
# class SayHelloView <
|
17
|
+
# class SayHelloView < Hanami::View
|
18
18
|
# config.paths = [File.join(__dir__, '..', 'templates')]
|
19
19
|
# config.template = 'say_hello'
|
20
20
|
#
|
@@ -35,7 +35,7 @@ module WebPipe
|
|
35
35
|
# instance can be resolved from it.
|
36
36
|
#
|
37
37
|
# @example
|
38
|
-
# WebPipe.load_extensions(:
|
38
|
+
# WebPipe.load_extensions(:hanami_view, :container)
|
39
39
|
#
|
40
40
|
# class App
|
41
41
|
# include WebPipe
|
@@ -50,18 +50,18 @@ module WebPipe
|
|
50
50
|
# end
|
51
51
|
# end
|
52
52
|
#
|
53
|
-
# Context ({
|
53
|
+
# Context ({Hanami::View::Context}) for the view can be set explicetly
|
54
54
|
# through the `context:` argument, as in a standard call to
|
55
|
-
# {
|
55
|
+
# {Hanami::View#call}. However, it is possible to leverage configured
|
56
56
|
# default context while still being able to inject request specific
|
57
57
|
# context. For that to work, `:view_context` should be present in
|
58
58
|
# {WebPipe::Conn#config}. Its value must be a lambda accepting the
|
59
59
|
# {Conn} instance and returning a hash, which will be passed to
|
60
|
-
# {
|
60
|
+
# {Hanami::View::Context#with} to create the final context at the
|
61
61
|
# moment {#view} is called.
|
62
62
|
#
|
63
63
|
# @example
|
64
|
-
# class MyContext <
|
64
|
+
# class MyContext < Hanami::View::Context
|
65
65
|
# attr_reader :current_path
|
66
66
|
#
|
67
67
|
# def initialize(current_path: nil, **options)
|
@@ -70,7 +70,7 @@ module WebPipe
|
|
70
70
|
# end
|
71
71
|
# end
|
72
72
|
#
|
73
|
-
# class SayHelloView <
|
73
|
+
# class SayHelloView < Hanami::View
|
74
74
|
# config.paths = [File.join(__dir__, '..', 'templates')]
|
75
75
|
# config.template = 'say_hello'
|
76
76
|
# config.default_context = MyContext.new
|
@@ -96,7 +96,7 @@ module WebPipe
|
|
96
96
|
# end
|
97
97
|
# end
|
98
98
|
#
|
99
|
-
# @see https://
|
99
|
+
# @see https://github.com/hanami/view
|
100
100
|
# @see WebPipe::Container
|
101
101
|
module DryView
|
102
102
|
# Where to find in {#config} request's view context generator.
|
@@ -107,17 +107,17 @@ module WebPipe
|
|
107
107
|
|
108
108
|
# Sets string output of a view as response body.
|
109
109
|
#
|
110
|
-
# If the view is not a {
|
110
|
+
# If the view is not a {Hanami::View} instance, it is resolved from
|
111
111
|
# the configured container.
|
112
112
|
#
|
113
113
|
# `kwargs` is used as the input for the view (the arguments that
|
114
|
-
# {
|
114
|
+
# {Hanami::View#call} receives). If they doesn't contain an explicit
|
115
115
|
# `context:` key, it can be added through the injection of the
|
116
116
|
# result of a lambda present in context's `:view_context`.(see
|
117
|
-
# {
|
117
|
+
# {Hanami::View::Context#with}).
|
118
118
|
#
|
119
|
-
# @param view_spec [
|
120
|
-
# @param kwargs [Hash] Arguments to pass along to `
|
119
|
+
# @param view_spec [Hanami::View, Any]
|
120
|
+
# @param kwargs [Hash] Arguments to pass along to `Hanami::View#call`
|
121
121
|
#
|
122
122
|
# @return WebPipe::Conn
|
123
123
|
def view(view_spec, **kwargs)
|
@@ -134,7 +134,7 @@ module WebPipe
|
|
134
134
|
private
|
135
135
|
|
136
136
|
def view_instance(view_spec)
|
137
|
-
return view_spec if view_spec.is_a?(
|
137
|
+
return view_spec if view_spec.is_a?(Hanami::View)
|
138
138
|
|
139
139
|
fetch_config(:container)[view_spec]
|
140
140
|
end
|
@@ -37,9 +37,8 @@ module WebPipe
|
|
37
37
|
# It's quite possible that you don't need more than that in terms of rails
|
38
38
|
# integration. Of course, surely you want something more elaborate to generate
|
39
39
|
# responses. For that, you can use the view or template system you like. One
|
40
|
-
# option that will play specially well here is `
|
41
|
-
#
|
42
|
-
# extension.
|
40
|
+
# option that will play specially well here is `hanami-view`. Furthermore, we
|
41
|
+
# have a tailored `hanami_view` extension.
|
43
42
|
#
|
44
43
|
# You need to use `:rails` extension if:
|
45
44
|
#
|
@@ -118,9 +117,6 @@ module WebPipe
|
|
118
117
|
# https://github.com/waiting-for-dev/rails-web_pipe
|
119
118
|
#
|
120
119
|
# @see https://guides.rubyonrails.org/routing.html#routing-to-rack-applications
|
121
|
-
# @see https://dry-rb.org/gems/dry-view/
|
122
|
-
# @see https://github.com/dry-rb/dry-view/tree/master/examples/rails
|
123
|
-
# @see https://waiting-for-dev.github.io/web_pipe/docs/extensions/dry_view.html
|
124
120
|
# @see https://api.rubyonrails.org/v6.0.1/classes/ActionController/Renderer.html
|
125
121
|
# @see https://api.rubyonrails.org/v6.0.1/classes/ActionController/Renderer.html
|
126
122
|
# @see https://api.rubyonrails.org/v6.0.1/classes/ActionView/Helpers/UrlHelper.html
|
data/lib/web_pipe/version.rb
CHANGED
data/lib/web_pipe.rb
CHANGED
@@ -27,8 +27,8 @@ module WebPipe
|
|
27
27
|
require 'web_pipe/extensions/dry_schema/plugs/sanitize_params'
|
28
28
|
end
|
29
29
|
|
30
|
-
register_extension :
|
31
|
-
require 'web_pipe/extensions/
|
30
|
+
register_extension :hanami_view do
|
31
|
+
require 'web_pipe/extensions/hanami_view/hanami_view'
|
32
32
|
end
|
33
33
|
|
34
34
|
register_extension :container do
|
data/web_pipe.gemspec
CHANGED
@@ -43,8 +43,6 @@ Gem::Specification.new do |spec|
|
|
43
43
|
spec.add_development_dependency 'bundler'
|
44
44
|
spec.add_development_dependency 'dry-schema', '~> 1.0'
|
45
45
|
spec.add_development_dependency 'dry-transformer', '~> 0.1'
|
46
|
-
# TODO: Readd when dry-rb 0.8 is released (ruby 3.0 support)
|
47
|
-
# spec.add_development_dependency 'dry-view', '~> 0.8'
|
48
46
|
spec.add_development_dependency 'pry-byebug'
|
49
47
|
spec.add_development_dependency 'rack-flash3', '~> 1.0'
|
50
48
|
spec.add_development_dependency 'rack-test', '~> 1.1'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: web_pipe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc Busqué
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-monads
|
@@ -277,8 +277,8 @@ files:
|
|
277
277
|
- docs/extensions/container.md
|
278
278
|
- docs/extensions/cookies.md
|
279
279
|
- docs/extensions/dry_schema.md
|
280
|
-
- docs/extensions/dry_view.md
|
281
280
|
- docs/extensions/flash.md
|
281
|
+
- docs/extensions/hanami_view.md
|
282
282
|
- docs/extensions/params.md
|
283
283
|
- docs/extensions/rails.md
|
284
284
|
- docs/extensions/redirect.md
|
@@ -318,8 +318,8 @@ files:
|
|
318
318
|
- lib/web_pipe/extensions/cookies/cookies.rb
|
319
319
|
- lib/web_pipe/extensions/dry_schema/dry_schema.rb
|
320
320
|
- lib/web_pipe/extensions/dry_schema/plugs/sanitize_params.rb
|
321
|
-
- lib/web_pipe/extensions/dry_view/dry_view.rb
|
322
321
|
- lib/web_pipe/extensions/flash/flash.rb
|
322
|
+
- lib/web_pipe/extensions/hanami_view/hanami_view.rb
|
323
323
|
- lib/web_pipe/extensions/params/params.rb
|
324
324
|
- lib/web_pipe/extensions/params/params/transf.rb
|
325
325
|
- lib/web_pipe/extensions/rails/rails.rb
|