Sha256: 34191fbfcb500d9a52bf158e01c7bfee67b8839cdbeb6d7f0533003a74a4a606

Contents?: true

Size: 716 Bytes

Versions: 4

Compression:

Stored size: 716 Bytes

Contents

require 'sass'

module SCSSLint
  # Contains all information for a parsed SCSS file, including its name,
  # contents, and parse tree.
  class Engine
    ENGINE_OPTIONS = { cache: false, syntax: :scss }

    attr_reader :contents, :filename, :lines, :tree

    def initialize(scss_or_filename)
      if File.exists?(scss_or_filename)
        @filename = scss_or_filename
        @engine = Sass::Engine.for_file(scss_or_filename, ENGINE_OPTIONS)
        @contents = File.open(scss_or_filename, 'r').read
      else
        @engine = Sass::Engine.new(scss_or_filename, ENGINE_OPTIONS)
        @contents = scss_or_filename
      end

      @lines = @contents.split("\n")
      @tree = @engine.to_tree
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
scss-lint-0.16.1 lib/scss_lint/engine.rb
scss-lint-0.16.0 lib/scss_lint/engine.rb
scss-lint-0.15.0 lib/scss_lint/engine.rb
scss-lint-0.14.0 lib/scss_lint/engine.rb