Class: Danger::FindRepoInfoFromURL

Inherits:
Object
  • Object
show all
Defined in:
lib/danger/ci_source/support/find_repo_info_from_url.rb

Constant Summary collapse

REGEXP =
%r{
  ://[^/]+/
  (?<slug>[^/]+(/[^/]+){1,2})
  (/(pull|merge_requests|pull-requests)/)
  (?<id>\d+)
}x

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ FindRepoInfoFromURL

Returns a new instance of FindRepoInfoFromURL.



12
13
14
# File 'lib/danger/ci_source/support/find_repo_info_from_url.rb', line 12

def initialize(url)
  @url = url
end

Instance Method Details

#callObject



16
17
18
19
20
21
22
# File 'lib/danger/ci_source/support/find_repo_info_from_url.rb', line 16

def call
  matched = url.match(REGEXP)

  if matched
    RepoInfo.new(matched[:slug], matched[:id])
  end
end