servactory 2.10.0 → 2.12.0.rc1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a2fbc5b445408bf8ff257cb28100af77be2fc232fd6dc267ab876fd0cc6544e
4
- data.tar.gz: ecfcab785c9322110e0d463c8934e26927c681e1e1005123303a2df7e0d7f941
3
+ metadata.gz: 42d8f2391ba24198b46219e80408d7bf1d304faca0dfd5a99e89ac841d246fe4
4
+ data.tar.gz: 93748b84e352a85641a18e2f50f7fbc1668c7d037a613b95f8ed47fe02fce079
5
5
  SHA512:
6
- metadata.gz: bf777f5c7a876a61d74f656e78c013d8a6b3477c86b51e4fa45d31776a23d63a02c2b5930ef65b30c6cd8f59e8bcd46988b27d43597af255315b5feb126ef92b
7
- data.tar.gz: eda54241a6625164bcb6407ec3605840edd6dd06905e7679277e617c2b46b29ed084d9445f3cf9ed84a60ab3a2e8552f8cfd93f5f9ec591a87e783f0b7f28da2
6
+ metadata.gz: 45895d6e4182f0ccdb4fd0c37e030232d809d8fb14d6117f793c5abac5292ceb172d5cd1aeb1fc48cb3cbda70e0ce4ba08a8752744f4776f431136b2c7b1dc8e
7
+ data.tar.gz: 97e972f65d377eec5eb1224d54c440e7cca90c66a32fd2fd398e87c482f355110fbc39453cfdca799b45e59af259bf5e393c039181e23f59ecb41bbfe5d478aa
@@ -28,8 +28,6 @@ module Servactory
28
28
  private
29
29
 
30
30
  def _call!(context, incoming_arguments)
