apple_png 0.0.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -220,11 +220,14 @@ static VALUE ApplePng_convert_apple_png(VALUE self, VALUE data) {
220
220
  switch (error) {
221
221
  case APPLE_PNG_STREAM_ERROR:
222
222
  case APPLE_PNG_DATA_ERROR:
223
- rb_raise(rb_eArgError, "Could not process the input data. Please make sure this is valid Apple PNG format data.");
223
+ {
224
+ VALUE eNotValidApplePng = rb_path2class("NotValidApplePngError");
225
+ rb_raise(eNotValidApplePng, "Could not process the input data. Please make sure this is valid Apple PNG format data.");
226
+ }
224
227
  case APPLE_PNG_ZLIB_VERSION_ERROR:
225
- rb_raise(rb_eArgError, "Unexpected Zlib version encountered. The caller was expecting Zlib " ZLIB_VERSION ".");
228
+ rb_raise(rb_eStandardError, "Unexpected Zlib version encountered. The caller was expecting Zlib " ZLIB_VERSION ".");
226
229
  case APPLE_PNG_NO_MEM_ERROR:
227
- rb_raise(rb_eArgError, "Ran out of memory while processing the PNG data.");
230
+ rb_raise(rb_eNoMemError, "Ran out of memory while processing the PNG data.");
228
231
  default:
229
232
  rb_raise(rb_eStandardError, "An unexpected error was encountered while processing the PNG data. Please make sure the input is valid Apple PNG format data.");
230
233
  }
@@ -242,13 +245,14 @@ Get the width and height from PNG data without actually converting it.
242
245
  @param data [String] Binary string containing Apple PNG data
243
246
  */
244
247
  static VALUE ApplePng_get_dimensions(VALUE self, VALUE data) {
248
+ VALUE eNotValidApplePng = rb_path2class("NotValidApplePngError");
245
249
  const char *oldPNG = StringValuePtr(data);
246
250
  size_t oldPNG_length = RSTRING_LEN(data);
247
251
  size_t cursor = 8;
248
252
 
249
253
  /* check whether this is actually a png file */
250
254
  if (strncmp(PNG_HEADER, oldPNG, 8) != 0) {
251
- rb_raise(rb_eArgError, "Input data is not a valid PNG file (missing the PNG magic bytes).");
255
+ rb_raise(eNotValidApplePng, "Input data is not a valid PNG file (missing the PNG magic bytes).");
252
256
  }
253
257
 
254
258
  while (cursor < oldPNG_length) {
@@ -266,7 +270,7 @@ static VALUE ApplePng_get_dimensions(VALUE self, VALUE data) {
266
270
  }
267
271
  }
268
272
 
269
- rb_raise(rb_eArgError, "Input data is not a valid PNG file (missing IHDR chunk).");
273
+ rb_raise(eNotValidApplePng, "Input data is not a valid PNG file (missing IHDR chunk).");
270
274
  }
271
275
 
272
276
  void Init_apple_png(void) {
data/lib/apple_png.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'apple_png/apple_png'
2
2
 
3
+ class NotValidApplePngError < StandardError; end
4
+
3
5
  class ApplePng
4
6
  attr_accessor :width, :height
5
7
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apple_png
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: