lib/buff/ignore/ignore_file.rb in buff-ignore-1.0.4 vs lib/buff/ignore/ignore_file.rb in buff-ignore-1.1.0
- old
+ new
@@ -61,10 +61,24 @@
list.reject! do |item|
item.strip.empty? || ignored?(item)
end
end
+ # Determine if a given filename should be ignored
+ #
+ # @param [String] filename
+ # the file to match
+ #
+ # @return [Boolean]
+ # true if the file should be ignored, false otherwise
+ def ignored?(filename)
+ base = File.expand_path(options[:base] || File.dirname(filepath))
+ basename = filename.sub(base + File::SEPARATOR, '')
+
+ ignores.any? { |ignore| File.fnmatch?(ignore, basename) }
+ end
+
private
# The list of options
#
# @return [Hash]
attr_reader :options
@@ -74,23 +88,9 @@
# @return [Array]
def ignores
@ignores ||= File.readlines(filepath).map(&:strip).reject do |line|
line.empty? || line =~ COMMENT_OR_WHITESPACE
end
- end
-
- # Helper boolean to determine if a given filename should be ignored
- #
- # @param [String] filename
- # the file to match
- #
- # @return [Boolean]
- # true if the file should be ignored, false otherwise
- def ignored?(filename)
- base = File.expand_path(options[:base] || File.dirname(filepath))
- basename = filename.sub(base + File::SEPARATOR, '')
-
- ignores.any? { |ignore| File.fnmatch?(ignore, basename) }
end
end
end
end