class RestoreBundledWith::Repository

The git repository

Constants

GIT_OPTIONS
GIT_PATH
LOCK_FILE
NEW_LINE
REF

Public Class Methods

new(git_path = GIT_PATH, git_options = GIT_OPTIONS) click to toggle source

@param git_path [String] git repository path @param git_options [Hash] ruby-git options

@return [Repository] Repository instance

# File lib/restore_bundled_with/repository.rb, line 14
def initialize(git_path = GIT_PATH, git_options = GIT_OPTIONS)
  @git_path = git_path
  @git_options = git_options
end

Public Instance Methods

fetch_file(file = LOCK_FILE, ref = REF, new_line = NEW_LINE) click to toggle source

@param file [String] target file @param ref [String] git ref @param new_line [String] file’s ending new line

@return [String] target file contents

# 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() click to toggle source

@return [Git::Base] ruby-git object

# File lib/restore_bundled_with/repository.rb, line 20
def git
  @git ||= Git.open(@git_path, @git_options)
end