Class: LockDiff::Github::RepositoryNameDetector
- Inherits:
-
Object
- Object
- LockDiff::Github::RepositoryNameDetector
- Defined in:
- lib/lock_diff/github/repository_name_detector.rb
Constant Summary collapse
- REGEXP =
%r!github\.com[/:](.*?)(?:\.git)?\z!
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(url) ⇒ RepositoryNameDetector
constructor
A new instance of RepositoryNameDetector.
Constructor Details
#initialize(url) ⇒ RepositoryNameDetector
Returns a new instance of RepositoryNameDetector.
6 7 8 |
# File 'lib/lock_diff/github/repository_name_detector.rb', line 6 def initialize(url) @url = url end |
Instance Method Details
#call ⇒ Object
10 11 12 13 14 15 16 |
# 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 |