Sha256: 13e7ed9d576ecf9942b300b1132b7106be4ad17c71f43b4642e0970ee5a39d3b

Contents?: true

Size: 555 Bytes

Versions: 2

Compression:

Stored size: 555 Bytes

Contents

module RestoreBundledWith
  class Repository
    LOCK_FILE = 'Gemfile.lock'
    REF = 'HEAD'
    GIT_PATH = '.'
    GIT_OPTIONS = {}
    NEW_LINE = "\n"

    def initialize(git_path = GIT_PATH, git_options = GIT_OPTIONS)
      @git_path = git_path
      @git_options = git_options
    end

    def git
      @git ||= Git.open(@git_path, @git_options)
    end

    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
restore_bundled_with-0.3.0 lib/restore_bundled_with/repository.rb
restore_bundled_with-0.2.0 lib/restore_bundled_with/repository.rb