File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change 6
6
raise unless ARGV . size == 2
7
7
method , file = ARGV
8
8
9
- lines = File . readlines ( file )
10
-
9
+ all_lines = File . readlines ( file )
11
10
12
11
method = "Root[#{ method } ]" unless method . start_with? ( 'Root[' )
13
12
method = " #{ method . strip } \n "
14
13
blank_line = " \n "
15
14
16
- i = lines . index ( method )
17
- raise "not found" unless i
18
- start = i - 1
15
+ lines = [ ]
16
+ while i = all_lines . index ( method )
17
+ start = i - 1
19
18
20
- # i += 1 until lines[i].strip.empty?
21
- i += 1 until lines [ i ] == blank_line
19
+ # i += 1 until lines[i].strip.empty?
20
+ i += 1 until all_lines [ i ] == blank_line
22
21
23
- lines = lines [ start ...i ]
22
+ lines . concat all_lines [ start ...i ]
23
+ lines << "\n "
24
+ all_lines = all_lines [ i ..-1 ]
25
+ end
26
+ raise "not found" if lines . empty?
27
+ lines . pop # Remove last \n
24
28
25
29
indent = lines . first [ /^ +/ ]
26
30
lines = lines . map { |line | line . sub ( indent , '' ) }
You can’t perform that action at this time.
0 commit comments