Class: SassRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/gitstats/renderer/sass.rb

Instance Method Summary collapse

Constructor Details

#initialize(templatedir, outdir, verbose) ⇒ SassRenderer

Returns a new instance of SassRenderer.



2
3
4
5
6
# File 'lib/gitstats/renderer/sass.rb', line 2

def initialize(templatedir, outdir, verbose)
  @templatedir = templatedir
  @outdir = outdir
  @verbose = verbose
end

Instance Method Details

#handle?(file) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/gitstats/renderer/sass.rb', line 12

def handle?(file)
  (file =~ /\.sass$/) || (file =~ /\.scss$/)
end

#nameObject



8
9
10
# File 'lib/gitstats/renderer/sass.rb', line 8

def name
  'sass/compass'
end

#render(file, stats) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/gitstats/renderer/sass.rb', line 16

def render(file, stats)
  scss = file =~ /\.scss$/

  ifile = File.join(@templatedir, file)
  ofile = File.join(@outdir, File.basename(file, scss ? '.scss' : '.sass') + '.css')

  lines = IO::readlines(ifile).join('')

  options = Compass.sass_engine_options
  options[:syntax] = scss ? :scss : :sass
  engine = Sass::Engine.new(lines, options)
  lines = engine.render

  File.new(ofile, 'w').write(lines)
end