Class: MyPrecious::GitInfoExtractor
- Inherits:
-
Object
- Object
- MyPrecious::GitInfoExtractor
- Defined in:
- lib/myprecious.rb
Overview
Tool for getting information about the Git repository associated with a directory
Constant Summary collapse
- URL_PATTERN =
/\/([^\/]+)\.git$/
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
Instance Method Summary collapse
- #git_info ⇒ Object
-
#initialize(dir) ⇒ GitInfoExtractor
constructor
A new instance of GitInfoExtractor.
- #origin_remote ⇒ Object
- #repo_name ⇒ Object
Constructor Details
#initialize(dir) ⇒ GitInfoExtractor
Returns a new instance of GitInfoExtractor.
190 191 192 193 |
# File 'lib/myprecious.rb', line 190 def initialize(dir) super() @dir = dir end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
194 195 196 |
# File 'lib/myprecious.rb', line 194 def dir @dir end |
Instance Method Details
#git_info ⇒ Object
196 197 198 |
# File 'lib/myprecious.rb', line 196 def git_info @git_info ||= Git.open(self.dir) end |
#origin_remote ⇒ Object
200 201 202 |
# File 'lib/myprecious.rb', line 200 def origin_remote git_info.remotes.find {|r| r.name == 'origin'} end |
#repo_name ⇒ Object
204 205 206 |
# File 'lib/myprecious.rb', line 204 def repo_name @repo_name ||= (URL_PATTERN =~ origin_remote.url) && $1 end |