pony-express 0.6.7 → 0.6.8

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.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/ext/mimetic.cxx +16 -17
  3. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.7
1
+ 0.6.8
data/ext/mimetic.cxx CHANGED
@@ -16,12 +16,10 @@ extern "C" {
16
16
  #define RUBY_ENCODING(str) string(rb_enc_get(str)->name)
17
17
  #define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f)
18
18
  #define FORCE_ENCODING(str,enc) rb_enc_associate(str, rb_to_encoding(enc)); ENC_CODERANGE_CLEAR(str);
19
- #define TO_S(v) rb_funcall(v, rb_intern("to_s"), 0)
20
- #define CSTRING(v) RSTRING_PTR(TYPE(v) != T_STRING ? TO_S(v) : v)
19
+ #define TO_S(v) rb_funcall(v, rb_intern("to_s"), 0)
20
+ #define CSTRING(v) RSTRING_PTR(TYPE(v) != T_STRING ? TO_S(v) : v)
21
21
 
22
22
  static VALUE rb_mMimetic;
23
- static VALUE eRuntimeError;
24
- static VALUE eArgumentError;
25
23
  static VALUE rb_UTF8, rb_ASCII;
26
24
 
27
25
  using namespace std;
@@ -76,7 +74,7 @@ bool mimetic_attach_file(MimeEntity *m, char* filename) {
76
74
  return true;
77
75
  }
78
76
  else {
79
- rb_raise(eRuntimeError, "Mimetic: Unable to read attachment file %s", filename);
77
+ rb_raise(rb_eRuntimeError, "Mimetic: Unable to read attachment file %s", filename);
80
78
  }
81
79
  return false;
82
80
  }
@@ -126,7 +124,7 @@ void rb_load_mime_types(VALUE self, VALUE filename) {
126
124
  file.close();
127
125
  }
128
126
  else {
129
- rb_raise(eRuntimeError, "Mimetic: Unable to load mime.types");
127
+ rb_raise(rb_eRuntimeError, "Mimetic: Unable to load mime.types");
130
128
  }
131
129
  }
132
130
 
@@ -138,10 +136,10 @@ VALUE rb_mimetic_build(VALUE self, VALUE options) {
138
136
  VALUE from = rb_hash_aref(options, ID2SYM(rb_intern("from")));
139
137
  VALUE subject = rb_hash_aref(options, ID2SYM(rb_intern("subject")));
140
138
 
141
- if (text == Qnil) rb_raise(eArgumentError, "Mimetic.build called without :text");
142
- if (from == Qnil) rb_raise(eArgumentError, "Mimetic.build called without :from");
143
- if (to == Qnil) rb_raise(eArgumentError, "Mimetic.build called without :to");
144
- if (subject == Qnil) rb_raise(eArgumentError, "Mimetic.build called without :subject");
139
+ if (text == Qnil) rb_raise(rb_eArgError, "Mimetic.build called without :text");
140
+ if (from == Qnil) rb_raise(rb_eArgError, "Mimetic.build called without :from");
141
+ if (to == Qnil) rb_raise(rb_eArgError, "Mimetic.build called without :to");
142
+ if (subject == Qnil) rb_raise(rb_eArgError, "Mimetic.build called without :subject");
145
143
 
146
144
  // optional fields
147
145
  VALUE mid = rb_hash_aref(options, ID2SYM(rb_intern("message_id")));
@@ -154,16 +152,16 @@ VALUE rb_mimetic_build(VALUE self, VALUE options) {
154
152
  VALUE files = rb_hash_aref(options, ID2SYM(rb_intern("attachments")));
155
153
 
156
154
  if (mid != Qnil && TYPE(mid) != T_STRING)
157
- rb_raise(eArgumentError, "Mimetic.build expects :message_id to be a string");
155
+ rb_raise(rb_eArgError, "Mimetic.build expects :message_id to be a string");
158
156
 
159
157
  if (tcid != Qnil && TYPE(tcid) != T_STRING)
160
- rb_raise(eArgumentError, "Mimetic.build expects :text_content_id to be a string");
158
+ rb_raise(rb_eArgError, "Mimetic.build expects :text_content_id to be a string");
161
159
 
162
160
  if (hcid != Qnil && TYPE(hcid) != T_STRING)
163
- rb_raise(eArgumentError, "Mimetic.build expects :html_content_id to be a string");
161
+ rb_raise(rb_eArgError, "Mimetic.build expects :html_content_id to be a string");
164
162
 
165
163
  if (files != Qnil && TYPE(files) != T_ARRAY)
166
- rb_raise(eArgumentError, "Mimetic.build expects :attachments to be an array");
164
+ rb_raise(rb_eArgError, "Mimetic.build expects :attachments to be an array");
167
165
 
168
166
  VALUE errors = Qnil;
169
167
  MimeEntity *message = NULL;
@@ -232,17 +230,18 @@ VALUE rb_mimetic_build(VALUE self, VALUE options) {
232
230
  errors = rb_str_new2("Unknown Error");
233
231
  }
234
232
 
235
- rb_raise(eRuntimeError, "Mimetic boo boo : %s\n", CSTRING(errors));
233
+ rb_raise(rb_eRuntimeError, "Mimetic boo boo : %s\n", CSTRING(errors));
236
234
  }
237
235
 
238
236
  extern "C" {
239
237
  void Init_mimetic(void) {
240
- eRuntimeError = CONST_GET(rb_mKernel, "RuntimeError");
241
- eArgumentError = CONST_GET(rb_mKernel, "ArgumentError");
242
238
  rb_mMimetic = rb_define_module("Mimetic");
243
239
  rb_define_module_function(rb_mMimetic, "build", VALUEFUNC(rb_mimetic_build), 1);
244
240
  rb_define_module_function(rb_mMimetic, "load_mime_types", VALUEFUNC(rb_load_mime_types), 1);
245
241
  rb_UTF8 = rb_str_new2("UTF-8");
246
242
  rb_ASCII = rb_str_new2("US-ASCII");
243
+
244
+ rb_global_variable(&rb_UTF8);
245
+ rb_global_variable(&rb_ASCII);
247
246
  }
248
247
  }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pony-express
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 7
10
- version: 0.6.7
9
+ - 8
10
+ version: 0.6.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bharanee Rathna