Sha256: f71218010bed643d66f998f827892f822202fc71004c1d0a90f4e509af6235b3

Contents?: true

Size: 750 Bytes

Versions: 6

Compression:

Stored size: 750 Bytes

Contents

# frozen_string_literal: true

module ImageProcessing
  # Null processor for image_processing that keeps source files untouched
  # and copy them to the destination if provided.
  module Null
    extend Chainable

    def self.valid_image?(file) = true

    class Processor < ImageProcessing::Processor
      def self.call(source:, loader:, operations:, saver:, destination: nil)
        fail ArgumentError, "A string path is expected, got #{source.class}" unless source.is_a?(String)
        fail ArgumentError, "File not found: #{source}" unless File.file?(source)

        if destination
          File.delete(destination) if File.identical?(source, destination)
          FileUtils.cp(source, destination)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
wasmify-rails-0.2.0 lib/image_processing/null.rb
wasmify-rails-0.1.5 lib/image_processing/null.rb
wasmify-rails-0.1.4 lib/image_processing/null.rb
wasmify-rails-0.1.3 lib/image_processing/null.rb
wasmify-rails-0.1.2 lib/image_processing/null.rb
wasmify-rails-0.1.1 lib/image_processing/null.rb