blackstack-core 1.2.29 → 1.2.31
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/examples/example01.rb +0 -0
 - data/examples/example02.rb +0 -0
 - data/lib/blackstack-core.rb +0 -0
 - data/lib/extend_datetime.rb +0 -0
 - data/lib/extend_exception.rb +0 -0
 - data/lib/extend_fixnum.rb +0 -0
 - data/lib/extend_float.rb +0 -0
 - data/lib/extend_string.rb +0 -0
 - data/lib/extend_time.rb +0 -0
 - data/lib/functions.rb +80 -28
 - metadata +3 -6
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: f9422bf619ee5c62514cede0f715c896f9721bd679c106b328dce187a5a404a6
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 46f704d4f1ce7e8c6d5664ef4c3de74bc5a1dd6179e42f8247956410445fccb4
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 4cffd17c2b4a54c112fc6cacd6fec8a3f48b9286ea83e401662770a6580f4c40c030a229be9b3a066b965fb5a853cb79eb85d7ae15d358e8ca5908d0fe830eab
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: b71b7512bd2e941742359dd7135772956ed8956eafb98dc1c459760e0055a8009faabb14d3bd9e300047b401a747f053794cce0deaf6ddfd8cb4d3e7b2ef9ef9
         
     | 
    
        data/examples/example01.rb
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        data/examples/example02.rb
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        data/lib/blackstack-core.rb
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        data/lib/extend_datetime.rb
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        data/lib/extend_exception.rb
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        data/lib/extend_fixnum.rb
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        data/lib/extend_float.rb
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        data/lib/extend_string.rb
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        data/lib/extend_time.rb
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        data/lib/functions.rb
    CHANGED
    
    | 
         @@ -862,6 +862,10 @@ module BlackStack 
     | 
|
| 
       862 
862 
     | 
    
         
             
                DEFAULT_SSL_VERIFY_MODE = OpenSSL::SSL::VERIFY_NONE
         
     | 
| 
       863 
863 
     | 
    
         
             
                SUCCESS = 'success'
         
     | 
| 
       864 
864 
     | 
    
         | 
| 
      
 865 
     | 
    
         
            +
                DEFAULT_OPEN_TIMEOUT  = 10    # seconds to wait for the initial connection
         
     | 
| 
      
 866 
     | 
    
         
            +
                DEFAULT_READ_TIMEOUT  = 30    # seconds to wait for each response
         
     | 
| 
      
 867 
     | 
    
         
            +
                DEFAULT_RETRY_ATTEMPTS = 3
         
     | 
| 
      
 868 
     | 
    
         
            +
             
     | 
| 
       865 
869 
     | 
    
         
             
                @@lockfiles = []
         
     | 
| 
       866 
870 
     | 
    
         | 
| 
       867 
871 
     | 
    
         
             
                @@max_api_call_channels = 0 # 0 means infinite
         
     | 
| 
         @@ -927,32 +931,81 @@ module BlackStack 
     | 
|
| 
       927 
931 
     | 
    
         
             
                #
         
     | 
| 
       928 
932 
     | 
    
         
             
                # TODO: parameter support_redirections has been deprecated.
         
     | 
| 
       929 
933 
     | 
    
         
             
                #
         
     | 
