sass 3.2.0.alpha.8 → 3.2.0.alpha.9

Sign up to get free protection for your applications and to get access to all the features.
data/REVISION CHANGED
@@ -1 +1 @@
1
- c041cad208c85248ccfd728f9c0a5ffe9eb9d51a
1
+ 61b2162d9e606e3c5838e21de0104ba643d851ca
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.2.0.alpha.8
1
+ 3.2.0.alpha.9
@@ -65,6 +65,7 @@ module Sass
65
65
  end
66
66
  end
67
67
 
68
+ require 'sass/logger'
68
69
  require 'sass/util'
69
70
 
70
71
  require 'sass/engine'
@@ -0,0 +1,15 @@
1
+ module Sass::Logger
2
+
3
+ end
4
+
5
+ require "sass/logger/log_level"
6
+ require "sass/logger/base"
7
+
8
+ module Sass
9
+
10
+ class << self
11
+ attr_accessor :logger
12
+ end
13
+
14
+ self.logger = Sass::Logger::Base.new
15
+ end
@@ -0,0 +1,32 @@
1
+ require 'sass/logger/log_level'
2
+
3
+ class Sass::Logger::Base
4
+
5
+ include Sass::Logger::LogLevel
6
+
7
+ attr_accessor :log_level
8
+ attr_accessor :disabled
9
+
10
+ log_level :trace
11
+ log_level :debug
12
+ log_level :info
13
+ log_level :warn
14
+ log_level :error
15
+
16
+ def initialize(log_level = :debug)
17
+ self.log_level = log_level
18
+ end
19
+
20
+ def logging_level?(level)
21
+ !disabled && self.class.log_level?(level, log_level)
22
+ end
23
+
24
+ def log(level, message)
25
+ self._log(level, message) if logging_level?(level)
26
+ end
27
+
28
+ def _log(level, message)
29
+ Kernel::warn(message)
30
+ end
31
+
32
+ end
@@ -0,0 +1,50 @@
1
+ module Sass
2
+ module Logger
3
+ module LogLevel
4
+
5
+ def self.included(base)
6
+ base.extend(ClassMethods)
7
+ end
8
+
9
+ module ClassMethods
10
+ def inherited(subclass)
11
+ subclass.log_levels = subclass.superclass.log_levels.dup
12
+ end
13
+
14
+ def log_levels
15
+ @log_levels ||= {}
16
+ end
17
+
18
+ def log_levels=(levels)
19
+ @log_levels = levels
20
+ end
21
+
22
+ def log_level?(level, min_level)
23
+ log_levels[level] >= log_levels[min_level]
24
+ end
25
+
26
+ def log_level(name, options = {})
27
+ if options[:prepend]
28
+ level = log_levels.values.min
29
+ level = level.nil? ? 0 : level - 1
30
+ else
31
+ level = log_levels.values.max
32
+ level = level.nil? ? 0 : level + 1
33
+ end
34
+ # (require 'ruby-debug'; debugger)
35
+ log_levels.update(name => level)
36
+ define_logger(name)
37
+ end
38
+
39
+ def define_logger(name, options = {})
40
+ class_eval %Q{
41
+ def #{name}(message)
42
+ #{options.fetch(:to, :log)}(#{name.inspect}, message)
43
+ end
44
+ }
45
+ end
46
+ end
47
+
48
+ end
49
+ end
50
+ end
@@ -293,19 +293,17 @@ module Sass
293
293
  #
294
294
  # @yield A block in which no Sass warnings will be printed
295
295
  def silence_sass_warnings
296
- old_silence_warnings = @@silence_warnings
297
- @@silence_warnings = true
296
+ old_level, Sass.logger.log_level = Sass.logger.log_level, :error
298
297
  yield
299
298
  ensure
300
- @@silence_warnings = old_silence_warnings
299
+ Sass.logger.log_level = old_level
301
300
  end
302
301
 
303
302
  # The same as `Kernel#warn`, but is silenced by \{#silence\_sass\_warnings}.
304
303
  #
305
304
  # @param msg [String]
306
305
  def sass_warn(msg)
