Sha256: 3ad3d3ab437ab154356ba0bf544fcfa5bca44a04efd3c2a64c867038667dccc7

Contents?: true

Size: 564 Bytes

Versions: 90

Compression:

Stored size: 564 Bytes

Contents

module Onebox
  class Matcher
    def initialize(link)
      @url = link
    end

    def ordered_engines
      @ordered_engines ||= Engine.engines.sort_by do |e|
        e.respond_to?(:priority) ? e.priority : 100
      end
    end

    def oneboxed
      uri = URI(@url)
      return unless uri.port.nil? || Onebox.options.allowed_ports.include?(uri.port)
      return unless uri.scheme.nil? || Onebox.options.allowed_schemes.include?(uri.scheme)
      ordered_engines.find { |engine| engine === uri }
    rescue URI::InvalidURIError
      nil
    end
  end
end

Version data entries

90 entries across 90 versions & 1 rubygems

Version Path
onebox-1.8.7 lib/onebox/matcher.rb
onebox-1.8.6 lib/onebox/matcher.rb
onebox-1.8.5 lib/onebox/matcher.rb
onebox-1.8.4 lib/onebox/matcher.rb
onebox-1.8.3 lib/onebox/matcher.rb
onebox-1.8.2 lib/onebox/matcher.rb
onebox-1.8.1 lib/onebox/matcher.rb
onebox-1.8.0 lib/onebox/matcher.rb
onebox-1.7.9 lib/onebox/matcher.rb
onebox-1.7.8 lib/onebox/matcher.rb