module Asciidoctor::Helpers

def self.rootname(file_name)

Returns the String filename with the file extension removed

# => "part1/chapter1"
Helpers.rootname('part1/chapter1.adoc')

Examples

file_name - The String file name to process

Public: Removes the file extension from filename and returns the result
def self.rootname(file_name)
  # alternatively, this could be written as ::File.basename file_name, ((::File.extname file_name) || '')
  (ext = ::File.extname(file_name)).empty? ? file_name : file_name[0...-ext.length]
end