class StyleStats::PathParser
Constants
- EXTENSIONS
Attributes
files[RW]
Public Class Methods
new(path)
click to toggle source
# File lib/style_stats/path_parser.rb, line 7 def initialize(path) self.files = parse(path) end
Private Instance Methods
fetch_files(path)
click to toggle source
# File lib/style_stats/path_parser.rb, line 23 def fetch_files(path) if File.directory?(path) Dir.entries(path).map { |file| path + file } else Dir.glob(path) end end
filter_extention(files)
click to toggle source
# File lib/style_stats/path_parser.rb, line 31 def filter_extention(files) files.select { |file| EXTENSIONS.include?(File.extname(file)) } end
parse(path)
click to toggle source
# File lib/style_stats/path_parser.rb, line 12 def parse(path) if path =~ URI::regexp [path] elsif File.file?(path) raise StyleStats::InvalidError.new if filter_extention([path]).empty? [path] else filter_extention(fetch_files(path)) end end