Sha256: 90f4f4643128d69dd4932bedfbde2eb2f1c18617a322b9c6ad466e3f2f4702c8
Contents?: true
Size: 599 Bytes
Versions: 10
Compression:
Stored size: 599 Bytes
Contents
require 'social_parser/provider/base' module SocialParser module Provider class Github < Base URL_FORMATS = { full: /((https?)?:\/\/)?(www\.)?github\.com\/(?<id>[\w\-\.]+)?/i # regular: /\Ahttps?:\/\/github\.com\/(?<id>.+?)\/?\Z/ } def provider :github end def url "https://github.#{domain}/#{username}" end private def parse_from_url URL_FORMATS.values.each do |format| m = format.match(url_from_attributes) return m[:id] if m end nil end end end end
Version data entries
10 entries across 10 versions & 1 rubygems