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