Sha256: 6840cab15471f841a8d77b02806a36ad0e68daeb572c4aa9a07e916ddf57a3ca

Contents?: true

Size: 546 Bytes

Versions: 6

Compression:

Stored size: 546 Bytes

Contents

module Docify
  # All supported formats
  FORMATS = ['rdoc', 'markdown', 'textile']
  
  # Aliases for file extensions
  ALIASES = {
    '.rdoc'     => 'rdoc',
    '.textile'  => 'textile',
    '.markdown' => 'markdown',
    '.md'       => 'markdown'
  }
  
  # Returns true if provided format is supported
  def self.valid_format?(f)
    FORMATS.include?(f)
  end
  
  # Automatically detect format from extension
  def self.detect_format(file)
    ext = File.extname(file).downcase
    ALIASES.key?(ext) ? ALIASES[ext] : FORMATS.first
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
docify-1.0.5 lib/docify/format.rb
docify-1.0.4 lib/docify/format.rb
docify-1.0.3 lib/docify/format.rb
docify-1.0.2 lib/docify/format.rb
docify-1.0.1 lib/docify/format.rb
docify-1.0.0 lib/docify/format.rb