Sha256: 3945ef3545314d7aa1fb38c003fdc2972cfb4240eecbf1fa098bf157426a5ff1

Contents?: true

Size: 690 Bytes

Versions: 4

Compression:

Stored size: 690 Bytes

Contents

module Serum
  module Rails
    class TypeSelection

      EXTENSIONS_BY_TYPE = {
        :ruby       => %w[ rb ],
        :javascript => %w[ js coffee coffeescript ],
        :views      => %w[ erb haml mab ]
      }.freeze

      DEFAULT_TYPES = EXTENSIONS_BY_TYPE.keys.freeze

      def initialize(types = nil)
        @types = types ? Array.wrap(types) : DEFAULT_TYPES
      end

      #def matches_path?(path)
      #  extensions.any? { |extension|
      #    path.ends_with?("\.#{extension}")
      #  }
      #end

      def extensions
        @types.collect { |type|
          EXTENSIONS_BY_TYPE[type] or raise "No such type: #{type}"
        }.flatten
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
serum-rails-0.2.1 lib/serum/rails/type_selection.rb
serum-rails-0.2.0 lib/serum/rails/type_selection.rb
serum-rails-0.1.1 lib/serum/rails/type_selection.rb
serum-rails-0.1.0 lib/serum/rails/type_selection.rb