31
- incoming_arguments = Servactory::Utils.adapt(incoming_arguments)
32
-
33
31
  context.send(
34
32
  :_call!,
35
33
  incoming_arguments:,
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Servactory
4
+ module Context
5
+ module Warehouse
6
+ class Base
7
+ def initialize(arguments = {})
8
+ @arguments = arguments
9
+ end
10
+
11
+ # def fetch!(name)
12
+ # @arguments.fetch(name)
13
+ # end
14
+
15
+ def fetch(name, default_value)
16
+ @arguments.fetch(name, default_value)
17
+ end
18
+
19
+ def assign(key, value)
20
+ @arguments[key] = value
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Servactory
4
+ module Context
5
+ module Warehouse
6
+ class Inputs < Base
7
+ def initialize(context, arguments = {})
8
+ @context = context
9
+
10
+ super(arguments)
11
+ end
12
+
13
+ def names
14
+ @arguments.keys
15
+ end
16
+
17
+ def merge!(arguments)
18
+ @arguments.merge!(arguments)
19
+ end
20
+
21
+ ##########################################################################
22
+
23
+ def method_missing(name, *_args)
24
+ input_name = @context.class.config.predicate_methods_enabled? ? name.to_s.chomp("?").to_sym : name
25
+
26
+ input_value = @arguments.fetch(input_name) { raise_error_for(input_name) }
27
+
28
+ if name.to_s.end_with?("?") && @context.class.config.predicate_methods_enabled?
29
+ Servactory::Utils.query_attribute(input_value)
30
+ else
31
+ input_value
32
+ end
33
+ end
34
+
35
+ def respond_to_missing?(name, *)
36
+ @arguments.fetch(name) { raise_error_for(name) }
37
+ end
38
+
39
+ ##########################################################################
40
+
41
+ def raise_error_for(input_name)
42
+ message_text = @context.send(:servactory_service_info).translate(
43
+ "inputs.undefined.for_fetch",
44
+ input_name:
45
+ )
46
+
47
+ raise @context.class.config.input_exception_class.new(
48
+ context: @context,
49
+ message: message_text,
50
+ input_name:
51
+ )
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Servactory
4
+ module Context
5
+ module Warehouse
6
+ class Internals < Base
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Servactory
4
+ module Context
5
+ module Warehouse
6
+ class Outputs < Base
7
+ extend Forwardable
8
+ def_delegators :@arguments, :each_pair
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Servactory
4
+ module Context
5
+ module Warehouse
6
+ class Setup
7
+ def initialize(context)
8
+ @context = context
9
+ end
10
+
11
+ def assign_inputs(arguments)
12
+ context_data[:inputs].merge!(arguments)
13
+ end
14
+
15
+ def fetch_input(name)
16
+ inputs.fetch(name, nil)
17
+ end
18
+
19
+ def assign_internal(name, value)
20
+ assign_attribute(:internals, name, value)
21
+ end
22
+
23
+ def fetch_internal(name)
24
+ internals.fetch(name, nil)
25
+ end
26
+
27
+ def assign_output(name, value)
28
+ assign_attribute(:outputs, name, value)
29
+ end
30
+
31
+ def fetch_output(name)
32
+ outputs.fetch(name, nil)
33
+ end
34
+
35
+ def inputs
36
+ @inputs ||= context_data.fetch(:inputs)
37
+ end
38
+
39
+ def internals
40
+ @internals ||= context_data.fetch(:internals)
41
+ end
42
+
43
+ def outputs
44
+ @outputs ||= context_data.fetch(:outputs)
45
+ end
46
+
47
+ private
48
+
49
+ def assign_attribute(section, name, value)
50
+ context_data[section].assign(name, value)
51
+ end
52
+
53
+ def context_data
54
+ @context_data ||= state.fetch(context_id)
55
+ end
56
+
57
+ def state
58
+ {
59
+ context_id => {
60
+ inputs: Servactory::Context::Warehouse::Inputs.new(@context),
61
+ internals: Servactory::Context::Warehouse::Internals.new,
62
+ outputs: Servactory::Context::Warehouse::Outputs.new
63
+ }
64
+ }
65
+ end
66
+
67
+ def context_id
68
+ @context_id ||= "context_#{@context.object_id}"
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -7,9 +7,8 @@ module Servactory
7
7
  RESERVED_ATTRIBUTES = %i[type required default].freeze
8
8
  private_constant :RESERVED_ATTRIBUTES
9
9
 
10
- def initialize(context:, incoming_arguments:, collection_of_inputs:)
10
+ def initialize(context:, collection_of_inputs:)
11
11
  @context = context
12
- @incoming_arguments = incoming_arguments
13
12
  @collection_of_inputs = collection_of_inputs
14
13
  end
15
14
 
@@ -41,7 +40,7 @@ module Servactory
41
40
 
42
41
  private
43
42
 
44
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Lint/UnusedMethodArgument
43
+ # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Lint/UnusedMethodArgument
45
44
  def fetch_with(name:, &block)
46
45
  input_name = @context.class.config.predicate_methods_enabled? ? name.to_s.chomp("?").to_sym : name
47
46
 
@@ -49,7 +48,7 @@ module Servactory
49
48
 
50
49
  return yield if input.nil?
51
50
 
52
- input_value = @incoming_arguments.fetch(input.name, nil)
51
+ input_value = @context.send(:servactory_service_warehouse).fetch_input(input.name)
53
52
  input_value = input.default if input.optional? && input_value.blank?
54
53
 
55
54
  if input.hash_mode? && (tmp_schema = input.schema.fetch(:is)).present?
@@ -65,7 +64,7 @@ module Servactory
65
64
  input_value
66
65
  end
67
66
  end
68
- # rubocop:enable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Lint/UnusedMethodArgument
67
+ # rubocop:enable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Lint/UnusedMethodArgument
69
68
 
70
69
  def prepare_hash_values_inside(object:, schema:) # rubocop:disable Metrics/MethodLength
71
70
  return object unless object.respond_to?(:fetch)
@@ -50,7 +50,7 @@ module Servactory
50
50
  value:
51
51
  )
52
52
 
53
- @context.send(:servactory_service_store).assign_internal(internal.name, value)
53
+ @context.send(:servactory_service_warehouse).assign_internal(internal.name, value)
54
54
  end
55
55
 
