6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/learn-tool/license-linter.rb', line 6
def self.parse_file(file, learn_error)
directory_file_array = sanitize_whitespace(File.open(file, "r:UTF-8").read)
valid_file_array = sanitize_whitespace(VALID_FILE.read)
diff = directory_file_array - valid_file_array
VALID_YEARS.each do |year|
diff.delete(year)
end
if diff.empty?
learn_error.license_error[:valid_license] = true
learn_error.valid_license = {message: "valid LICENSE.md", color: :green}
else
learn_error.license_error[:valid_license] = false
learn_error.valid_license = {message: "invalid LICENSE.md - Errors: #{diff}", color: :red}
end
end
|