lib/scss_lint/engine.rb in scss-lint-0.34.0 vs lib/scss_lint/engine.rb in scss-lint-0.35.0
- old
+ new
@@ -11,15 +11,17 @@
attr_reader :contents, :filename, :lines, :tree
# Creates a parsed representation of an SCSS document from the given string
# or file.
#
- # @param scss_or_filename [String]
- def initialize(scss_or_filename)
- if File.exist?(scss_or_filename)
- build_from_file(scss_or_filename)
- else
- build_from_string(scss_or_filename)
+ # @param options [Hash]
+ # @option options [String] :file The file to load
+ # @option options [String] :code The code to parse
+ def initialize(options = {})
+ if options[:file]
+ build_from_file(options[:file])
+ elsif options[:code]
+ build_from_string(options[:code])
end
# Need to force encoding to avoid Windows-related bugs.
# Need `to_a` for Ruby 1.9.3.
@lines = @contents.force_encoding('UTF-8').lines.to_a