56
56
  def fetch_with(name:, &block) # rubocop:disable Metrics/AbcSize, Lint/UnusedMethodArgument
@@ -59,7 +59,7 @@ module Servactory
59
59
 
60
60
  return yield if internal.nil?
61
61
 
62
- internal_value = @context.send(:servactory_service_store).fetch_internal(internal.name)
62
+ internal_value = @context.send(:servactory_service_warehouse).fetch_internal(internal.name)
63
63
 
64
64
  if name.to_s.end_with?("?") && @context.class.config.predicate_methods_enabled?
65
65
  Servactory::Utils.query_attribute(internal_value)
@@ -50,7 +50,7 @@ module Servactory
50
50
  value:
51
51
  )
52
52
 
53
- @context.send(:servactory_service_store).assign_output(output.name, value)
53
+ @context.send(:servactory_service_warehouse).assign_output(output.name, value)
54
54
  end
55
55
 
56
56
  def fetch_with(name:, &block) # rubocop:disable Metrics/AbcSize, Lint/UnusedMethodArgument
@@ -59,7 +59,7 @@ module Servactory
59
59
 
60
60
  return yield if output.nil?
61
61
 
62
- output_value = @context.send(:servactory_service_store).fetch_output(output.name)
62
+ output_value = @context.send(:servactory_service_warehouse).fetch_output(output.name)
63
63
 
64
64
  if name.to_s.end_with?("?") && @context.class.config.predicate_methods_enabled?
65
65
  Servactory::Utils.query_attribute(output_value)
@@ -23,7 +23,6 @@ module Servactory
23
23
  def inputs
24
24
  @inputs ||= Inputs.new(
25
25
  context: self,
26
- incoming_arguments:,
27
26
  collection_of_inputs:
28
27
  )
29
28
  end
@@ -83,8 +82,7 @@ module Servactory
83
82
 
84
83
  private
85
84
 
86
- attr_reader :incoming_arguments,
87
- :collection_of_inputs,
85
+ attr_reader :collection_of_inputs,
88
86
  :collection_of_internals,
89
87
  :collection_of_outputs
90
88
 
@@ -105,13 +103,11 @@ module Servactory
105
103
  end
106
104
 
107
105
  def call!(
108
- incoming_arguments:,
109
106
  collection_of_inputs:,
110
107
  collection_of_internals:,
111
108
  collection_of_outputs:,
112
109
  **
113
110
  )
114
- @incoming_arguments = incoming_arguments
115
111
  @collection_of_inputs = collection_of_inputs
116
112
  @collection_of_internals = collection_of_internals
117
113
  @collection_of_outputs = collection_of_outputs
@@ -130,8 +126,8 @@ module Servactory
130
126
  @servactory_service_info ||= self.class::Actor.new(self)
131
127
  end
132
128
 
133
- def servactory_service_store
134
- @servactory_service_store ||= Store.new(self)
129
+ def servactory_service_warehouse
130
+ @servactory_service_warehouse ||= Warehouse::Setup.new(self)
135
131
  end
136
132
  end
137
133
  end
@@ -8,9 +8,8 @@ module Servactory
8
8
  new(...).find!
9
9
  end
10
10
 
11
- def initialize(context, incoming_arguments, collection_of_inputs)
11
+ def initialize(context, collection_of_inputs)
12
12
  @context = context
13
- @incoming_arguments = incoming_arguments
14
13
  @collection_of_inputs = collection_of_inputs
15
14
  end
16
15
 
@@ -31,7 +30,9 @@ module Servactory
31
30
  private
32
31
 
33
32
  def unnecessary_attributes
34
- @unnecessary_attributes ||= @incoming_arguments.keys - @collection_of_inputs.names
33
+ @unnecessary_attributes ||=
34
+ @context.send(:servactory_service_warehouse).inputs.names -
35
+ @collection_of_inputs.names
35
36
  end
36
37
  end
37
38
  end
@@ -8,9 +8,8 @@ module Servactory
8
8
  new(...).validate!
9
9
  end
10
10
 
