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>[^/]+/[^/]+)
  (/(pull|merge_requests|pull-requests)/)
  (?<id>\d+)
}x

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ FindRepoInfoFromURL

Returns a new instance of FindRepoInfoFromURL.



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

def initialize(url)
  @url = url
end

Instance Method Details

#callObject



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

def call
  matched = url.match(REGEXP)

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