class Codeowners::Checker::FileAsArray
Convert CODEOWNERS file content to an array.
Attributes
content[W]
filename[R]
Public Class Methods
new(filename)
click to toggle source
# File lib/codeowners/checker/file_as_array.rb, line 10 def initialize(filename) @filename = filename @target_dir, = File.split(@filename) end
Public Instance Methods
content()
click to toggle source
@return <Array> of lines chomped
# File lib/codeowners/checker/file_as_array.rb, line 16 def content @content ||= File.readlines(@filename).map(&:chomp) rescue Errno::ENOENT @content = [] end
persist!()
click to toggle source
Save content to the @file Creates the directory of the file if needed
# File lib/codeowners/checker/file_as_array.rb, line 24 def persist! Dir.mkdir(@target_dir) unless Dir.exist?(@target_dir) File.open(@filename, 'w+') do |f| f.puts content end end