Module: Cardio::Utils

Defined in:
lib/cardio/utils.rb

Overview

Utilities that may need to be run even when mods are not loaded.

Class Method Summary collapse

Class Method Details

.delete_tmp_files!(id = nil) ⇒ Object

deletes tmp directory within files directory It’s here because it gets called as part of cache clearing, which sometimes gets called in a context where card mods are not loaded. Why does cache clearing need to do this??



23
24
25
26
27
28
29
# File 'lib/cardio/utils.rb', line 23

def delete_tmp_files! id=nil
  raise "no files directory" unless files_dir

  delete_tmp_files id
rescue StandardError
  Rails.logger.info "failed to remove tmp files"
end

.empty_trashObject



5
6
7
8
9
10
11
12
13
# File 'lib/cardio/utils.rb', line 5

def empty_trash
  delete_trashed_files
  Card.where(trash: true).in_batches.update_all(left_id: nil, right_id: nil)
  Card.where(trash: true).in_batches.delete_all
  Card::Action.delete_cardless
  Card::Change.delete_actionless
  Card::Act.delete_actionless
  Card::Reference.clean
end

.seed_test_dbObject



15
16
17
# File 'lib/cardio/utils.rb', line 15

def seed_test_db
  system "env RAILS_ENV=test bundle exec rake db:seed:replant"
end