servactory 2.11.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: a14d75bf3c1035ecffff36644b509241bdea300d28b56aa91e15e933c9184cb1
4
- data.tar.gz: 062d490213f603fa45571b4217f3a8f8a892e92fdfd348e6702b2c71246d9480
3
+ metadata.gz: 42d8f2391ba24198b46219e80408d7bf1d304faca0dfd5a99e89ac841d246fe4
4
+ data.tar.gz: 93748b84e352a85641a18e2f50f7fbc1668c7d037a613b95f8ed47fe02fce079
5
5
  SHA512:
6
- metadata.gz: 95b646ef01984996b9a9607e2a01a6adb324e76d0b637a78f4de73105840a3c17af27b20ca2286805161f5eb134da3b9b616d8ec7de6b5fc86bcc7847e265bfc
7
- data.tar.gz: 61e57e674dbd46d934da1cbbe63b8574cd890913ca9ae63082529e627140105d724ba3e1a761c73a081eac7cb94169752dfd424cd7b9a17c3629910937e8917e
6
+ metadata.gz: 45895d6e4182f0ccdb4fd0c37e030232d809d8fb14d6117f793c5abac5292ceb172d5cd1aeb1fc48cb3cbda70e0ce4ba08a8752744f4776f431136b2c7b1dc8e
7
+ data.tar.gz: 97e972f65d377eec5eb1224d54c440e7cca90c66a32fd2fd398e87c482f355110fbc39453cfdca799b45e59af259bf5e393c039181e23f59ecb41bbfe5d478aa
@@ -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
@@ -40,7 +40,7 @@ module Servactory
40
40
 
41
41
  private
42
42
 
43
- # 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
44
44
  def fetch_with(name:, &block)
45
45
  input_name = @context.class.config.predicate_methods_enabled? ? name.to_s.chomp("?").to_sym : name
46
46
 
@@ -48,7 +48,7 @@ module Servactory
48
48
 
49
49
  return yield if input.nil?
50
50
 
51
- input_value = @context.send(:servactory_service_store).fetch_input(input.name)
51
+ input_value = @context.send(:servactory_service_warehouse).fetch_input(input.name)
52
52
  input_value = input.default if input.optional? && input_value.blank?
53
53
 
54
54
  if input.hash_mode? && (tmp_schema = input.schema.fetch(:is)).present?
@@ -64,7 +64,7 @@ module Servactory
64
64
  input_value
65
65
  end
66
66
  end
67
- # 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
68
68
 
69
69
  def prepare_hash_values_inside(object:, schema:) # rubocop:disable Metrics/MethodLength
70
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)
@@ -126,8 +126,8 @@ module Servactory
126
126
  @servactory_service_info ||= self.class::Actor.new(self)
127
127
  end
128
128
 
129
- def servactory_service_store
130
- @servactory_service_store ||= Store.new(self)
129
+ def servactory_service_warehouse
130
+ @servactory_service_warehouse ||= Warehouse::Setup.new(self)
131
131
  end
132
132
  end
133
133
  end
@@ -31,7 +31,7 @@ module Servactory
31
31
 
32
32
  def unnecessary_attributes
33
33
  @unnecessary_attributes ||=
34
- @context.send(:servactory_service_store).inputs.keys -
34
+ @context.send(:servactory_service_warehouse).inputs.names -
35
35
  @collection_of_inputs.names
36
36
  end
37
37
  end
@@ -51,7 +51,7 @@ module Servactory
51
51
  validation_class.check(
52
52
  context: @context,
53
53
  attribute: input,
54
- value: @context.send(:servactory_service_store).fetch_input(input.name),
54
+ value: @context.send(:servactory_service_warehouse).fetch_input(input.name),
55
55
  check_key:,
56
56
  check_options:
57
57
  )
@@ -3,7 +3,7 @@
3
3
  module Servactory
4
4
  module Inputs
5
5
  module Tools
