Sha256: da530597782fec870d0e68e8169fea7d527e94d97d3932712ba68e430927a2b8

Contents?: true

Size: 1.01 KB

Versions: 36

Compression:

Stored size: 1.01 KB

Contents

require 'fileutils'

namespace :pageflow do
  namespace :entries do
    desc 'Export a single entry specified by its ID.'
    task :export, [:entry_id] => :environment do |_t, args|
      current_timestamp = Time.now.strftime('%Y%m%d%H%M%S')
      entry = Pageflow::Entry.includes(:draft, :published_revision).find(args[:entry_id])
      archive_file_name = Rails.root.join(
        "tmp/entries_export_#{current_timestamp}/entry_#{entry.id}.zip"
      )

      FileUtils.mkdir_p(File.dirname(archive_file_name))
      Pageflow::EntryExportImport.export(entry, archive_file_name)
    end

    desc 'Import entries from file containing one or multiple lines of JSON describing an entry.'
    task :import, [:archive_file_path, :user_id] => :environment do |_t, args|
      archive_file_path = args[:archive_file_path]
      raise 'Could not find JSON file for import' unless File.exist?(archive_file_path)

      user = User.find(args[:user_id])

      Pageflow::EntryExportImport.import(archive_file_path, creator: user)
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
pageflow-17.0.4 lib/tasks/entry_export_import.rake
pageflow-17.0.3 lib/tasks/entry_export_import.rake
pageflow-17.0.2 lib/tasks/entry_export_import.rake
pageflow-17.0.1 lib/tasks/entry_export_import.rake
pageflow-17.0.0 lib/tasks/entry_export_import.rake
pageflow-16.2.0 lib/tasks/entry_export_import.rake
pageflow-16.1.0 lib/tasks/entry_export_import.rake
pageflow-16.0.0 lib/tasks/entry_export_import.rake
pageflow-15.8.0 lib/tasks/entry_export_import.rake
pageflow-15.7.1 lib/tasks/entry_export_import.rake
pageflow-15.7.0 lib/tasks/entry_export_import.rake
pageflow-15.6.1 lib/tasks/entry_export_import.rake
pageflow-15.6.0 lib/tasks/entry_export_import.rake
pageflow-15.5.0 lib/tasks/entry_export_import.rake
pageflow-15.4.0 lib/tasks/entry_export_import.rake
pageflow-15.3.0 lib/tasks/entry_export_import.rake
pageflow-15.2.2 lib/tasks/entry_export_import.rake
pageflow-15.2.1 lib/tasks/entry_export_import.rake
pageflow-15.2.0 lib/tasks/entry_export_import.rake
pageflow-15.1.2 lib/tasks/entry_export_import.rake