module Domainatrix
Constants
- DOMAIN_PARSER
Keep Constant for backwards compat
- VERSION
Public Class Methods
custom_parse(url, dat = "
click to toggle source
# File lib/domainatrix.rb, line 22 def self.custom_parse(url, dat = "#{File.dirname(__FILE__)}/effective_tld_names.dat", sections = ["ICANN DOMAINS"]) Url.new(DomainParser.new(dat, sections).parse(url)) end
icann_parse(url, dat = "
click to toggle source
# File lib/domainatrix.rb, line 18 def self.icann_parse(url, dat = "#{File.dirname(__FILE__)}/effective_tld_names.dat", sections = ["ICANN DOMAINS"]) Url.new(DomainParser.new(dat, sections).parse(url)) end
parse(url)
click to toggle source
# File lib/domainatrix.rb, line 26 def self.parse(url) #Url.new(DomainParser.parse(url)) #<-- Still slow implementation at this point Url.new(DOMAIN_PARSER.parse(url)) end
scan(text, &block)
click to toggle source
# File lib/domainatrix.rb, line 31 def self.scan(text, &block) return [] unless text @schemes ||= %w(http https) all_trailing_clutter = /[.,:);]+$/ clutter_without_parens = /[.,:);]+$/ candidate_urls = ::URI.extract(text, @schemes) candidate_urls.map! do |url| # If the URL has an open paren, allow closing parens. if url.include?("(") url.gsub(clutter_without_parens, '') else url.gsub(all_trailing_clutter, '') end end urls = candidate_urls.map do |url| begin parse(url) rescue Addressable::URI::InvalidURIError end end.compact urls.map!(&block) if block urls end