Top Level Namespace
Defined Under Namespace
Modules: EnLint Classes: AnEncoding
Constant Summary collapse
- DEFAULT_IGNORES =
%w( .hg/ .svn/ .git/ .git .gitignore node_modules/ .vagrant/ Gemfile.lock .exe .bin .pdf .png .jpg .jpeg .svg .min.js -min.js )
- DEFAULT_RULES =
Note that order is significant; Only the earliest file pattern match’s rule applies.
[ [/\.reg$/, /(ascii|utf-16)/], [/.*/, /(utf-8|ascii|binary|unknown)/] ]
- NO_SUCH_FILE =
Warning for files that do not exist
'no such file'
Class Method Summary collapse
- .check(filename, rules = DEFAULT_RULES) ⇒ Object
- .recursive_list(directory, ignores = DEFAULT_IGNORES) ⇒ Object
Class Method Details
.check(filename, rules = DEFAULT_RULES) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/enlint.rb', line 103 def self.check(filename, rules = DEFAULT_RULES) line = `file -i "#{filename}" 2>&1` encoding = AnEncoding.parse(filename, line) encoding_difference = encoding.violate?(rules) if encoding_difference then puts encoding.to_s(encoding_difference) end end |
.recursive_list(directory, ignores = DEFAULT_IGNORES) ⇒ Object
95 96 97 98 99 100 101 |
# File 'lib/enlint.rb', line 95 def self.recursive_list(directory, ignores = DEFAULT_IGNORES) Find.find(directory).reject do |f| File.directory?(f) || ignores.any? { |ignore| f =~ /#{ignore}/ } || File.binary?(f) end end |