@@ -88,29 +88,37 @@ def header(options = {})
88
88
end
89
89
out << '' if magic_comments_map . any?
90
90
91
- out += [ "# #{ options [ :wrapper_open ] } " ] if options [ :wrapper_open ]
91
+ out << comment ( options [ :wrapper_open ] ) if options [ :wrapper_open ]
92
92
93
- out += [ "# #{ options [ :format_markdown ] ? PREFIX_MD : PREFIX } " + ( options [ :timestamp ] ? " (Updated #{ Time . now . strftime ( '%Y-%m-%d %H:%M' ) } )" : '' ) ]
94
- out += [ '#' ]
93
+ out << comment ( options [ :format_markdown ] ? PREFIX_MD : PREFIX ) + ( options [ :timestamp ] ? " (Updated #{ Time . now . strftime ( '%Y-%m-%d %H:%M' ) } )" : '' )
94
+ out << comment
95
95
return out if routes_map . size . zero?
96
96
97
97
maxs = [ HEADER_ROW . map ( &:size ) ] + routes_map [ 1 ..-1 ] . map { |line | line . split . map ( &:size ) }
98
98
99
99
if options [ :format_markdown ]
100
100
max = maxs . map ( &:max ) . compact . max
101
101
102
- out += [ "# #{ content ( HEADER_ROW , maxs , options ) } " ]
103
- out += [ "# #{ content ( [ '-' * max , '-' * max , '-' * max , '-' * max ] , maxs , options ) } " ]
102
+ out << comment ( content ( HEADER_ROW , maxs , options ) )
103
+ out << comment ( content ( [ '-' * max , '-' * max , '-' * max , '-' * max ] , maxs , options ) )
104
104
else
105
- out += [ "# #{ content ( routes_map [ 0 ] , maxs , options ) } " ]
105
+ out << comment ( content ( routes_map [ 0 ] , maxs , options ) )
106
106
end
107
107
108
- out += routes_map [ 1 ..-1 ] . map { |line | "# #{ content ( options [ :format_markdown ] ? line . split ( ' ' ) : line , maxs , options ) } " }
109
- out += [ "# #{ options [ :wrapper_close ] } " ] if options [ :wrapper_close ]
108
+ out += routes_map [ 1 ..-1 ] . map { |line | comment ( content ( options [ :format_markdown ] ? line . split ( ' ' ) : line , maxs , options ) ) }
109
+ out << comment ( options [ :wrapper_close ] ) if options [ :wrapper_close ]
110
110
111
111
out
112
112
end
113
113
114
+ def comment ( row = '' )
115
+ if row == ''
116
+ '#'
117
+ else
118
+ "# #{ row } "
119
+ end
120
+ end
121
+
114
122
# TODO: write the method doc using ruby rdoc formats
115
123
# This method returns an array of 'real_content' and 'header_position'.
116
124
# 'header_position' will either be :before, :after, or
0 commit comments