Module: Giteaucrat::Formatters

Defined in:
lib/giteaucrat/formatters.rb,
lib/giteaucrat/formatters/formatter.rb,
lib/giteaucrat/formatters/java_formatter.rb,
lib/giteaucrat/formatters/ruby_formatter.rb,
lib/giteaucrat/formatters/sass_formatter.rb,
lib/giteaucrat/formatters/coffee_formatter.rb,
lib/giteaucrat/formatters/erlang_formatter.rb,
lib/giteaucrat/formatters/python_formatter.rb

Defined Under Namespace

Classes: CoffeeFormatter, ErlangFormatter, Formatter, JavaFormatter, PythonFormatter, RubyFormatter, SassFormatter

Constant Summary collapse

UnknownFormatError =
Class.new(StandardError)
EXTENSIONS =
{
  '.rb' => :RubyFormatter,
  '.java' => :JavaFormatter,
  '.py' => :PythonFormatter,
  '.sass' => :SassFormatter,
  '.scss' => :SassFormatter,
  '.coffee' => :CoffeeFormatter,
  '.erl' => :ErlangFormatter
}.freeze

Class Method Summary collapse

Class Method Details

.formatter_for(file) ⇒ Object

Raises:



27
28
29
30
31
32
# File 'lib/giteaucrat/formatters.rb', line 27

def formatter_for(file)
  extension = ::File.extname(file.name)
  formatter = EXTENSIONS[extension]
  raise(UnknownFormatError, extension) unless formatter
  const_get(formatter).new(file)
end