Class: ZipFileBuilder

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

Constant Summary collapse

THEMES_PATH =
File.join('public', 'vinsol_spree_themes')
INVALID_DIRECTORIES =
['.', '..', 'precompiled_assets']

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(theme) ⇒ ZipFileBuilder

Returns a new instance of ZipFileBuilder.



10
11
12
13
14
15
# File 'app/services/zip_file_builder.rb', line 10

def initialize(theme)
  @theme = theme
  @name = name
  input_theme_directory_path
  output_zip_file_path
end

Instance Attribute Details

#entriesObject (readonly)

Returns the value of attribute entries.



8
9
10
# File 'app/services/zip_file_builder.rb', line 8

def entries
  @entries
end

#input_pathObject (readonly)

Returns the value of attribute input_path.



8
9
10
# File 'app/services/zip_file_builder.rb', line 8

def input_path
  @input_path
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'app/services/zip_file_builder.rb', line 8

def name
  @name
end

#output_pathObject (readonly)

Returns the value of attribute output_path.



8
9
10
# File 'app/services/zip_file_builder.rb', line 8

def output_path
  @output_path
end

#themeObject (readonly)

Returns the value of attribute theme.



8
9
10
# File 'app/services/zip_file_builder.rb', line 8

def theme
  @theme
end

#zipObject (readonly)

Returns the value of attribute zip.



8
9
10
# File 'app/services/zip_file_builder.rb', line 8

def zip
  @zip
end

Instance Method Details

#archiveObject



17
18
19
20
21
22
# File 'app/services/zip_file_builder.rb', line 17

def archive
  remove
  @entries = get_directory_content(input_theme_directory_path)
  delete_non_zip_content(@entries)
  build_zip_file
end

#removeObject



24
25
26
# File 'app/services/zip_file_builder.rb', line 24

def remove
  File.delete(output_path) if File.exist?(output_path)
end