Sha256: c067ef895e87f0d9c842884560567c97c65b337691dd9ade4b4d8fb445282c1d

Contents?: true

Size: 648 Bytes

Versions: 2

Compression:

Stored size: 648 Bytes

Contents

# frozen_string_literal: true

require_relative "rtlcss/version"
require "mini_racer"

module Rtlcss
  class FlipError < StandardError; end

  def self.flip_css(orig_css)
    @context ||=
      begin
        context = MiniRacer::Context.new(timeout: 10_000)
        context.eval(
          File.read(File.expand_path("../dist/main.js", __dir__))
        )
        context.eval(<<~JS)
          function rtlcssWrapper(origCss) {
            return rtlcss.process(origCss);
          }
        JS
        context
      end
    @context.call("rtlcssWrapper", orig_css)
  rescue MiniRacer::RuntimeError => e
    raise FlipError.new(cause: e)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rtlcss-0.2.1 lib/rtlcss.rb
rtlcss-0.2.0 lib/rtlcss.rb