Class: Gurney::GitFileReader
- Inherits:
-
Object
- Object
- Gurney::GitFileReader
- Defined in:
- lib/gurney/git_file_reader.rb
Instance Method Summary collapse
-
#initialize(git, branch, read_from_git:) ⇒ GitFileReader
constructor
A new instance of GitFileReader.
- #read(filename) ⇒ Object
Constructor Details
#initialize(git, branch, read_from_git:) ⇒ GitFileReader
Returns a new instance of GitFileReader.
4 5 6 7 8 |
# File 'lib/gurney/git_file_reader.rb', line 4 def initialize(git, branch, read_from_git:) @git = git @branch = branch @read_from_git = read_from_git end |
Instance Method Details
#read(filename) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/gurney/git_file_reader.rb', line 10 def read(filename) if @read_from_git begin @git.show("#{@branch}:#{filename}") rescue Git::GitExecuteError # happens if branch does not exist end else File.read(filename) if File.exist?(filename) end end |