servactory 1.8.0 → 1.8.2
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/README.md +13 -5
- data/lib/servactory/context/workspace/internals.rb +3 -1
- data/lib/servactory/context/workspace/outputs.rb +3 -1
- data/lib/servactory/inputs/input.rb +11 -5
- data/lib/servactory/inputs/options_collection.rb +9 -1
- data/lib/servactory/methods/dsl.rb +2 -2
- data/lib/servactory/result.rb +34 -12
- data/lib/servactory/version.rb +1 -1
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a87d01c5389b8d6d538b2cd1befe0cd8fa51b0ea578eefb8c0c0b457957fa75
|
4
|
+
data.tar.gz: 4ff7989cf58492790ad7cfef807cd2a2f6befacefa9407a4fb04e3b4567e2d6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b880c2475447311de03023601adc91597b38ecd083d5e108e4df8869dd65137d2a4001066142234c609c69aecf279d211be2258f806d662fc43893e97fea978
|
7
|
+
data.tar.gz: 8efc74ceb569789340dad5b3e1d54cc996528fda101f6bbf9719b9c8f55fc70baf5674659116d27312cc271ec9a7e0764f4de4c9e8a26d674377c157cc1a3330
|
data/README.md
CHANGED
@@ -9,12 +9,18 @@ A set of tools for building reliable services of any complexity.
|
|
9
9
|
|
10
10
|
See [servactory.com](https://servactory.com) for documentation.
|
11
11
|
|
12
|
-
##
|
12
|
+
## Example
|
13
|
+
|
14
|
+
### Installation
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem "servactory"
|
18
|
+
```
|
13
19
|
|
14
20
|
### Service
|
15
21
|
|
16
22
|
```ruby
|
17
|
-
class UserService::Authenticate <
|
23
|
+
class UserService::Authenticate < Servactory::Base
|
18
24
|
input :email, type: String
|
19
25
|
input :password, type: String
|
20
26
|
|
@@ -32,7 +38,7 @@ class UserService::Authenticate < ApplicationService::Base
|
|
32
38
|
end
|
33
39
|
```
|
34
40
|
|
35
|
-
###
|
41
|
+
### Usage
|
36
42
|
|
37
43
|
```ruby
|
38
44
|
class SessionsController < ApplicationController
|
@@ -58,8 +64,10 @@ end
|
|
58
64
|
|
59
65
|
## Contributing
|
60
66
|
|
61
|
-
This project is intended to be a safe, welcoming space for collaboration.
|
67
|
+
This project is intended to be a safe, welcoming space for collaboration.
|
68
|
+
Contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
69
|
+
We recommend reading the [contributing guide](./website/docs/CONTRIBUTING.md) as well.
|
62
70
|
|
63
71
|
## License
|
64
72
|
|
65
|
-
|
73
|
+
Servactory is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
@@ -28,7 +28,9 @@ module Servactory
|
|
28
28
|
|
29
29
|
return yield unless @collection_of_internals.names.include?(prepared_name)
|
30
30
|
|
31
|
-
internal = @collection_of_internals.find_by(name: prepared_name)
|
31
|
+
internal = @collection_of_internals.find_by(name: prepared_name) # ::Servactory::Internals::Internal
|
32
|
+
|
33
|
+
return yield if internal.nil?
|
32
34
|
|
33
35
|
Servactory::Internals::Validations::Type.validate!(
|
34
36
|
context: @context,
|
@@ -28,7 +28,9 @@ module Servactory
|
|
28
28
|
|
29
29
|
return yield unless @collection_of_outputs.names.include?(prepared_name)
|
30
30
|
|
31
|
-
output = @collection_of_outputs.find_by(name: prepared_name)
|
31
|
+
output = @collection_of_outputs.find_by(name: prepared_name) # ::Servactory::Outputs::Output
|
32
|
+
|
33
|
+
return yield if output.nil?
|
32
34
|
|
33
35
|
Servactory::Outputs::Validations::Type.validate!(
|
34
36
|
context: @context,
|
@@ -24,14 +24,20 @@ module Servactory
|
|
24
24
|
options = apply_helpers_for_options(helpers: helpers, options: options) if helpers.present?
|
25
25
|
|
26
26
|
add_basic_options_with(type: type, options: options)
|
27
|
+
end
|
28
|
+
# rubocop:enable Style/KeywordParametersOrder
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
+
def method_missing(name, *args, &block)
|
31
|
+
option = collection_of_options.find_by(name: name)
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
+
return super if option.nil?
|
34
|
+
|
35
|
+
option.value
|
36
|
+
end
|
37
|
+
|
38
|
+
def respond_to_missing?(name, *)
|
39
|
+
collection_of_options.names.include?(name) || super
|
33
40
|
end
|
34
|
-
# rubocop:enable Style/KeywordParametersOrder
|
35
41
|
|
36
42
|
def apply_helpers_for_options(helpers:, options:)
|
37
43
|
prepared_options = {}
|
@@ -5,12 +5,16 @@ module Servactory
|
|
5
5
|
class OptionsCollection
|
6
6
|
# NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
|
7
7
|
extend Forwardable
|
8
|
-
def_delegators :@collection, :<<, :filter, :each, :map, :flat_map
|
8
|
+
def_delegators :@collection, :<<, :filter, :each, :map, :flat_map, :find
|
9
9
|
|
10
10
|
def initialize(*)
|
11
11
|
@collection = Set.new
|
12
12
|
end
|
13
13
|
|
14
|
+
def names
|
15
|
+
map(&:name)
|
16
|
+
end
|
17
|
+
|
14
18
|
def validation_classes
|
15
19
|
filter { |option| option.validation_class.present? }.map(&:validation_class).uniq
|
16
20
|
end
|
@@ -34,6 +38,10 @@ module Servactory
|
|
34
38
|
end
|
35
39
|
end.reject(&:blank?).first
|
36
40
|
end
|
41
|
+
|
42
|
+
def find_by(name:)
|
43
|
+
find { |option| option.name == name }
|
44
|
+
end
|
37
45
|
end
|
38
46
|
end
|
39
47
|
end
|
@@ -87,8 +87,8 @@ module Servactory
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
-
def respond_to_missing?(
|
91
|
-
Servactory.configuration.aliases_for_make.include?(
|
90
|
+
def respond_to_missing?(name, *)
|
91
|
+
Servactory.configuration.aliases_for_make.include?(name) ||
|
92
92
|
Servactory.configuration.shortcuts_for_make.include?(name) ||
|
93
93
|
super
|
94
94
|
end
|
data/lib/servactory/result.rb
CHANGED
@@ -3,26 +3,46 @@
|
|
3
3
|
module Servactory
|
4
4
|
class Result
|
5
5
|
def self.success_for(...)
|
6
|
-
new.send(:
|
6
|
+
new(...).send(:as_success)
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.failure_for(...)
|
10
|
-
new.send(:
|
10
|
+
new(...).send(:as_failure)
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
def initialize(context: nil, collection_of_outputs: nil, exception: nil)
|
14
|
+
@context = context
|
15
|
+
@collection_of_outputs = collection_of_outputs
|
16
|
+
@exception = exception
|
17
|
+
end
|
18
|
+
|
19
|
+
def method_missing(name, *args, &block)
|
20
|
+
output = @collection_of_outputs&.find_by(name: name)
|
21
|
+
|
22
|
+
return super if output.nil?
|
23
|
+
|
24
|
+
output_value_for(output)
|
25
|
+
end
|
14
26
|
|
15
|
-
def
|
16
|
-
|
27
|
+
def respond_to_missing?(name, *)
|
28
|
+
@collection_of_outputs&.names&.include?(name) || super
|
29
|
+
end
|
30
|
+
|
31
|
+
def inspect
|
32
|
+
"#<#{self.class.name} #{draw_result}>"
|
33
|
+
end
|
17
34
|
|
35
|
+
private
|
36
|
+
|
37
|
+
def as_success
|
18
38
|
define_singleton_method(:success?) { true }
|
19
39
|
define_singleton_method(:failure?) { false }
|
20
40
|
|
21
41
|
self
|
22
42
|
end
|
23
43
|
|
24
|
-
def
|
25
|
-
define_singleton_method(:error) { exception }
|
44
|
+
def as_failure
|
45
|
+
define_singleton_method(:error) { @exception }
|
26
46
|
|
27
47
|
define_singleton_method(:success?) { false }
|
28
48
|
define_singleton_method(:failure?) { true }
|
@@ -30,12 +50,14 @@ module Servactory
|
|
30
50
|
self
|
31
51
|
end
|
32
52
|
|
33
|
-
def
|
34
|
-
collection_of_outputs
|
35
|
-
|
53
|
+
def draw_result
|
54
|
+
@collection_of_outputs&.map do |output|
|
55
|
+
"@#{output.name}=#{output_value_for(output).inspect}"
|
56
|
+
end&.join(", ")
|
57
|
+
end
|
36
58
|
|
37
|
-
|
38
|
-
|
59
|
+
def output_value_for(output)
|
60
|
+
@context.instance_variable_get(:"@#{output.name}")
|
39
61
|
end
|
40
62
|
end
|
41
63
|
end
|
data/lib/servactory/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: servactory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Sokolov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -80,20 +80,6 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '13.0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rbs
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '3.1'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '3.1'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: rspec
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,6 +150,20 @@ dependencies:
|
|
164
150
|
- - "~>"
|
165
151
|
- !ruby/object:Gem::Version
|
166
152
|
version: '2.19'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: steep
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '1.4'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '1.4'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: yard
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|