Class: RestoreFromRepository::Repository
- Inherits:
-
Object
- Object
- RestoreFromRepository::Repository
- Defined in:
- lib/restore_from_repository/repository.rb
Overview
The git repository
Constant Summary collapse
- REF =
'HEAD'.freeze
- GIT_PATH =
'.'.freeze
- GIT_OPTIONS =
{}.freeze
- NEW_LINE =
"\n".freeze
Instance Method Summary collapse
-
#fetch_file(file, ref = REF, new_line = NEW_LINE) ⇒ String
Target file contents.
-
#git ⇒ Git::Base
Ruby-git object.
-
#initialize(git_path = GIT_PATH, git_options = GIT_OPTIONS) ⇒ Repository
constructor
Repository instance.
Constructor Details
#initialize(git_path = GIT_PATH, git_options = GIT_OPTIONS) ⇒ Repository
Returns Repository instance.
13 14 15 16 |
# File 'lib/restore_from_repository/repository.rb', line 13 def initialize(git_path = GIT_PATH, = GIT_OPTIONS) @git_path = git_path @git_options = end |
Instance Method Details
#fetch_file(file, ref = REF, new_line = NEW_LINE) ⇒ String
Returns target file contents.
28 29 30 31 32 33 34 |
# File 'lib/restore_from_repository/repository.rb', line 28 def fetch_file(file, ref = REF, new_line = NEW_LINE) raise TypeError if file.nil? # NOTE: git.cat_file trims last \n? text = git.cat_file("#{ref}:#{file}") text + new_line end |
#git ⇒ Git::Base
Returns ruby-git object.
19 20 21 |
# File 'lib/restore_from_repository/repository.rb', line 19 def git @git ||= Git.open(@git_path, @git_options) end |