Sha256: bcfc7b009aa3e8b0a8a1d7a84a09ab98e80e05d663194046c6495834ee72be9f

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

# coding: utf-8

################################################
# © Alexander Semyonov, 2013—2013, MIT License #
# Author: Alexander Semyonov <al@semyonov.us>  #
################################################

require 'giteaucrat'

module Giteaucrat
  module Formatters
    UnknownFormatError = Class.new(StandardError)

    EXTENSIONS = {
      '.rb' => :RubyFormatter,
      '.java' => :JavaFormatter,
      '.py' => :PythonFormatter,
      '.sass' => :SassFormatter,
      '.scss' => :SassFormatter,
      '.coffee' => :CoffeeFormatter,
    }

    module_function

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

require 'giteaucrat/formatters/formatter'

require 'giteaucrat/formatters/coffee_formatter'
require 'giteaucrat/formatters/java_formatter'
require 'giteaucrat/formatters/python_formatter'
require 'giteaucrat/formatters/ruby_formatter'
require 'giteaucrat/formatters/sass_formatter'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
giteaucrat-0.0.3 lib/giteaucrat/formatters.rb