Method: Licit::Licenser#check_file_header

Defined in:
lib/licit/licenser.rb

#check_file_header(file) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/licit/licenser.rb', line 81

def check_file_header(file)
  at_beginning = true
  File.open(file, 'r') do |f|
    begin
      header.each_line do |header_line|
        begin
          file_line = f.readline
        end while at_beginning && should_skip?(file_line)
        at_beginning = false

        return false unless file_line.start_with? '#'
        file_line = file_line[1..-1].strip
        return false if file_line != header_line.chomp
      end
    rescue EOFError
      return false
    end
  end
  true
end