lib/rocket_job/batch/tabular/input.rb in rocketjob-5.4.1 vs lib/rocket_job/batch/tabular/input.rb in rocketjob-6.0.0.rc1
- old
+ new
@@ -1,30 +1,30 @@
require "active_support/concern"
module RocketJob
module Batch
class Tabular
- # For the simple case where all `input_categories` have the same format,
- # If multiple input categories are used with different formats, then use IOStreams::Tabular directly
- # instead of this plugin.
+ # @deprecated
module Input
extend ActiveSupport::Concern
included do
+ warn "#{name} is using RocketJob::Batch::Tabular::Input which is deprecated"
+
field :tabular_input_header, type: Array, class_attribute: true, user_editable: true
- field :tabular_input_format, type: Symbol, default: :csv, class_attribute: true, user_editable: true
+ field :tabular_input_format, type: Mongoid::StringifiedSymbol, default: :csv, class_attribute: true, user_editable: true
field :tabular_input_options, type: Hash, class_attribute: true
# tabular_input_mode: [:line | :array | :hash]
# :line
# Uploads the file a line (String) at a time for processing by workers.
# :array
# Parses each line from the file as an Array and uploads each array for processing by workers.
# :hash
# Parses each line from the file into a Hash and uploads each hash for processing by workers.
# See IOStreams#each.
- field :tabular_input_mode, type: Symbol, default: :line, class_attribute: true, user_editable: true, copy_on_restart: true
+ field :tabular_input_mode, type: Mongoid::StringifiedSymbol, default: :line, class_attribute: true, user_editable: true, copy_on_restart: true
validates_inclusion_of :tabular_input_format, in: IOStreams::Tabular.registered_formats
validates_inclusion_of :tabular_input_mode, in: %i[line array hash row record]
validate :tabular_input_header_present
@@ -117,10 +117,12 @@
self.tabular_input_header = tabular_input.header.columns
end
def tabular_input_header_present
- if tabular_input_header.present? || !tabular_input.header? || (tabular_input_mode == :hash || tabular_input_mode == :record)
+ if tabular_input_header.present? ||
+ !tabular_input.header? ||
+ (tabular_input_mode == :hash || tabular_input_mode == :record)
return
end
errors.add(:tabular_input_header, "is required when tabular_input_format is #{tabular_input_format.inspect}")
end