Sha256: 0f0ca1bc701a80291c1b18010adc57a1ed44d6080b483af3f4ba0c3434d30e49

Contents?: true

Size: 764 Bytes

Versions: 16

Compression:

Stored size: 764 Bytes

Contents

module ActiveRecordCSVImporter
  # Generate a human readable message for the given report.
  class ReportMessage
    def self.call(report)
      new(report).to_s
    end

    def initialize(report)
      @report = report
    end

    attr_accessor :report

    def to_s
      send("report_#{report.status}")
    end

    private

    def report_pending
      "Import hasn't started yet"
    end

    def report_in_progress
      'Import in progress'
    end

    def report_done
      'Import completed'
    end

    def report_invalid_header
      "The following columns are required: #{report.missing_columns.join(', ')}"
    end

    def report_invalid_csv_file
      report.parser_error
    end

    def report_aborted
      'Import aborted'
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
activerecord_csv_importer-0.4.0 lib/activerecord_csv_importer/report_message.rb
activerecord_csv_importer-0.3.0 lib/activerecord_csv_importer/report_message.rb
activerecord_csv_importer-0.2.3 lib/activerecord_csv_importer/report_message.rb
activerecord_csv_importer-0.2.2 lib/activerecord_csv_importer/report_message.rb
activerecord_csv_importer-0.2.1 lib/activerecord_csv_importer/report_message.rb
activerecord_csv_importer-0.2.0 lib/activerecord_csv_importer/report_message.rb
activerecord_csv_importer-0.1.9 lib/activerecord_csv_importer/report_message.rb
activerecord_csv_importer-0.1.8 lib/activerecord_csv_importer/report_message.rb
activerecord_csv_importer-0.1.7 lib/activerecord_csv_importer/report_message.rb
activerecord_csv_importer-0.1.6 lib/activerecord_csv_importer/report_message.rb
activerecord_csv_importer-0.1.5 lib/activerecord_csv_importer/report_message.rb
activerecord_csv_importer-0.1.4 lib/activerecord_csv_importer/report_message.rb
activerecord_csv_importer-0.1.3 lib/activerecord_csv_importer/report_message.rb
activerecord_csv_importer-0.1.2 lib/activerecord_csv_importer/report_message.rb
activerecord_csv_importer-0.1.1 lib/activerecord_csv_importer/report_message.rb
activerecord_csv_importer-0.1.0 lib/activerecord_csv_importer/report_message.rb