Sha256: e1b575f1d89032af80db36c82b37f83e43aa7be1a8a65114a1aaa45567f371ce

Contents?: true

Size: 551 Bytes

Versions: 1

Compression:

Stored size: 551 Bytes

Contents

require 'colander/invalid_file'
require 'colander/parser/xls'
require 'colander/parser/xlsx'
require 'colander/parser/plain'

module Colander
  EMAIL_REGEXP = /\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}\b/

  def self.parse(file_path, file_name = nil)
    parser = case (file_name || file_path).split(".").last
    when "xls"
      Parser::Xls.new(file_path)
    when "xlsx"
      Parser::Xlsx.new(file_path)
    when "csv", "txt"
      Parser::Plain.new(file_path)
    else
      raise InvalidFile
    end
    parser.parse
    parser
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
colander-0.2.3 lib/colander.rb