servactory 2.2.0.rc3 → 2.2.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: e5277367d01d5c23db3c801f825d1712c09985c5c46f4776154dfbcf5b1f3a39
4
- data.tar.gz: caf9a6aee71b1aad8fb6864891e2fff8d10343a60dda587751f1e1f84de6f219
3
+ metadata.gz: 206566afd8ea64686928cf73cc5900e9a61c931ed6519e4e52305dad0e9845e4
4
+ data.tar.gz: edf4a6bcc1da04242ee0983dd6097913cb860a720d4dadd53bba5d1974576384
5
5
  SHA512:
6
- metadata.gz: '018e0d467b3ac2a2dd76937de6c1048622038d2f80381b28672ddeb9b47e575920d0704a8b6b0dd73c4ec30c76acca72bad7da55b2c052614f7db94b36299b5c'
7
- data.tar.gz: 3e4b1ad12e8f69068ed578330ce6bbee417400b40b042f5ae35245ca14c5e257a7330ccfceb475932833af510fcef3c0534bd22b90d6ae980cf55dd7ae939157
6
+ metadata.gz: eb6f14cb003123bea8192676582bea31dad5e9929596adf8929798687f7bad66f1b628a327a6584688572d9b9725ecc5460abd613f3a9818d1b635f877f0806f
7
+ data.tar.gz: bb35e3efe53a8ef9e386301af595de8250d4d0e8228ce2fd4e80a09c17b1a573abf31154e4848535c3bc048012ea5a1521f48389ff8f0b9533e9919430c21ebe
@@ -7,6 +7,7 @@ en:
7
7
  methods:
8
8
  call:
9
9
  not_used: "[%{service_class_name}] Nothing to perform. Use `make` or create a `call` method."
10
+ cannot_be_overwritten: "[%{service_class_name}] The following methods cannot be overwritten: %{list_of_methods}"
10
11
  inputs:
11
12
  undefined:
12
13
  getter: "[%{service_class_name}] Undefined input attribute `%{input_name}`"
@@ -7,6 +7,7 @@ ru:
7
7
  methods:
8
8
  call:
9
9
  not_used: "[%{service_class_name}] Нечего выполнять. Используйте `make` или создайте метод `call`."
10
+ cannot_be_overwritten: "[%{service_class_name}] Нельзя перезаписать следующие методы: %{list_of_methods}"
10
11
  inputs:
11
12
  undefined:
12
13
  getter: "[%{service_class_name}] Неизвестный входящий атрибут `%{input_name}`"
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Servactory
4
+ module Actions
5
+ module Tools
6
+ class Rules
7
+ RESERVED_METHOD_NAMES = %i[
8
+ inputs
9
+ internals
10
+ outputs
11
+ success!
12
+ fail_input!
13
+ fail_internal!
14
+ fail_output!
15
+ fail!
16
+ fail_result!
17
+ ].freeze
18
+ private_constant :RESERVED_METHOD_NAMES
19
+
20
+ def self.check!(...)
21
+ new(...).check!
22
+ end
23
+
24
+ def initialize(context)
25
+ @context = context
26
+ end
27
+
28
+ def check!
29
+ check_public_methods!
30
+ check_protected_methods!
31
+ check_private_methods!
32
+ end
33
+
34
+ private
35
+
36
+ def check_public_methods!
37
+ check_in!(@context.public_methods(false))
38
+ end
39
+
40
+ def check_protected_methods!
41
+ check_in!(@context.protected_methods(false))
42
+ end
43
+
44
+ def check_private_methods!
45
+ check_in!(@context.private_methods(false))
46
+ end
47
+
48
+ def check_in!(list_of_methods)
49
+ found_reserved_names = RESERVED_METHOD_NAMES & list_of_methods
50
+
51
+ return if found_reserved_names.empty?
52
+
53
+ formatted_text = found_reserved_names.map { |method_name| "`#{method_name}`" }.join(", ")
54
+
55
+ raise_message_with!(formatted_text)
56
+ end
57
+
58
+ def raise_message_with!(formatted_text)
59
+ raise @context.class.config.failure_class.new(
60
+ type: :base,
61
+ message: I18n.t(
62
+ "servactory.methods.cannot_be_overwritten",
63
+ service_class_name: @context.class.name,
64
+ list_of_methods: formatted_text
65
+ )
66
+ )
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -8,6 +8,7 @@ module Servactory
8
8
  def call!(collection_of_stages:, **)
9
9
  super
10
10
 
11
+ Servactory::Actions::Tools::Rules.check!(self)
11
12
  Servactory::Actions::Tools::Runner.run!(self, collection_of_stages)
12
13
  end
13
14
  end
@@ -5,7 +5,7 @@ module Servactory
5
5
  MAJOR = 2
6
6
  MINOR = 2
7
7
  PATCH = 0
8
- PRE = "rc3"
8
+ PRE = nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
11
11
  end
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: 2.2.0.rc3
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Sokolov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-24 00:00:00.000000000 Z
11
+ date: 2024-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -245,6 +245,7 @@ files:
245
245
  - lib/servactory/actions/shortcuts/collection.rb
246
246
  - lib/servactory/actions/stages/collection.rb
247
247
  - lib/servactory/actions/stages/stage.rb
248
+ - lib/servactory/actions/tools/rules.rb
248
249
  - lib/servactory/actions/tools/runner.rb
249
250
  - lib/servactory/actions/workspace.rb
250
251
  - lib/servactory/base.rb