lib/plugins/pre_commit/checks/nb_space.rb in pre-commit-0.12.0 vs lib/plugins/pre_commit/checks/nb_space.rb in pre-commit-0.13.0
- old
+ new
@@ -1,10 +1,13 @@
# encoding: utf-8
+require 'pre-commit/checks/plugin'
+
module PreCommit
module Checks
- class NbSpace
- def self.call(staged_files)
+ class NbSpace < Plugin
+
+ def call(staged_files)
nb_space = " "
raise "you messed that up" unless nb_space.bytes.to_a == [194, 160]
staged_files.reject! { |f| f =~ /^vendor\// || !File.read(f, encoding: 'utf-8').include?(nb_space) }
@@ -16,8 +19,13 @@
end
return if bad.empty?
"Detected non-breaking space in #{bad.map { |f,l,c| "#{f}:#{l+1} character:#{c+1}" }.join(" and")}, remove it!"
end
+
+ def self.description
+ "Detected non-breaking spaces 194, 160."
+ end
+
end
end
end