featury 1.0.0.rc8 → 1.0.0.rc10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 201bfafa1c5c535c36980e60a29e9d5e3228330386c84fc36926b99992481050
4
- data.tar.gz: 267bf926a5f57d734ac0714f24af0bd87dc11ba4dfb77b768ac0bfa464719e2d
3
+ metadata.gz: 14297b1c9de5c23902ac31a3bbf5930f1694695cf7e88744e8325be9a71be266
4
+ data.tar.gz: 6f133ad9be42d5a5f76c7ec6808e1e9d85181756162c779e7faaf5d61fc23231
5
5
  SHA512:
6
- metadata.gz: c8c3deaa91faf85292cad10a0295af1396739859a890449a9bff78a47f05010d22d681efc3b7759ca5acdd1d7855e4a9a5a7c9a15ac1fb5f008b6df7ee49bda2
7
- data.tar.gz: addc261eba38e98918fa64f22c5f0288716b6ff9995ab179cfb5ff8943164f821ab6539c4363b93ec7ebba0b2f2f7d9e4f7f4e079aa57c467ab63ea46514c0c5
6
+ metadata.gz: abc8f9cb6fe9ac5e43ea0d46f9cb63d18162aba75b8f4d6e9c1cbae904cb003015bea58b7d0915f4858beafc71382e797b09805ac790363dbb4d016053f24fc5
7
+ data.tar.gz: 44e7baf756f9fa40abc60a1bc1a53ab4984eb4581f3e1f82ba1591affddaab68bb33b6b90f773e14472c883b5f8092a7079ddb2711d7a5271c0cf3d5f5dccc15
@@ -9,8 +9,8 @@ en:
9
9
  cannot_be_overwritten: "[%{service_class_name}] The following methods cannot be overwritten: %{list_of_methods}"
10
10
  inputs:
11
11
  undefined:
12
- getter: "[%{service_class_name}] Undefined resource attribute `%{input_name}`"
13
- setter: "[%{service_class_name}] Undefined resource attribute `%{input_name}`"
12
+ for_fetch: "[%{service_class_name}] Undefined resource attribute `%{input_name}`"
13
+ for_assign: "[%{service_class_name}] Undefined resource attribute `%{input_name}`"
14
14
  validations:
15
15
  inclusion:
16
16
  default_error: "[%{service_class_name}] Wrong value in `%{input_name}`, must be one of `%{input_inclusion}`"
@@ -30,6 +30,10 @@ en:
30
30
  default: "[%{service_class_name}] Resource `%{input_name}` received value `%{value}`, which is less than `%{option_value}`"
31
31
  max:
32
32
  default: "[%{service_class_name}] Resource `%{input_name}` received value `%{value}`, which is greater than `%{option_value}`"
33
+ multiple_of:
34
+ default: "[%{service_class_name}] Resource `%{input_name}` has the value `%{value}`, which is not a multiple of `%{option_value}`"
35
+ blank: "[%{service_class_name}] Resource `%{input_name}` has an invalid value `%{option_value}` in option `%{option_name}`"
36
+ divided_by_0: "[%{service_class_name}] Resource `%{input_name}` has an invalid value `%{option_value}` in option `%{option_name}`"
33
37
  required:
34
38
  default_error:
35
39
  default: "[%{service_class_name}] Required resource `%{input_name}` is missing"
@@ -45,8 +49,8 @@ en:
45
49
  error: "[%{service_class_name}] Conflict in `%{input_name}` resource options: `%{conflict_code}`"
46
50
  internals:
47
51
  undefined:
48
- getter: "[%{service_class_name}] Undefined internal attribute `%{internal_name}`"
49
- setter: "[%{service_class_name}] Undefined internal attribute `%{internal_name}`"
52
+ for_fetch: "[%{service_class_name}] Undefined internal attribute `%{internal_name}`"
53
+ for_assign: "[%{service_class_name}] Undefined internal attribute `%{internal_name}`"
50
54
  validations:
51
55
  inclusion:
52
56
  default_error: "[%{service_class_name}] Wrong value in `%{internal_name}`, must be one of `%{internal_inclusion}`"
@@ -66,6 +70,10 @@ en:
66
70
  default: "[%{service_class_name}] Internal attribute `%{internal_name}` received value `%{value}`, which is less than `%{option_value}`"
