class Ubi::Memoria::Site
A site, url and title?
Attributes
link[RW]
uri[RW]
Public Class Methods
key()
click to toggle source
# File lib/ubi/memorias/site.rb, line 52 def key :site end
new(text, _hint = nil, opts = {})
click to toggle source
# File lib/ubi/memorias/site.rb, line 7 def initialize(text, _hint = nil, opts = {}) text = text.downcase.gsub(/^\(|\.$/, '') text = "http://#{text}" unless text =~ %r{^\w{3,5}://} @text = text @link = tld_parser @opts = opts end
regex(_hint)
click to toggle source
Regex only for *.tld %r{https?://((?:w+?)+)(?:/|.)} (?:??)[a-zA-Z0-9-._?,'/\+&%$#=~]+
%r{(?:https?://)?(?:www.)?+.[a-zA-Z]{2,3}}
((?:https://)|(?:http://)|(?:www.))?(+. [a-zA-Z]{2,3}(?:??)[a-zA-Z0-9-._?,'/\+&%$#=~]+)
www.regexr.com/3bkne /([(https?)://(www.)?a-zA-Z0-9:@%._+~#=]{2,256}.[a-z]{2,6}b (?:[-a-zA-Z0-9@:%_+.~#?&//?=]*))/
without @
# File lib/ubi/memorias/site.rb, line 44 def regex(_hint) %r{ ([(https?)://(www\.)?a-zA-Z0-9:%\._\+~#=]{2,256} \.[a-z]{2,6}\b (?:[-a-zA-Z0-9@:%_\+.~#?&//?=]*)) }x end
Public Instance Methods
format()
click to toggle source
Prefix http:// if there isn't one defined
# File lib/ubi/memorias/site.rb, line 24 def format text end
tld_parser()
click to toggle source
# File lib/ubi/memorias/site.rb, line 15 def tld_parser @uri = URI.parse(text) @link = PublicSuffix.parse(uri.host) rescue PublicSuffix::DomainInvalid nil end