teckel 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +3 -0
- data/.github/workflows/ci.yml +25 -0
- data/.gitignore +2 -0
- data/CHANGELOG.md +12 -0
- data/DEVELOPMENT.md +8 -4
- data/Gemfile +8 -0
- data/README.md +22 -14
- data/Rakefile +5 -0
- data/lib/teckel.rb +3 -0
- data/lib/teckel/chain.rb +230 -25
- data/lib/teckel/config.rb +40 -48
- data/lib/teckel/none.rb +18 -0
- data/lib/teckel/operation.rb +183 -110
- data/lib/teckel/operation/results.rb +12 -11
- data/lib/teckel/result.rb +2 -2
- data/lib/teckel/version.rb +1 -1
- data/teckel.gemspec +0 -1
- metadata +5 -24
- data/Gemfile.lock +0 -71
@@ -2,10 +2,11 @@
|
|
2
2
|
|
3
3
|
module Teckel
|
4
4
|
module Operation
|
5
|
-
# Works just like
|
5
|
+
# Works just like {Teckel::Operation}, but wraps +output+ and +error+ into a
|
6
|
+
# {Teckel::Result Teckel::Result}.
|
6
7
|
#
|
7
|
-
#
|
8
|
-
# gets passed to your Operation code.
|
8
|
+
# If a {Teckel::Result Teckel::Result} is given as +input+, it will get unwrapped,
|
9
|
+
# so that the original {Teckel::Result#value} gets passed to your Operation code.
|
9
10
|
#
|
10
11
|
# @example
|
11
12
|
#
|
@@ -17,14 +18,13 @@ module Teckel
|
|
17
18
|
# error Types::Hash.schema(message: Types::String, errors: Types::Array.of(Types::Hash))
|
18
19
|
#
|
19
20
|
# # @param [Hash<name: String, age: Integer>]
|
20
|
-
# # @return [User
|
21
|
+
# # @return [User,Hash<message: String, errors: [Hash]>]
|
21
22
|
# def call(input)
|
22
23
|
# user = User.new(name: input[:name], age: input[:age])
|
23
|
-
# if user.
|
24
|
-
# # exits early with success, prevents any further execution
|
25
|
-
# success!(user)
|
24
|
+
# if user.save
|
25
|
+
# success!(user) # exits early with success, prevents any further execution
|
26
26
|
# else
|
27
|
-
# fail!(message: "Could not
|
27
|
+
# fail!(message: "Could not save User", errors: user.errors)
|
28
28
|
# end
|
29
29
|
# end
|
30
30
|
# end
|
@@ -43,9 +43,10 @@ module Teckel
|
|
43
43
|
# # Unwrapping failure input:
|
44
44
|
# CreateUser.call(Teckel::Result.new({name: "Bob", age: 23}, false)).success.is_a?(User) #=> true
|
45
45
|
#
|
46
|
-
#
|
46
|
+
# @!visibility public
|
47
47
|
module Results
|
48
|
-
|
48
|
+
# Overwrites the defaults {Teckel::Operation::Runner} to un/wrap input, output and error
|
49
|
+
class Runner < Teckel::Operation::Runner
|
49
50
|
private
|
50
51
|
|
51
52
|
def build_input(input)
|
@@ -64,7 +65,7 @@ module Teckel
|
|
64
65
|
|
65
66
|
def self.included(receiver)
|
66
67
|
receiver.send :include, Teckel::Operation unless Teckel::Operation >= receiver
|
67
|
-
receiver.send :
|
68
|
+
receiver.send :runner, Runner
|
68
69
|
end
|
69
70
|
end
|
70
71
|
end
|
data/lib/teckel/result.rb
CHANGED
@@ -24,13 +24,13 @@ module Teckel
|
|
24
24
|
# Teckel::Result.new("some error", false).success("other default") #=> "other default"
|
25
25
|
# Teckel::Result.new("some error", false).success { |value| "Failed: #{value}" } #=> "Failed: some error"
|
26
26
|
#
|
27
|
-
#
|
27
|
+
# @!visibility public
|
28
28
|
class Result
|
29
29
|
# @param value [Mixed] the value/payload of the result.
|
30
30
|
# @param success [Bool] whether this is a successful result
|
31
31
|
def initialize(value, success)
|
32
32
|
@value = value
|
33
|
-
@success = success
|
33
|
+
@success = (!!success).freeze
|
34
34
|
end
|
35
35
|
|
36
36
|
# @!attribute [r] value
|
data/lib/teckel/version.rb
CHANGED
data/teckel.gemspec
CHANGED
@@ -25,7 +25,6 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.require_paths = ["lib"]
|
26
26
|
|
27
27
|
spec.add_development_dependency "bundler", "~> 2.0"
|
28
|
-
spec.add_development_dependency "dry-struct", ">= 1.1.1", "< 2"
|
29
28
|
spec.add_development_dependency "rake", ">= 10.0"
|
30
29
|
spec.add_development_dependency "rspec", "~> 3.0"
|
31
30
|
spec.add_development_dependency "yard"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teckel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Schulze
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,26 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: dry-struct
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.1.1
|
34
|
-
- - "<"
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: '2'
|
37
|
-
type: :development
|
38
|
-
prerelease: false
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
41
|
-
- - ">="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: 1.1.1
|
44
|
-
- - "<"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '2'
|
47
27
|
- !ruby/object:Gem::Dependency
|
48
28
|
name: rake
|
49
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +88,7 @@ executables: []
|
|
108
88
|
extensions: []
|
109
89
|
extra_rdoc_files: []
|
110
90
|
files:
|
91
|
+
- ".codeclimate.yml"
|
111
92
|
- ".github/workflows/ci.yml"
|
112
93
|
- ".github/workflows/pages.yml"
|
113
94
|
- ".gitignore"
|
@@ -118,7 +99,6 @@ files:
|
|
118
99
|
- CHANGELOG.md
|
119
100
|
- DEVELOPMENT.md
|
120
101
|
- Gemfile
|
121
|
-
- Gemfile.lock
|
122
102
|
- LICENSE
|
123
103
|
- README.md
|
124
104
|
- Rakefile
|
@@ -130,6 +110,7 @@ files:
|
|
130
110
|
- lib/teckel.rb
|
131
111
|
- lib/teckel/chain.rb
|
132
112
|
- lib/teckel/config.rb
|
113
|
+
- lib/teckel/none.rb
|
133
114
|
- lib/teckel/operation.rb
|
134
115
|
- lib/teckel/operation/results.rb
|
135
116
|
- lib/teckel/result.rb
|
@@ -154,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
135
|
- !ruby/object:Gem::Version
|
155
136
|
version: '0'
|
156
137
|
requirements: []
|
157
|
-
rubygems_version: 3.
|
138
|
+
rubygems_version: 3.1.2
|
158
139
|
signing_key:
|
159
140
|
specification_version: 4
|
160
141
|
summary: Operations with enforced in/out/err data structures
|
data/Gemfile.lock
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
teckel (0.1.0)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
concurrent-ruby (1.1.5)
|
10
|
-
diff-lcs (1.3)
|
11
|
-
dry-configurable (0.9.0)
|
12
|
-
concurrent-ruby (~> 1.0)
|
13
|
-
dry-core (~> 0.4, >= 0.4.7)
|
14
|
-
dry-container (0.7.2)
|
15
|
-
concurrent-ruby (~> 1.0)
|
16
|
-
dry-configurable (~> 0.1, >= 0.1.3)
|
17
|
-
dry-core (0.4.9)
|
18
|
-
concurrent-ruby (~> 1.0)
|
19
|
-
dry-equalizer (0.3.0)
|
20
|
-
dry-inflector (0.2.0)
|
21
|
-
dry-logic (1.0.5)
|
22
|
-
concurrent-ruby (~> 1.0)
|
23
|
-
dry-core (~> 0.2)
|
24
|
-
dry-equalizer (~> 0.2)
|
25
|
-
dry-struct (1.2.0)
|
26
|
-
dry-core (~> 0.4, >= 0.4.3)
|
27
|
-
dry-equalizer (~> 0.3)
|
28
|
-
dry-types (~> 1.0)
|
29
|
-
ice_nine (~> 0.11)
|
30
|
-
dry-types (1.2.2)
|
31
|
-
concurrent-ruby (~> 1.0)
|
32
|
-
dry-container (~> 0.3)
|
33
|
-
dry-core (~> 0.4, >= 0.4.4)
|
34
|
-
dry-equalizer (~> 0.3)
|
35
|
-
dry-inflector (~> 0.1, >= 0.1.2)
|
36
|
-
dry-logic (~> 1.0, >= 1.0.2)
|
37
|
-
ice_nine (0.11.2)
|
38
|
-
minitest (5.13.0)
|
39
|
-
rake (13.0.1)
|
40
|
-
rspec (3.9.0)
|
41
|
-
rspec-core (~> 3.9.0)
|
42
|
-
rspec-expectations (~> 3.9.0)
|
43
|
-
rspec-mocks (~> 3.9.0)
|
44
|
-
rspec-core (3.9.1)
|
45
|
-
rspec-support (~> 3.9.1)
|
46
|
-
rspec-expectations (3.9.0)
|
47
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
-
rspec-support (~> 3.9.0)
|
49
|
-
rspec-mocks (3.9.1)
|
50
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
51
|
-
rspec-support (~> 3.9.0)
|
52
|
-
rspec-support (3.9.2)
|
53
|
-
yard (0.9.22)
|
54
|
-
yard-doctest (0.1.17)
|
55
|
-
minitest
|
56
|
-
yard
|
57
|
-
|
58
|
-
PLATFORMS
|
59
|
-
ruby
|
60
|
-
|
61
|
-
DEPENDENCIES
|
62
|
-
bundler (~> 2.0)
|
63
|
-
dry-struct (>= 1.1.1, < 2)
|
64
|
-
rake (>= 10.0)
|
65
|
-
rspec (~> 3.0)
|
66
|
-
teckel!
|
67
|
-
yard
|
68
|
-
yard-doctest
|
69
|
-
|
70
|
-
BUNDLED WITH
|
71
|
-
2.1.2
|