lazibi 0.1.13 → 0.1.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. data/.autotest +44 -2
  2. data/History.txt +10 -1
  3. data/Manifest.txt +114 -91
  4. data/README.txt +4 -125
  5. data/Rakefile +20 -10
  6. data/config/lazibi_config_template.rb +15 -0
  7. data/lib/core/beautify_engine.rb +10 -0
  8. data/lib/core/default_engine.rb +11 -0
  9. data/lib/core/engine_base.rb +74 -0
  10. data/lib/filter/beautify_filter.rb +148 -0
  11. data/lib/filter/filter_base.rb +19 -0
  12. data/lib/filter/optional_do_filter.rb +66 -0
  13. data/lib/filter/optional_end_filter.rb +124 -0
  14. data/lib/filter/syntax_guard_filter.rb +77 -0
  15. data/lib/helper/application_helper.rb +9 -0
  16. data/lib/helper/beautify_filter_helper.rb +52 -0
  17. data/lib/helper/filter_helper.rb +133 -0
  18. data/lib/helper/task_helper.rb +53 -45
  19. data/lib/lazibi.rb +1 -4
  20. data/lib/lazibi/version.rb +1 -1
  21. data/lib/task.rb +41 -32
  22. data/spec/core/beautify_engine_spec.rb +12 -0
  23. data/spec/core/default_engine_spec.rb +28 -0
  24. data/spec/core/engine_base_spec.rb +23 -0
  25. data/spec/filter/beautify_filter_spec.rb +64 -0
  26. data/spec/filter/filter_spec_helper.rb +9 -0
  27. data/spec/filter/optional_do_filter_spec.rb +56 -0
  28. data/spec/filter/optional_end_filter_spec.rb +84 -0
  29. data/spec/filter/syntax_guard_filter_spec.rb +35 -0
  30. data/spec/fixtures/beautify/metas/square_brackets.txt +6 -0
  31. data/{test/fixtures/functional/ruby → spec/fixtures/beautify/rbs}/square_brackets.txt +1 -1
  32. data/{test → spec}/fixtures/clean/comment_break.txt +0 -0
  33. data/{test → spec}/fixtures/clean/complex_string.txt +0 -0
  34. data/{test → spec}/fixtures/clean/end_concat.txt +0 -0
  35. data/{test → spec}/fixtures/clean/long_indent.txt +0 -0
  36. data/{test → spec}/fixtures/clean/mixed_re.txt +0 -0
  37. data/{test → spec}/fixtures/clean/only_if.txt +0 -0
  38. data/{test → spec}/fixtures/clean/re.txt +0 -0
  39. data/{test → spec}/fixtures/clean/semi_colon_after_end.txt +0 -0
  40. data/{test → spec}/fixtures/clean/sep_line.txt +0 -0
  41. data/{test → spec}/fixtures/clean/unless_problem.txt +0 -0
  42. data/{test → spec}/fixtures/meta/basic_class.txt +0 -0
  43. data/{test → spec}/fixtures/meta/case.txt +0 -0
  44. data/{test → spec}/fixtures/meta/class_with_def.txt +0 -0
  45. data/{test → spec}/fixtures/meta/comment.txt +0 -0
  46. data/{test → spec}/fixtures/meta/comment_after_end.txt +0 -0
  47. data/{test → spec}/fixtures/meta/eval_code.txt +0 -0
  48. data/{test → spec}/fixtures/meta/here_doc.txt +0 -0
  49. data/{test → spec}/fixtures/meta/inline_do_end.txt +0 -0
  50. data/{test → spec}/fixtures/meta/inline_end.txt +0 -0
  51. data/{test → spec}/fixtures/meta/loop.txt +0 -0
  52. data/{test → spec}/fixtures/meta/middle.txt +0 -0
  53. data/{test → spec}/fixtures/meta/multi_blocks.txt +0 -0
  54. data/{test → spec}/fixtures/meta/nested_comment.txt +0 -0
  55. data/{test → spec}/fixtures/meta/optional_do.txt +0 -0
  56. data/{test → spec}/fixtures/meta/optional_do_with_nasty_chars.txt +0 -0
  57. data/{test → spec}/fixtures/meta/partial_method.txt +0 -0
  58. data/{test → spec}/fixtures/meta/single_method.txt +0 -0
  59. data/{test → spec}/fixtures/meta/two_methods.txt +0 -0
  60. data/{test/fixtures/functional/simply → spec/fixtures/optional_do/metas}/brackets_block.txt +0 -0
  61. data/{test/fixtures/functional/simply → spec/fixtures/optional_do/metas}/classical.txt +0 -0
  62. data/{test/fixtures/functional/simply → spec/fixtures/optional_do/metas}/describe.txt +0 -0
  63. data/{test/fixtures/functional/simply → spec/fixtures/optional_do/metas}/do_block.txt +0 -0
  64. data/{test/fixtures/functional/simply → spec/fixtures/optional_do/metas}/lambda.txt +0 -0
  65. data/{test/fixtures/functional/simply → spec/fixtures/optional_do/metas}/square_brackets.txt +2 -2
  66. data/{test/fixtures/functional/ruby → spec/fixtures/optional_do/rbs}/brackets_block.txt +0 -0
  67. data/{test/fixtures/functional/ruby → spec/fixtures/optional_do/rbs}/classical.txt +0 -0
  68. data/{test/fixtures/functional/ruby → spec/fixtures/optional_do/rbs}/describe.txt +0 -0
  69. data/{test/fixtures/functional/ruby → spec/fixtures/optional_do/rbs}/do_block.txt +0 -0
  70. data/{test/fixtures/functional/ruby → spec/fixtures/optional_do/rbs}/lambda.txt +0 -0
  71. data/spec/fixtures/optional_do/rbs/square_brackets.txt +6 -0
  72. data/{test → spec}/fixtures/real/basic_class.txt +0 -0
  73. data/{test → spec}/fixtures/real/case.txt +0 -0
  74. data/{test → spec}/fixtures/real/class_with_def.txt +0 -0
  75. data/{test → spec}/fixtures/real/comment.txt +0 -0
  76. data/{test → spec}/fixtures/real/comment_after_end.txt +0 -0
  77. data/{test → spec}/fixtures/real/comment_after_end_expected.txt +0 -0
  78. data/{test → spec}/fixtures/real/comment_break.txt +0 -0
  79. data/{test → spec}/fixtures/real/complex_string.txt +0 -0
  80. data/{test → spec}/fixtures/real/end_concat.txt +0 -0
  81. data/{test → spec}/fixtures/real/eval_code.txt +0 -0
  82. data/{test → spec}/fixtures/real/general_eval.txt +0 -0
  83. data/{test → spec}/fixtures/real/here_doc.txt +0 -0
  84. data/{test → spec}/fixtures/real/inline_do_end.txt +0 -0
  85. data/{test → spec}/fixtures/real/inline_end.txt +0 -0
  86. data/{test → spec}/fixtures/real/javascript.txt +0 -0
  87. data/{test → spec}/fixtures/real/long_indent.txt +0 -0
  88. data/{test → spec}/fixtures/real/loop.txt +0 -0
  89. data/{test → spec}/fixtures/real/middle.txt +0 -0
  90. data/{test → spec}/fixtures/real/mixed_re.txt +0 -0
  91. data/{test → spec}/fixtures/real/multi_blocks.txt +0 -0
  92. data/{test → spec}/fixtures/real/nested_comment.txt +0 -0
  93. data/{test → spec}/fixtures/real/only_if.txt +0 -0
  94. data/{test → spec}/fixtures/real/optional_do.txt +0 -0
  95. data/{test → spec}/fixtures/real/optional_do_with_nasty_chars.txt +0 -0
  96. data/{test → spec}/fixtures/real/partial_method.txt +0 -0
  97. data/{test → spec}/fixtures/real/re.txt +0 -0
  98. data/{test → spec}/fixtures/real/semi_colon_after_end.txt +0 -0
  99. data/{test → spec}/fixtures/real/sep_line.txt +0 -0
  100. data/{test → spec}/fixtures/real/single_method.txt +0 -0
  101. data/{test → spec}/fixtures/real/strange_syntax_1.txt +0 -0
  102. data/{test → spec}/fixtures/real/two_methods.txt +0 -0
  103. data/{test → spec}/fixtures/real/unless_problem.txt +0 -0
  104. data/spec/helper/filter_helper_spec.rb +35 -0
  105. data/spec/helper/task_helper_spec.rb +21 -0
  106. data/spec/lazibi_spec.rb +22 -0
  107. data/spec/spec_helper.rb +16 -0
  108. data/webgen/src/code/examples/migration.py.rb +10 -0
  109. data/webgen/src/code/examples/rspec.py.rb +7 -0
  110. data/webgen/src/css/blossom_base.css +172 -0
  111. data/webgen/src/css/blossom_v05.css +48 -0
  112. data/webgen/src/css/code.css +32 -0
  113. data/webgen/src/css/hack.css +13 -0
  114. data/webgen/src/css/print.css +178 -0
  115. data/webgen/src/default.template +90 -0
  116. data/webgen/src/development.page +19 -0
  117. data/webgen/src/documentation.page +44 -0
  118. data/webgen/src/faq.page +42 -0
  119. data/webgen/src/images/cover_landscape.jpg +0 -0
  120. data/webgen/src/images/example_picture03.jpg +0 -0
  121. data/webgen/src/images/example_picture04.jpg +0 -0
  122. data/webgen/src/index.page +45 -0
  123. data/webgen/src/installation.page +17 -0
  124. metadata +214 -175
  125. data/coverage/index.html +0 -476
  126. data/coverage/lib-helper-parser_helper_rb.html +0 -718
  127. data/coverage/lib-helper-task_helper_rb.html +0 -684
  128. data/coverage/lib-lazibi-version_rb.html +0 -640
  129. data/coverage/lib-lazibi_rb.html +0 -664
  130. data/coverage/lib-parser_rb.html +0 -787
  131. data/coverage/lib-task_rb.html +0 -751
  132. data/lib/helper/app_helper.rb +0 -0
  133. data/lib/helper/parser_helper.rb +0 -92
  134. data/lib/parser.rb +0 -194
  135. data/lib/vendor/beautifier.rb +0 -278
  136. data/test/test_functional.rb +0 -75
  137. data/test/test_helper.rb +0 -7
  138. data/test/test_unit.rb +0 -151
  139. data/website/index.html +0 -234
  140. data/website/index.txt +0 -135
  141. data/website/javascripts/rounded_corners_lite.inc.js +0 -285
  142. data/website/stylesheets/screen.css +0 -140
  143. data/website/template.rhtml +0 -48
