Class: Decidim::DownloadYourDataExporter
- Inherits:
-
Object
- Object
- Decidim::DownloadYourDataExporter
- Defined in:
- app/services/decidim/download_your_data_exporter.rb
Overview
Public: Generates a 7z(seven zip) file with data files ready to be persisted somewhere so users can download their data.
In fact, the 7z file wraps a ZIP file which finally contains the data files.
Constant Summary collapse
- DEFAULT_EXPORT_FORMAT =
"CSV"
- ZIP_FILE_NAME =
"download-your-data.zip"
Instance Method Summary collapse
- #export ⇒ Object
-
#initialize(user, path, password, export_format = DEFAULT_EXPORT_FORMAT) ⇒ DownloadYourDataExporter
constructor
Public: Initializes the class.
Constructor Details
#initialize(user, path, password, export_format = DEFAULT_EXPORT_FORMAT) ⇒ DownloadYourDataExporter
Public: Initializes the class.
user - The user to export the data from. path - The String path where to write the zip file. password - The password to protect the zip file. export_format - The format of the data files inside the zip file. (CSV by default)
20 21 22 23 24 25 |
# File 'app/services/decidim/download_your_data_exporter.rb', line 20 def initialize(user, path, password, export_format = DEFAULT_EXPORT_FORMAT) @user = user @path = File. path @export_format = export_format @password = password end |
Instance Method Details
#export ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'app/services/decidim/download_your_data_exporter.rb', line 27 def export tmpdir = Dir.mktmpdir("temporary-download-your-data-dir") user_data, = save_user_data(tmpdir, user_data) (tmpdir, ) SevenZipWrapper.compress_and_encrypt(filename: @path, password: @password, input_directory: tmpdir) end |