lib/io_streams/tabular.rb in iostreams-1.2.0 vs lib/io_streams/tabular.rb in iostreams-1.2.1

- old
+ new

@@ -50,10 +50,38 @@ # # Parameters # format: [Symbol] # :csv, :hash, :array, :json, :psv, :fixed # - # For all other parameters, see Tabular::Header.new + # file_name: [String] + # When `:format` is not supplied the file name can be used to infer the required format. + # Optional. Default: nil + # + # format_options: [Hash] + # Any specialized format specific options. For example, `:fixed` format requires the file definition. + # + # columns [Array<String>] + # The header columns when the file does not include a header row. + # Note: + # It is recommended to keep all columns as strings to avoid any issues when persistence + # with MongoDB when it converts symbol keys to strings. + # + # allowed_columns [Array<String>] + # List of columns to allow. + # Default: nil ( Allow all columns ) + # Note: + # When supplied any columns that are rejected will be returned in the cleansed columns + # as nil so that they can be ignored during processing. + # + # required_columns [Array<String>] + # List of columns that must be present, otherwise an Exception is raised. + # + # skip_unknown [true|false] + # true: + # Skip columns not present in the `allowed_columns` by cleansing them to nil. + # #as_hash will skip these additional columns entirely as if they were not in the file at all. + # false: + # Raises Tabular::InvalidHeader when a column is supplied that is not in the whitelist. def initialize(format: nil, file_name: nil, format_options: nil, **args) @header = Header.new(**args) klass = if file_name && format.nil? self.class.parser_class_for_file_name(file_name)