Class: Seo::Scanner
- Inherits:
-
Object
- Object
- Seo::Scanner
- Defined in:
- lib/seo/scanner.rb
Instance Method Summary collapse
-
#initialize(config) ⇒ Scanner
constructor
A new instance of Scanner.
- #scan(root = Dir.pwd) ⇒ Object
Constructor Details
#initialize(config) ⇒ Scanner
Returns a new instance of Scanner.
7 8 9 10 |
# File 'lib/seo/scanner.rb', line 7 def initialize(config) @include_patterns = config["include"] || [] @exclude_patterns = config["exclude"] || [] end |
Instance Method Details
#scan(root = Dir.pwd) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/seo/scanner.rb', line 12 def scan(root = Dir.pwd) files = @include_patterns.flat_map do |pattern| Dir.glob(File.join(root, pattern)) end.uniq.sort files.reject do |file| @exclude_patterns.any? do |pattern| File.fnmatch?(File.join(root, pattern), file, File::FNM_PATHNAME) end end end |