Sha256: e6a020a51e9058140a6a174ff5b49d8dee5cbe12d8a7d31fb7fce4b2f78aba7a
Contents?: true
Size: 738 Bytes
Versions: 7
Compression:
Stored size: 738 Bytes
Contents
class StyleStats class PathParser EXTENSIONS = ['.less', '.styl', '.stylus', '.css'] attr_accessor :files def initialize(path) self.files = parse(path) end private 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 def fetch_files(path) if File.directory?(path) Dir.entries(path).map { |file| path + file } else Dir.glob(path) end end def filter_extention(files) files.select { |file| EXTENSIONS.include?(File.extname(file)) } end end end
Version data entries
7 entries across 7 versions & 1 rubygems