Sha256: da1fcb7733a33e3769b7dcd296de4564f637b220d687d1127783991e5c17fbe4

Contents?: true

Size: 591 Bytes

Versions: 6

Compression:

Stored size: 591 Bytes

Contents

module Visdiff
  class Image
    attr_reader :identifier, :fullpath
    attr_accessor :client

    def initialize identifier, fullpath
      @identifier = identifier
      @fullpath = fullpath
    end

    def basename
      File.basename(fullpath)
    end

    def signature
      @signature ||= IO.popen(["identify", "-format", "%#", '--', fullpath]) do |f|
        f.read
      end
    end

    def submit!
      @client.submit_image self
    end

    def attributes
      {image: upload_io}
    end

    def upload_io
      Faraday::UploadIO.new(fullpath, 'image/png')
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
visdiff-0.0.6 lib/visdiff/image.rb
visdiff-0.0.5 lib/visdiff/image.rb
visdiff-0.0.4 lib/visdiff/image.rb
visdiff-0.0.3 lib/visdiff/image.rb
visdiff-0.0.2 lib/visdiff/image.rb
visdiff-0.0.1 lib/visdiff/image.rb