Class: GitRemote
- Inherits:
-
Object
- Object
- GitRemote
- Defined in:
- lib/pimpmychangelog/git_remote.rb
Constant Summary collapse
- REPOSITORY_PATTERN =
%r{ # Define recurring patterns (?<part> [\w\d-]+ ){0} (?<user>\g<part>)/(?<repo>\g<part>)(.git)?$ }x
Instance Attribute Summary collapse
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(url = nil) ⇒ GitRemote
constructor
A new instance of GitRemote.
Constructor Details
#initialize(url = nil) ⇒ GitRemote
Returns a new instance of GitRemote.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pimpmychangelog/git_remote.rb', line 10 def initialize(url = nil) @url = url || fetch_url match = @url.match(REPOSITORY_PATTERN) @user = match[:user] @project = match[:repo] unless @user && @project raise "Can't extract github user and project from origin remote" end end |
Instance Attribute Details
#project ⇒ Object (readonly)
Returns the value of attribute project.
23 24 25 |
# File 'lib/pimpmychangelog/git_remote.rb', line 23 def project @project end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
23 24 25 |
# File 'lib/pimpmychangelog/git_remote.rb', line 23 def user @user end |