erbal 1.0.rc4 → 1.0.rc6
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/erbal/erbal.c +7 -3
- data/ext/erbal/parser.c +2 -2
- data/ext/erbal/parser.rl +2 -2
- data/spec/erbal_spec.rb +7 -2
- data/tasks/gem.rake +1 -1
- metadata +4 -4
data/ext/erbal/erbal.c
CHANGED
@@ -15,7 +15,11 @@ VALUE rb_erbal_alloc(VALUE klass) {
|
|
15
15
|
return obj;
|
16
16
|
}
|
17
17
|
|
18
|
-
VALUE rb_erbal_initialize(
|
18
|
+
VALUE rb_erbal_initialize(int argc, VALUE *argv, VALUE self) {
|
19
|
+
VALUE str, buffer_name, options;
|
20
|
+
|
21
|
+
rb_scan_args(argc, argv, "21", &str, &buffer_name, &options);
|
22
|
+
|
19
23
|
Check_Type(str, T_STRING);
|
20
24
|
Check_Type(buffer_name, T_STRING);
|
21
25
|
|
@@ -24,7 +28,7 @@ VALUE rb_erbal_initialize(VALUE self, VALUE str, VALUE buffer_name, VALUE option
|
|
24
28
|
parser->buffer_name = buffer_name;
|
25
29
|
parser->str = str;
|
26
30
|
|
27
|
-
if (options
|
31
|
+
if (NIL_P(options)) {
|
28
32
|
parser->options = rb_hash_new();
|
29
33
|
} else {
|
30
34
|
Check_Type(options, T_HASH);
|
@@ -45,6 +49,6 @@ VALUE rb_erbal_parse(VALUE self) {
|
|
45
49
|
void Init_erbal() {
|
46
50
|
cErbal = rb_define_class("Erbal", rb_cObject);
|
47
51
|
rb_define_alloc_func(cErbal, rb_erbal_alloc);
|
48
|
-
rb_define_method(cErbal, "initialize", rb_erbal_initialize,
|
52
|
+
rb_define_method(cErbal, "initialize", rb_erbal_initialize, -1);
|
49
53
|
rb_define_method(cErbal, "parse", rb_erbal_parse, 0);
|
50
54
|
}
|
data/ext/erbal/parser.c
CHANGED
@@ -122,7 +122,7 @@ inline VALUE erbal_escape_special_chars(erbal_parser *parser, int shift) {
|
|
122
122
|
|
123
123
|
inline void erbal_concat_chars_seen(erbal_parser *parser, int shift) {
|
124
124
|
if (parser->chars_seen != 0) {
|
125
|
-
if (parser->in_buffer_shift) {
|
125
|
+
if (parser->in_buffer_shift && parser->state == OUTSIDE_TAG) {
|
126
126
|
rb_str_concat(parser->src, erbal_escape_special_chars(parser, shift));
|
127
127
|
} else {
|
128
128
|
rb_str_buf_cat(parser->src, ((p + shift) - parser->chars_seen), parser->chars_seen);
|
@@ -157,7 +157,7 @@ inline void erbal_parser_finish(erbal_parser *parser) {
|
|
157
157
|
}
|
158
158
|
|
159
159
|
rb_str_concat(parser->src, parser->buffer_name);
|
160
|
-
|
160
|
+
|
161
161
|
if (parser->debug) {
|
162
162
|
printf("ERBAL DEBUG: %s\n", RSTRING(rb_inspect(parser->src))->ptr);
|
163
163
|
}
|
data/ext/erbal/parser.rl
CHANGED
@@ -121,7 +121,7 @@ inline VALUE erbal_escape_special_chars(erbal_parser *parser, int shift) {
|
|
121
121
|
|
122
122
|
inline void erbal_concat_chars_seen(erbal_parser *parser, int shift) {
|
123
123
|
if (parser->chars_seen != 0) {
|
124
|
-
if (parser->in_buffer_shift) {
|
124
|
+
if (parser->in_buffer_shift && parser->state == OUTSIDE_TAG) {
|
125
125
|
rb_str_concat(parser->src, erbal_escape_special_chars(parser, shift));
|
126
126
|
} else {
|
127
127
|
rb_str_buf_cat(parser->src, ((p + shift) - parser->chars_seen), parser->chars_seen);
|
@@ -156,7 +156,7 @@ inline void erbal_parser_finish(erbal_parser *parser) {
|
|
156
156
|
}
|
157
157
|
|
158
158
|
rb_str_concat(parser->src, parser->buffer_name);
|
159
|
-
|
159
|
+
|
160
160
|
if (parser->debug) {
|
161
161
|
printf("ERBAL DEBUG: %s\n", RSTRING(rb_inspect(parser->src))->ptr);
|
162
162
|
}
|
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'
|
5
|
+
Erbal.new(str, '@out').parse
|
6
6
|
end
|
7
7
|
|
8
8
|
def erubis_parse(str)
|
@@ -63,7 +63,7 @@ describe Erbal do
|
|
63
63
|
erbal_parse("1 + 1 is <%= 1 + 1 %>, and 2 + 2 is <%= 2 + 2 %>. Easy!").should == "@out = '';@out << %Q`1 + 1 is \#{ 1 + 1 }, and 2 + 2 is \#{ 2 + 2 }. Easy!`;@out"
|
64
64
|
end
|
65
65
|
|
66
|
-
it "should escape a hash character that signifies the start of a string interpolation" do
|
66
|
+
it "should escape a hash character that signifies the start of a string interpolation when outside tags" do
|
67
67
|
erbal_parse("<%= 1 + 1 -%> wee \#{1 + 3}").should == "@out = '';@out << %Q`\#{ 1 + 1 } wee \\\#{1 + 3}`;@out"
|
68
68
|
eval(erbal_parse("<%= 1 + 1 -%> wee \#{1 + 3}")).should == eval(erubis_parse("<%= 1 + 1 -%> wee \#{1 + 3}"))
|
69
69
|
|
@@ -77,6 +77,11 @@ describe Erbal do
|
|
77
77
|
eval(erbal_parse('<%= 1 + 1 -%> wee #{1 + 3}')).should == eval(erubis_parse('<%= 1 + 1 -%> wee #{1 + 3}'))
|
78
78
|
end
|
79
79
|
|
80
|
+
it "should not escape a hash character that signifies the start of a string interpolation when inside tags" do
|
81
|
+
erbal_parse('<%= "#{1 + 1}" -%>').should == "@out = '';@out << %Q`\#{ \"\#{1 + 1}\" }`;@out"
|
82
|
+
eval(erbal_parse('<%= "#{1 + 1}" -%>')).should == eval(erubis_parse('<%= "#{1 + 1}" -%>'))
|
83
|
+
end
|
84
|
+
|
80
85
|
it "should escape a backtick character that signifies the end off a buffer shift" do
|
81
86
|
erbal_parse("weeee `").should == "@out = '';@out << %Q`weeee \\``;@out"
|
82
87
|
eval(erbal_parse("weeee `")).should == eval(erubis_parse("weeee `"));
|
data/tasks/gem.rake
CHANGED
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:
|
4
|
+
hash: 977940499
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- rc6
|
10
|
+
version: 1.0.rc6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ian Leitch
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-12-
|
18
|
+
date: 2010-12-30 00:00:00 +11:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|