require 'sass'

module SCSSLint
  class Engine
    ENGINE_OPTIONS = { cache: false, syntax: :scss }

    attr_reader :contents, :tree

    def initialize(scss_or_filename)
      if File.exists?(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

      @tree = @engine.to_tree
    end
  end
end

require 'sass'

module SCSSLint
  class Engine
    ENGINE_OPTIONS = { cache: false, syntax: :scss }

    attr_reader :contents, :lines, :tree

    def initialize(scss_or_filename)
      if File.exists?(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

Allow access to lines of CSS file in Engine
Allow access to lines of CSS file in Engine

To give linters the ability to inspect individual lines of a SCSS
document, a `lines` accessor was added. This allows greater visibility
into aspects of the document that are lost in the abstract syntax tree
(e.g. whitespace).

Change-Id: Ifffc39bcebf04628cbf99be0bc3efd7e212299cf
Reviewed-on: https://gerrit.causes.com/16562
Reviewed-by: Greg Hurrell <79e2475f81a6317276bf7cbb3958b20d289b78df@causes.com>
Tested-by: Shane da Silva <6f6e68d1df92f30cb4b3ce35260ddf94a402f33d@causes.com>
