Class: Git::Duo::Repo
- Inherits:
-
Object
- Object
- Git::Duo::Repo
- Defined in:
- lib/git/duo/repo.rb
Instance Attribute Summary collapse
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#wrapper ⇒ Object
readonly
Returns the value of attribute wrapper.
Class Method Summary collapse
Instance Method Summary collapse
- #authors ⇒ Object
- #authors=(*new_authors) ⇒ Object
- #committer ⇒ Object
- #email ⇒ Object
- #email=(new_email) ⇒ Object
-
#initialize(directory, opts = {}) ⇒ Repo
constructor
A new instance of Repo.
- #save ⇒ Object
- #solo! ⇒ Object
Constructor Details
#initialize(directory, opts = {}) ⇒ Repo
Returns a new instance of Repo.
13 14 15 16 |
# File 'lib/git/duo/repo.rb', line 13 def initialize(directory, opts = {}) @directory = File.(directory) @wrapper = opts.fetch(:wrapper) { Git::Duo::Wrapper.new(git_directory) } end |
Instance Attribute Details
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
11 12 13 |
# File 'lib/git/duo/repo.rb', line 11 def directory @directory end |
#wrapper ⇒ Object (readonly)
Returns the value of attribute wrapper.
11 12 13 |
# File 'lib/git/duo/repo.rb', line 11 def wrapper @wrapper end |
Class Method Details
.current ⇒ Object
7 8 9 |
# File 'lib/git/duo/repo.rb', line 7 def self.current new Dir.pwd end |
Instance Method Details
#authors ⇒ Object
18 19 20 21 22 23 |
# File 'lib/git/duo/repo.rb', line 18 def return if defined? config. reject {|key| key }. map {|a| Git::Duo::Author.import(a) } end |
#authors=(*new_authors) ⇒ Object
25 26 27 |
# File 'lib/git/duo/repo.rb', line 25 def * = * end |
#committer ⇒ Object
29 30 31 32 33 34 |
# File 'lib/git/duo/repo.rb', line 29 def committer name = wrapper.config("user.name").shift email = wrapper.config("user.email").shift Author.new(name: name, email: email).to_s end |
#email ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/git/duo/repo.rb', line 36 def email return @email if defined? @email config. select {|key| key }. map {|key| key.gsub(/^email\s/, '') }. first end |
#email=(new_email) ⇒ Object
44 45 46 |
# File 'lib/git/duo/repo.rb', line 44 def email=(new_email) @email = new_email end |
#save ⇒ Object
52 53 54 55 |
# File 'lib/git/duo/repo.rb', line 52 def save save_email if email if end |
#solo! ⇒ Object
48 49 50 |
# File 'lib/git/duo/repo.rb', line 48 def solo! wrapper.config '--remove-section user' end |