Class: Csscss::Reporter
- Inherits:
-
Object
- Object
- Csscss::Reporter
- Defined in:
- lib/csscss/reporter.rb
Instance Method Summary collapse
-
#initialize(redundancies) ⇒ Reporter
constructor
A new instance of Reporter.
- #report(options = {}) ⇒ Object
Constructor Details
#initialize(redundancies) ⇒ Reporter
Returns a new instance of Reporter.
3 4 5 |
# File 'lib/csscss/reporter.rb', line 3 def initialize(redundancies) @redundancies = redundancies end |
Instance Method Details
#report(options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/csscss/reporter.rb', line 7 def report( = {}) verbose = .fetch(:verbose, false) should_color = .fetch(:color, true) io = StringIO.new @redundancies.each do |selector_groups, declarations| selector_groups = selector_groups.map {|selectors| "{#{maybe_color(selectors, :red, should_color)}}" } last_selector = selector_groups.pop count = declarations.size io.puts %Q(#{selector_groups.join(", ")} AND #{last_selector} share #{maybe_color(count, :red, should_color)} rule#{"s" if count > 1}) if verbose declarations.each {|dec| io.puts(" - #{maybe_color(dec, :yellow, should_color)}") } end end io.rewind io.read end |