Class: CsvFastImporter::Configuration
- Inherits:
-
Object
- Object
- CsvFastImporter::Configuration
- Defined in:
- lib/csv_fast_importer/configuration.rb
Overview
Gather all import configurations based on given file and additional parameters. This class is also responsible for default configuration.
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
Instance Method Summary collapse
- #column_separator ⇒ Object
- #deletion? ⇒ Boolean
- #destination_table ⇒ Object
- #encoding ⇒ Object
-
#initialize(file, parameters = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #mapping ⇒ Object
- #row_index_column ⇒ Object
- #transactional? ⇒ Boolean
- #transactional_forced? ⇒ Boolean
- #truncate? ⇒ Boolean
Constructor Details
#initialize(file, parameters = {}) ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 12 |
# File 'lib/csv_fast_importer/configuration.rb', line 9 def initialize(file, parameters = {}) @file = file @parameters = parameters end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
7 8 9 |
# File 'lib/csv_fast_importer/configuration.rb', line 7 def file @file end |
Instance Method Details
#column_separator ⇒ Object
18 19 20 |
# File 'lib/csv_fast_importer/configuration.rb', line 18 def column_separator @column_separator ||= @parameters[:col_sep] || ';' end |
#deletion? ⇒ Boolean
46 47 48 |
# File 'lib/csv_fast_importer/configuration.rb', line 46 def deletion? @deletion ||= !(@parameters[:deletion] == :none) end |
#destination_table ⇒ Object
26 27 28 |
# File 'lib/csv_fast_importer/configuration.rb', line 26 def destination_table @destination_table ||= (@parameters[:destination] || File.basename(@file, '.*')) end |
#encoding ⇒ Object
14 15 16 |
# File 'lib/csv_fast_importer/configuration.rb', line 14 def encoding @encoding ||= @parameters[:encoding] || 'UTF-8' end |
#mapping ⇒ Object
22 23 24 |
# File 'lib/csv_fast_importer/configuration.rb', line 22 def mapping @mapping ||= downcase_keys_and_values(@parameters[:mapping] || {}) end |
#row_index_column ⇒ Object
30 31 32 |
# File 'lib/csv_fast_importer/configuration.rb', line 30 def row_index_column @row_index_column ||= @parameters[:row_index_column] end |
#transactional? ⇒ Boolean
34 35 36 |
# File 'lib/csv_fast_importer/configuration.rb', line 34 def transactional? @transactional ||= !(@parameters[:transaction] == :disabled) end |
#transactional_forced? ⇒ Boolean
38 39 40 |
# File 'lib/csv_fast_importer/configuration.rb', line 38 def transactional_forced? @transactional_forced ||= (@parameters[:transaction] == :enabled) end |
#truncate? ⇒ Boolean
42 43 44 |
# File 'lib/csv_fast_importer/configuration.rb', line 42 def truncate? @deletion ||= @parameters[:deletion] == :truncate end |