Class: GitCompound::Repository::RemoteFile::GitArchiveStrategy

Inherits:
RemoteFileStrategy show all
Defined in:
lib/git_compound/repository/remote_file/git_archive_strategy.rb

Overview

Git archive strategy

Instance Method Summary collapse

Constructor Details

#initialize(source, ref, file) ⇒ GitArchiveStrategy

Returns a new instance of GitArchiveStrategy.



7
8
9
10
11
12
# File 'lib/git_compound/repository/remote_file/git_archive_strategy.rb', line 7

def initialize(source, ref, file)
  super
  opts = "--format=tar --remote=#{@source} #{@ref} -- #{@file} | tar -O -xf -"
  @command = GitCommand.new(:archive, opts)
  @command.execute!
end

Instance Method Details

#contentsObject



14
15
16
17
18
# File 'lib/git_compound/repository/remote_file/git_archive_strategy.rb', line 14

def contents
  raise FileUnreachableError unless reachable?
  raise FileNotFoundError unless exists?
  @command.output
end

#exists?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/git_compound/repository/remote_file/git_archive_strategy.rb', line 24

def exists?
  @command.valid?
end

#reachable?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/git_compound/repository/remote_file/git_archive_strategy.rb', line 20

def reachable?
  @command.valid? || @command.output.include?('did not match any files')
end