Class: GitCompound::Repository::RemoteFile
- Inherits:
-
Object
- Object
- GitCompound::Repository::RemoteFile
- Defined in:
- lib/git_compound.rb,
lib/git_compound/repository/remote_file.rb,
lib/git_compound/repository/remote_file/github_strategy.rb,
lib/git_compound/repository/remote_file/git_archive_strategy.rb,
lib/git_compound/repository/remote_file/remote_file_strategy.rb
Overview
Remote file loader based on strategies
Defined Under Namespace
Classes: GitArchiveStrategy, GithubStrategy, RemoteFileStrategy
Instance Method Summary collapse
- #contents ⇒ Object
-
#initialize(source, ref, file, strategies = nil) ⇒ RemoteFile
constructor
A new instance of RemoteFile.
- #strategies_available ⇒ Object
Constructor Details
#initialize(source, ref, file, strategies = nil) ⇒ RemoteFile
Returns a new instance of RemoteFile.
6 7 8 9 10 11 |
# 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 |
Instance Method Details
#contents ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# 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 ⇒ Object
24 25 26 27 28 29 30 31 |
# 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 |