Class: Renderer
- Inherits:
-
Object
- Object
- Renderer
- Defined in:
- lib/gitstats/renderer.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(templatedir, outdir, verbose) ⇒ Renderer
constructor
A new instance of Renderer.
- #render(stats) ⇒ Object
Constructor Details
#initialize(templatedir, outdir, verbose) ⇒ Renderer
Returns a new instance of Renderer.
7 8 9 10 11 12 |
# File 'lib/gitstats/renderer.rb', line 7 def initialize(templatedir, outdir, verbose) @templatedir = templatedir @outdir = outdir @verbose = verbose @renderers = @@renderers.map { |x| x.new(templatedir, outdir, verbose) } end |
Class Method Details
.register(cls) ⇒ Object
2 3 4 5 |
# File 'lib/gitstats/renderer.rb', line 2 def self.register(cls) @@renderers ||= Array.new @@renderers << cls end |
Instance Method Details
#render(stats) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gitstats/renderer.rb', line 14 def render(stats) Dir.chdir(@templatedir) { Dir.glob('*').sort }.each do |file| next unless File.file?(File.join(@templatedir, file)) r = @renderers.find { |r| r.handle?(file) } if r.nil? puts "copying '#{file}' ..." if @verbose FileUtils.copy(File.join(@templatedir, file), @outdir) else puts "rendering '#{file}' using #{r.name} ..." if @verbose r.render(file, stats) end end end |