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 +4 -4
- data/config/locales/en.yml +1 -0
- data/config/locales/ru.yml +1 -0
- data/lib/servactory/actions/tools/rules.rb +71 -0
- data/lib/servactory/actions/workspace.rb +1 -0
- data/lib/servactory/version.rb +1 -1
- metadata +3 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 206566afd8ea64686928cf73cc5900e9a61c931ed6519e4e52305dad0e9845e4
         | 
| 4 | 
            +
              data.tar.gz: edf4a6bcc1da04242ee0983dd6097913cb860a720d4dadd53bba5d1974576384
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: eb6f14cb003123bea8192676582bea31dad5e9929596adf8929798687f7bad66f1b628a327a6584688572d9b9725ecc5460abd613f3a9818d1b635f877f0806f
         | 
| 7 | 
            +
              data.tar.gz: bb35e3efe53a8ef9e386301af595de8250d4d0e8228ce2fd4e80a09c17b1a573abf31154e4848535c3bc048012ea5a1521f48389ff8f0b9533e9919430c21ebe
         | 
    
        data/config/locales/en.yml
    CHANGED
    
    | @@ -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}`"
         | 
    
        data/config/locales/ru.yml
    CHANGED
    
    | @@ -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
         | 
    
        data/lib/servactory/version.rb
    CHANGED
    
    
    
        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 | 
| 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- | 
| 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
         |