class AdLint::Source
DESCRIPTION¶ ↑
Target source file.
Attributes
included_at[R]
Public Class Methods
Public Instance Methods
analysis_target?(traits)
click to toggle source
# File lib/adlint/source.rb, line 74 def analysis_target?(traits) Location.new(@fpath).in_analysis_target?(traits) end
open() { |io| ... }
click to toggle source
system_header?()
click to toggle source
# File lib/adlint/source.rb, line 70 def system_header? false end
to_s()
click to toggle source
user_header?()
click to toggle source
# File lib/adlint/source.rb, line 66 def user_header? false end
Private Instance Methods
notify_cr_at_eol_found(loc)
click to toggle source
# File lib/adlint/source.rb, line 122 def notify_cr_at_eol_found(loc) on_cr_at_eol_found.invoke(loc) end
notify_eof_mark_at_eof_found(loc)
click to toggle source
# File lib/adlint/source.rb, line 126 def notify_eof_mark_at_eof_found(loc) on_eof_mark_at_eof_found.invoke(loc) end
notify_eof_newline_not_found(loc)
click to toggle source
# File lib/adlint/source.rb, line 130 def notify_eof_newline_not_found(loc) on_eof_newline_not_found.invoke(loc) end
read_content(fpath)
click to toggle source
# File lib/adlint/source.rb, line 101 def read_content(fpath) cont = IO.read(fpath, mode: "rb", encoding: @fenc || "binary") if cont =~ /\r/ notify_cr_at_eol_found(Location.new(fpath)) cont = cont.gsub(/\r\n|\r/, "\n") end if cont =~ /\x1a/ notify_eof_mark_at_eof_found(Location.new(fpath)) cont = cont.gsub(/\x1a/, "") end unless cont.end_with?("\n") notify_eof_newline_not_found(Location.new(fpath)) cont << "\n" end cont end