Class: Railspress::ContentImportService

Inherits:
Object
  • Object
show all
Defined in:
app/services/railspress/content_import_service.rb

Defined Under Namespace

Classes: Result

Constant Summary collapse

MAX_ZIP_SIZE =
50.megabytes
MAX_ENTRIES =
500
SUPPORTED_IMAGE_TYPES =
%w[.jpg .jpeg .png .gif .webp].freeze

Instance Method Summary collapse

Constructor Details

#initialize(zip_file) ⇒ ContentImportService

Returns a new instance of ContentImportService.



23
24
25
26
27
28
29
30
# File 'app/services/railspress/content_import_service.rb', line 23

def initialize(zip_file)
  @zip_file = zip_file
  @created = 0
  @updated = 0
  @restored = 0
  @errors = []
  @extract_dir = nil
end

Instance Method Details

#callObject



32
33
34
35
36
37
38
# File 'app/services/railspress/content_import_service.rb', line 32

def call
  validate_zip_size!
  extract_and_process
  Result.new(created: @created, updated: @updated, restored: @restored, errors: @errors)
ensure
  cleanup_temp_dir
end