Module: PngCheck
- Extended by:
- FFI::Library
- Defined in:
- lib/pngcheck.rb,
lib/pngcheck/recipe.rb,
lib/pngcheck/version.rb
Defined Under Namespace
Classes: CorruptPngError, EmptyPngError, Recipe
Constant Summary collapse
- EMPTY_IMAGE =
"Image is empty"- STATUS_OK =
0- STATUS_WARNING =
an error in some circumstances but not in all
1- STATUS_MINOR_ERROR =
minor spec errors (e.g., out-of-range values)
3- STATUS_MAJOR_ERROR =
file corruption, invalid chunk length/layout, etc.
4- STATUS_CRITICAL_ERROR =
unexpected EOF or other file(system) error
5- EXTRA_MESSAGE_SIZE =
1024- VERSION =
"0.2.8"- @@semaphore =
Mutex.new
Class Method Summary collapse
- .analyze_buffer(data) ⇒ Object
- .analyze_file(path) ⇒ Object
- .check_buffer(data) ⇒ Object
- .check_file(path) ⇒ Object
Class Method Details
.analyze_buffer(data) ⇒ Object
61 62 63 64 65 |
# File 'lib/pngcheck.rb', line 61 def analyze_buffer(data) return [STATUS_CRITICAL_ERROR, EMPTY_IMAGE] if data.empty? do_analyze_buffer(data) end |
.analyze_file(path) ⇒ Object
47 48 49 50 51 |
# File 'lib/pngcheck.rb', line 47 def analyze_file(path) return [STATUS_CRITICAL_ERROR, EMPTY_IMAGE] if File.zero? path do_analyze_file(path) end |
.check_buffer(data) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/pngcheck.rb', line 67 def check_buffer(data) status, info = analyze_buffer(data) raise EmptyPngError.new if info.eql? EMPTY_IMAGE raise CorruptPngError.new info unless status == STATUS_OK true end |
.check_file(path) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/pngcheck.rb', line 53 def check_file(path) status, info = analyze_file(path) raise EmptyPngError.new if info.eql? EMPTY_IMAGE raise CorruptPngError.new info unless status == STATUS_OK true end |