Sha256: 381356da575c23c4be1349c42c1e969bc949f3bdaf7139be3d9283e9759e7150
Contents?: true
Size: 879 Bytes
Versions: 4
Compression:
Stored size: 879 Bytes
Contents
require 'rubygems' require 'active_record' require 'uri' module Murlsh class Url < ActiveRecord::Base def title read_attribute(:title) || read_attribute(:url) || 'title missing' end def same_author?(other) other and other.email and other.name and email and name and email == other.email and name == other.name end Widely_known = %w{ wikipedia.org flickr.com github.com twitter.com vimeo.com youtube.com } def hostrec begin domain = URI(url).host[/[a-z\d-]+\.[a-z]{2,}(\.[a-z]{2})?$/].downcase rescue Exception => e domain = nil end yield domain unless !domain or title.downcase.index(domain) or Widely_known.include?(domain) end def is_image? %w{image/gif image/jpeg image/png}.include?(content_type) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
murlsh-0.2.4 | lib/murlsh/url.rb |
murlsh-0.2.3 | lib/murlsh/url.rb |
murlsh-0.2.2 | lib/murlsh/url.rb |
murlsh-0.2.1 | lib/murlsh/url.rb |