Sha256: c6aad8b2804d58163d5fc4f0c3dcb192f0607ac943a71a22dca6590d8845e1bb

Contents?: true

Size: 405 Bytes

Versions: 23

Compression:

Stored size: 405 Bytes

Contents

require "marcel"

module Lookbook
  class FileDataUriEncoder < Service
    attr_reader :path

    def initialize(path, mime_type = nil)
      @path = path
      @mime_type = mime_type
    end

    def content
      File.read(path)
    end

    def mime_type
      @mime_type || Marcel::MimeType.for(Pathname.new(path))
    end

    def call
      DataUriEncoder.call(content, mime_type)
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
lookbook-2.0.0.beta.7 lib/lookbook/services/urls/file_data_uri_encoder.rb
lookbook-2.0.0.beta.6 lib/lookbook/services/urls/file_data_uri_encoder.rb
lookbook-2.0.0.beta.5 lib/lookbook/services/urls/file_data_uri_encoder.rb