Sha256: c412f0183db14ded5ea298ae6c0aaaf3cbedc2fd2979669a82415172a4a3dc29

Contents?: true

Size: 612 Bytes

Versions: 1

Compression:

Stored size: 612 Bytes

Contents

require 'pathname'
require 'execjs'

module RailsPixrem
  class Processor
    def initialize(options = {})
      @options = { root_value: '16px' }.merge(options)
    end

    def process(css)
      processor.call('process', css, @options[:root_value])
    end

    private

    def processor
      @processor ||= ExecJS.compile(processor_js)
    end

    def processor_js
      [pixrem_js, process_proxy].join(';')
    end

    def pixrem_js
      @@pixrem_js ||= Pathname(__FILE__).join('../../../vendor/pixrem.js').read
    end

    def process_proxy
      "var process = require('pixrem');"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails-pixrem-0.0.1 lib/rails-pixrem/processor.rb