307
- return if @@silence_warnings
308
- warn(msg)
306
+ Sass.logger.warn(msg)
309
307
  end
310
308
 
311
309
  ## Cross Rails Version Compatibility
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../test_helper'
3
+ require 'pathname'
4
+
5
+ class LoggerTest < Test::Unit::TestCase
6
+
7
+ class InterceptedLogger < Sass::Logger::Base
8
+
9
+ attr_accessor :messages
10
+
11
+ def initialize(*args)
12
+ super
13
+ self.messages = []
14
+ end
15
+
16
+ def reset!
17
+ self.messages = []
18
+ end
19
+
20
+ def _log(*args)
21
+ messages << [args]
22
+ end
23
+
24
+ end
25
+
26
+ def test_global_sass_logger_instance_exists
27
+ assert Sass.logger.respond_to?(:warn)
28
+ end
29
+
30
+ def test_log_level_orders
31
+ logged_levels = {
32
+ :trace => [ [], [:trace, :debug, :info, :warn, :error]],
33
+ :debug => [ [:trace], [:debug, :info, :warn, :error]],
34
+ :info => [ [:trace, :debug], [:info, :warn, :error]],
35
+ :warn => [ [:trace, :debug, :info], [:warn, :error]],
36
+ :error => [ [:trace, :debug, :info, :warn], [:error]]
37
+ }
38
+ logged_levels.each do |level, (should_not_be_logged, should_be_logged)|
39
+ logger = Sass::Logger::Base.new(level)
40
+ should_not_be_logged.each do |should_level|
41
+ assert !logger.logging_level?(should_level)
42
+ end
43
+ should_be_logged.each do |should_level|
44
+ assert logger.logging_level?(should_level)
45
+ end
46
+ end
47
+ end
48
+
49
+ def test_logging_can_be_disabled
50
+ logger = InterceptedLogger.new
51
+ # (require 'ruby-debug'; debugger)
52
+ logger.error("message #1")
53
+ assert_equal 1, logger.messages.size
54
+ logger.reset!
55
+ logger.disabled = true
56
+ logger.error("message #2")
57
+ assert_equal 0, logger.messages.size
58
+ end
59
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sass
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0.alpha.8
4
+ version: 3.2.0.alpha.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Weizenbaum
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-06-11 00:00:00 -04:00
14
+ date: 2011-06-19 00:00:00 -04:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -137,6 +137,9 @@ files:
137
137
  - lib/sass/util.rb
138
138
  - lib/sass/util/subset_map.rb
139
139
  - lib/sass/version.rb
140
+ - lib/sass/logger.rb
141
+ - lib/sass/logger/base.rb
142
+ - lib/sass/logger/log_level.rb
140
143
  - vendor/fssm/LICENSE
141
144
  - vendor/fssm/README.markdown
142
145
  - vendor/fssm/Rakefile
@@ -177,6 +180,8 @@ files:
177
180
  - test/sass/data/hsl-rgb.txt
178
181
  - test/sass/engine_test.rb
179
182
  - test/sass/extend_test.rb
183
+ - test/sass/fixtures/test_staleness_check_across_importers.css
184
+ - test/sass/fixtures/test_staleness_check_across_importers.scss
180
185
  - test/sass/functions_test.rb
181
186
  - test/sass/importer_test.rb
182
187
  - test/sass/less_conversion_test.rb
@@ -264,8 +269,7 @@ files:
264
269
  - test/sass/test_helper.rb
265
270
  - test/sass/util/subset_map_test.rb
266
271
  - test/sass/util_test.rb
267
- - test/sass/fixtures/test_staleness_check_across_importers.css
268
- - test/sass/fixtures/test_staleness_check_across_importers.scss
272
+ - test/sass/logger_test.rb
269
273
  - test/test_helper.rb
270
274
  - extra/update_watch.rb
271
275
  - Rakefile
@@ -323,3 +327,4 @@ test_files:
323
327
  - test/sass/scss/scss_test.rb
324
328
  - test/sass/util/subset_map_test.rb
325
329
  - test/sass/util_test.rb
330
+ - test/sass/logger_test.rb