67
71
  max:
68
72
  default: "[%{service_class_name}] Internal attribute `%{internal_name}` received value `%{value}`, which is greater than `%{option_value}`"
73
+ multiple_of:
74
+ default: "[%{service_class_name}] Internal attribute `%{internal_name}` has the value `%{value}`, which is not a multiple of `%{option_value}`"
75
+ blank: "[%{service_class_name}] Internal attribute `%{internal_name}` has an invalid value `%{option_value}` in option `%{option_name}`"
76
+ divided_by_0: "[%{service_class_name}] Internal attribute `%{internal_name}` has an invalid value `%{option_value}` in option `%{option_name}`"
69
77
  type:
70
78
  default_error:
71
79
  default: "[%{service_class_name}] Wrong type of internal attribute `%{internal_name}`, expected `%{expected_type}`, got `%{given_type}`"
@@ -73,8 +81,8 @@ en:
73
81
  wrong_element_type: "[%{service_class_name}] Wrong type in internal attribute hash `%{internal_name}`, expected `%{expected_type}` for `%{key_name}`, got `%{given_type}`"
74
82
  outputs:
75
83
  undefined:
76
- getter: "[%{service_class_name}] Undefined output attribute `%{output_name}`"
77
- setter: "[%{service_class_name}] Undefined output attribute `%{output_name}`"
84
+ for_fetch: "[%{service_class_name}] Undefined output attribute `%{output_name}`"
85
+ for_assign: "[%{service_class_name}] Undefined output attribute `%{output_name}`"
78
86
  validations:
79
87
  inclusion:
80
88
  default_error: "[%{service_class_name}] Wrong value in `%{output_name}`, must be one of `%{output_inclusion}`"
@@ -94,6 +102,10 @@ en:
94
102
  default: "[%{service_class_name}] Output attribute `%{output_name}` received value `%{value}`, which is less than `%{option_value}`"
95
103
  max:
96
104
  default: "[%{service_class_name}] Output attribute `%{output_name}` received value `%{value}`, which is greater than `%{option_value}`"
105
+ multiple_of:
106
+ default: "[%{service_class_name}] Output attribute `%{output_name}` has the value `%{value}`, which is not a multiple of `%{option_value}`"
107
+ blank: "[%{service_class_name}] Output attribute `%{output_name}` has an invalid value `%{option_value}` in option `%{option_name}`"
108
+ divided_by_0: "[%{service_class_name}] Output attribute `%{output_name}` has an invalid value `%{option_value}` in option `%{option_name}`"
97
109
  type:
98
110
  default_error:
99
111
  default: "[%{service_class_name}] Wrong type of output attribute `%{output_name}`, expected `%{expected_type}`, got `%{given_type}`"
@@ -9,8 +9,8 @@ ru:
9
9
  cannot_be_overwritten: "[%{service_class_name}] Нельзя перезаписать следующие методы: %{list_of_methods}"
10
10
  inputs:
11
11
  undefined:
12
- getter: "[%{service_class_name}] Неизвестный входящий атрибут `%{input_name}`"
13
- setter: "[%{service_class_name}] Неизвестный входящий атрибут `%{input_name}`"
12
+ for_fetch: "[%{service_class_name}] Неизвестный входящий атрибут `%{input_name}`"
13
+ for_assign: "[%{service_class_name}] Неизвестный входящий атрибут `%{input_name}`"
14
14
  validations:
15
15
  inclusion:
16
16
  default_error: "[%{service_class_name}] Неправильное значение в `%{input_name}`, должно быть одним из `%{input_inclusion}`"
@@ -30,6 +30,10 @@ ru:
30
30
  default: "[%{service_class_name}] Ресурс `%{input_name}` получил значение `%{value}`, которое меньше `%{option_value}`"
31
31
  max:
32
32
  default: "[%{service_class_name}] Ресурс `%{input_name}` получил значение `%{value}`, которое больше `%{option_value}`"