6
- class Store
6
+ class Warehouse
7
7
  def self.assign(...)
8
8
  new(...).assign
9
9
  end
@@ -14,7 +14,7 @@ module Servactory
14
14
  end
15
15
 
16
16
  def assign
17
- @context.send(:servactory_service_store).assign_inputs(adapted_arguments)
17
+ @context.send(:servactory_service_warehouse).assign_inputs(adapted_arguments)
18
18
  end
19
19
 
20
20
  private
@@ -8,7 +8,7 @@ module Servactory
8
8
  def call!(incoming_arguments:, **)
9
9
  super
10
10
 
11
- Tools::Store.assign(self, incoming_arguments)
11
+ Tools::Warehouse.assign(self, incoming_arguments)
12
12
 
13
13
  Tools::Unnecessary.find!(self, collection_of_inputs)
14
14
  Tools::Rules.check!(self, collection_of_inputs)
@@ -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 = 11
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,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servactory
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.0
4
+ version: 2.12.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Sokolov
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-01-01 00:00:00.000000000 Z
10
+ date: 2025-02-08 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activesupport
@@ -189,14 +189,14 @@ dependencies:
189
189
  requirements:
190
190
  - - ">="
191
191
  - !ruby/object:Gem::Version
192
- version: '0.1'
192
+ version: '0.5'
193
193
  type: :development
194
194
  prerelease: false
195
195
  version_requirements: !ruby/object:Gem::Requirement
196
196
  requirements:
197
197
  - - ">="
198
198
  - !ruby/object:Gem::Version
199
- version: '0.1'
199
+ version: '0.5'
200
200
  - !ruby/object:Gem::Dependency
201
201
  name: steep
202
202
  requirement: !ruby/object:Gem::Requirement
@@ -249,7 +249,11 @@ files:
249
249
  - lib/servactory/configuration/setup.rb
250
250
  - lib/servactory/context/callable.rb
251
251
  - lib/servactory/context/dsl.rb
252
- - 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
253
257
  - lib/servactory/context/workspace.rb
254
258
  - lib/servactory/context/workspace/inputs.rb
255
259
  - lib/servactory/context/workspace/internals.rb
@@ -268,9 +272,9 @@ files:
268
272
  - lib/servactory/inputs/dsl.rb
269
273
  - lib/servactory/inputs/input.rb
270
274
  - lib/servactory/inputs/tools/rules.rb
271
- - lib/servactory/inputs/tools/store.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
@@ -1,71 +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 assign_inputs(arguments)
11
- context_data[:inputs].merge!(arguments)
12
- end
13
-
14
- def fetch_input(name)
15
- inputs.fetch(name, nil)
16
- end
17
-
18
- def assign_internal(name, value)
19
- assign_attribute(:internals, name, value)
20
- end
21
-
22
- def fetch_internal(name)
23
- internals.fetch(name, nil)
24
- end
25
-
26
- def assign_output(name, value)
27
- assign_attribute(:outputs, name, value)
28
- end
29
-
30
- def fetch_output(name)
31
- outputs.fetch(name, nil)
32
- end
33
-
34
- def inputs
35
- @inputs ||= context_data.fetch(:inputs)
36
- end
37
-
38
- def internals
39
- @internals ||= context_data.fetch(:internals)
40
- end
41
-
42
- def outputs
43
- @outputs ||= context_data.fetch(:outputs)
44
- end
45
-
46
- private
47
-
48
- def assign_attribute(section, name, value)
49
- context_data[section].merge!({ name => value })
50
- end
51
-
52
- def context_data
53
- @context_data ||= state.fetch(context_id)
54
- end
55
-
56
- def state
57
- {
58
- context_id => {
59
- inputs: {},
60
- internals: {},
61
- outputs: {}
62
- }
63
- }
64
- end
65
-
66
- def context_id
67
- @context_id ||= "context_#{@context.object_id}"
68
- end
69
- end
70
- end
71
- end