Sha256: cbf2062f917f215d9d0d05aadf21c706d89ded1a6f833f749665e239e5af683f

Contents?: true

Size: 629 Bytes

Versions: 4

Compression:

Stored size: 629 Bytes

Contents

# frozen_string_literal: true

require 'json'

module Leftovers
  module Precompilers
    class Precompiler
      def initialize(precompiler, matcher)
        @precompiler = precompiler
        @matcher = matcher
      end

      def precompile(content, file)
        return unless @matcher === file.relative_path

        begin
          @precompiler.precompile(content)
        rescue PrecompileError => e
          e.warn(path: file.relative_path)
          ''
        rescue ::StandardError => e
          ::Leftovers.warn "#{e.class}: #{file.relative_path} #{e.message}"
          ''
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
leftovers-0.12.2 lib/leftovers/precompilers/precompiler.rb
leftovers-0.12.1 lib/leftovers/precompilers/precompiler.rb
leftovers-0.12.0 lib/leftovers/precompilers/precompiler.rb
leftovers-0.11.2 lib/leftovers/precompilers/precompiler.rb