require 'sass'

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

    attr_reader :contents

    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
    end

    def tree
      @engine.to_tree
    end
  end
end

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

Build parse tree on Engine initialization
Build parse tree on Engine initialization

`Sass::Engine.to_tree` apparently generates a new parse tree each time.
In order to save some processing time, initialize the parse tree only
once.

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