Sha256: 3cfb2d61b64dbae19861968ba86e6f4d50d4a6e867d7db22c02ca9be0fc43530

Contents?: true

Size: 668 Bytes

Versions: 8

Compression:

Stored size: 668 Bytes

Contents

module Fitting
  class Skip
    class API
      attr_accessor :type, :host, :prefix, :path

      def initialize(type, host, prefix)
        @type = type
        @host = host
        @prefix = prefix
      end

      def self.all(apis)
        return [] unless apis
        apis.map do |api|
          next if api['method'] || api['path']
          new('provided', api['host'], api['prefix'])
        end.compact
      end

      def self.find(apis, log)
        apis.find do |api|
          if log.host == api.host
            api.prefix.nil? || api.prefix == '' || log.path[0..api.prefix.size - 1] == api.prefix
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fitting-4.2.1 lib/fitting/skip/api.rb
fitting-4.2.0 lib/fitting/skip/api.rb
fitting-4.1.0 lib/fitting/skip/api.rb
fitting-4.0.4 lib/fitting/skip/api.rb
fitting-4.0.3 lib/fitting/skip/api.rb
fitting-4.0.2 lib/fitting/skip/api.rb
fitting-4.0.1 lib/fitting/skip/api.rb
fitting-4.0.0 lib/fitting/skip/api.rb