Module: StillActive::Repository
Constant Summary collapse
- REPO_REGEX =
%r{(https?://(?:www\.)?(github|gitlab)\.com/([\w.\-]+)/([\w.\-]+))}i
Instance Method Summary collapse
Instance Method Details
#url_with_owner_and_name(url:) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/still_active/repository.rb', line 15 def url_with_owner_and_name(url:) match = url&.match(REPO_REGEX) return { source: :unhandled, owner: nil, name: nil } unless match url = match[1].delete_suffix(".git") name = match[4].delete_suffix(".git") { url: url, source: match[2].to_sym, owner: match[3], name: name } end |
#valid?(url:) ⇒ Boolean
9 10 11 12 13 |
# File 'lib/still_active/repository.rb', line 9 def valid?(url:) return false if url.nil? url.match?(REPO_REGEX) end |