erbal 1.0.rc1 → 1.0.rc2

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.
data/ext/erbal/erbal.c CHANGED
@@ -15,13 +15,22 @@ VALUE rb_erbal_alloc(VALUE klass) {
15
15
  return obj;
16
16
  }
17
17
 
18
- VALUE rb_erbal_initialize(VALUE self, VALUE str, VALUE buffer_name) {
18
+ VALUE rb_erbal_initialize(VALUE self, VALUE str, VALUE buffer_name, VALUE options) {
19
19
  Check_Type(str, T_STRING);
20
20
  Check_Type(buffer_name, T_STRING);
21
+
21
22
  erbal_parser *parser = NULL;
22
23
  Data_Get_Struct(self, erbal_parser, parser);
23
24
  parser->buffer_name = buffer_name;
24
25
  parser->str = str;
26
+
27
+ if (options == Qtrue) {
28
+ parser->options = rb_hash_new();
29
+ } else {
30
+ Check_Type(options, T_HASH);
31
+ parser->options = options;
32
+ }
33
+
25
34
  return self;
26
35
  }
27
36
 
@@ -36,6 +45,6 @@ VALUE rb_erbal_parse(VALUE self) {
36
45
  void Init_erbal() {
37
46
  cErbal = rb_define_class("Erbal", rb_cObject);
38
47
  rb_define_alloc_func(cErbal, rb_erbal_alloc);
39
- rb_define_method(cErbal, "initialize", rb_erbal_initialize, 2);
48
+ rb_define_method(cErbal, "initialize", rb_erbal_initialize, 3);
40
49
  rb_define_method(cErbal, "parse", rb_erbal_parse, 0);
41
50
  }
data/ext/erbal/parser.c CHANGED
@@ -152,16 +152,26 @@ inline void erbal_parser_finish(erbal_parser *parser) {
152
152
  }
153
153
 
154
154
  rb_str_concat(parser->src, parser->buffer_name);
155
+
156
+ if (parser->debug) {
157
+ printf("ERBAL DEBUG: %s\n", RSTRING(rb_inspect(parser->src))->ptr);
158
+ }
155
159
  }
156
160
 
157
161
  void erbal_parser_init(erbal_parser *parser) {
158
162
  parser->chars_seen = 0;
159
163
  parser->in_buffer_shift = 0;
160
164
  parser->state = OUTSIDE_TAG;
165
+ parser->debug = 0;
166
+
167
+ if (rb_hash_aref(parser->options, ID2SYM(rb_intern("debug"))) == Qtrue) {
168
+ parser->debug = 1;
169
+ }
170
+
161
171
  parser->src = rb_str_dup(parser->buffer_name);
162
172
  rb_str_buf_cat(parser->src, " = '';", 6);
163
173
 
164
- #line 165 "parser.c"
174
+ #line 175 "parser.c"
165
175
  {
166
176
  cs = erbal_parser_start;
167
177
  ts = 0;
@@ -169,14 +179,14 @@ void erbal_parser_init(erbal_parser *parser) {
169
179
  act = 0;
170
180
  }
171
181
 
172
- #line 162 "parser.rl"
182
+ #line 172 "parser.rl"
173
183
  }
174
184
 
175
185
  void erbal_parser_exec(erbal_parser *parser) {
176
186
  p = RSTRING(parser->str)->ptr;
177
187
  pe = p + strlen(p);
178
188
 
179
- #line 180 "parser.c"
189
+ #line 190 "parser.c"
180
190
  {
181
191
  if ( p == pe )
182
192
  goto _test_eof;
@@ -222,7 +232,7 @@ st1:
222
232
  case 1:
223
233
  #line 1 "NONE"
224
234
  {ts = p;}
225
- #line 226 "parser.c"
235
+ #line 236 "parser.c"
226
236
  switch( (*p) ) {
227
237
  case 37: goto st2;
228
238
  case 45: goto tr4;
@@ -244,7 +254,7 @@ st3:
244
254
  if ( ++p == pe )
245
255
  goto _test_eof3;
246
256
  case 3:
247
- #line 248 "parser.c"
257
+ #line 258 "parser.c"
248
258
  if ( (*p) == 37 )
249
259
  goto st0;
250
260
  goto tr6;
@@ -293,6 +303,6 @@ case 5:
293
303
 
294
304
  }
295
305
 
296
- #line 168 "parser.rl"
306
+ #line 178 "parser.rl"
297
307
  erbal_parser_finish(parser);
298
308
  }
data/ext/erbal/parser.h CHANGED
@@ -4,8 +4,8 @@
4
4
  #include "ruby.h"
5
5
 
6
6
  typedef struct erbal_parser {
7
- unsigned int state, chars_seen, in_buffer_shift;
8
- VALUE str, src, buffer_name;
7
+ unsigned int state, chars_seen, in_buffer_shift, debug;
8
+ VALUE str, src, buffer_name, options;
9
9
  } erbal_parser;
10
10
 
11
11
  inline void erbal_parser_tag_open(erbal_parser*);
data/ext/erbal/parser.rl CHANGED
@@ -150,12 +150,22 @@ inline void erbal_parser_finish(erbal_parser *parser) {
150
150
  }
151
151
 
152
152
  rb_str_concat(parser->src, parser->buffer_name);
153
+
154
+ if (parser->debug) {
155
+ printf("ERBAL DEBUG: %s\n", RSTRING(rb_inspect(parser->src))->ptr);
156
+ }
153
157
  }
154
158
 
155
159
  void erbal_parser_init(erbal_parser *parser) {
156
160
  parser->chars_seen = 0;
157
161
  parser->in_buffer_shift = 0;
158
162
  parser->state = OUTSIDE_TAG;
163
+ parser->debug = 0;
164
+
165
+ if (rb_hash_aref(parser->options, ID2SYM(rb_intern("debug"))) == Qtrue) {
166
+ parser->debug = 1;
167
+ }
168
+
159
169
  parser->src = rb_str_dup(parser->buffer_name);
160
170
  rb_str_buf_cat(parser->src, " = '';", 6);
161
171
  %% write init;
data/spec/erbal_spec.rb CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Erbal do
4
4
  def erbal_parse(str)
5
- Erbal.new(str, '@out').parse
5
+ Erbal.new(str, '@out', {:debug => false}).parse
6
6
  end
7
7
 
8
8
  def erubis_parse(str)
data/tasks/gem.rake CHANGED
@@ -2,7 +2,7 @@ require 'rake/gempackagetask'
2
2
  require 'yaml'
3
3
 
4
4
  WIN_SUFFIX = ENV['WIN_SUFFIX'] || 'i386-mswin32'
5
- ERBAL_VERSION = '1.0.rc1'
5
+ ERBAL_VERSION = '1.0.rc2'
6
6
 
7
7
  task :clean => :clobber_package
8
8
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erbal
3
3
  version: !ruby/object:Gem::Version
4
- hash: 977940502
4
+ hash: 977940503
5
5
  prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - rc1
10
- version: 1.0.rc1
9
+ - rc2
10
+ version: 1.0.rc2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ian Leitch