class LockDiff::Github::RepositoryNameDetector

Constants

REGEXP

Public Class Methods

new(url) click to toggle source
# File lib/lock_diff/github/repository_name_detector.rb, line 6
def initialize(url)
  @url = url
end

Public Instance Methods

call() click to toggle source
# File lib/lock_diff/github/repository_name_detector.rb, line 10
def call
  return unless @url
  path = @url.match(REGEXP).to_a.last&.split('#')&.first
  return unless path
  repository_name = path.split("/").first(2).join("/")
  repository_name if repository_name.match?(/.+\/.+/)
end