Sha256: b61ce59cd0b1188fae1abda392cf22a059cb91dea51dc95889dd8b31e9ea91c4

Contents?: true

Size: 913 Bytes

Versions: 2

Compression:

Stored size: 913 Bytes

Contents

require 'json'
require 'set'

module HtmlScssClassChecker
  class ClassChecker
    attr_reader :unmatched_classes, :file_class_mapping

    def initialize(config)
      @known_classes = Set.new(config['known_classes'])
      @html_directories = config['html_directories']
      @scss_directories = config['scss_directories']
      @unmatched_classes = Set.new
      @file_class_mapping = {}
    end

    def check
      process_directories(@html_directories, 'html')
      process_directories(@scss_directories, 'scss')
    end

    private

    def process_directories(directories, file_type)
      directories.each do |directory|
        Dir.glob("#{directory}/**/*.#{file_type}").each do |file|
          classes = FileProcessor.new(file, file_type).list_classes
          @unmatched_classes.merge(classes - @known_classes)
          @file_class_mapping[file] = classes
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
html_scss_class_checker-0.2.1 lib/html_scss_class_checker/class_checker.rb
html_scss_class_checker-0.2.0 lib/html_scss_class_checker/class_checker.rb