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.3.4 lib/lookbook/services/urls/file_data_uri_encoder.rb
lookbook-2.3.3 lib/lookbook/services/urls/file_data_uri_encoder.rb
lookbook-2.3.2 lib/lookbook/services/urls/file_data_uri_encoder.rb
lookbook-2.3.0 lib/lookbook/services/urls/file_data_uri_encoder.rb
lookbook-2.2.2 lib/lookbook/services/urls/file_data_uri_encoder.rb
lookbook-2.2.1 lib/lookbook/services/urls/file_data_uri_encoder.rb
lookbook-2.2.0 lib/lookbook/services/urls/file_data_uri_encoder.rb
lookbook-2.1.1 lib/lookbook/services/urls/file_data_uri_encoder.rb
lookbook-2.1.0 lib/lookbook/services/urls/file_data_uri_encoder.rb
lookbook-2.0.5 lib/lookbook/services/urls/file_data_uri_encoder.rb
lookbook-2.0.4 lib/lookbook/services/urls/file_data_uri_encoder.rb
lookbook-2.0.3 lib/lookbook/services/urls/file_data_uri_encoder.rb
lookbook-2.0.2 lib/lookbook/services/urls/file_data_uri_encoder.rb
lookbook-2.0.1 lib/lookbook/services/urls/file_data_uri_encoder.rb
lookbook-2.0.0 lib/lookbook/services/urls/file_data_uri_encoder.rb
lookbook-2.0.0.rc.3 lib/lookbook/services/urls/file_data_uri_encoder.rb
lookbook-2.0.0.rc.2 lib/lookbook/services/urls/file_data_uri_encoder.rb
lookbook-2.0.0.rc.1 lib/lookbook/services/urls/file_data_uri_encoder.rb
lookbook-2.0.0.beta.9 lib/lookbook/services/urls/file_data_uri_encoder.rb
lookbook-2.0.0.beta.8 lib/lookbook/services/urls/file_data_uri_encoder.rb