Class: HDOC::Repository
- Inherits:
-
Object
- Object
- HDOC::Repository
- Defined in:
- lib/1hdoc/core/repository.rb
Overview
Provides an interface for interact with Git repositories.
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
Class Method Summary collapse
Instance Method Summary collapse
- #commit(message) ⇒ Object
-
#initialize(repo_path, adapter = Git) ⇒ Repository
constructor
A new instance of Repository.
- #push ⇒ Object
Constructor Details
#initialize(repo_path, adapter = Git) ⇒ Repository
Returns a new instance of Repository.
13 14 15 16 17 18 |
# File 'lib/1hdoc/core/repository.rb', line 13 def initialize(repo_path, adapter = Git) @adapter = adapter @repo = @adapter.open(repo_path) rescue ArgumentError $stderr.puts 'The given repository is not a valid one.' end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
5 6 7 |
# File 'lib/1hdoc/core/repository.rb', line 5 def adapter @adapter end |
Class Method Details
.clone(url, destination, adapter = Git) ⇒ Object
7 8 9 10 11 |
# File 'lib/1hdoc/core/repository.rb', line 7 def self.clone(url, destination, adapter = Git) adapter.clone(url, destination) rescue adapter::GitExecuteError => error $stderr.puts error. end |
Instance Method Details
#commit(message) ⇒ Object
20 21 22 23 |
# File 'lib/1hdoc/core/repository.rb', line 20 def commit() @repo.add(all: true) @repo.commit() end |
#push ⇒ Object
25 26 27 28 29 |
# File 'lib/1hdoc/core/repository.rb', line 25 def push @repo.push rescue adapter::GitExecuteError => error $stderr.puts error. end |