class GitCompound::Repository::RemoteFile

Remote file strategy

Remote file loader based on strategies

Public Class Methods

new(source, ref, file, strategies = nil) click to toggle source
# File lib/git_compound/repository/remote_file.rb, line 6
def initialize(source, ref, file, strategies = nil)
  @source     = source
  @ref        = ref
  @file       = file
  @strategies = strategies
end

Public Instance Methods

contents() click to toggle source
# File lib/git_compound/repository/remote_file.rb, line 13
def contents
  @strategies ||= strategies_available
  @strategies.each do |remote_file_strategy|
    remote_file = remote_file_strategy.new(@source, @ref, @file)
    next unless remote_file.reachable?
    return remote_file.contents
  end
  raise FileUnreachableError,
        "Couldn't reach file #{@file} after trying #{@strategies.count} stategies"
end
strategies_available() click to toggle source
# File lib/git_compound/repository/remote_file.rb, line 24
def strategies_available
  # Strategies ordered by #reachable? method overhead
  # More general strategies should be placed at lower positions,
  # but this also depends on #reachable? overhead.
  #
  [GithubStrategy,
   GitArchiveStrategy]
end