@@ -39,7 +39,7 @@ module AnnotateModels
3939 }
4040 } . freeze
4141
42- MAGIC_COMMENT_MATCHER = Regexp . new ( /(^#\s *encoding:.*(?:\n |r\n ))|(^# coding:.*(?:\n |\r \n ))|(^# -\* - coding:.*(?:\n |\r \n ))|(^# -\* - encoding\s ?:.*(?:\n |\r \n ))|(^#\s *frozen_string_literal:.+(?:\n |\r \n ))|(^# -\* - frozen_string_literal\s *:.+-\* -(?:\n |\r \n ))/ ) . freeze
42+ MAGIC_COMMENT_MATCHER = /(^#\s *encoding:.*(?:\n |r\n ))|(^# coding:.*(?:\n |\r \n ))|(^# -\* - coding:.*(?:\n |\r \n ))|(^# -\* - encoding\s ?:.*(?:\n |\r \n ))|(^#\s *frozen_string_literal:.+(?:\n |\r \n ))|(^# -\* - frozen_string_literal\s *:.+-\* -(?:\n |\r \n ))/ . freeze
4343
4444 class << self
4545 def annotate_pattern ( options = { } )
@@ -155,8 +155,8 @@ def get_schema_info(klass, header, options = {}) # rubocop:disable Metrics/Metho
155155 with_comments_column = with_comments_column? ( klass , options )
156156
157157 # Precalculate Values
158- cols_meta = cols . map do |col |
159- col_comment = with_comments || with_comments_column ? col . comment &.gsub ( / \n / , "\\ n" ) : nil
158+ cols_meta = cols . to_h do |col |
159+ col_comment = with_comments || with_comments_column ? col . comment &.gsub ( " \n " , "\\ n" ) : nil
160160 col_type = get_col_type ( col )
161161 attrs = get_attributes ( col , col_type , klass , options )
162162 col_name = if with_comments && col_comment
@@ -166,7 +166,7 @@ def get_schema_info(klass, header, options = {}) # rubocop:disable Metrics/Metho
166166 end
167167 simple_formatted_attrs = attrs . join ( ", " )
168168 [ col . name , { col_type : col_type , attrs : attrs , col_name : col_name , simple_formatted_attrs : simple_formatted_attrs , col_comment : col_comment } ]
169- end . to_h
169+ end
170170
171171 # Output annotation
172172 bare_max_attrs_length = cols_meta . map { |_ , m | m [ :simple_formatted_attrs ] . length } . max
@@ -179,15 +179,15 @@ def get_schema_info(klass, header, options = {}) # rubocop:disable Metrics/Metho
179179 col_comment = cols_meta [ col . name ] [ :col_comment ]
180180
181181 if options [ :format_rdoc ]
182- info << sprintf ( "# %-#{ max_size } .#{ max_size } s<tt>%s</tt>" , "*#{ col_name } *::" , attrs . unshift ( col_type ) . join ( ", " ) ) . rstrip + "\n "
182+ info << ( sprintf ( "# %-#{ max_size } .#{ max_size } s<tt>%s</tt>" , "*#{ col_name } *::" , attrs . unshift ( col_type ) . join ( ", " ) ) . rstrip + "\n " )
183183 elsif options [ :format_yard ]
184- info << sprintf ( "# @!attribute #{ col_name } " ) + "\n "
184+ info << ( sprintf ( "# @!attribute #{ col_name } " ) + "\n " )
185185 ruby_class = col . respond_to? ( :array ) && col . array ? "Array<#{ map_col_type_to_ruby_classes ( col_type ) } >" : map_col_type_to_ruby_classes ( col_type )
186- info << sprintf ( "# @return [#{ ruby_class } ]" ) + "\n "
186+ info << ( sprintf ( "# @return [#{ ruby_class } ]" ) + "\n " )
187187 elsif options [ :format_markdown ]
188188 name_remainder = max_size - col_name . length - non_ascii_length ( col_name )
189189 type_remainder = ( md_type_allowance - 2 ) - col_type . length
190- info << ( sprintf ( "# **`%s`**%#{ name_remainder } s | `%s`%#{ type_remainder } s | `%s`" , col_name , " " , col_type , " " , attrs . join ( ", " ) . rstrip ) ) . gsub ( '``' , ' ' ) . rstrip + "\n "
190+ info << ( ( sprintf ( "# **`%s`**%#{ name_remainder } s | `%s`%#{ type_remainder } s | `%s`" , col_name , " " , col_type , " " , attrs . join ( ", " ) . rstrip ) ) . gsub ( '``' , ' ' ) . rstrip + "\n " )
191191 elsif with_comments_column
192192 info << format_default ( col_name , max_size , col_type , bare_type_allowance , simple_formatted_attrs , bare_max_attrs_length , col_comment )
193193 else
@@ -704,7 +704,7 @@ def parse_options(options = {})
704704 end
705705
706706 def split_model_dir ( option_value )
707- option_value = option_value . is_a? ( Array ) ? option_value : option_value . split ( ',' )
707+ option_value = option_value . split ( ',' ) unless option_value . is_a? ( Array )
708708 option_value . map ( &:strip ) . reject ( &:empty? )
709709 end
710710
0 commit comments