11
- def initialize(context, incoming_arguments, collection_of_inputs)
11
+ def initialize(context, collection_of_inputs)
12
12
  @context = context
13
- @incoming_arguments = incoming_arguments
14
13
  @collection_of_inputs = collection_of_inputs
15
14
  end
16
15
 
@@ -52,7 +51,7 @@ module Servactory
52
51
  validation_class.check(
53
52
  context: @context,
54
53
  attribute: input,
55
- value: @incoming_arguments.fetch(input.name, nil),
54
+ value: @context.send(:servactory_service_warehouse).fetch_input(input.name),
56
55
  check_key:,
57
56
  check_options:
58
57
  )
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Servactory
4
+ module Inputs
5
+ module Tools
6
+ class Warehouse
7
+ def self.assign(...)
8
+ new(...).assign
9
+ end
10
+
11
+ def initialize(context, incoming_arguments)
12
+ @context = context
13
+ @incoming_arguments = incoming_arguments
14
+ end
15
+
16
+ def assign
17
+ @context.send(:servactory_service_warehouse).assign_inputs(adapted_arguments)
18
+ end
19
+
20
+ private
21
+
22
+ def adapted_arguments
23
+ Servactory::Utils.adapt(@incoming_arguments)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -5,12 +5,14 @@ module Servactory
5
5
  module Workspace
6
6
  private
7
7
 
8
- def call!(incoming_arguments:, collection_of_inputs:, **)
8
+ def call!(incoming_arguments:, **)
9
9
  super
10
10
 
11
- Tools::Unnecessary.find!(self, incoming_arguments, collection_of_inputs)
11
+ Tools::Warehouse.assign(self, incoming_arguments)
12
+
13
+ Tools::Unnecessary.find!(self, collection_of_inputs)
12
14
  Tools::Rules.check!(self, collection_of_inputs)
13
- Tools::Validation.validate!(self, incoming_arguments, collection_of_inputs)
15
+ Tools::Validation.validate!(self, collection_of_inputs)
14
16
  end
15
17
  end
16
18
  end
@@ -108,12 +108,12 @@ module Servactory
108
108
  return if @define_methods.blank?
109
109
 
110
110
  @define_methods_template ||= @define_methods.map do |define_method|
111
- <<-RUBY
112
- def #{define_method.name}
113
- #{define_method.content.call(option: @body)}
111
+ <<-RUBY.squish
112
+ def #{define_method.name};
113
+ #{define_method.content.call(option: @body)};
114
114
  end
115
115
  RUBY
116
- end.join("\n")
116
+ end.join("; ")
117
117
  end
118
118
  end
119
119
  end
@@ -116,7 +116,7 @@ module Servactory
116
116
 
117
117
  def outputs
