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.
184 185 186 187 |
# File 'lib/myprecious.rb', line 184 def initialize(dir) super() @dir = dir end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
188 189 190 |
# File 'lib/myprecious.rb', line 188 def dir @dir end |
Instance Method Details
#git_info ⇒ Object
190 191 192 |
# File 'lib/myprecious.rb', line 190 def git_info @git_info ||= Git.open(self.dir) end |
#origin_remote ⇒ Object
194 195 196 |
# File 'lib/myprecious.rb', line 194 def origin_remote git_info.remotes.find {|r| r.name == 'origin'} end |
#repo_name ⇒ Object
198 199 200 |
# File 'lib/myprecious.rb', line 198 def repo_name @repo_name ||= (URL_PATTERN =~ origin_remote.url) && $1 end |