Class: RestoreBundledWith::Repository
- Inherits:
-
Object
- Object
- RestoreBundledWith::Repository
- Defined in:
- lib/restore_bundled_with/repository.rb
Constant Summary collapse
- LOCK_FILE =
'Gemfile.lock'- REF =
'HEAD'- GIT_PATH =
'.'- GIT_OPTIONS =
{}
- NEW_LINE =
"\n"
Instance Method Summary collapse
- #fetch_file(file = LOCK_FILE, ref = REF, new_line = NEW_LINE) ⇒ Object
- #git ⇒ Object
-
#initialize(git_path = GIT_PATH, git_options = GIT_OPTIONS) ⇒ Repository
constructor
A new instance of Repository.
Constructor Details
#initialize(git_path = GIT_PATH, git_options = GIT_OPTIONS) ⇒ Repository
Returns a new instance of Repository.
9 10 11 12 |
# File 'lib/restore_bundled_with/repository.rb', line 9 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) ⇒ Object
18 19 20 21 22 |
# File 'lib/restore_bundled_with/repository.rb', line 18 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 ⇒ Object
14 15 16 |
# File 'lib/restore_bundled_with/repository.rb', line 14 def git @git ||= Git.open(@git_path, @git_options) end |