Class: Codeowners::Checker::FileAsArray
- Inherits:
-
Object
- Object
- Codeowners::Checker::FileAsArray
- Defined in:
- lib/codeowners/checker/file_as_array.rb
Overview
Convert CODEOWNERS file content to an array.
Instance Method Summary collapse
- #content ⇒ Object
- #content=(content) ⇒ Object
-
#initialize(file) ⇒ FileAsArray
constructor
A new instance of FileAsArray.
Constructor Details
#initialize(file) ⇒ FileAsArray
Returns a new instance of FileAsArray.
7 8 9 10 |
# File 'lib/codeowners/checker/file_as_array.rb', line 7 def initialize(file) @file = file @target_dir, = File.split(@file) end |
Instance Method Details
#content ⇒ Object
12 13 14 15 16 |
# File 'lib/codeowners/checker/file_as_array.rb', line 12 def content @content ||= File.readlines(@file).map(&:chomp) rescue Errno::ENOENT @content = [] end |
#content=(content) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/codeowners/checker/file_as_array.rb', line 18 def content=(content) @content = content Dir.mkdir(@target_dir) unless Dir.exist?(@target_dir) File.open(@file, 'w+') do |f| f.puts content end end |