33
+ multiple_of:
34
+ default: "[%{service_class_name}] Ресурс `%{input_name}` имеет значение `%{value}`, которое не кратно `%{option_value}`"
35
+ blank: "[%{service_class_name}] Ресурс `%{input_name}` имеет недопустимое значение `%{option_value}` в опции `%{option_name}`"
36
+ divided_by_0: "[%{service_class_name}] Ресурс `%{input_name}` имеет недопустимое значение `%{option_value}` в опции `%{option_name}`"
33
37
  required:
34
38
  default_error:
35
39
  default: "[%{service_class_name}] Обязательный ресурс `%{input_name}` отсутствует"
@@ -45,8 +49,8 @@ ru:
45
49
  error: "[%{service_class_name}] Конфликт в опциях ресурса `%{input_name}`: `%{conflict_code}`"
46
50
  internals:
47
51
  undefined:
48
- getter: "[%{service_class_name}] Неизвестный внутренний атрибут `%{internal_name}`"
49
- setter: "[%{service_class_name}] Неизвестный внутренний атрибут `%{internal_name}`"
52
+ for_fetch: "[%{service_class_name}] Неизвестный внутренний атрибут `%{internal_name}`"
53
+ for_assign: "[%{service_class_name}] Неизвестный внутренний атрибут `%{internal_name}`"
50
54
  validations:
51
55
  inclusion:
52
56
  default_error: "[%{service_class_name}] Неправильное значение в `%{internal_name}`, должно быть одним из `%{internal_inclusion}`"
@@ -66,6 +70,10 @@ ru:
66
70
  default: "[%{service_class_name}] Внутренний атрибут `%{internal_name}` получил значение `%{value}`, которое меньше `%{option_value}`"
67
71
  max:
68
72
  default: "[%{service_class_name}] Внутренний атрибут `%{internal_name}` получил значение `%{value}`, которое больше `%{option_value}`"
73
+ multiple_of:
74
+ default: "[%{service_class_name}] Внутренний атрибут `%{internal_name}` имеет значение `%{value}`, которое не кратно `%{option_value}`"
75
+ blank: "[%{service_class_name}] Внутренний атрибут `%{internal_name}` имеет недопустимое значение `%{option_value}` в опции `%{option_name}`"
76
+ divided_by_0: "[%{service_class_name}] Внутренний атрибут `%{internal_name}` имеет недопустимое значение `%{option_value}` в опции `%{option_name}`"
69
77
  type:
70
78
  default_error:
71
79
  default: "[%{service_class_name}] Неправильный тип внутреннего атрибута `%{internal_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
@@ -73,8 +81,8 @@ ru:
73
81
  wrong_element_type: "[%{service_class_name}] Неправильный тип в хеше внутреннего атрибута `%{internal_name}`, для `%{key_name}` ожидалось `%{expected_type}`, получено `%{given_type}`"
74
82
  outputs:
75
83
  undefined:
76
- getter: "[%{service_class_name}] Неизвестный выходящий атрибут `%{output_name}`"
77
- setter: "[%{service_class_name}] Неизвестный выходящий атрибут `%{output_name}`"
84
+ for_fetch: "[%{service_class_name}] Неизвестный выходящий атрибут `%{output_name}`"
85
+ for_assign: "[%{service_class_name}] Неизвестный выходящий атрибут `%{output_name}`"
78
86
  validations:
79
87
  inclusion:
80
88
  default_error: "[%{service_class_name}] Неправильное значение в `%{output_name}`, должно быть одним из `%{output_inclusion}`"
@@ -94,6 +102,10 @@ ru:
94
102
  default: "[%{service_class_name}] Выходящий атрибут `%{output_name}` получил значение `%{value}`, которое меньше `%{option_value}`"
95
103
  max:
96
104
  default: "[%{service_class_name}] Выходящий атрибут `%{output_name}` получил значение `%{value}`, которое больше `%{option_value}`"
105
+ multiple_of:
106
+ default: "[%{service_class_name}] Выходящий атрибут `%{output_name}` имеет значение `%{value}`, которое не кратно `%{option_value}`"
107
+ blank: "[%{service_class_name}] Выходящий атрибут `%{output_name}` имеет недопустимое значение `%{option_value}` в опции `%{option_name}`"
108
+ divided_by_0: "[%{service_class_name}] Выходящий атрибут `%{output_name}` имеет недопустимое значение `%{option_value}` в опции `%{option_name}`"
97
109
  type:
