web_pipe 0.12.1 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d7a3628fa20a1c650c63fc908cc7c9b4e503657414bf7b849e9ba60b61e02921
4
- data.tar.gz: 59f50a884043943ccd93017bea7c27b8f488c5f31f3e76dba1ab20442526de13
3
+ metadata.gz: 1a993e68cff01cb6b0ef493b6bdf3207e62a7baca650302c9f65024f3981c18a
4
+ data.tar.gz: dc94f7dfabc97ad712a058f725e85831c38fe2658f42adeca3243b29f10273f9
5
5
  SHA512:
6
- metadata.gz: 9645c64a425650d254195f5b4fdd9ee80d8de6f05e410525fe47074a8f7aeccfe2ee6d73fc90cbd622eeb929e89d0439cc2f1d0af6a2f419d7ca011c6877caa9
7
- data.tar.gz: f0123575ea916a8f7aafc67039dfb640c7d05806f01af6ad5101e2d9bd28b98bcb1ce8886b8959a4d9ff9db322f166670ed1d963dcb5d2447b289b14bd611c9f
6
+ metadata.gz: 2e5925278ef21f20b3c9b8ae25f7bd614c7e17b278693f3521f018cefe1acd1ef63116aba61a9722bc1f4d5b98bfbeb56a6e03d0d246ac359aa595e4c451f6eb
7
+ data.tar.gz: baf191023d9a19ed7facfc77f3107db45e2adb1949a25e4fc306b0a9f85e061e474fc557848beb469aaf0c5ad0446918b9c285b63cc5501bf21d31c19229878c
data/.gitignore CHANGED
@@ -10,4 +10,8 @@
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
12
 
13
- Gemfile.lock
13
+ Gemfile.lock
14
+
15
+ Dockerfile
16
+ docker-compose.yml
17
+ .dockerignore
@@ -0,0 +1,15 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.7.2
3
+ NewCops: enable
4
+ SuggestExtensions: false
5
+ Exclude:
6
+ - "*.gemspec"
7
+ - vendor/**/*
8
+ - Gemfile
9
+
10
+ Metrics/BlockLength:
11
+ Exclude:
12
+ - spec/**/*
13
+
14
+ Naming/AccessorMethodName:
15
+ Enabled: false
@@ -1,10 +1,11 @@
1
- sudo: false
2
1
  language: ruby
2
+ cache: bundler
3
3
  rvm:
4
- - 2.5
5
4
  - 2.6
6
5
  - 2.7
6
+ - 3.0
7
7
  before_install:
8
8
  - gem update --system --no-doc
9
9
  script:
10
10
  - bundle exec rspec
