Class: Danger::FindRepoInfoFromURL
- Inherits:
-
Object
- Object
- Danger::FindRepoInfoFromURL
- 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
- REGEXPBB =
Regex used to extract info from Bitbucket server URLs, as they use a quite different format
%r{ (?:[\/:])projects \/([^\/.]+) \/repos\/([^\/.]+) \/pull-requests \/(\d+) }x
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(url) ⇒ FindRepoInfoFromURL
constructor
A new instance of FindRepoInfoFromURL.
Constructor Details
#initialize(url) ⇒ FindRepoInfoFromURL
Returns a new instance of FindRepoInfoFromURL.
30 31 32 |
# File 'lib/danger/ci_source/support/find_repo_info_from_url.rb', line 30 def initialize(url) @url = url end |
Instance Method Details
#call ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/danger/ci_source/support/find_repo_info_from_url.rb', line 34 def call matched = url.match(REGEXPBB) if matched RepoInfo.new("#{matched[1]}/#{matched[2]}", matched[3]) else matched = url.match(REGEXP) if matched RepoInfo.new(matched[:slug], matched[:id]) end end end |