Sha256: 232e00b610573a57c8949ce1a11dbc2bedaa8e54fc048c8d364891d70b4e9794
Contents?: true
Size: 756 Bytes
Versions: 1
Compression:
Stored size: 756 Bytes
Contents
# Warning for using semicolons outside of class declarations. class Wool::ExtraBlankLinesWarning < Wool::FileWarning EXTRA_LINE = /\n[\t ]*\Z/ type :style severity 1 short_desc 'Extra blank lines' desc { "This file has #{count_extra_lines} blank lines at the end of it." } def match?(body = self.body) body =~ EXTRA_LINE end def fix body.gsub(/\s*\Z/, '') end # Counts how many extra lines there are at the end of the file. def count_extra_lines # We use this logic because #lines ignores blank lines at the end, and # split(/\n/) does as well. count = 0 working_body = self.body.dup while working_body =~ EXTRA_LINE working_body.sub!(EXTRA_LINE, '') count += 1 end count end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wool-0.5.1 | lib/wool/warnings/extra_blank_lines.rb |