11
+ - bundle exec rubocop
@@ -4,6 +4,13 @@ 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.13.0] - 2021-01-15
8
+ ### Added
9
+ - **BREAKING**. Ruby 2.5 deprecated.
10
+ [#40](https://github.com/waiting-for-dev/web_pipe/pull/40)
11
+ - Ruby 3.0 supported.
12
+ [#41](https://github.com/waiting-for-dev/web_pipe/pull/41)
13
+
7
14
  ## [0.12.1] - 2019-03-18
8
15
  ### Fixed
9
16
  - Update rake to fix security alert
data/Gemfile CHANGED
@@ -6,3 +6,8 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
6
 
7
7
  # Specify your gem's dependencies in web_pipe.gemspec
8
8
  gemspec
9
+
10
+ # TODO: Remove when dry-rb 0.8 is released (ruby 3.0 support)
11
+ group :development do
12
+ gem 'dry-view', github: 'dry-rb/dry-view', ref: 'a048e32'
13
+ end
@@ -12,9 +12,10 @@ conn.params # => { 'foo' => 'bar' }
12
12
  ```
13
13
 
14
14
  You can configure a stack of transformations to be applied to the
15
- parameter hash. For that, we lean on [`transproc`
16
- gem](https://github.com/solnic/transproc) (you have to add it yourself to your
17
- Gemfile). All hash transformations in `transproc` are available by default.
15
+ parameter hash. For that, we lean on [`dry-transformer`
16
+ gem](https://github.com/dry-rb/dry-transformer) (you have to add it yourself to
17
+ your Gemfile). All hash transformations in `dry-transformer` are available by
18
+ default.
18
19
 
19
20
  Transformations must be configured under `:param_transformations`
20
21
  key:
@@ -15,12 +15,12 @@ module WebPipe
15
15
  # @param env [Types::Env] Rack's env
16
16
  #
17
17
  # @return [Conn::Ongoing]
18
+ # rubocop:disable Metrics/MethodLength
18
19
  def self.call(env)
19
20
  rr = Rack::Request.new(env)
20
21
  Conn::Ongoing.new(
21
22
  request: rr,
22
23
  env: env,
23
-
24
24
  scheme: rr.scheme.to_sym,
25
25
  request_method: rr.request_method.downcase.to_sym,
26
26
  host: rr.host,
@@ -33,6 +33,7 @@ module WebPipe
33
33
  request_headers: Headers.extract(env)
34
34
  )
35
35
  end
36
+ # rubocop:enable Metrics/MethodLength
36
37
  end
37
38
  end
38
39
  end
@@ -28,11 +28,11 @@ module WebPipe
28
28
  # @param returned [Any] What was returned from the {Operation}
29
29
  def initialize(returned)
30
30
  super(
31
- <<~eos
31
+ <<~MSG
32
32
  An operation returned +#{returned.inspect}+. To be valid,
33
33
  an operation must return whether a
34
34
  WebPipe::Conn::Ongoing or a WebPipe::Conn::Halted.
35
- eos
35
+ MSG
36
36
  )
37
37
  end
38
38
  end
@@ -8,9 +8,9 @@ module WebPipe
8
8
  # @param key [Any] Key not found in the bag
9
9
  def initialize(key)
10
10
  super(
11
- <<~eos
11
+ <<~MSG
12
12
  Bag does not contain a key with name +#{key}+.
13
- eos
13
+ MSG
14
14
  )
15
15
  end
16
16
  end
@@ -21,9 +21,9 @@ module WebPipe
21
21
  # @param key [Any] Key not found in config
22
22
  def initialize(key)
23
23
  super(
24
- <<~eos
24
+ <<~MSG
25
25
  Config does not contain a key with name +#{key}+.
26
- eos
26
+ MSG
27
27
  )
28
28
  end
29
29
  end
@@ -36,10 +36,10 @@ module WebPipe
36
36
  # @param gem [String] Gem name for the middleware
37
37
  def initialize(feature, middleware, gem)
38
38
  super(
39
- <<~eos
39
+ <<~MSG
40
40
  In order to use #{feature} you must use #{middleware} middleware:
41
41
  https://rubygems.org/gems/#{gem}
42
- eos
42
+ MSG
43
43
  )
44
44
  end
45
45
  end
@@ -25,7 +25,7 @@ module WebPipe
25
25
  Hash[
26
26
  env
27
27
  .select { |k, _v| k.start_with?('HTTP_') }
28
- .map { |k, v| pair(k[5..-1], v) }
28
+ .map { |k, v| pair(k[5..], v) }
29
29
  .concat(
30
30
  env
31
31
  .select { |k, _v| HEADERS_AS_CGI.include?(k) }
@@ -99,9 +99,7 @@ module WebPipe
99
99
  #
100
100
  # @see #normalize_key
101
101
  def self.normalize(headers)
102
- Hash[
103
- headers.map { |k, v| [normalize_key(k), v] }
104
- ]
102
+ headers.transform_keys { |k| normalize_key(k) }
105
103
  end
106
104
  end
107
105
  end
@@ -25,6 +25,7 @@ module WebPipe
25
25
  def initialize(container: EMPTY_CONTAINER)
26
26
  @container = Types::Container[container]
27
27
  @class_context = ClassContext.new(container: container)
28
+ super()
28
29
  end
29
30
 
30
31
  def included(klass)
@@ -33,6 +33,7 @@ module WebPipe
33
33
  @dsl_context = DSLContext.new([], [])
34
34
  define_container
35
35
  define_dsl
36
+ super()
36
37
  end
37
38
 
38
39
  private
@@ -66,7 +66,7 @@ module WebPipe
66
66
  spec
67
67
  else
68
68
  block_spec
69
- end
69
+ end
70
70
 
71
71
  plugs << Plug.new(name: name, spec: plug_spec)
72
72
  end
@@ -48,6 +48,7 @@ module WebPipe
48
48
  # @return [Array<RackSupport::Middlewares>]
49
49
  attr_reader :middlewares
50
50
 
51
+ # rubocop:disable Metrics/AbcSize
51
52
  def initialize(injects = EMPTY_INJECTIONS)
52
53
  @injections = Injections[injects]
53
54
  container = self.class.container
@@ -60,6 +61,7 @@ module WebPipe
60
61
  app = App.new(operations)
61
62
  @rack_app = RackSupport::AppWithMiddlewares.new(middlewares, app)
62
63
  end
64
+ # rubocop:enable Metrics/AbcSize
63
65
 
64
66
  # Expected interface for rack.
65
67
  #
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'web_pipe'
4
4
 
5
+ #:nodoc:
5
6
  module WebPipe
6
7
  # Extension adding a `#container` method which returns {Conn#config}
7
8
  # `:container` key.
@@ -4,6 +4,7 @@ require 'web_pipe'
4
4
  require 'web_pipe/types'
5
5
  require 'rack/utils'
6
6
 
7
+ #:nodoc:
7
8
  module WebPipe
8
9
  # Extension to help dealing with request and response cookies.
9
10
  #
@@ -4,6 +4,7 @@ require 'web_pipe'
4
4
 
5
5
  WebPipe.load_extensions(:params)
6
6
 
7
+ #:nodoc:
7
8
  module WebPipe
8
9
  # Integration with `dry-schema` validation library.
9
10
  #
@@ -4,6 +4,7 @@ require 'web_pipe/types'
4
4
  require 'web_pipe/conn'
5
5
  require 'dry/view'
6
6
 
7
+ #:nodoc:
7
8
  module WebPipe
8
9
  # Integration with `dry-view` rendering system.
9
10
  #
@@ -3,6 +3,7 @@
3
3
  require 'web_pipe/conn'
4
4
  require 'web_pipe/conn_support/errors'
5
5
 
6
+ #:nodoc:
6
7
  module WebPipe
7
8
  # Provides with a typical flash messages functionality.
8
9
  #
@@ -3,6 +3,7 @@
3
3
  require 'web_pipe/types'
4
4
  require 'web_pipe/extensions/params/params/transf'
5
5
 
6
+ #:nodoc:
6
7
  module WebPipe
7
8
  # Adds a {Conn#params} method which can perform any number of
8
9
  # transformations to the request parameters.
@@ -4,6 +4,7 @@ require 'dry/transformer'
4
4
 
5
5
  module WebPipe
6
6
  module Params
7
+ # Parameter transformations from dry-transformer.
7
8
  module Transf
8
9
  extend Dry::Transformer::Registry
9
10
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'web_pipe/conn'
4
4
 
5
+ #:nodoc:
5
6
  module WebPipe
6
7
  # Integrates with Rails framework.
7
8
  #
@@ -73,7 +74,7 @@ module WebPipe
73
74
  # class ApplicationController < ActionController::Base
74
75
  # # By default uses the layout in `layouts/application`
75
76
  # end
76
- #
77
+ #
77
78
  # # app/controllers/articles_index.rb
78
79
  # require 'web_pipe/plugs/config'
79
80
  #
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'web_pipe/types'
4
4
 
5
+ #:nodoc:
5
6
  module WebPipe
6
7
  # Helper method to create redirect responses.
7
8
  #
@@ -4,6 +4,7 @@ require 'web_pipe/conn'
4
4
  require 'web_pipe/types'
5
5
  require 'rack'
6
6
 
7
+ #:nodoc:
7
8
  module WebPipe
8
9
  # Wrapper around Rack::Session middlewares.
9
10
  #
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #:nodoc:
3
4
  module WebPipe
4
5
  # Adds helper methods related to the request URL.
5
6
  #
@@ -25,11 +25,11 @@ module WebPipe
25
25
  # @param name [Any] Name for the plug that can't be resolved
26
26
  def initialize(name)
27
27
  super(
28
- <<~eos
28
+ <<~MSG
29
29
  Plug with name +#{name}+ is invalid. It must be something
30
30
  callable, an instance method when no operation is given,
31
31
  or something callable registered in the container."
32
- eos
32
+ MSG
33
33
  )
34
34
  end
35
35
  end
@@ -83,7 +83,7 @@ module WebPipe
83
83
  spec
84
84
  elsif spec.nil?
85
85
  pipe.method(name)
86
- elsif container[spec]&.respond_to?(:call)
86
+ elsif container[spec].respond_to?(:call)
87
87
  container[spec]
88
88
  else
89
89
  raise InvalidPlugError, name
@@ -60,10 +60,11 @@ module WebPipe
60
60
  # @return [Array<RackSupport::Middleware>]
61
61
  def call
62
62
  klass = spec[0]
63
- options = spec[1..-1] || Types::EMPTY_ARRAY
64
- if klass.is_a?(WebPipe)
63
+ options = spec[1..] || Types::EMPTY_ARRAY
64
+ case klass
65
+ when WebPipe
65
66
  klass.middlewares
66
- elsif klass.is_a?(Class)
67
+ when Class
67
68
  [Middleware.new(middleware: klass, options: options)]
68
69
  end
69
70
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WebPipe
4
- VERSION = '0.12.1'
4
+ VERSION = '0.13.0'
5
5
  end
@@ -43,7 +43,8 @@ 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
- spec.add_development_dependency 'dry-view', '~> 0.7'
46
+ # TODO: Readd when dry-rb 0.8 is released (ruby 3.0 support)
47
+ # spec.add_development_dependency 'dry-view', '~> 0.8'
47
48
  spec.add_development_dependency 'pry-byebug'
48
49
  spec.add_development_dependency 'rack-flash3', '~> 1.0'
49
50
  spec.add_development_dependency 'rack-test', '~> 1.1'
@@ -51,4 +52,6 @@ Gem::Specification.new do |spec|
51
52
  spec.add_development_dependency 'redcarpet', '~> 3.4'
52
53
  spec.add_development_dependency 'rspec', '~> 3.0'
53
54
  spec.add_development_dependency 'yard', '~> 0.9', '>= 0.9.20'
55
+ spec.add_development_dependency 'rubocop', '~> 1.8'
56
+ spec.add_development_dependency 'rubocop-rspec', '~> 2.1'
54
57
  end
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.12.1
4
+ version: 0.13.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: 1970-01-01 00:00:00.000000000 Z
11
+ date: 2021-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-monads
@@ -108,20 +108,6 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0.1'
111
- - !ruby/object:Gem::Dependency
112
- name: dry-view
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '0.7'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '0.7'
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: pry-byebug
127
113
  requirement: !ruby/object:Gem::Requirement
@@ -232,6 +218,34 @@ dependencies:
232
218
  - - ">="
233
219
  - !ruby/object:Gem::Version
234
220
  version: 0.9.20
221
+ - !ruby/object:Gem::Dependency
222
+ name: rubocop
223
+ requirement: !ruby/object:Gem::Requirement
224
+ requirements:
225
+ - - "~>"
226
+ - !ruby/object:Gem::Version
227
+ version: '1.8'
228
+ type: :development
229
+ prerelease: false
230
+ version_requirements: !ruby/object:Gem::Requirement
231
+ requirements:
232
+ - - "~>"
233
+ - !ruby/object:Gem::Version
234
+ version: '1.8'
235
+ - !ruby/object:Gem::Dependency
236
+ name: rubocop-rspec
237
+ requirement: !ruby/object:Gem::Requirement
238
+ requirements:
239
+ - - "~>"
240
+ - !ruby/object:Gem::Version
241
+ version: '2.1'
242
+ type: :development
243
+ prerelease: false
244
+ version_requirements: !ruby/object:Gem::Requirement
245
+ requirements:
246
+ - - "~>"
247
+ - !ruby/object:Gem::Version
248
+ version: '2.1'
235
249
  description:
236
250
  email:
237
251
  - marc@lamarciana.com
@@ -241,6 +255,7 @@ extra_rdoc_files: []
241
255
  files:
242
256
  - ".gitignore"
243
257
  - ".rspec"
258
+ - ".rubocop.yml"
244
259
  - ".travis.yml"
245
260
  - ".yardopts"
246
261
  - CHANGELOG.md
@@ -341,7 +356,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
341
356
  - !ruby/object:Gem::Version
342
357
  version: '0'
343
358
  requirements: []
344
- rubygems_version: 3.1.2
359
+ rubygems_version: 3.2.3
345
360
  signing_key:
346
361
  specification_version: 4
347
362
  summary: Rack application builder through a pipe of operations on an immutable struct.