2024-03-07 22:48:01 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class RepositoryExportService
|
2024-04-09 10:20:23 +08:00
|
|
|
def initialize(file_type, rows, columns, user, repository, handle_name_func = nil, in_module: false, empty_export: false)
|
2024-03-07 22:48:01 +08:00
|
|
|
@file_type = file_type
|
|
|
|
@user = user
|
|
|
|
@rows = rows
|
|
|
|
@columns = columns
|
|
|
|
@repository = repository
|
|
|
|
@handle_name_func = handle_name_func
|
|
|
|
@in_module = in_module
|
2024-04-09 10:18:20 +08:00
|
|
|
@empty_export = empty_export
|
2024-03-07 22:48:01 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def export!
|
|
|
|
case @file_type
|
|
|
|
when :csv
|
2024-04-09 10:18:20 +08:00
|
|
|
file_data = RepositoryCsvExport.to_csv(@rows, @columns, @user, @repository, @handle_name_func, @in_module, @empty_export)
|
2024-03-07 22:48:01 +08:00
|
|
|
when :xlsx
|
|
|
|
file_data = RepositoryXlsxExport.to_xlsx(@rows, @columns, @user, @repository, @handle_name_func, @in_module)
|
|
|
|
end
|
|
|
|
|
|
|
|
file_data
|
|
|
|
end
|
|
|
|
end
|