1
0
Fork 0

Add interactor ImportAll

This commit is contained in:
Alex Kotov 2019-08-18 09:44:29 +05:00
parent 1ddd6be5d7
commit 4a7a273a31
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
3 changed files with 31 additions and 0 deletions

View file

@ -0,0 +1,22 @@
# frozen_string_literal: true
class ImportAll
include Interactor
def dirname
@dirname ||= Pathname.new(context.dirname).realpath.freeze
end
def call
import 'LPR_PEOPLE_ALL.csv', ImportPerson
import 'LPR_CONTACTS_ALL.csv', ImportContact
end
private
def import(filename, interactor)
CSV.read(dirname.join(filename), col_sep: ';').drop(1).each do |row|
interactor.call row: row
end
end
end

View file

@ -18,6 +18,8 @@ require 'sprockets/railtie'
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
require 'csv'
module Partynest
class Application < Rails::Application
FILTER_PARAMS = %i[

View file

@ -0,0 +1,7 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ImportAll do
pending "add some examples to (or delete) #{__FILE__}"
end