Module: CSVConverter

Defined in:
lib/csv_converter.rb,
lib/csv_converter/version.rb,
lib/csv_converter/file_processor.rb,
lib/csv_converter/entity_processor.rb,
lib/csv_converter/attribute_processor.rb,
lib/csv_converter/converters/base_converter.rb,
lib/csv_converter/converters/date_converter.rb,
lib/csv_converter/converters/hash_converter.rb,
lib/csv_converter/converters/array_converter.rb,
lib/csv_converter/converters/float_converter.rb,
lib/csv_converter/converters/string_converter.rb,
lib/csv_converter/converters/boolean_converter.rb,
lib/csv_converter/converters/integer_converter.rb,
lib/csv_converter/converters/lowercase_converter.rb,
lib/csv_converter/converters/uppercase_converter.rb,
lib/csv_converter/converters/big_decimal_converter.rb

Overview

CSVConverter groups and transforms tabulated data contained in files such as csv or spreadsheets.

Defined Under Namespace

Modules: Converters Classes: AttributeProcessor, EntityProcessor, Error, FileProcessor

Constant Summary collapse

ALIASES =
{
  array: 'CSVConverter::Converters::ArrayConverter',
  boolean: 'CSVConverter::Converters::BooleanConverter',
  date: 'CSVConverter::Converters::DateConverter',
  decimal: 'CSVConverter::Converters::BigDecimalConverter',
  float: 'CSVConverter::Converters::FloatConverter',
  hash: 'CSVConverter::Converters::HashConverter',
  integer: 'CSVConverter::Converters::IntegerConverter',
  lowercase: 'CSVConverter::Converters::LowercaseConverter',
  string: 'CSVConverter::Converters::StringConverter',
  uppercase: 'CSVConverter::Converters::UppercaseConverter'
}.with_indifferent_access
VERSION =
'0.1.2'

Class Method Summary collapse

Class Method Details

.add_alias(new_alias, klass) ⇒ @see #aliases

Adds an alias to the list of aliases

Parameters:

  • new_alias (Symbol, String)

    the name of the alias

  • klass (Symbol, String)

    class name of the converter

Returns:



73
74
75
# File 'lib/csv_converter.rb', line 73

def self.add_alias(new_alias, klass)
  @aliases = aliases.merge(new_alias.to_sym => klass.to_s)
end

.add_aliases(new_aliases) ⇒ @see #aliases

Adds one or more alieases to the list of aliases

Parameters:

  • new_aliases (Hash)

    list of aliases to append to the list, where the key is the name of the alias and the value is the class name of the converter

Returns:



81
82
83
# File 'lib/csv_converter.rb', line 81

def self.add_aliases(new_aliases)
  @aliases = aliases.merge(new_aliases)
end

.aliasesHash

When no custom aliases are included it returns CSVConverter::ALIASES. When custom converter alises are included it returns the whole list of aliases.

Returns:

  • (Hash)

    list of aliases for each converter class.



65
66
67
# File 'lib/csv_converter.rb', line 65

def self.aliases
  @aliases || ALIASES
end