118
118
  @outputs ||= Outputs.new(
119
- outputs: @context.send(:servactory_service_store).outputs,
119
+ outputs: @context.send(:servactory_service_warehouse).outputs,
120
120
  predicate_methods_enabled: if @context.is_a?(Servactory::TestKit::Result)
121
121
  true
122
122
  else
@@ -17,7 +17,7 @@ module Servactory
17
17
 
18
18
  def initialize(attributes = {})
19
19
  attributes.each_pair do |name, value|
20
- servactory_service_store.assign_output(name, value)
20
+ servactory_service_warehouse.assign_output(name, value)
21
21
  end
22
22
  end
23
23
 
@@ -25,8 +25,8 @@ module Servactory
25
25
 
26
26
  private
27
27
 
28
- def servactory_service_store
29
- @servactory_service_store ||= Servactory::Context::Store.new(self)
28
+ def servactory_service_warehouse
29
+ @servactory_service_warehouse ||= Servactory::Context::Warehouse::Setup.new(self)
30
30
  end
31
31
  end
32
32
  end
@@ -3,9 +3,9 @@
3
3
  module Servactory
4
4
  module VERSION
5
5
  MAJOR = 2
6
- MINOR = 10
6
+ MINOR = 12
7
7
  PATCH = 0
8
- PRE = nil
8
+ PRE = "rc1"
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
11
11
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servactory
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.0
4
+ version: 2.12.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Sokolov
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-12-20 00:00:00.000000000 Z
10
+ date: 2025-02-08 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -190,14 +189,14 @@ dependencies:
190
189
  requirements:
191
190
  - - ">="
192
191
  - !ruby/object:Gem::Version
193
- version: '0.1'
192
+ version: '0.5'
194
193
  type: :development
195
194
  prerelease: false
196
195
  version_requirements: !ruby/object:Gem::Requirement
197
196
  requirements:
198
197
  - - ">="
199
198
  - !ruby/object:Gem::Version
200
- version: '0.1'
199
+ version: '0.5'
201
200
  - !ruby/object:Gem::Dependency
202
201
  name: steep
203
202
  requirement: !ruby/object:Gem::Requirement
@@ -250,7 +249,11 @@ files:
250
249
  - lib/servactory/configuration/setup.rb
251
250
  - lib/servactory/context/callable.rb
252
251
  - lib/servactory/context/dsl.rb
253
- - lib/servactory/context/store.rb
252
+ - lib/servactory/context/warehouse/base.rb
253
+ - lib/servactory/context/warehouse/inputs.rb
254
+ - lib/servactory/context/warehouse/internals.rb
255
+ - lib/servactory/context/warehouse/outputs.rb
256
+ - lib/servactory/context/warehouse/setup.rb
254
257
  - lib/servactory/context/workspace.rb
255
258
  - lib/servactory/context/workspace/inputs.rb
256
259
  - lib/servactory/context/workspace/internals.rb
@@ -271,6 +274,7 @@ files:
271
274
  - lib/servactory/inputs/tools/rules.rb
272
275
  - lib/servactory/inputs/tools/unnecessary.rb
273
276
  - lib/servactory/inputs/tools/validation.rb
277
+ - lib/servactory/inputs/tools/warehouse.rb
274
278
  - lib/servactory/inputs/translator/required.rb
275
279
  - lib/servactory/inputs/validations/base.rb
276
280
  - lib/servactory/inputs/validations/errors.rb
@@ -334,7 +338,6 @@ metadata:
334
338
  bug_tracker_uri: https://github.com/servactory/servactory/issues
335
339
  changelog_uri: https://github.com/servactory/servactory/blob/master/CHANGELOG.md
336
340
  rubygems_mfa_required: 'true'
337
- post_install_message:
338
341
  rdoc_options: []
339
342
  require_paths:
340
343
  - lib
@@ -349,8 +352,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
349
352
  - !ruby/object:Gem::Version
350
353
  version: '0'
351
354
  requirements: []
352
- rubygems_version: 3.5.23
353
- signing_key:
355
+ rubygems_version: 3.6.2
354
356
  specification_version: 4
355
357
  summary: A set of tools for building reliable services of any complexity
356
358
  test_files: []
@@ -1,58 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Servactory
4
- module Context
5
- class Store
6
- def initialize(context)
7
- @context = context
8
- end
9
-
10
- def fetch_internal(name)
11
- internals.fetch(name, nil)
12
- end
13
-
14
- def assign_internal(name, value)
15
- assign_attribute(:internals, name, value)
16
- end
17
-
18
- def fetch_output(name)
19
- outputs.fetch(name, nil)
20
- end
21
-
22
- def assign_output(name, value)
23
- assign_attribute(:outputs, name, value)
24
- end
25
-
26
- def outputs
27
- @outputs ||= context_data.fetch(:outputs)
28
- end
29
-
30
- private
31
-
32
- def assign_attribute(section, name, value)
33
- context_data[section].merge!({ name => value })
34
- end
35
-
36
- def internals
37
- @internals ||= context_data.fetch(:internals)
38
- end
39
-
40
- def context_data
41
- @context_data ||= state.fetch(context_id)
42
- end
43
-
44
- def state
45
- {
46
- context_id => {
47
- internals: {},
48
- outputs: {}
49
- }
50
- }
51
- end
52
-
53
- def context_id
54
- @context_id ||= "context_#{@context.object_id}"
55
- end
56
- end
57
- end
58
- end