class Fragmenter::Validators::ImageValidator

Attributes

errors[R]
request[R]

Public Class Methods

new(request) click to toggle source
# File lib/fragmenter/validators/image_validator.rb, line 6
def initialize(request)
  @request = request
  @errors  = []
end

Public Instance Methods

part?() click to toggle source
# File lib/fragmenter/validators/image_validator.rb, line 11
def part?
  false
end
valid?() click to toggle source
# File lib/fragmenter/validators/image_validator.rb, line 15
def valid?
  return true unless fragmenter.complete?

  identifiable = identifiable?

  unless identifiable
    errors << 'Rebuilt fragments are not a valid image'
  end

  identifiable
end

Private Instance Methods

fragmenter() click to toggle source
# File lib/fragmenter/validators/image_validator.rb, line 29
def fragmenter
  request.fragmenter
end
identifiable?() click to toggle source
# File lib/fragmenter/validators/image_validator.rb, line 33
def identifiable?
  IO.popen('identify -', 'w', err: '/dev/null', out: '/dev/null') do |io|
    io << fragmenter.rebuild
  end

  $?.success?
end