drudje 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/drudje.rb +28 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 09a241d58388c291a9137422a90a555bfb43556f
|
4
|
+
data.tar.gz: e21845df3a912f89dfdf3a57b0b9277ec618f9c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cfec2ac4b4a73f75dd5f41a90c9d65391c07adb1f769719f63c3774c270e787786fc5d6bd583f5e83d463da5741dde83265103b74aa6f523add5b1b9cd7e4ac
|
7
|
+
data.tar.gz: 3426059e0b3011ecb2e28fd1dd3ec744bb3361cc115b15f933212615e45c779c8dee359a1a4b8ab14a7e82948684b9a16d2b5eeff786813f698023fe91be0561
|
data/lib/drudje.rb
CHANGED
@@ -87,8 +87,35 @@ class Drudje
|
|
87
87
|
render template, args
|
88
88
|
end
|
89
89
|
|
90
|
+
def find_call_loc(str, cstart = 0, cend = str.length)
|
91
|
+
group_start = str.index('[[', cstart)
|
92
|
+
group_end = str.rindex(']]', cend)
|
93
|
+
return nil if !group_start || !group_end
|
94
|
+
|
95
|
+
# We want group_end to point to the last ], not the first
|
96
|
+
group_end = group_end + 1
|
97
|
+
|
98
|
+
call_start = group_start + 2
|
99
|
+
call_end = group_end - 2
|
100
|
+
length = call_end - call_start + 1
|
101
|
+
substr = str[call_start, length]
|
102
|
+
# Make sure the substring doesn't have more calls nested
|
103
|
+
if substr =~ /\[\[/
|
104
|
+
find_call_loc(str, call_start, group_end)
|
105
|
+
elsif substr =~ /\]\]/
|
106
|
+
find_call_loc(str, group_start, call_end)
|
107
|
+
else
|
108
|
+
[group_start, group_end]
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
90
112
|
def process_pass(str)
|
91
|
-
|
113
|
+
call_loc = find_call_loc(str)
|
114
|
+
return str if !call_loc
|
115
|
+
before = str[0, call_loc[0]]
|
116
|
+
during = str[call_loc[0]+2..call_loc[1]-2]
|
117
|
+
after = str[call_loc[1]+1,str.length]
|
118
|
+
before + expand(during) + after
|
92
119
|
end
|
93
120
|
|
94
121
|
def process(str)
|