Module: Cardio
- Extended by:
- Schema
- Defined in:
- lib/cardio.rb,
lib/cardio/schema.rb
Defined Under Namespace
Modules: Schema
Constant Summary collapse
- CARD_GEM_ROOT =
File.("../..", __FILE__)
Class Method Summary collapse
- .add_initializers(dir) ⇒ Object
- .add_mod_initializers(mod_path) ⇒ Object
- .add_path(path, options = {}) ⇒ Object
- .cache ⇒ Object
- .default_configs ⇒ Object
- .each_mod_path ⇒ Object
- .future_stamp ⇒ Object
- .gem_root ⇒ Object
- .migration_paths(type) ⇒ Object
- .read_only? ⇒ Boolean
- .root ⇒ Object
- .set_config(config) ⇒ Object
- .set_db_paths ⇒ Object
-
.set_default_value(config, setting, *value) ⇒ Object
In production mode set_config gets called twice.
- .set_initializer_paths ⇒ Object
- .set_mod_paths ⇒ Object
- .set_paths(paths) ⇒ Object
Methods included from Schema
assume_migrated_upto_version, schema, schema_mode, schema_stamp_path, schema_suffix, with_suffix
Class Method Details
.add_initializers(dir) ⇒ Object
130 131 132 133 134 |
# File 'lib/cardio.rb', line 130 def add_initializers dir Dir.glob("#{dir}/config/initializers").each do |initializers_dir| paths["config/initializers"] << initializers_dir end end |
.add_mod_initializers(mod_path) ⇒ Object
124 125 126 127 128 |
# File 'lib/cardio.rb', line 124 def add_mod_initializers mod_path Dir.glob("#{mod_path}/*/config/initializers").each do |initializers_dir| paths["mod/config/initializers"] << initializers_dir end end |
.add_path(path, options = {}) ⇒ Object
150 151 152 153 154 |
# File 'lib/cardio.rb', line 150 def add_path path, ={} root = .delete(:root) || gem_root [:with] = File.join(root, ([:with] || path)) paths.add path, end |
.cache ⇒ Object
23 24 25 |
# File 'lib/cardio.rb', line 23 def cache @cache ||= ::Rails.cache end |
.default_configs ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/cardio.rb', line 27 def default_configs { read_only: read_only?, allow_inline_styles: false, recaptcha_public_key: nil, recaptcha_private_key: nil, recaptcha_proxy: nil, override_host: nil, override_protocol: nil, no_authentication: false, files_web_path: "files", max_char_count: 200, max_depth: 20, email_defaults: nil, token_expiry: 2.days, acts_per_page: 10, space_last_in_multispace: true, closed_search_limit: 10, paging_limit: 20, non_createable_types: [%w(signup setting set)], view_cache: true, encoding: "utf-8", request_logger: false, performance_logger: false, sql_comments: true, file_storage: :local, file_buckets: {}, file_default_bucket: nil, allow_irreversible_admin_tasks: false } end |
.each_mod_path ⇒ Object
136 137 138 139 140 |
# File 'lib/cardio.rb', line 136 def each_mod_path paths["mod"].each do |mod_path| yield mod_path end end |
.future_stamp ⇒ Object
156 157 158 159 |
# File 'lib/cardio.rb', line 156 def future_stamp # # used in test data @future_stamp ||= Time.zone.local 2020, 1, 1, 0, 0, 0 end |
.gem_root ⇒ Object
146 147 148 |
# File 'lib/cardio.rb', line 146 def gem_root CARD_GEM_ROOT end |
.migration_paths(type) ⇒ Object
161 162 163 164 165 166 167 168 169 170 |
# File 'lib/cardio.rb', line 161 def migration_paths type list = paths["db/migrate#{schema_suffix type}"].to_a if type == :deck_cards Card::Mod.dirs.each("db/migrate_cards") do |path| list += Dir.glob path end end list.flatten end |
.read_only? ⇒ Boolean
82 83 84 |
# File 'lib/cardio.rb', line 82 def read_only? !ENV["DECKO_READ_ONLY"].nil? end |
.set_config(config) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/cardio.rb', line 68 def set_config config @@config = config config.autoload_paths += Dir["#{gem_root}/lib/**/"] config.autoload_paths += Dir["#{gem_root}/mod/*/lib/**/"] config.autoload_paths += Dir["#{root}/mod/*/lib/**/"] #config.autoload_paths += Dir["#{root}/mod/*/set/**/"] default_configs.each_pair do |setting, value| set_default_value(config, setting, *value) end end |
.set_db_paths ⇒ Object
104 105 106 107 108 109 110 |
# File 'lib/cardio.rb', line 104 def set_db_paths add_path "db" add_path "db/migrate" add_path "db/migrate_core_cards" add_path "db/migrate_deck_cards", root: root, with: "db/migrate_cards" add_path "db/seeds.rb", with: "db/seeds.rb" end |
.set_default_value(config, setting, *value) ⇒ Object
In production mode set_config gets called twice. The second call overrides all deck config settings so don't change settings here if they already exist
89 90 91 |
# File 'lib/cardio.rb', line 89 def set_default_value config, setting, *value config.send("#{setting}=", *value) unless config.respond_to? setting end |
.set_initializer_paths ⇒ Object
112 113 114 115 116 |
# File 'lib/cardio.rb', line 112 def set_initializer_paths add_path "config/initializers", glob: "**/*.rb" add_path "mod/config/initializers", glob: "**/*.rb" add_initializers root end |
.set_mod_paths ⇒ Object
118 119 120 121 122 |
# File 'lib/cardio.rb', line 118 def set_mod_paths each_mod_path do |mod_path| add_mod_initializers mod_path end end |