ditto_code 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dittocode/parse.rb +52 -41
- 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: 5fed41ea34a21cd5ca04e6e1e49170f86c22d196
|
4
|
+
data.tar.gz: cee727cacd7234595c33cd6e716d392842ffa896
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7138f2589367b8d2c8526bbc4ef4db56226cb804a842610b5f5df878d358e121fd39098def71a255a21c5a7d74e309a23f44abca774ae65becf7f632dbb52175
|
7
|
+
data.tar.gz: a775da4d2ad86fe823d76b72e9d987ca30263cd1321ec047b8ec4bfa8a9218b91f72687e054a40c102fee5f1ecada3c5942a716d9aa3ec5c3beb4e9544ef449e
|
data/lib/dittocode/parse.rb
CHANGED
@@ -42,54 +42,59 @@ module DittoCode
|
|
42
42
|
# Each line........
|
43
43
|
file.each_line do | line |
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
else
|
48
|
-
m = /[\s]*DittoCode::Exec.if[\s]+['|"](?<environment>[a-zA-Z]+)['|"] do/.match(line)
|
49
|
-
end
|
45
|
+
# Ignore the line require ditto_code to delete it on final releases
|
46
|
+
if /[\s]*require[\s]*['|"](ditto_code)['|"]/.match(line).nil?
|
50
47
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
48
|
+
if @isView
|
49
|
+
m = /[\s]*<%[\s]*DittoCode::Exec.if[\s]+['|"](?<environment>[a-zA-Z]+)['|"][\s]+do[\s]*%>/.match(line)
|
50
|
+
else
|
51
|
+
m = /[\s]*DittoCode::Exec.if[\s]+['|"](?<environment>[a-zA-Z]+)['|"] do/.match(line)
|
52
|
+
end
|
56
53
|
|
57
|
-
if
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
54
|
+
if m
|
55
|
+
actions[:env] = m[:environment]
|
56
|
+
actions[:atack] = true;
|
57
|
+
actions[:ends] = 1;
|
58
|
+
else
|
59
|
+
|
60
|
+
if !actions[:atack]
|
61
|
+
if file.eof?
|
62
|
+
# Don't print a \n in the last line
|
63
|
+
out_file.print(line)
|
64
|
+
else
|
65
|
+
out_file.puts(line)
|
66
|
+
end
|
64
67
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
+
else
|
69
|
+
# He is transforming
|
70
|
+
dittos += 1
|
68
71
|
|
69
|
-
|
70
|
-
|
72
|
+
# Check if the line is end
|
73
|
+
if isEnd? line
|
71
74
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
75
|
+
# If is the last end, it's coincide with the end of the block
|
76
|
+
if actions[:ends] == 1
|
77
|
+
actions[:atack] = false
|
78
|
+
elsif actions[:env] == @env
|
79
|
+
# Only how if we must mantain it
|
80
|
+
check_with_indent(out_file, line)
|
81
|
+
end
|
79
82
|
|
80
|
-
|
83
|
+
actions[:ends] -= 1
|
81
84
|
|
82
|
-
|
85
|
+
else
|
83
86
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
+
# prints of coincide with the environment
|
88
|
+
if actions[:env] == @env
|
89
|
+
check_with_indent(out_file, line)
|
90
|
+
end
|
91
|
+
|
92
|
+
# Check if we need to add a new end
|
93
|
+
new_ends = moreEnds? line
|
94
|
+
actions[:ends] += new_ends
|
95
|
+
dittos += new_ends
|
87
96
|
end
|
88
97
|
|
89
|
-
# Check if we need to add a new end
|
90
|
-
new_ends = moreEnds? line
|
91
|
-
actions[:ends] += new_ends
|
92
|
-
dittos += new_ends
|
93
98
|
end
|
94
99
|
|
95
100
|
end
|
@@ -149,11 +154,17 @@ module DittoCode
|
|
149
154
|
|
150
155
|
# Get the initializers and the ends of the blocks
|
151
156
|
if @isView
|
152
|
-
initializers = line.scan(/<%[\s]*(case|unless|if|do|def)[\s]+/).size
|
157
|
+
initializers = line.scan(/<%[\s]*(case|unless|if|do|def)[\s]+/).size
|
158
|
+
initializers += line.scan(/<%[@=;\s\w\d]*(case|unless|if|do|def)[\s]+/).size
|
159
|
+
|
153
160
|
finals = line.scan(/[\s]+(end)[\s]*%>/).size
|
154
161
|
else
|
155
|
-
initializers = line.scan(/^
|
156
|
-
|
162
|
+
initializers = line.scan(/^[\s\t]*(case|unless|if|do|def)[\s]+/).size # If, def, unless... of a start line
|
163
|
+
initializers += line.scan(/[\s\t]+(case|do)[\s]+[|]+/).size # Case or do inside a line
|
164
|
+
initializers += line.scan(/[\s\t]+(do)[\s]*$/).size # Finals do
|
165
|
+
initializers += line.scan(/[\s\t]+(if|unless)[\s]+[@=\d\w\s]+(?:then){1}/).size # Only if|unless + then, this line disable error by: unless|if var
|
166
|
+
|
167
|
+
finals = line.scan(/[\s\t]*(end)[\s]*$/).size
|
157
168
|
end
|
158
169
|
|
159
170
|
# Return the difference
|