class Rgr::Globber
Attributes
ignored_prefixes[R]
paths[R]
Public Class Methods
new()
click to toggle source
# File lib/rgr/globber.rb, line 5 def initialize @paths = [] @ignored_prefixes = [] end
Public Instance Methods
add_path(path)
click to toggle source
# File lib/rgr/globber.rb, line 10 def add_path(path) paths << path end
each_file() { |file| ... }
click to toggle source
# File lib/rgr/globber.rb, line 18 def each_file return enum_for(:each_file) unless block_given? unfiltered_files.each do |file| next if ignored?(file) yield file end end
glob_path(path)
click to toggle source
# File lib/rgr/globber.rb, line 43 def glob_path(path) if File.file?(path) [path] else Dir["#{path}/**/*.rb"] end end
ignore_prefix(prefix)
click to toggle source
# File lib/rgr/globber.rb, line 14 def ignore_prefix(prefix) ignored_prefixes << prefix end
ignored?(file)
click to toggle source
# File lib/rgr/globber.rb, line 27 def ignored?(file) ignored_prefixes.any? { |prefix| file.start_with?(prefix) } end
unfiltered_files()
click to toggle source
# File lib/rgr/globber.rb, line 33 def unfiltered_files if paths.empty? Dir["**/*.rb"] else paths.flat_map { |path| glob_path(path) } end end