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.48 lib/onebox/matcher.rb
onebox-1.8.47 lib/onebox/matcher.rb
onebox-1.8.46 lib/onebox/matcher.rb
onebox-1.8.45 lib/onebox/matcher.rb
onebox-1.8.44 lib/onebox/matcher.rb
onebox-1.8.43 lib/onebox/matcher.rb
onebox-1.8.42 lib/onebox/matcher.rb
onebox-1.8.41 lib/onebox/matcher.rb
onebox-1.8.40 lib/onebox/matcher.rb
onebox-1.8.39 lib/onebox/matcher.rb
onebox-1.8.38 lib/onebox/matcher.rb
onebox-1.8.36 lib/onebox/matcher.rb
onebox-1.8.35 lib/onebox/matcher.rb
onebox-1.8.34 lib/onebox/matcher.rb
onebox-1.8.33 lib/onebox/matcher.rb
onebox-1.8.32 lib/onebox/matcher.rb
onebox-1.8.31 lib/onebox/matcher.rb
onebox-1.8.30 lib/onebox/matcher.rb
onebox-1.8.29 lib/onebox/matcher.rb
onebox-1.8.28 lib/onebox/matcher.rb