Class: Pk::IgnoreFile
- Inherits:
-
Object
- Object
- Pk::IgnoreFile
- Defined in:
- lib/pk/ignore_file.rb
Constant Summary collapse
- PKIGNORE_NAMES =
%w(pkignore .pkignore).freeze
Instance Method Summary collapse
- #ignore_file?(filename) ⇒ Boolean
-
#initialize(path) ⇒ IgnoreFile
constructor
A new instance of IgnoreFile.
Constructor Details
#initialize(path) ⇒ IgnoreFile
Returns a new instance of IgnoreFile.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/pk/ignore_file.rb', line 5 def initialize(path) @ignore_list = PKIGNORE_NAMES.dup PKIGNORE_NAMES.each do |filename| file = File.(File.join(path, filename)) if File.exist? file @ignore_list = @ignore_list + File.open(file, 'r').read.split("\n") break end end end |
Instance Method Details
#ignore_file?(filename) ⇒ Boolean
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/pk/ignore_file.rb', line 16 def ignore_file?(filename) ignore = false @ignore_list.each do |ignore_pattern| if File.fnmatch(ignore_pattern, filename, File::FNM_PATHNAME) ignore = true break end end ignore end |