Module: StillActive::Repository

Extended by:
Repository
Included in:
Repository
Defined in:
lib/still_active/repository.rb

Constant Summary collapse

GITHUB_REGEX =
%r{(http(?:s)?://(?:www\.)?(github)\.com/((?:\w|_|-)+)/((?:\w|_|-)+))}i
GITLAB_REGEX =
%r{(http(?:s)?://(?:www\.)?(gitlab)\.com/((?:\w|_|-)+)/((?:\w|_|-)+))}i

Instance Method Summary collapse

Instance Method Details

#url_with_owner_and_name(url:) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/still_active/repository.rb', line 19

def url_with_owner_and_name(url:)
  [GITHUB_REGEX, GITLAB_REGEX].each do |regex|
    values = url&.scan(regex)&.first
    next if values.nil? || values.empty?

    return HASH_KEYS.zip(values).to_h
  end
  { source: :unhandled, owner: nil, name: nil }
end

#valid?(url:) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
# File 'lib/still_active/repository.rb', line 13

def valid?(url:)
  [GITHUB_REGEX, GITLAB_REGEX].any? do |regex|
    !url.scan(regex)&.first.nil?
  end
end