File without changes
@@ -1,92 +0,0 @@
1
- $:.unshift(File.dirname(__FILE__) + '/../vendor')
2
-
3
- require 'beautifier'
4
-
5
- module Lazibi
6
- module ParserHelper
7
- SKIP = "#skip_parse"
8
-
9
- def get_indent( line )
10
- line =~ /( *)/
11
- $1.size
12
- end
13
-
14
- def get_rest( line )
15
- line =~/( *)/
16
- $'
17
- end
18
-
19
- def begin_keys
20
- [
21
- /^module\b/,
22
- /(=\s*|^|<<\s*)if\b/,
23
- /(=\s*|^|<<\s*)until\b/,
24
- /(=\s*|^|<<\s*)for\b/,
25
- /(=\s*|^|<<\s*)unless\b/,
26
- /(=\s*|^|<<\s*)while\b/,
27
- /(=\s*|^|<<\s*)begin\b/,
28
- /(=\s*|^|<<\s*)loop\b\s*do/,
29
- /\bcase\b/,
30
- /^class\b/,
31
- /^def\b/,
32
- /\bdo\b/,
33
- ]
34
- end
35
-
36
- def middle_keys
37
- [
38
- /^then\b/,
39
- /^else\b/,
40
- /^elsif\b/,
41
- /^ensure\b/,
42
- /^rescue\b/,
43
- /^when\b/
44
- ]
45
- end
46
-
47
-
48
- def end_keys
49
- /^end\b/
50
- end
51
-
52
- def start_anchor?( str )
53
- return false if str =~ /^#/
54
- str = clean_line str
55
- group_match str, begin_keys
56
- end
57
-
58
- def middle_anchor?( str )
59
- str = clean_line str
60
- group_match str, middle_keys
61
- end
62
-
63
-
64
- def group_match(str, patterns)
65
- for pattern in patterns
66
- return true if str =~ pattern
67
- end
68
- false
69
- end
70
-
71
- def end_anchor?(str)
72
- str =~ end_keys
73
- end
74
-
75
- def clean_line(line, leave_comment = false)
76
- Beautifier::clean_line line, leave_comment
77
- end
78
-
79
- # why?
80
- def nasty_line?(line)
81
- return false
82
- s = %w! \/ ' " \( \{ \[ !
83
- p = Regexp.new(s.join('|'))
84
- return line =~ p
85
- end
86
-
87
- def comment_at_end(line)
88
- return false if line.strip ==''
89
- clean_line(line, true) =~ /#/
90
- end
91
- end
92
- end
data/lib/parser.rb DELETED
@@ -1,194 +0,0 @@
1
- $:.unshift(File.dirname(__FILE__) + '/helper')
2
-
3
- require 'parser_helper'
4
-
5
- module Lazibi
6
- module Parser
7
- include ParserHelper
8
-
9
- def to_py( rb, filters = [] )
10
- py = []
11
- lines = rb.split("\n")
12
- lines.each_index do |index|
13
- l = filter_for_to_py(lines, index, filters)
14
- if l.strip =~ /^end$/
15
- next
16
- end
17
- l = remove_colon_at_end(l)
18
-
19
- s = l
20
- if comment_at_end(l)
21
- s = s.sub(/(\s*;\s*end*\s*)(#.*)/, ' \2')
22
- s = s.sub(/(\s+end*\s*)(#.*)/, ' \2')
23
- else
24
- s = s.sub(/\s+end\s*$/, '')
25
- s = remove_colon_at_end(s)
26
- end
27
-
28
- py << s
29
- end
30
-
31
- py.join("\n")
32
- end
33
-
34
-
35
- def remove_colon_at_end(l)
36
- if comment_at_end(l)
37
- l.sub /(\s*;\s*)(#.*)/, ' \2'
38
- else
39
- l.sub /;*$/, ''
40
- end
41
- end
42
-
43
- def to_rb( content, filters = [] )
44
- return '' if content.strip == ''
45
- lines = content.split("\n")
46
- first_line = lines.first.strip
47
- return lines[1..-1].join("\n") if first_line == '#skip_parse'
48
- insert_end content, filters
49
- end
50
-
51
-
52
- # private
53
-
54
- def insert_end( content, filters )
55
- @lines = content.split("\n")
56
- progress = 0
57
- while progress < @lines.size
58
- lines = @lines[progress..-1]
59
- lines.each_index do |index|
60
- # run through filters
61
- # destructively
62
- l = filter_for_to_rb(lines, index, filters)
63
- @lines[progress] = l
64
- safe_l = clean_block(clean_line(get_rest(l)))
65
- if l =~ /dependencies/
66
- puts l, safe_l, clean_line(get_rest(l))
67
- end
68
- if start_anchor? safe_l
69
- relative_index_for_end = find_end( lines[index..-1], get_indent(l))
70
- unless relative_index_for_end
71
- progress += 1
72
- break
73
- end
74
- index_for_end = relative_index_for_end + index
75
-
76
- if relative_index_for_end == 0 && !comment_at_end(l)
77
- #l = lines[index_for_end]
78
- lines[index_for_end] = lines[index_for_end].rstrip + '; end'
79
- else
80
- lines[index_for_end] = lines[index_for_end] + "\n" + ' ' * get_indent(l) + "end"
81
- end
82
- head = @lines[0...progress]
83
- tail = lines[index..-1].join("\n").split("\n")
84
-
85
- @lines = head + tail
86
-
87
-
88
- progress += 1
89
- break
90
- end
91
- progress += 1
92
- end
93
- end
94
-
95
- result = @lines.join("\n")
96
- end
97
-
98
- def find_end( lines, indent )
99
- return 0 if lines.size == 1
100
-
101
- anchor = 0
102
-
103
- lines = lines[1..-1]
104
- lines.each_index do |i|
105
- l = lines[i]
106
- next if l.strip == ''
107
- if l.strip =~ /^#/
108
- if get_indent(l) > indent
109
- anchor = i + 1
110
- end
111
- next
112
- end
113
- return anchor if get_indent(l) < indent
114
- if get_indent(l) == indent
115
- rest = get_rest l
116
- if start_anchor? rest
117
- return anchor
118
- elsif end_anchor? rest
119
- return false
120
- elsif middle_anchor? rest
121
- anchor = i + 1
122
- next
123
- else
124
- return anchor
125
- end
126
- end
127
- anchor = i + 1
128
- end
129
- return anchor
130
- end
131
-
132
- def filter_for_to_rb(lines, index, filters)
133
- l = lines[index]
134
- if filters.include?( :optional_do )
135
- l = optional_do_filter_to_rb(lines, index)
136
- end
137
- # destructive behaviour
138
- lines[index] = l
139
- l
140
- end
141
-
142
- def optional_do_filter_to_rb(lines, index)
143
- l = lines[index]
144
- return l if l.strip == ''
145
- return l if l =~ /[\{\[]\s*$/
146
- rest = get_rest(l)
147
- return l if start_anchor?(rest) || middle_anchor?(rest) || end_anchor?(rest)
148
-
149
- l_check = clean_line l
150
- # bad code
151
- # return l if nasty_line?(l_check)
152
- next_line = ''
153
- if index + 1 < lines.size
154
- lines[index+1..-1].each_index do |i|
155
- abs_i = index + 1 + i
156
- next if lines[abs_i].strip == ''
157
- next_line = lines[abs_i]
158
- break
159
- end
160
- else
161
- return l
162
- end
163
- if get_indent(next_line) > get_indent(l)
164
- return l.rstrip + ' do'
165
- else
166
- return l
167
- end
168
- end
169
-
170
-
171
- def filter_for_to_py(lines, index, filters)
172
- l = lines[index]
173
- if filters.include?( :optional_do )
174
- l = optional_do_filter_to_py( lines, index )
175
- end
176
-
177
- # destructive behaviour
178
- lines[index] = l
179
- l
180
- end
181
-
182
- def optional_do_filter_to_py(lines, index)
183
- l = lines[index]
184
- return l if l.strip == ''
185
- return l if l.strip[0..0] == '#'
186
- l_check = clean_line(l).strip
187
- if l_check.size > 2 && l.strip[-3..-1] == ' do' && !nasty_line?(l_check)
188
- l = l.rstrip[0...-3].rstrip
189
- return l
190
- end
191
- return l
192
- end
193
- end
194
- end
@@ -1,278 +0,0 @@
1
- # Ruby beautifier, version 1.3, 04/03/2006
2
- # Copyright (c) 2006, P. Lutus
3
- # TextMate modifications by T. Burks
4
- # Released under the GPL
5
- # Modified for lazibi by Jinjing
6
-
7
- module Beautifier
8
-
9
- $tabSize = 2
10
- $tabStr = " "
11
-
12
- # indent regexp tests
13
-
14
- $indentExp = [
15
- /^module\b/,
16
- /(=\s*|^|<<\s*)if\b/,
17
- /(=\s*|^|<<\s*)until\b/,
18
- /(=\s*|^|<<\s*)for\b/,
19
- /(=\s*|^|<<\s*)unless\b/,
20
- /(=\s*|^|<<\s*)while\b/,
21
- /(=\s*|^|<<\s*)begin\b/,
22
- /(=\s*|^|<<\s*)loop\b/,
23
- # /\bthen\b/,
24
- /\bcase\b/,
25
- /^class\b/,
26
- /^rescue\b/,
27
- /^def\b/,
28
- /\bdo\b/,
29
- /^else\b/,
30
- /^elsif\b/,
31
- /^ensure\b/,
32
- /\bwhen\b/,
33
- /\{[^\}]*$/,
34
- /\[[^\]]*$/
35
- ]
36
-
37
- # outdent regexp tests
38
-
39
- $outdentExp = [
40
- /^rescue\b/,
41
- /^ensure\b/,
42
- /^elsif\b/,
43
- # /\bthen\b/,
44
- /^end\b/,
45
- /^else\b/,
46
- /\bwhen\b/,
47
- /^[^\{]*\}/,
48
- /^[^\[]*\]/
49
- ]
50
-
51
-
52
-
53
- def self.makeTab(tab)
54
- return (tab < 0) ? "":$tabStr * $tabSize * tab
55
- end
56
-
57
- def self.addLine(line,tab)
58
- line.strip!
59
- line = makeTab(tab)+line if line.length > 0
60
- return line + "\n"
61
- end
62
-
63
- def self.clean_line( line, leave_comment = false )
64
-
65
- # throw out sequences that will
66
- # only sow confusion
67
- # " \"" << "#{base}/#{path}".gsub(/["?<>\*]/, '') << "\""
68
- tline = line.dup.sub /[;]*$/, ''
69
-
70
-
71
-
72
-
73
- tline.gsub!(/#\{.*?\}/,"")
74
- tline.gsub!(/\\\"/,"'")
75
-
76
- # deal with nested syntax
77
-
78
- tline.gsub!(/"\/*?"/,"\"\"")
79
- tline.gsub!(/\/.*?[^\\]\//,"//")
80
-
81
- # again
82
- tline.gsub!(/".*?"/,"\"\"")
83
- tline.gsub!(/'.*?'/,"''")
84
- tline.gsub!(/`.*?`/,"''")
85
-
86
- # more ..
87
- tline.gsub!(/%[qwsrx]\{.*?\}/, "''")
88
- tline.gsub!(/%[qwsrx]\(.*?\)/, "''")
89
- tline.gsub!(/%[qwsrx]\[.*?\]/, "''")
90
- tline.gsub!(/%[qwsrx](.).*?\1/, "''")
91
-
92
- tline.gsub!(/#.*$/, '') unless leave_comment
93
-
94
- tline
95
- end
96
-
97
- def self.split_end( source )
98
- lines = source.split("\n")
99
- new_lines = []
100
- for line in lines
101
- if line =~ /^\s*#/
102
- new_lines << line
103
- else
104
- new_lines << line.gsub( /\send\./, "\nend." )
105
- end
106
- end
107
-
108
- new_lines.join("\n")
109
- end
110
-
111
- def self.join_sep_line( source )
112
- lines = source.split("\n")
113
- continue = false
114
- buffer = ''
115
- new_lines = []
116
- for line in lines
117
- if clean_line(line, true).strip =~ /#/
118
- if continue
119
- new_lines << buffer
120
- new_lines << line
121
- buffer = ''
122
- else
123
- new_lines << line
124
- end
125
- next
126
- end
127
-
128
- if continue
129
- if line.strip == ''
130
- continue = false
131
- new_lines << buffer
132
- new_lines << line
133
- buffer = ''
134
- elsif line.strip[-1..-1] == "\\"
135
- continue = true
136
- buffer += ' ' + line.strip[0...-1].strip
137
- else
138
- continue = false
139
- buffer += ' ' + line.lstrip
140
- new_lines << buffer
141
- buffer = ''
142
- end
143
- else
144
- if line.strip == ''
145
- new_lines << line
146
- elsif line.strip[-1..-1] == "\\"
147
- continue = true
148
- buffer += line.rstrip[0...-1].strip
149
- else
150
- new_lines << line
151
- end
152
- end
153
- end
154
-
155
- new_lines.join("\n")
156
- end
157
-
158
-
159
- def self.valid?( line )
160
- not_supported = using_eval?(line) || here_doc?(line) || special_syntax(line)
161
- return !not_supported
162
- end
163
-
164
- def self.using_eval?( line )
165
- line =~ /\b(class|module|instance)_eval\b/
166
- end
167
-
168
- def self.here_doc?( line )
169
- line =~ /(=\s*<<)|(<<-)/
170
- end
171
-
172
- def self.special_syntax( line )
173
- patterns = [
174
- /:\[\]=/,
175
- /\beval\b/,
176
- /javascript_cdata/
177
- ]
178
- for p in patterns
179
- return true if line =~ p
180
- end
181
-
182
- false
183
- end
184
-
185
- def self.valid_before_clean?( line )
186
- r = line =~ /#\{[^\{]*#\{.*\}.*\}/
187
- r.nil?
188
- end
189
-
190
-
191
- def self.ruby( source )
192
- invalid = false
193
- #source = join_sep_line(split_end(source))
194
- source = split_end(source)
195
- commentBlock = false
196
- multiLineArray = Array.new
197
- multiLineStr = ""
198
- tab = 0
199
- dest = ""
200
- source.split("\n").each do |line|
201
- # combine continuing lines
202
- if(!(clean_line(line, true) =~ /\s*#/) && line =~ /[^\\]\\\s*$/)
203
- multiLineArray.push line
204
- multiLineStr += line.sub(/^(.*)\\\s*$/,"\\1")
205
- next
206
- end
207
-
208
- # add final line
209
- if(multiLineStr.length > 0)
210
- multiLineArray.push line
211
- multiLineStr += line.sub(/^(.*)\\\s*$/,"\\1")
212
- end
213
-
214
- tline = ((multiLineStr.length > 0)?multiLineStr:line).strip
215
- if(tline =~ /^=begin/)
216
- commentBlock = true
217
- end
218
- if(commentBlock)
219
- # add the line unchanged
220
- dest += line + "\n"
221
- else
222
- commentLine = (tline =~ /^#/)
223
- if(!commentLine)
224
- # throw out sequences that will
225
- # only sow confusion
226
- valid_before = valid_before_clean?( tline )
227
- tline = clean_line(tline)
228
- unless ( valid?(tline) && valid_before )
229
- puts '- ' + tline
230
- invalid = true
231
- break
232
- end
233
- $outdentExp.each do |re|
234
- if(tline =~ re)
235
- tab -= 1
236
- break
237
- end
238
- end
239
- end
240
- if (multiLineArray.length > 0)
241
- first_line = true
242
- multiLineArray.each do |ml|
243
- if first_line
244
- dest += addLine(ml,tab)
245
- first_line = false
246
- elsif ml.strip =~ /^unless/ || ml.strip =~ /^if/
247
- dest = dest.chop.rstrip.chop.rstrip + ' ' + ml.strip + "\n"
248
- else
249
- dest += addLine(ml,tab)
250
- end
251
- end
252
- multiLineArray.clear
253
- multiLineStr = ""
254
- else
255
- dest += addLine(line,tab)
256
- end
257
- if(!commentLine)
258
- $indentExp.each do |re|
259
- if(tline =~ re) && !(tline =~ /\s+end\s*$/)
260
- tab += 1
261
- break
262
- end
263
- end
264
- end
265
- end
266
- if(tline =~ /^=end/)
267
- commentBlock = false
268
- end
269
- end
270
- # STDOUT.write(dest)
271
- # uncomment this to complain about mismatched blocks
272
- # if(tab != 0)
273
- # STDERR.puts "Indentation error: #{tab}"
274
- #
275
- return false if invalid
276
- dest
277
- end
278
- end