98
110
  default_error:
99
111
  default: "[%{service_class_name}] Неправильный тип выходящего атрибута `%{output_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
@@ -36,51 +36,47 @@ module Featury
36
36
  input :collection_of_features, type: Featury::Features::Collection
37
37
  input :collection_of_groups, type: Featury::Groups::Collection
38
38
 
39
- internal :conditions_are_true, type: [TrueClass, FalseClass]
40
- internal :features_are_true, type: [TrueClass, FalseClass]
41
- internal :groups_are_true, type: [TrueClass, FalseClass]
42
-
43
39
  output :all_true, type: [TrueClass, FalseClass]
44
40
 
45
- check :conditions
46
- check :features
47
- check :groups
48
-
49
41
  check :all
50
42
 
51
43
  private
52
44
 
53
- def check_conditions
54
- internals.conditions_are_true = inputs.collection_of_conditions.all? do |condition|
45
+ def check_all
46
+ outputs.all_true = conditions_are_true
47
+ return unless outputs.all_true
48
+
49
+ outputs.all_true = features_are_true
50
+ return unless outputs.all_true
51
+
52
+ outputs.all_true = groups_are_true
53
+ end
54
+
55
+ ####################################################################
56
+
57
+ def conditions_are_true
58
+ inputs.collection_of_conditions.all? do |condition|
55
59
  condition.block.call(resources: inputs)
56
60
  end
57
61
  end
58
62
 
59
- def check_features # rubocop:disable Metrics/AbcSize
63
+ def features_are_true
60
64
  options = inputs.collection_of_resources.only_option.to_h do |resource|
61
65
  [resource.name, inputs.public_send(resource.name)]
62
66
  end
63
67
 
64
- internals.features_are_true =
65
- inputs.action.block.call(features: inputs.collection_of_features.list, **options)
68
+ inputs.action.block.call(features: inputs.collection_of_features.list, **options)
66
69
  end
67
70
 
68
- def check_groups # rubocop:disable Metrics/AbcSize
71
+ def groups_are_true
69
72
  arguments = inputs.collection_of_resources.only_nested.to_h do |resource|
70
73
  [resource.name, inputs.public_send(resource.name)]
71
74
  end
72
75
 
73
- internals.groups_are_true = inputs.collection_of_groups.all? do |group|
76
+ inputs.collection_of_groups.all? do |group|
74
77
  group.group.public_send(inputs.action.name, **arguments)
75
78
  end
76
79
  end
77
-
78
- def check_all
79
- outputs.all_true =
80
- internals.conditions_are_true &&
81
- internals.features_are_true &&
82
- internals.groups_are_true
83
- end
84
80
  end
85
81
  end
86
82
  end
@@ -9,28 +9,6 @@ module Featury
9
9
  def initialize(collection = Set.new)
10
10
  @collection = collection
11
11
  end
12
-
13
- def names
14
- map(&:name)
15
- end
16
-
17
- def internal_names
18
- map { |attribute| attribute.to.name }
19
- end
20
-
21
- def include_class_exist?
22
- @include_class_exist ||= filter do |attribute| # rubocop:disable Performance/Count
23
- include_class = attribute.to.include_class
24
-
25
- next false if include_class.nil?
26
-
27
- if [Set, Array].include?(include_class)
28
- include_class.any? { |item| item <= Datory::Base }
29
- else
30
- include_class <= Datory::Base
31
- end
32
- end.size.positive?
33
- end
34
12
  end
35
13
  end
36
14
  end
@@ -5,7 +5,7 @@ module Featury
5
5
  MAJOR = 1
6
6
  MINOR = 0
7
7
  PATCH = 0
8
- PRE = "rc8"
8
+ PRE = "rc10"
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: featury
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc8
4
+ version: 1.0.0.rc10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Sokolov
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-19 00:00:00.000000000 Z
10
+ date: 2025-02-20 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activesupport
@@ -49,14 +49,14 @@ dependencies:
49
49
  requirements:
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 2.9.0
52
+ version: 2.11.0
53
53
  type: :runtime
54
54
  prerelease: false
55
55
  version_requirements: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 2.9.0
59
+ version: 2.11.0
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: zeitwerk
62
62
  requirement: !ruby/object:Gem::Requirement