servactory 2.12.0 → 2.13.0

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: 0452d2479f148cd3390a5b6b3801f596687a93fd26f9a2dcdf533c0b4b6eaec9
4
- data.tar.gz: ea379698c7a2589e48fbf1eeef5252838808f8fbf8336e00c288adef2c8893e0
3
+ metadata.gz: effe21494947a824c5ee5f49b022a92157a69906a6b5f41cdf96a02b08bedc55
4
+ data.tar.gz: 7d52a8e143393e05824426f6c62e2d767191cee35b106fc159f3c2d72bfab50e
5
5
  SHA512:
6
- metadata.gz: 7122cf6929ed3655a28befe660226f0c0e424febd02c665a3cec2876ac2e1856057bef035e6d017c222b798f691c21b94759203dbfe7b317371d2fc89d3da650
7
- data.tar.gz: 8834aa51502c33b07070b1055027fce2a6a99cadbf3b872c97cb62f91ea200c14d11e391cb3a24115fde1e49c3596da40edca4394cbf79278e4b3ee4bb9d7dbf
6
+ metadata.gz: e10b019ae010c04a64fe28fc0e06b7e10d756ad7f6217e45c9241cc81c421fdbae8e36944de03b3de035aa307ed0b93a73a77e375fa218bfe198ed2a24a3e37a
7
+ data.tar.gz: 511d7cb765402d1a3b1ce41d30d7abf1964a0070191a10aaa3eb0109089b8a5ad49dde6e6904e539c8a1cc4bfe5343e48a10f13df378b0ab8472ed02d6d584ef
@@ -4,9 +4,6 @@ module Servactory
4
4
  module Context
5
5
  module Workspace
6
6
  class Inputs
7
- RESERVED_ATTRIBUTES = %i[type required default].freeze
8
- private_constant :RESERVED_ATTRIBUTES
9
-
10
7
  def initialize(context:, collection_of_inputs:)
11
8
  @context = context
12
9
  @collection_of_inputs = collection_of_inputs
@@ -29,8 +29,7 @@ module Servactory
29
29
  end
30
30
 
31
31
  def description
32
- result = "schema: "
33
- result + schema_data
32
+ "schema: #{schema_data}"
34
33
  end
35
34
 
36
35
  def matches?(subject)
@@ -58,10 +57,20 @@ module Servactory
58
57
  schema_data_equal?
59
58
  end
60
59
 
61
- def schema_data_equal?
60
+ def schema_data_equal? # rubocop:disable Metrics/MethodLength
61
+ matcher_result =
62
+ RSpec::Expectations::ExpectationHelper
63
+ .with_matcher(
64
+ RSpec::Expectations::PositiveExpectationHandler,
65
+ RSpec::Matchers::BuiltIn::Match.new(schema_data),
66
+ nil
67
+ ) do |matcher|
68
+ matcher.matches?(attribute_schema_is)
69
+ end
70
+
62
71
  @schema_data_equal ||=
63
72
  (
64
- schema_data.present? && schema_data == attribute_schema_is
73
+ schema_data.present? && matcher_result
65
74
  ) || schema_data.blank?
66
75
  end
67
76
 
@@ -4,8 +4,8 @@ module Servactory
4
4
  module ToolKit
5
5
  module DynamicOptions
6
6
  class Schema < Must # rubocop:disable Metrics/ClassLength
7
- RESERVED_ATTRIBUTES = %i[type required default].freeze
8
- private_constant :RESERVED_ATTRIBUTES
7
+ RESERVED_OPTIONS = %i[type required default payload].freeze
8
+ private_constant :RESERVED_OPTIONS
9
9
 
10
10
  def self.use(option_name = :schema, default_hash_mode_class_names:)
11
11
  instance = new(option_name, :is, false)
@@ -65,7 +65,7 @@ module Servactory
65
65
  if attribute_type == Hash
66
66
  validate_for!(
67
67
  object: object.fetch(schema_key, {}),
68
- schema: schema_value.except(*RESERVED_ATTRIBUTES),
68
+ schema: schema_value.except(*RESERVED_OPTIONS),
69
69
  root_schema_key: schema_key
70
70
  )
71
71
  else
@@ -134,14 +134,18 @@ module Servactory
134
134
  if attribute_type == Hash
135
135
  prepare_object_with!(
136
136
  object: object.fetch(schema_key, {}),
137
- schema: schema_value.except(*RESERVED_ATTRIBUTES)
137
+ schema: schema_value.except(*RESERVED_OPTIONS)
138
138
  )
139
139
  else
140
- next object unless object[schema_key].nil?
140
+ unless (default = schema_value.fetch(:default, nil)).nil?
141
+ object[schema_key] = default
142
+ end
141
143
 
142
- next object if (default = schema_value.fetch(:default, nil)).nil?
144
+ unless (input_prepare = schema_value.fetch(:prepare, nil)).nil?
145
+ object[schema_key] = input_prepare.call(value: object[schema_key])
146
+ end
143
147
 
144
- object[schema_key] = default
148
+ object
145
149
  end
146
150
  end
147
151
  end
@@ -3,7 +3,7 @@
3
3
  module Servactory
4
4
  module VERSION
5
5
  MAJOR = 2
6
- MINOR = 12
6
+ MINOR = 13
7
7
  PATCH = 0
8
8
  PRE = nil
9
9
 
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.12.0
4
+ version: 2.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Sokolov
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-03-02 00:00:00.000000000 Z
10
+ date: 2025-03-06 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activesupport