Class: GitCompound::Repository::RemoteFile::GithubStrategy
- Inherits:
-
RemoteFileStrategy
- Object
- RemoteFileStrategy
- GitCompound::Repository::RemoteFile::GithubStrategy
- Defined in:
- lib/git_compound/repository/remote_file/github_strategy.rb
Overview
Git archive strategy
Constant Summary collapse
- GITHUB_URI =
'https://raw.githubusercontent.com'
- GITHUB_PATTERN =
'[email protected]:|https:\/\/github.com'
Instance Method Summary collapse
- #contents ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(source, ref, file) ⇒ GithubStrategy
constructor
A new instance of GithubStrategy.
- #reachable? ⇒ Boolean
Constructor Details
#initialize(source, ref, file) ⇒ GithubStrategy
Returns a new instance of GithubStrategy.
13 14 15 16 |
# File 'lib/git_compound/repository/remote_file/github_strategy.rb', line 13 def initialize(source, ref, file) super @uri = github_uri end |
Instance Method Details
#contents ⇒ Object
18 19 20 21 22 |
# File 'lib/git_compound/repository/remote_file/github_strategy.rb', line 18 def contents raise FileUnreachableError unless reachable? raise FileNotFoundError unless exists? @response.body end |
#exists? ⇒ Boolean
28 29 30 31 |
# File 'lib/git_compound/repository/remote_file/github_strategy.rb', line 28 def exists? @response ||= http_response(@uri) @response.code == 200.to_s end |
#reachable? ⇒ Boolean
24 25 26 |
# File 'lib/git_compound/repository/remote_file/github_strategy.rb', line 24 def reachable? @source.match(/#{GITHUB_PATTERN}/) ? true : false end |