simple_endpoint 1.0.0 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +35 -12
- data/.gitignore +1 -0
- data/.rubocop.yml +5 -2
- data/.ruby-version +1 -1
- data/{CHNAGES.md → CHANGES.md} +8 -0
- data/README.md +3 -3
- data/lib/simple_endpoint/version.rb +1 -1
- data/lib/simple_endpoint.rb +5 -6
- data/simple_endpoint.gemspec +3 -3
- metadata +12 -14
- data/Gemfile.lock +0 -66
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 564abc9a2f3de05e4253902c202322a01032d846674f4a4a9bc6f21855ae5d25
|
4
|
+
data.tar.gz: fd91c69ca42ed20076c8b4c209f9c38d0a43d962d68e16abc815eb23dd955a25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21914d7baf720ce8cc5be7e92852904057c3000dbb19b5d9a27bc2141a763b965da145c5f46ad9f8766f2beadcc04bc91c98e42c850e8978258e32f3a9a6525d
|
7
|
+
data.tar.gz: b2a0364c9bd4fc38d611ddf3d2278c29ecba8fc565fd658173471181d25296eb6e89dceee9f8a2ddb31bcd6b5e5739228f59f93fc935eed47762cb3ec43770ec
|
data/.circleci/config.yml
CHANGED
@@ -1,25 +1,48 @@
|
|
1
|
-
version: 2
|
1
|
+
version: 2.1
|
2
|
+
|
3
|
+
executors:
|
4
|
+
test_executor:
|
5
|
+
docker:
|
6
|
+
- image: circleci/ruby:${RUBY_VERSION}
|
7
|
+
working_directory: ~/simple_endpoint
|
8
|
+
|
2
9
|
jobs:
|
3
10
|
build:
|
4
|
-
|
5
|
-
|
6
|
-
|
11
|
+
environment:
|
12
|
+
RUBY_VERSION: << parameters.ruby_version >>
|
13
|
+
BUNDLER_VERSION: 2.1.4
|
14
|
+
executor: test_executor
|
15
|
+
parameters:
|
16
|
+
ruby_version:
|
17
|
+
type: string
|
7
18
|
steps:
|
8
19
|
- checkout
|
9
20
|
|
10
|
-
-
|
11
|
-
|
12
|
-
|
13
|
-
|
21
|
+
- run:
|
22
|
+
name: 'Install bundler'
|
23
|
+
command: 'gem install bundler'
|
24
|
+
|
14
25
|
- run:
|
15
26
|
name: Install dependencies
|
16
27
|
command: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs 4 --retry 3
|
17
28
|
|
18
|
-
-
|
19
|
-
|
20
|
-
|
21
|
-
- vendor/bundle
|
29
|
+
# - run:
|
30
|
+
# name: Run Rubocop
|
31
|
+
# command: bundle exec rubocop
|
22
32
|
|
23
33
|
- run:
|
24
34
|
name: Run Tests
|
25
35
|
command: bundle exec rspec
|
36
|
+
|
37
|
+
workflows:
|
38
|
+
build_and_test:
|
39
|
+
jobs:
|
40
|
+
- build:
|
41
|
+
name: 'ruby 2.6.8'
|
42
|
+
ruby_version: 2.6.8
|
43
|
+
- build:
|
44
|
+
name: 'ruby 2.7.0'
|
45
|
+
ruby_version: 2.7.0
|
46
|
+
- build:
|
47
|
+
name: 'ruby 3.0.3'
|
48
|
+
ruby_version: 3.0.3
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,20 +1,23 @@
|
|
1
1
|
require: rubocop-rspec
|
2
2
|
|
3
3
|
AllCops:
|
4
|
+
TargetRubyVersion: 3.1
|
5
|
+
NewCops: enable
|
6
|
+
SuggestExtensions: false
|
4
7
|
Exclude:
|
5
8
|
- 'simple_endpoint.gemspec'
|
6
9
|
|
7
10
|
Style/Documentation:
|
8
11
|
Enabled: false
|
9
12
|
|
10
|
-
|
13
|
+
Layout/LineLength:
|
11
14
|
Max: 120
|
12
15
|
|
13
16
|
Style/FrozenStringLiteralComment:
|
14
17
|
Enabled: true
|
15
18
|
|
16
19
|
Metrics/BlockLength:
|
17
|
-
|
20
|
+
IgnoredMethods: ['describe','context']
|
18
21
|
|
19
22
|
RSpec/DescribeClass:
|
20
23
|
Enabled: false
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.1.0
|
data/{CHNAGES.md → CHANGES.md}
RENAMED
@@ -1,6 +1,14 @@
|
|
1
1
|
simple_endpoint changelog
|
2
2
|
=====================
|
3
3
|
|
4
|
+
[2022-02-12] Version 1.0.2
|
5
|
+
---------------------------
|
6
|
+
- Add Ruby 3+ support
|
7
|
+
|
8
|
+
[2022-02-09] Version 1.0.1
|
9
|
+
---------------------------
|
10
|
+
- Add Ruby 2.7+ support
|
11
|
+
|
4
12
|
[2020-01-25] Version 1.0.0
|
5
13
|
---------------------------
|
6
14
|
**Breaking changes**
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@ Dry-matcher free implementation of trailblazer endpoint.
|
|
8
8
|
Add this to your Gemfile:
|
9
9
|
|
10
10
|
```ruby
|
11
|
-
gem 'simple_endpoint', '~> 1.0.
|
11
|
+
gem 'simple_endpoint', '~> 1.0.2'
|
12
12
|
```
|
13
13
|
|
14
14
|
## Getting Started
|
@@ -57,7 +57,7 @@ end
|
|
57
57
|
|
58
58
|
`OperationIsNotHandled` error will be raised if `#default_cases` doesn't contain case for specific operation result.
|
59
59
|
|
60
|
-
`
|
60
|
+
`UnhandledResultError` will be raised if `#default_handler` doesn't contain for some cases.
|
61
61
|
|
62
62
|
`NotImplementedError` will be raised if `default_cases` or `default_handler` methods aren't defined.
|
63
63
|
|
@@ -74,7 +74,7 @@ Now you are able to use `endpoint` method at other controllers
|
|
74
74
|
| `:different_cases`| no | {} | Cases that should be redefined for exact `#endpoint` call |
|
75
75
|
| `:different_handler` | no | {} | Case of handler that should be handled in different way |
|
76
76
|
| `:options` | no | {} | Additional hash which will be merged to `#ednpoint_options` method result before operation execution |
|
77
|
-
| `:
|
77
|
+
| `:before_response` | no | {} | Allow to process code before specific case handler |
|
78
78
|
| `:renderer_options` | no | {} | Allow to pass serializer options from controller and Will available inside handler as second parameter.
|
79
79
|
|
80
80
|
|
data/lib/simple_endpoint.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'simple_endpoint/version'
|
4
3
|
# rubocop:disable Metrics/ParameterLists
|
5
4
|
module SimpleEndpoint
|
6
5
|
module Controller
|
@@ -16,7 +15,7 @@ module SimpleEndpoint
|
|
16
15
|
default_cases.merge(different_cases),
|
17
16
|
renderer_options,
|
18
17
|
before_response,
|
19
|
-
endpoint_options.merge(options)
|
18
|
+
**endpoint_options.merge(options)
|
20
19
|
)
|
21
20
|
end
|
22
21
|
|
@@ -44,7 +43,7 @@ module SimpleEndpoint
|
|
44
43
|
def call(result, cases, renderer_options = {}, handler = {}, before_response = {})
|
45
44
|
matched_case = matched_case(cases, result)
|
46
45
|
procees_handler(matched_case, before_response, result, renderer_options) unless before_response.empty?
|
47
|
-
procees_handler(matched_case, handler, result, renderer_options,
|
46
|
+
procees_handler(matched_case, handler, result, renderer_options, UnhandledResultError)
|
48
47
|
end
|
49
48
|
|
50
49
|
def matched_case(cases, result)
|
@@ -56,7 +55,7 @@ module SimpleEndpoint
|
|
56
55
|
|
57
56
|
def procees_handler(matched_case, handler, result, renderer_options, exception_class = nil)
|
58
57
|
if handler.key?(matched_case)
|
59
|
-
handler
|
58
|
+
handler[matched_case]&.(result, **renderer_options)
|
60
59
|
elsif exception_class
|
61
60
|
raise exception_class, "Key: #{matched_case} is not present at #{handler}"
|
62
61
|
end
|
@@ -68,7 +67,7 @@ module SimpleEndpoint
|
|
68
67
|
end
|
69
68
|
|
70
69
|
class OperationIsNotHandled < StandardError; end
|
71
|
-
class
|
70
|
+
class UnhandledResultError < StandardError; end
|
72
71
|
|
73
72
|
OPERATION_IS_NOT_HANDLER_ERROR = 'Current operation result is not handled at #default_cases method'
|
74
73
|
HANDLER_ERROR_MESSAGE = <<-LARGE_ERROR
|
@@ -87,7 +86,7 @@ module SimpleEndpoint
|
|
87
86
|
when :success then render :json ...
|
88
87
|
else
|
89
88
|
# just in case you forgot to add handler for some of case
|
90
|
-
SimpleEndpoint::
|
89
|
+
SimpleEndpoint::UnhandledResultError, 'Oh nooooo!!! Really???!!'
|
91
90
|
end
|
92
91
|
end
|
93
92
|
end
|
data/simple_endpoint.gemspec
CHANGED
@@ -32,10 +32,10 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
33
33
|
spec.require_paths = ['lib']
|
34
34
|
|
35
|
-
spec.add_development_dependency 'bundler', '
|
35
|
+
spec.add_development_dependency 'bundler', '>= 2.1.0'
|
36
36
|
spec.add_development_dependency 'pry-byebug'
|
37
|
-
spec.add_development_dependency 'rake', '~>
|
37
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
38
38
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
39
|
-
spec.add_development_dependency 'rubocop', '~>
|
39
|
+
spec.add_development_dependency 'rubocop', '~> 1.25.1'
|
40
40
|
spec.add_development_dependency 'rubocop-rspec'
|
41
41
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_endpoint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Bal
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.1.0
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pry-byebug
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '13.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '13.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 1.25.1
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 1.25.1
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rubocop-rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,9 +108,8 @@ files:
|
|
108
108
|
- ".rubocop.yml"
|
109
109
|
- ".ruby-gemset"
|
110
110
|
- ".ruby-version"
|
111
|
-
-
|
111
|
+
- CHANGES.md
|
112
112
|
- Gemfile
|
113
|
-
- Gemfile.lock
|
114
113
|
- LICENSE
|
115
114
|
- README.md
|
116
115
|
- Rakefile
|
@@ -138,8 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
137
|
- !ruby/object:Gem::Version
|
139
138
|
version: '0'
|
140
139
|
requirements: []
|
141
|
-
|
142
|
-
rubygems_version: 2.7.9
|
140
|
+
rubygems_version: 3.1.6
|
143
141
|
signing_key:
|
144
142
|
specification_version: 4
|
145
143
|
summary: Simple implementation of Trailblazer endpoint
|
data/Gemfile.lock
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
simple_endpoint (1.0.0)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
ast (2.4.0)
|
10
|
-
byebug (10.0.2)
|
11
|
-
coderay (1.1.2)
|
12
|
-
diff-lcs (1.3)
|
13
|
-
jaro_winkler (1.5.4)
|
14
|
-
method_source (0.9.2)
|
15
|
-
parallel (1.19.1)
|
16
|
-
parser (2.7.0.2)
|
17
|
-
ast (~> 2.4.0)
|
18
|
-
powerpack (0.1.2)
|
19
|
-
pry (0.12.2)
|
20
|
-
coderay (~> 1.1.0)
|
21
|
-
method_source (~> 0.9.0)
|
22
|
-
pry-byebug (3.6.0)
|
23
|
-
byebug (~> 10.0)
|
24
|
-
pry (~> 0.10)
|
25
|
-
rainbow (3.0.0)
|
26
|
-
rake (10.5.0)
|
27
|
-
rspec (3.8.0)
|
28
|
-
rspec-core (~> 3.8.0)
|
29
|
-
rspec-expectations (~> 3.8.0)
|
30
|
-
rspec-mocks (~> 3.8.0)
|
31
|
-
rspec-core (3.8.0)
|
32
|
-
rspec-support (~> 3.8.0)
|
33
|
-
rspec-expectations (3.8.2)
|
34
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
-
rspec-support (~> 3.8.0)
|
36
|
-
rspec-mocks (3.8.0)
|
37
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
-
rspec-support (~> 3.8.0)
|
39
|
-
rspec-support (3.8.0)
|
40
|
-
rubocop (0.61.1)
|
41
|
-
jaro_winkler (~> 1.5.1)
|
42
|
-
parallel (~> 1.10)
|
43
|
-
parser (>= 2.5, != 2.5.1.1)
|
44
|
-
powerpack (~> 0.1)
|
45
|
-
rainbow (>= 2.2.2, < 4.0)
|
46
|
-
ruby-progressbar (~> 1.7)
|
47
|
-
unicode-display_width (~> 1.4.0)
|
48
|
-
rubocop-rspec (1.35.0)
|
49
|
-
rubocop (>= 0.60.0)
|
50
|
-
ruby-progressbar (1.10.1)
|
51
|
-
unicode-display_width (1.4.1)
|
52
|
-
|
53
|
-
PLATFORMS
|
54
|
-
ruby
|
55
|
-
|
56
|
-
DEPENDENCIES
|
57
|
-
bundler (~> 1.16)
|
58
|
-
pry-byebug
|
59
|
-
rake (~> 10.0)
|
60
|
-
rspec (~> 3.0)
|
61
|
-
rubocop (~> 0.61.0)
|
62
|
-
rubocop-rspec
|
63
|
-
simple_endpoint!
|
64
|
-
|
65
|
-
BUNDLED WITH
|
66
|
-
1.17.2
|