Sha256: 1e741cab49c90e8eeab191283308f855e18f57661ce9d690d3a68b04c545f667

Contents?: true

Size: 1009 Bytes

Versions: 14

Compression:

Stored size: 1009 Bytes

Contents

# frozen_string_literal: true

module Proscenium
  class Middleware
    class Esbuild < Base
      class CompileError < Base::CompileError
        def initialize(args)
          detail = args[:detail]
          detail = ActiveSupport::HashWithIndifferentAccess.new(Oj.load(detail, mode: :strict))

          args[:detail] = if detail[:location]
                            "#{detail[:text]} in #{detail[:location][:file]}:" +
                              detail[:location][:line].to_s
                          else
                            detail[:text]
                          end

          super args
        end
      end

      def attempt
        render_response Proscenium::Builder.build(path_to_build, root: Rails.root.to_s,
                                                                 base_url: @request.base_url)
      rescue Proscenium::Builder::CompileError => e
        raise self.class::CompileError, { file: @request.fullpath, detail: e.message }, caller
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
proscenium-0.11.0.pre.7-x86_64-linux lib/proscenium/middleware/esbuild.rb
proscenium-0.11.0.pre.7-aarch64-linux lib/proscenium/middleware/esbuild.rb
proscenium-0.11.0.pre.7-arm64-darwin lib/proscenium/middleware/esbuild.rb
proscenium-0.11.0.pre.7-x86_64-darwin lib/proscenium/middleware/esbuild.rb
proscenium-0.11.0.pre.6-x86_64-linux lib/proscenium/middleware/esbuild.rb
proscenium-0.11.0.pre.6-aarch64-linux lib/proscenium/middleware/esbuild.rb
proscenium-0.11.0.pre.6-arm64-darwin lib/proscenium/middleware/esbuild.rb
proscenium-0.11.0.pre.6-x86_64-darwin lib/proscenium/middleware/esbuild.rb
proscenium-0.11.0.pre.5-x86_64-linux lib/proscenium/middleware/esbuild.rb
proscenium-0.11.0.pre.5-aarch64-linux lib/proscenium/middleware/esbuild.rb
proscenium-0.11.0.pre.5-arm64-darwin lib/proscenium/middleware/esbuild.rb
proscenium-0.11.0.pre.5-x86_64-darwin lib/proscenium/middleware/esbuild.rb
proscenium-0.11.0.pre.4-x86_64-linux lib/proscenium/middleware/esbuild.rb
proscenium-0.11.0.pre.4-arm64-darwin lib/proscenium/middleware/esbuild.rb