| 
       930 
     | 
    
         
            -
                def self.call_post(url, 
     | 
| 
       931 
     | 
    
         
            -
                   
     | 
| 
       932 
     | 
    
         
            -
                   
     | 
| 
       933 
     | 
    
         
            -
                   
     | 
| 
       934 
     | 
    
         
            -
             
     | 
| 
       935 
     | 
    
         
            -
                   
     | 
| 
       936 
     | 
    
         
            -
                   
     | 
| 
       937 
     | 
    
         
            -
             
     | 
| 
       938 
     | 
    
         
            -
                   
     | 
| 
       939 
     | 
    
         
            -
             
     | 
| 
       940 
     | 
    
         
            -
             
     | 
| 
       941 
     | 
    
         
            -
             
     | 
| 
       942 
     | 
    
         
            -
             
     | 
| 
       943 
     | 
    
         
            -
             
     | 
| 
       944 
     | 
    
         
            -
             
     | 
| 
       945 
     | 
    
         
            -
             
     | 
| 
       946 
     | 
    
         
            -
                   
     | 
| 
       947 
     | 
    
         
            -
             
     | 
| 
       948 
     | 
    
         
            -
             
     | 
| 
       949 
     | 
    
         
            -
             
     | 
| 
       950 
     | 
    
         
            -
             
     | 
| 
       951 
     | 
    
         
            -
             
     | 
| 
       952 
     | 
    
         
            -
             
     | 
| 
      
 934 
     | 
    
         
            +
                def self.call_post(url,
         
     | 
| 
      
 935 
     | 
    
         
            +
                  body = {},
         
     | 
| 
      
 936 
     | 
    
         
            +
                  ssl_verify_mode = BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE,
         
     | 
| 
      
 937 
     | 
    
         
            +
                  support_redirections = true)
         
     | 
| 
      
 938 
     | 
    
         
            +
             
     | 
| 
      
 939 
     | 
    
         
            +
                  max_redirects = 5
         
     | 
| 
      
 940 
     | 
    
         
            +
                  attempts      = 0
         
     | 
| 
      
 941 
     | 
    
         
            +
             
     | 
| 
      
 942 
     | 
    
         
            +
                  while attempts < DEFAULT_RETRY_ATTEMPTS
         
     | 
| 
      
 943 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 944 
     | 
    
         
            +
                      # Create a basic Faraday connection
         
     | 
| 
      
 945 
     | 
    
         
            +
                      conn = Faraday.new(
         
     | 
| 
      
 946 
     | 
    
         
            +
                        url: url, #"#{uri.scheme}://#{uri.host}:#{uri.port}", 
         
     | 
| 
      
 947 
     | 
    
         
            +
                        ssl: { verify: ssl_verify_mode != OpenSSL::SSL::VERIFY_NONE },
         
     | 
| 
      
 948 
     | 
    
         
            +
                        request: {
         
     | 
| 
      
 949 
     | 
    
         
            +
                          open_timeout: DEFAULT_OPEN_TIMEOUT,
         
     | 
| 
      
 950 
     | 
    
         
            +
                          timeout:      DEFAULT_READ_TIMEOUT
         
     | 
| 
      
 951 
     | 
    
         
            +
                        }
         
     | 
| 
      
 952 
     | 
    
         
            +
                      ) do |f|
         
     | 
| 
      
 953 
     | 
    
         
            +
                        f.adapter Faraday.default_adapter
         
     | 
| 
      
 954 
     | 
    
         
            +
                      end
         
     | 
| 
      
 955 
     | 
    
         
            +
             
     | 
| 
      
 956 
     | 
    
         
            +
                      # Perform the initial POST request
         
     | 
| 
      
 957 
     | 
    
         
            +
                      response = conn.post(uri.path) do |req|
         
     | 
| 
      
 958 
     | 
    
         
            +
                        req.body = JSON.generate(body) # Manually serialize to JSON
         
     | 
| 
      
 959 
     | 
    
         
            +
                        req.headers['Content-Type'] = 'application/json'
         
     | 
| 
      
 960 
     | 
    
         
            +
                        req.headers['Accept']       = 'application/json'
         
     | 
| 
      
 961 
     | 
    
         
            +
                      end
         
     | 
| 
      
 962 
     | 
    
         
            +
             
     | 
| 
      
 963 
     | 
    
         
            +
                      # Manually handle HTTP redirects if requested
         
     | 
| 
      
 964 
     | 
    
         
            +
                      redirect_count = 0
         
     | 
| 
      
 965 
     | 
    
         
            +
                      while support_redirections &&
         
     | 
| 
      
 966 
     | 
    
         
            +
                        response.status.between?(300, 399) &&
         
     | 
| 
      
 967 
     | 
    
         
            +
                        response.headers['location'] &&
         
     | 
| 
      
 968 
     | 
    
         
            +
                        redirect_count < max_redirects
         
     | 
| 
      
 969 
     | 
    
         
            +
             
     | 
| 
      
 970 
     | 
    
         
            +
                        redirect_count += 1
         
     | 
| 
      
 971 
     | 
    
         
            +
                        new_url = URI.join(url, response.headers['location']).to_s
         
     | 
| 
      
 972 
     | 
    
         
            +
             
     | 
| 
      
 973 
     | 
    
         
            +
                        # Update `url` for the next iteration
         
     | 
| 
      
 974 
     | 
    
         
            +
                        url = new_url
         
     | 
| 
      
 975 
     | 
    
         
            +
                        uri = URI.parse(new_url)
         
     | 
| 
      
 976 
     | 
    
         
            +
             
     | 
| 
      
 977 
     | 
    
         
            +
                        response = conn.post(uri.path) do |req|
         
     | 
| 
      
 978 
     | 
    
         
            +
                          req.body = JSON.generate(body)
         
     | 
| 
      
 979 
     | 
    
         
            +
                          req.headers['Content-Type'] = 'application/json'
         
     | 
| 
      
 980 
     | 
    
         
            +
                          req.headers['Accept']       = 'application/json'
         
     | 
| 
      
 981 
     | 
    
         
            +
                        end
         
     | 
| 
      
 982 
     | 
    
         
            +
                      end
         
     | 
| 
      
 983 
     | 
    
         
            +
             
     | 
| 
      
 984 
     | 
    
         
            +
                      # Raise an error if the final response is not 2xx
         
     | 
| 
      
 985 
     | 
    
         
            +
                      unless response.success?
         
     | 
| 
      
 986 
     | 
    
         
            +
                        raise "HTTP #{response.status}: #{response.body}"
         
     | 
| 
      
 987 
     | 
    
         
            +
                      end
         
     | 
| 
      
 988 
     | 
    
         
            +
             
     | 
| 
      
 989 
     | 
    
         
            +
                      # If all is good, return the Faraday response object
         
     | 
| 
      
 990 
     | 
    
         
            +
                      return response
         
     | 
| 
      
 991 
     | 
    
         
            +
             
     | 
| 
      
 992 
     | 
    
         
            +
                    rescue Errno::ETIMEDOUT, Timeout::Error, Faraday::ConnectionFailed => e
         
     | 
| 
      
 993 
     | 
    
         
            +
                      # Basic retry logic for transient network errors
         
     | 
| 
      
 994 
     | 
    
         
            +
                      attempts += 1
         
     | 
| 
      
 995 
     | 
    
         
            +
                      if attempts < DEFAULT_RETRY_ATTEMPTS
         
     | 
| 
      
 996 
     | 
    
         
            +
                        sleep_time = 2**attempts
         
     | 
| 
      
 997 
     | 
    
         
            +
                        sleep(sleep_time)  # Exponential backoff
         
     | 
| 
      
 998 
     | 
    
         
            +
                        retry
         
     | 
| 
      
 999 
     | 
    
         
            +
                      else
         
     | 
| 
      
 1000 
     | 
    
         
            +
                        # Too many failures, re-raise
         
     | 
| 
      
 1001 
     | 
    
         
            +
                        raise e
         
     | 
| 
      
 1002 
     | 
    
         
            +
                      end
         
     | 
| 
      
 1003 
     | 
    
         
            +
                    rescue => e
         
     | 
| 
      
 1004 
     | 
    
         
            +
                      # For any other error, just re-raise
         
     | 
| 
      
 1005 
     | 
    
         
            +
                      raise e
         
     | 
| 
      
 1006 
     | 
    
         
            +
                    end
         
     | 
| 
       953 
1007 
     | 
    
         
             
                  end
         
     | 
| 
       954 
     | 
    
         
            -
             
     | 
| 
       955 
     | 
    
         
            -
                end
         
     | 
| 
      
 1008 
     | 
    
         
            +
                end # def self.call_post
         
     | 
| 
       956 
1009 
     | 
    
         | 
| 
       957 
1010 
     | 
    
         
             
                # TODO: deprecated
         
     | 
| 
       958 
1011 
     | 
    
         
             
                def self.api_call(url, params={}, method=BlackStack::Netting::CALL_METHOD_POST, ssl_verify_mode=BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE, max_retries=5)
         
     | 
| 
         @@ -963,9 +1016,8 @@ module BlackStack 
     | 
|
| 
       963 
1016 
     | 
    
         
             
                  while (nTries < max_retries && bSuccess == false)
         
     | 
| 
       964 
1017 
     | 
    
         
             
                    begin
         
     | 
| 
       965 
1018 
     | 
    
         
             
                      nTries = nTries + 1
         
     | 
| 
       966 
     | 
    
         
            -
                       
     | 
| 
       967 
     | 
    
         
            -
                      res = BlackStack::Netting:: 
     | 
| 
       968 
     | 
    
         
            -
                      res = BlackStack::Netting::call_get(uri, params, ssl_verify_mode) if method==BlackStack::Netting::CALL_METHOD_GET
         
     | 
| 
      
 1019 
     | 
    
         
            +
                      res = BlackStack::Netting::call_post(url, params, ssl_verify_mode) if method==BlackStack::Netting::CALL_METHOD_POST
         
     | 
| 
      
 1020 
     | 
    
         
            +
                      res = BlackStack::Netting::call_get(url, params, ssl_verify_mode) if method==BlackStack::Netting::CALL_METHOD_GET
         
     | 
| 
       969 
1021 
     | 
    
         
             
                      parsed = JSON.parse(res.body)
         
     | 
| 
       970 
1022 
     | 
    
         
             
                      if (parsed['status']==BlackStack::Netting::SUCCESS)
         
     | 
| 
       971 
1023 
     | 
    
         
             
                        bSuccess = true
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: blackstack-core
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.2. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.2.31
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Leandro Daniel Sardi
         
     | 
| 
       8 
     | 
    
         
            -
            autorequire: 
         
     | 
| 
       9 
8 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
9 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2025-01- 
     | 
| 
      
 10 
     | 
    
         
            +
            date: 2025-01-30 00:00:00.000000000 Z
         
     | 
| 
       12 
11 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
12 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
13 
     | 
    
         
             
              name: content_spinning
         
     | 
| 
         @@ -86,7 +85,6 @@ homepage: https://rubygems.org/gems/blackstack-core 
     | 
|
| 
       86 
85 
     | 
    
         
             
            licenses:
         
     | 
| 
       87 
86 
     | 
    
         
             
            - MIT
         
     | 
| 
       88 
87 
     | 
    
         
             
            metadata: {}
         
     | 
| 
       89 
     | 
    
         
            -
            post_install_message: 
         
     | 
| 
       90 
88 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       91 
89 
     | 
    
         
             
            require_paths:
         
     | 
| 
       92 
90 
     | 
    
         
             
            - lib
         
     | 
| 
         @@ -101,8 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       101 
99 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       102 
100 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       103 
101 
     | 
    
         
             
            requirements: []
         
     | 
| 
       104 
     | 
    
         
            -
            rubygems_version: 3.3 
     | 
| 
       105 
     | 
    
         
            -
            signing_key: 
         
     | 
| 
      
 102 
     | 
    
         
            +
            rubygems_version: 3.6.3
         
     | 
| 
       106 
103 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       107 
104 
     | 
    
         
             
            summary: Core modules, functions and constants for the BlackStack framework.
         
     | 
| 
       108 
105 
     | 
    
         
             
            test_files: []
         
     |