Sha256: 174f16a50cb4a0104304dc6847a1bd61c6f28eb8ecac4bc7777b2d2a8d6e535f

Contents?: true

Size: 575 Bytes

Versions: 2

Compression:

Stored size: 575 Bytes

Contents

require 'style_stats/templates/table'

class StyleStats
  class Template
    include CommandLineReporter

    def initialize(css, options = {})
      @css = css
      @options = {format: :default}
      @options.merge!(options)
    end

    def render
      case @options[:format].to_s.to_sym
      when :md, :html
        text = File.read("#{File.dirname(__FILE__)}/templates/#{@options[:format]}.erb")
        ERB.new(text, nil, '-').run(binding)
      when :json
        puts @css.analyze.to_json
      else
        Table.new(@css.analyze).run
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
style_stats-0.2.0 lib/style_stats/template.rb
style_stats-0.1.0 lib/style_stats/template.rb