servactory 2.2.0.rc3 → 2.2.0.rc4

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: e5277367d01d5c23db3c801f825d1712c09985c5c46f4776154dfbcf5b1f3a39
4
- data.tar.gz: caf9a6aee71b1aad8fb6864891e2fff8d10343a60dda587751f1e1f84de6f219
3
+ metadata.gz: '018fb4d826b26f9497722a3f89104d1869b478f8b9e5a951bc1b3af2e065a8fa'
4
+ data.tar.gz: 2a47ba47a772ab0825a544888ce0cdcfe840aa9a50ac32971135d3d23dae60fd
5
5
  SHA512:
6
- metadata.gz: '018e0d467b3ac2a2dd76937de6c1048622038d2f80381b28672ddeb9b47e575920d0704a8b6b0dd73c4ec30c76acca72bad7da55b2c052614f7db94b36299b5c'
7
- data.tar.gz: 3e4b1ad12e8f69068ed578330ce6bbee417400b40b042f5ae35245ca14c5e257a7330ccfceb475932833af510fcef3c0534bd22b90d6ae980cf55dd7ae939157
6
+ metadata.gz: e6b88d34c9a3efba9ed2fc47b963284cb6bcdc998dc5f2d8a5f9973d93ac42a825ac8ac6eb5f0f2a15348dc34380274c88d1d43162cd653b1be1062621874fe9
7
+ data.tar.gz: 115231d9fa2863b7c7ad02867ea79c363c11369c621e125d331e1ad2be16c810b790dcc5f8a98f091701097d989a9b8c8c352a65089f4cf1ad90b29d1c93abfd
@@ -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 = "rc4"
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.rc4
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-27 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