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.
21 22 23 |
# File 'lib/danger/ci_source/support/find_repo_info_from_url.rb', line 21 def initialize(url) @url = url end |
Instance Method Details
#call ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/danger/ci_source/support/find_repo_info_from_url.rb', line 25 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 |