Class: Sass::Deprecation
- Inherits:
-
Object
- Object
- Sass::Deprecation
- Defined in:
- .ruby-sass/lib/sass/deprecation.rb
Overview
A deprecation warning that should only be printed once for a given line in a given file.
A global Deprecation instance should be created for each type of deprecation warning, and `warn` should be called each time a warning is needed.
Constant Summary
- @@allow_double_warnings =
false
Class Method Summary (collapse)
-
.allow_double_warnings ⇒ Object
Runs a block in which double deprecation warnings for the same location are allowed.
Instance Method Summary (collapse)
-
#initialize ⇒ Deprecation
constructor
A new instance of Deprecation.
-
#warn(filename, line, column_or_message, message = nil) ⇒ Object
Prints `message` as a deprecation warning associated with `filename`, `line`, and optionally `column`.
Constructor Details
#initialize ⇒ Deprecation
Returns a new instance of Deprecation
20 21 22 23 |
# File '.ruby-sass/lib/sass/deprecation.rb', line 20 def initialize # A set of filename, line pairs for which warnings have been emitted. @seen = Set.new end |
Constructor Details
#initialize ⇒ Deprecation
Returns a new instance of Deprecation
20 21 22 23 |
# File '.ruby-sass/lib/sass/deprecation.rb', line 20 def initialize # A set of filename, line pairs for which warnings have been emitted. @seen = Set.new end |
Class Method Details
.allow_double_warnings ⇒ Object
Runs a block in which double deprecation warnings for the same location are allowed.
12 13 14 15 16 17 18 |
# File '.ruby-sass/lib/sass/deprecation.rb', line 12 def self.allow_double_warnings old_allow_double_warnings = @@allow_double_warnings @@allow_double_warnings = true yield ensure @@allow_double_warnings = old_allow_double_warnings end |
Instance Method Details
#warn(filename, line, message) ⇒ Object #warn(filename, line, column, message) ⇒ Object
Prints `message` as a deprecation warning associated with `filename`, `line`, and optionally `column`.
This ensures that only one message will be printed for each line of a given file.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File '.ruby-sass/lib/sass/deprecation.rb', line 40 def warn(filename, line, , = nil) return if !@@allow_double_warnings && @seen.add?([filename, line]).nil? if column = else = end location = "line #{line}" location << ", column #{column}" if column location << " of #{filename}" if filename Sass::Util.sass_warn("DEPRECATION WARNING on #{location}:\n#{}") end |