Method: Howzit::StringUtils#note_title

Defined in:
lib/howzit/stringutils.rb

#note_title(file, truncate = 0) ⇒ Object

Get the title of the build note (top level header)



24
25
26
27
28
29
30
31
32
33
# File 'lib/howzit/stringutils.rb', line 24

def note_title(file, truncate = 0)
  title = match(/(?:^(\S.*?)(?=\n==)|^# ?(.*?)$)/)
  title = if title
            title[1].nil? ? title[2] : title[1]
          else
            file.sub(/(\.\w+)?$/, '')
          end

  title && truncate.positive? ? title.trunc(truncate) : title
end