Module: Cardio::Utils

Included in:
Cardio
Defined in:
lib/cardio/utils.rb

Overview

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

Instance Method Summary collapse

Instance 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??



18
19
20
21
22
23
# File 'lib/cardio/utils.rb', line 18

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

#seed_test_dbObject



10
11
12
# File 'lib/cardio/utils.rb', line 10

def seed_test_db
  system "env RAILS_ENV=test bundle exec rake db:fixtures:load"
end

#tr(key, args = {}) ⇒ Object



4
5
6
7
8
# File 'lib/cardio/utils.rb', line 4

def tr key, args={}
  kaller = args.delete(:caller) || caller
  args[:scope] ||= Card::Set.scope kaller
  ::I18n.t key, args
end