Class: SCSSLint::Engine
- Inherits:
-
Object
- Object
- SCSSLint::Engine
- Defined in:
- lib/scss_lint/engine.rb
Overview
Contains all information for a parsed SCSS file, including its name, contents, and parse tree.
Constant Summary collapse
- ENGINE_OPTIONS =
{ cache: false, syntax: :scss }.freeze
Instance Attribute Summary collapse
-
#any_control_commands ⇒ Object
readonly
Returns the value of attribute any_control_commands.
-
#contents ⇒ Object
readonly
Returns the value of attribute contents.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#tree ⇒ Object
readonly
Returns the value of attribute tree.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Engine
constructor
Creates a parsed representation of an SCSS document from the given string or file.
Constructor Details
#initialize(options = {}) ⇒ Engine
Creates a parsed representation of an SCSS document from the given string or file.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/scss_lint/engine.rb', line 24 def initialize( = {}) @preprocess_command = [:preprocess_command] @preprocess_files = [:preprocess_files] build() # Need to force encoding to avoid Windows-related bugs. # Need to encode with universal newline to avoid other Windows-related bugs. encoding = 'UTF-8' @lines = @contents.force_encoding(encoding) .encode(encoding, universal_newline: true) .lines @tree = @engine.to_tree find_any_control_commands rescue Encoding::UndefinedConversionError, Sass::SyntaxError, ArgumentError => error if error.is_a?(Encoding::UndefinedConversionError) || error..match(/invalid.*(byte sequence|character)/i) raise FileEncodingError, "Unable to parse SCSS file: #{error}", error.backtrace else raise end end |
Instance Attribute Details
#any_control_commands ⇒ Object (readonly)
Returns the value of attribute any_control_commands.
13 14 15 |
# File 'lib/scss_lint/engine.rb', line 13 def any_control_commands @any_control_commands end |
#contents ⇒ Object (readonly)
Returns the value of attribute contents.
13 14 15 |
# File 'lib/scss_lint/engine.rb', line 13 def contents @contents end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
13 14 15 |
# File 'lib/scss_lint/engine.rb', line 13 def filename @filename end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
13 14 15 |
# File 'lib/scss_lint/engine.rb', line 13 def lines @lines end |
#tree ⇒ Object (readonly)
Returns the value of attribute tree.
13 14 15 |
# File 'lib/scss_lint/engine.rb', line 13 def tree @tree end |