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.69 lib/onebox/matcher.rb
onebox-1.8.68 lib/onebox/matcher.rb
onebox-1.8.67 lib/onebox/matcher.rb
onebox-1.8.66 lib/onebox/matcher.rb
onebox-1.8.65 lib/onebox/matcher.rb
onebox-1.8.64 lib/onebox/matcher.rb
onebox-1.8.63 lib/onebox/matcher.rb
onebox-1.8.62 lib/onebox/matcher.rb
onebox-1.8.61 lib/onebox/matcher.rb
onebox-1.8.60 lib/onebox/matcher.rb
onebox-1.8.59 lib/onebox/matcher.rb
onebox-1.8.58 lib/onebox/matcher.rb
onebox-1.8.57 lib/onebox/matcher.rb
onebox-1.8.55 lib/onebox/matcher.rb
onebox-1.8.54 lib/onebox/matcher.rb
onebox-1.8.53 lib/onebox/matcher.rb
onebox-1.8.52 lib/onebox/matcher.rb
onebox-1.8.51 lib/onebox/matcher.rb
onebox-1.8.50 lib/onebox/matcher.rb
onebox-1.8.49 lib/onebox/matcher.rb