diff --git a/app/service/csv_service.rb b/app/service/csv_service.rb new file mode 100644 index 0000000..7b9810b --- /dev/null +++ b/app/service/csv_service.rb @@ -0,0 +1,10 @@ +require 'csv' + +class CsvService + attr_accessor :filepath, :csv_table + + def initialize(filepath) + @filepath = filepath + @csv_table = CSV.read(filepath, headers: true) + end +end diff --git a/app/service/file_service.rb b/app/service/file_service.rb new file mode 100644 index 0000000..ec70260 --- /dev/null +++ b/app/service/file_service.rb @@ -0,0 +1,5 @@ +class FileService + def initialize + # TODO: 書く + end +end diff --git a/app/service/import_service/title.rb b/app/service/import_service/title.rb new file mode 100644 index 0000000..d8dc43a --- /dev/null +++ b/app/service/import_service/title.rb @@ -0,0 +1,20 @@ +module ImportService + class Title + def execute + ActiveRecord::Base.transaction do + ::Title.import(columns, values, validate: true) + end + end + + def columns + [:name] + end + + def values + [ + ['abc'], + ['def'], + ] + end + end +end