Module: Cardio

Extended by:
Delaying
Defined in:
lib/cardio/commands.rb,
lib/cardio.rb,
lib/cardio/job.rb,
lib/cardio/mod.rb,
lib/cardio/seed.rb,
lib/cardio/utils.rb,
lib/cardio/record.rb,
lib/cardio/schema.rb,
lib/cardio/command.rb,
lib/cardio/mod/eat.rb,
lib/cardio/mod/sow.rb,
lib/cardio/railtie.rb,
lib/cardio/version.rb,
lib/cardio/delaying.rb,
lib/cardio/mod/dirs.rb,
lib/cardio/migration.rb,
lib/cardio/generators.rb,
lib/cardio/mod/loader.rb,
lib/cardio/script_loader.rb,
lib/cardio/command/custom.rb,
lib/cardio/migration/core.rb,
lib/cardio/generators/base.rb,
lib/cardio/mod/eat/edibles.rb,
lib/cardio/mod/modfile_api.rb,
lib/cardio/mod/class_methods.rb,
lib/cardio/mod/load_strategy.rb,
lib/cardio/mod/modfile_loader.rb,
lib/cardio/generators/mod_base.rb,
lib/cardio/mod/module_template.rb,
lib/cardio/command/command_base.rb,
lib/cardio/command/rake_command.rb,
lib/cardio/command/rspec_command.rb,
lib/cardio/mod/loader/set_loader.rb,
lib/generators/mod/mod_generator.rb,
lib/generators/set/set_generator.rb,
lib/cardio/generators/deck_helper.rb,
lib/cardio/mod/load_strategy/eval.rb,
lib/cardio/mod/loader/set_template.rb,
lib/generators/deck/deck_generator.rb,
lib/cardio/migration/deck_structure.rb,
lib/cardio/generators/rails_overrides.rb,
lib/cardio/mod/load_strategy/tmp_files.rb,
lib/cardio/command/rspec_command/parser.rb,
lib/cardio/mod/loader/set_pattern_loader.rb,
lib/cardio/mod/load_strategy/set_tmp_files.rb,
lib/generators/migration/migration_generator.rb,
lib/cardio/mod/load_strategy/pattern_tmp_files.rb,
lib/cardio/mod/load_strategy/set_binding_magic.rb

Overview

We could have used CommandsBase (and may yet move to that), but it’s worth noting that this might have caused its own confusion with CommandBase, a base class for classes that handle specific kinds of commands.

Defined Under Namespace

Modules: Delaying, Generators, Schema, ScriptLoader, Seed, Utils, Version Classes: Command, Commands, Job, Migration, Mod, Railtie, Record

Constant Summary collapse

Application =

The application class from which card applications inherit

Rails::Application

Class Method Summary collapse

Methods included from Delaying

delaying!, delaying?

Class Method Details

.cacheObject



37
38
39
# File 'lib/cardio.rb', line 37

def cache
  @cache ||= ::Rails.cache
end

.card_defined?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/cardio.rb', line 22

def card_defined?
  const_defined? "Card"
end

.databaseObject



41
42
43
# File 'lib/cardio.rb', line 41

def database
  @database ||= config.database_configuration.dig Rails.env, "database"
end

.gem_rootObject



18
19
20
# File 'lib/cardio.rb', line 18

def gem_root
  @gem_root ||= File.expand_path "..", __dir__
end

.load_card!Object



32
33
34
35
# File 'lib/cardio.rb', line 32

def load_card!
  require "card"
  ActiveSupport.run_load_hooks :after_card
end

.load_card?Boolean

Returns:

  • (Boolean)


26
27
28
29
30
# File 'lib/cardio.rb', line 26

def load_card?
  ActiveRecord::Base.connection && !card_defined?
rescue StandardError
  false
end

.modsObject



45
46
47
# File 'lib/cardio.rb', line 45

def mods
  Mod.dirs.mods
end

.with_config(tmp) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/cardio.rb', line 49

def with_config tmp
  keep = tmp.keys.each_with_object({}) { |k, h| h[k] = config.send k }
  tmp.each { |k, v| config.send "#{k}=", v }
  yield
ensure
  keep.each { |k, v| config.send "#{k}=", v }
end