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.89 lib/onebox/matcher.rb
onebox-1.8.88 lib/onebox/matcher.rb
onebox-1.8.87 lib/onebox/matcher.rb
onebox-1.8.86 lib/onebox/matcher.rb
onebox-1.8.85 lib/onebox/matcher.rb
onebox-1.8.84 lib/onebox/matcher.rb
onebox-1.8.83 lib/onebox/matcher.rb
onebox-1.8.82 lib/onebox/matcher.rb
onebox-1.8.81 lib/onebox/matcher.rb
onebox-1.8.80 lib/onebox/matcher.rb
onebox-1.8.79 lib/onebox/matcher.rb
onebox-1.8.78 lib/onebox/matcher.rb
onebox-1.8.77 lib/onebox/matcher.rb
onebox-1.8.76 lib/onebox/matcher.rb
onebox-1.8.75 lib/onebox/matcher.rb
onebox-1.8.74 lib/onebox/matcher.rb
onebox-1.8.73 lib/onebox/matcher.rb
onebox-1.8.72 lib/onebox/matcher.rb
onebox-1.8.71 lib/onebox/matcher.rb
onebox-1.8.70 lib/onebox/matcher.rb