Module: StillActive::Repository
Constant Summary collapse
- SOURCE_BY_HOST =
codeberg.org is the one Forgejo/Gitea host wired up today; it speaks the same Gitea API as any self-hosted instance, so its source is :forgejo (the forge software, what ForgejoClient handles), not :codeberg (the host).
{ "github.com" => :github, "gitlab.com" => :gitlab, "codeberg.org" => :forgejo, }.freeze
- REPO_REGEX =
%r{(?<url>https?://(?:www\.)?(?<host>github\.com|gitlab\.com|codeberg\.org)/(?<owner>[\w.\-]+)/(?<name>[\w.\-]+))}i
Instance Method Summary collapse
Instance Method Details
#url_with_owner_and_name(url:) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/still_active/repository.rb', line 23 def url_with_owner_and_name(url:) match = url&.match(REPO_REGEX) return { source: :unhandled, owner: nil, name: nil } unless match clean_url = match[:url].delete_suffix(".git") name = match[:name].delete_suffix(".git") { url: clean_url, source: SOURCE_BY_HOST.fetch(match[:host].downcase), owner: match[:owner], name: name } end |
#valid?(url:) ⇒ Boolean
17 18 19 20 21 |
# File 'lib/still_active/repository.rb', line 17 def valid?(url:) return false if url.nil? url.match?(REPO_REGEX) end |