Class: Spellr::FileList
- Inherits:
-
Object
- Object
- Spellr::FileList
- Includes:
- Enumerable
- Defined in:
- lib/spellr/file_list.rb
Instance Method Summary collapse
- #cli_only?(file) ⇒ Boolean
- #config_only?(file) ⇒ Boolean
- #each ⇒ Object
-
#initialize(*patterns) ⇒ FileList
constructor
A new instance of FileList.
- #to_a ⇒ Object
- #wordlist?(file) ⇒ Boolean
Constructor Details
#initialize(*patterns) ⇒ FileList
Returns a new instance of FileList.
11 12 13 |
# File 'lib/spellr/file_list.rb', line 11 def initialize(*patterns) @patterns = patterns end |
Instance Method Details
#cli_only?(file) ⇒ Boolean
23 24 25 |
# File 'lib/spellr/file_list.rb', line 23 def cli_only?(file) @patterns.empty? || @patterns.any? { |p| file.fnmatch?(p) } end |
#config_only?(file) ⇒ Boolean
19 20 21 |
# File 'lib/spellr/file_list.rb', line 19 def config_only?(file) Spellr.config.only.empty? || Spellr.config.only.any? { |o| file.fnmatch?(o) } end |
#each ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/spellr/file_list.rb', line 27 def each # TODO: handle no gitignore gitignore = ::File.join(Dir.pwd, '.gitignore') gitignore = nil unless ::File.exist?(gitignore) FastIgnore.new(rules: Spellr.config.ignored, gitignore: gitignore).each do |file| file = Spellr::File.new(file) next unless cli_only?(file) next if wordlist?(file) next unless config_only?(file) yield(file) end end |
#to_a ⇒ Object
41 42 43 |
# File 'lib/spellr/file_list.rb', line 41 def to_a enum_for(:each).to_a end |
#wordlist?(file) ⇒ Boolean
15 16 17 |
# File 'lib/spellr/file_list.rb', line 15 def wordlist?(file) Spellr.config.all_wordlist_paths.any? { |w| w == file } end |