Sha256: 8e8ee0ad517f2caf90e5ff8f05065ac167be8de7fcd33302e1f940c5d078858f

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

# -*- coding: utf-8 -*-

require 'turnip_formatter/template'
require 'sass'

module TurnipFormatter
  class Template
    class << self
      def project_name
        RSpec.configuration.respond_to?(:project_name) ? RSpec.configuration.project_name : 'Turnip'
      end

      def add_js(js_string)
        js_list << js_string
      end

      def add_js_file(file)
        js_list << File.read(file)
      end

      def add_scss(scss_string)
        css_list << Sass::Engine.new(scss_string, scss_option).render
      end

      def add_scss_file(path)
        css_list << Sass::Engine.for_file(path, scss_option).render
      end

      def js_render
        js_list.join("\n")
      end

      def css_render
        css_list.join("\n")
      end

      def js_list
        @js_list ||= []
      end

      def css_list
        @css_list ||= []
      end

      def scss_option
        { syntax: :scss, style: :compressed }
      end
    end
  end
end

(File.dirname(__FILE__) + '/template').tap do |dirname|
  TurnipFormatter::Template.add_scss_file(dirname + '/turnip_formatter.scss')
  TurnipFormatter::Template.add_js_file(dirname + '/turnip_formatter.js')
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
turnip_formatter-0.2.7 lib/turnip_formatter/template.rb