Class: RestoreBundledWith::Repository
- Inherits:
-
Object
- Object
- RestoreBundledWith::Repository
- Defined in:
- lib/restore_bundled_with/repository.rb
Overview
The git repository
Constant Summary collapse
- LOCK_FILE =
'Gemfile.lock'.freeze
- REF =
'HEAD'.freeze
- GIT_PATH =
'.'.freeze
- GIT_OPTIONS =
{}.freeze
- NEW_LINE =
"\n".freeze
Instance Method Summary collapse
-
#fetch_file(file = LOCK_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.
14 15 16 17 |
# File 'lib/restore_bundled_with/repository.rb', line 14 def initialize(git_path = GIT_PATH, = GIT_OPTIONS) @git_path = git_path @git_options = end |
Instance Method Details
#fetch_file(file = LOCK_FILE, ref = REF, new_line = NEW_LINE) ⇒ String
Returns target file contents.
29 30 31 32 33 |
# File 'lib/restore_bundled_with/repository.rb', line 29 def fetch_file(file = LOCK_FILE, ref = REF, new_line = NEW_LINE) # NOTE: git.cat_file trims last \n? text = git.cat_file("#{ref}:#{file}") text + new_line end |
#git ⇒ Git::Base
Returns ruby-git object.
20 21 22 |
# File 'lib/restore_bundled_with/repository.rb', line 20 def git @git ||= Git.open(@git_path, @git_options) end |