Sha256: 03cfe43b6aa25f548ad46e50af48892e2a4a37c58c7f1909a8ced44e36590e44

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

# coding: utf-8
# frozen_string_literal: true

############################################
# © Alex Semyonov, 2013—2017, MIT License  #
# Author: Alex Semyonov <alex@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,
      '.erl' => :ErlangFormatter
    }.freeze

    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/erlang_formatter'
require 'giteaucrat/formatters/java_formatter'
require 'giteaucrat/formatters/python_formatter'
require 'giteaucrat/formatters/ruby_formatter'
require 'giteaucrat/formatters/sass_formatter'

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
giteaucrat-0.1.0 lib/giteaucrat/formatters.rb
giteaucrat-0.0.8 lib/giteaucrat/formatters.rb