card 1.101.4 → 1.101.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/config/i18n-tasks.yml +0 -5
- data/config/initializers/01_core_extensions/array.rb +2 -1
- data/config/initializers/01_core_extensions/hash.rb +1 -0
- data/config/initializers/01_core_extensions/object.rb +15 -11
- data/config/initializers/02_patches/active_job.rb +1 -1
- data/config/initializers/02_patches/active_record.rb +1 -3
- data/config/initializers/02_patches/better_errors.rb +1 -3
- data/config/initializers/02_patches/kaminari.rb +2 -2
- data/config/initializers/deck_config.rb +1 -1
- data/config/initializers/inflections.rb +1 -0
- data/config/initializers/internationalization.rb +23 -21
- data/config/initializers/mime_types.rb +1 -0
- data/config/initializers/notification.rb +1 -0
- data/config/initializers/patches.rb +6 -5
- data/config/locales/en.yml +10 -16
- data/db/migrate/20110511221913_require_earlier_migrations.rb +1 -0
- data/db/migrate/20121111025347_require_1_10_migrations.rb +1 -0
- data/db/migrate/20121118114000_split_link_type.rb +1 -0
- data/db/migrate/20121118115000_update_link_type.rb +1 -0
- data/db/migrate/20130106052640_table_cleanup.rb +2 -2
- data/db/migrate/20130109015336_trunk_left.rb +1 -0
- data/db/migrate/20130411210957_update_codenames.rb +1 -0
- data/db/migrate/20140822073704_create_new_revision_tables.rb +1 -0
- data/db/migrate/20141001105348_move_revisions_to_actions.rb +9 -3
- data/db/migrate/20141216053032_better_index_names.rb +9 -6
- data/db/migrate/20170908114442_create_delayed_jobs.rb +1 -1
- data/db/migrate/20170908114452_increase_text_size_for_delayed_jobs.rb +1 -1
- data/db/migrate/20180514152037_add_card_virtuals_table.rb +1 -1
- data/db/migrate_core_cards/20120611203506_rails_inflection_updates.rb +2 -1
- data/db/migrate_core_cards/20130411191151_renaming_for_menu.rb +9 -9
- data/db/migrate_core_cards/20130419215612_import_help_text.rb +3 -2
- data/db/migrate_core_cards/20130823192433_add_style_cards.rb +5 -5
- data/db/migrate_core_cards/20130910183318_move_styles_to_content.rb +3 -2
- data/db/migrate_core_cards/20130920291703_update_stylesheets.rb +2 -4
- data/db/migrate_core_cards/20131016172445_common_css_patch.rb +1 -3
- data/db/migrate_core_cards/20140110193325_reset_account_request_type.rb +1 -3
- data/db/migrate_core_cards/20140307231621_user_data_to_cards.rb +12 -8
- data/db/migrate_core_cards/20140317035504_account_requests_to_signups.rb +2 -4
- data/db/migrate_core_cards/20140512155840_add_script_cards.rb +16 -9
- data/db/migrate_core_cards/20140629222005_add_email_cards.rb +19 -11
- data/db/migrate_core_cards/20140725180118_config_card_updates.rb +1 -1
- data/db/migrate_core_cards/20141115034214_config_descriptions_etc.rb +1 -1
- data/db/migrate_core_cards/20141119001955_make_symlinks_relative.rb +1 -1
- data/db/migrate_core_cards/20141204061304_watchers_to_following.rb +2 -0
- data/db/migrate_core_cards/20141216155251_add_more_following_cards.rb +4 -2
- data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +1 -1
- data/db/migrate_core_cards/20150220134731_following_to_follow_rule.rb +3 -4
- data/db/migrate_core_cards/20150317162412_bootstrap_themes.rb +8 -4
- data/db/migrate_core_cards/20150326205655_bootswatch_themes.rb +14 -7
- data/db/migrate_core_cards/20150429090551_search_card_context.rb +6 -4
- data/db/migrate_core_cards/20150508212032_menu_compatibility.rb +4 -2
- data/db/migrate_core_cards/20150510031118_fix_skin_codenames.rb +2 -1
- data/db/migrate_core_cards/20150601133433_add_recent_setting_session_card.rb +3 -3
- data/db/migrate_core_cards/20150610171702_add_debugger_session_card.rb +2 -1
- data/db/migrate_core_cards/20150610180019_add_recaptcha_key_and_admin_info_cards.rb +4 -3
- data/db/migrate_core_cards/20150724123438_update_file_and_image_cards.rb +6 -2
- data/db/migrate_core_cards/20150807205221_create_references_for_search_cards.rb +1 -1
- data/db/migrate_core_cards/20150824135418_update_file_history.rb +2 -0
- data/db/migrate_core_cards/20160804112510_reorganize_scripts.rb +1 -1
- data/db/migrate_core_cards/20160811115836_rename_stats_to_admin.rb +1 -0
- data/db/migrate_core_cards/20160914132636_fix_mod_files.rb +2 -0
- data/db/migrate_core_cards/20161102202156_tweak_recaptcha_setting_cards.rb +6 -6
- data/db/migrate_core_cards/20161103154836_update_keys.rb +2 -1
- data/db/migrate_core_cards/20170209132834_email_test_context.rb +2 -0
- data/db/migrate_core_cards/20170314175313_add_notification_event_card.rb +3 -3
- data/db/migrate_core_cards/20170515101262_add_advanced_edit_cards.rb +1 -1
- data/db/migrate_core_cards/20170608200649_add_input_options_codename.rb +1 -1
- data/db/migrate_core_cards/20180712042655_head_rule.rb +3 -4
- data/db/migrate_core_cards/20180905061537_migrate_layouts.rb +4 -4
- data/db/migrate_core_cards/20181120200937_update_layout.rb +1 -1
- data/db/migrate_core_cards/20190320091257_upgrade_recaptcha_to_v3.rb +7 -7
- data/db/migrate_core_cards/20190424100531_update_credit_image.rb +1 -0
- data/db/migrate_core_cards/20190502130029_add_shark_and_help_desk_role.rb +15 -14
- data/db/migrate_core_cards/20190503122739_update_pristine_data.rb +1 -1
- data/db/migrate_core_cards/20190625153616_pointer_overhaul.rb +9 -5
- data/db/migrate_core_cards/20190718140126_add_guides.rb +3 -3
- data/db/migrate_core_cards/20190822093633_move_help_text_to_code.rb +1 -2
- data/db/migrate_core_cards/20190823220018_cleanup_for_decko_1_0.rb +1 -1
- data/db/migrate_core_cards/20190829093961_cardtype_grouping.rb +7 -7
- data/db/migrate_core_cards/20190902193208_input_type.rb +1 -3
- data/db/migrate_core_cards/20190909104250_add_cardtype_input_types.rb +2 -2
- data/db/migrate_core_cards/20191028135243_add_link_editor_to_tiny_mce_config.rb +1 -0
- data/db/migrate_core_cards/20191115160748_history_cleanup.rb +0 -1
- data/db/migrate_core_cards/20191118145629_codename_fixes.rb +1 -2
- data/db/migrate_core_cards/20200821231558_add_nest_list_type.rb +1 -1
- data/db/seed/new/card_actions.yml +2153 -2145
- data/db/seed/new/card_acts.yml +3 -3
- data/db/seed/new/card_references.yml +900 -858
- data/db/seed/new/cards.yml +4869 -4848
- data/db/seed/new/schema_migrations_deck_cards.yml +2 -0
- data/db/seed/test/fixtures/card_actions.yml +3563 -3547
- data/db/seed/test/fixtures/card_acts.yml +675 -675
- data/db/seed/test/fixtures/card_changes.yml +103 -103
- data/db/seed/test/fixtures/card_references.yml +2165 -2123
- data/db/seed/test/fixtures/cards.yml +7862 -7751
- data/db/seed/test/fixtures/schema_migrations_deck_cards.yml +2 -0
- data/db/test_seed.rb +33 -34
- data/lib/card.rb +1 -0
- data/lib/card/auth/token.rb +2 -2
- data/lib/card/cache.rb +2 -1
- data/lib/card/cache/all.rb +5 -0
- data/lib/card/cache/card_class.rb +3 -0
- data/lib/card/codename.rb +1 -1
- data/lib/card/content.rb +4 -8
- data/lib/card/content/chunk.rb +1 -1
- data/lib/card/content/clean.rb +4 -3
- data/lib/card/content/diff.rb +3 -2
- data/lib/card/content/diff/l_c_s/processor.rb +1 -1
- data/lib/card/content/diff/result.rb +1 -0
- data/lib/card/content/parser.rb +2 -2
- data/lib/card/content/truncate.rb +6 -6
- data/lib/card/director.rb +1 -1
- data/lib/card/director/all.rb +2 -2
- data/lib/card/director/card_methods.rb +1 -0
- data/lib/card/director/event_delay.rb +4 -6
- data/lib/card/director/run.rb +2 -0
- data/lib/card/director/stages.rb +3 -2
- data/lib/card/env/location.rb +4 -3
- data/lib/card/fetch.rb +7 -4
- data/lib/card/fetch/all.rb +1 -0
- data/lib/card/fetch/card_class.rb +35 -27
- data/lib/card/fetch/results.rb +9 -0
- data/lib/card/fetch/retrieve.rb +2 -0
- data/lib/card/fetch/store.rb +1 -0
- data/lib/card/format/content.rb +1 -3
- data/lib/card/format/error.rb +6 -1
- data/lib/card/format/method_delegation.rb +10 -2
- data/lib/card/format/nest.rb +2 -1
- data/lib/card/format/nest/fetch.rb +2 -0
- data/lib/card/format/nesting/mode.rb +1 -1
- data/lib/card/format/nesting/subformat.rb +2 -1
- data/lib/card/format/render.rb +2 -2
- data/lib/card/format/wrapper.rb +1 -1
- data/lib/card/lexicon.rb +3 -2
- data/lib/card/mark.rb +17 -15
- data/lib/card/model/save_helper.rb +3 -3
- data/lib/card/name.rb +10 -9
- data/lib/card/name/all.rb +3 -0
- data/lib/card/name/all/descendants.rb +3 -4
- data/lib/card/name/card_class.rb +2 -0
- data/lib/card/name/fields_and_traits.rb +4 -2
- data/lib/card/name/name_variants.rb +0 -1
- data/lib/card/query.rb +17 -17
- data/lib/card/query/card_query/interpretation.rb +1 -0
- data/lib/card/query/card_query/match_attributes.rb +2 -1
- data/lib/card/query/card_query/normalization.rb +1 -0
- data/lib/card/query/card_query/reference_attributes.rb +1 -1
- data/lib/card/query/join.rb +1 -1
- data/lib/card/query/value/match_value.rb +1 -0
- data/lib/card/reference/all.rb +7 -2
- data/lib/card/rule/all.rb +1 -0
- data/lib/card/rule/cache.rb +2 -0
- data/lib/card/set/advanced_api.rb +3 -2
- data/lib/card/set/event.rb +2 -2
- data/lib/card/set/event/all.rb +6 -0
- data/lib/card/set/event/delayed_event.rb +6 -6
- data/lib/card/set/event/options.rb +1 -0
- data/lib/card/set/format/abstract_format/view_definition.rb +1 -0
- data/lib/card/set/format/abstract_format/view_opts.rb +1 -0
- data/lib/card/set/i18n_scope.rb +4 -2
- data/lib/card/set/inheritance.rb +0 -1
- data/lib/card/set/loader.rb +0 -2
- data/lib/card/set/pattern/base.rb +3 -2
- data/lib/card/set/pattern/class_methods.rb +2 -2
- data/lib/card/set/required_field.rb +4 -1
- data/lib/card/setting.rb +3 -0
- data/lib/card/subcards.rb +3 -4
- data/lib/card/tasks/card/file_card_creator/abstract_file_card/ruby_file.rb +1 -1
- data/lib/card/tasks/card/file_card_creator/output_helper.rb +2 -4
- data/lib/card/tasks/card/migrate.rake +2 -2
- data/lib/card/view/cache.rb +6 -8
- data/lib/card/view/cache/cache_action.rb +1 -2
- data/lib/card/view/cache/stub.rb +1 -1
- data/lib/card/view/options.rb +3 -3
- data/lib/card/view/permission.rb +1 -0
- data/lib/cardio.rb +1 -1
- data/lib/cardio/migration.rb +1 -1
- data/lib/cardio/migration/deck_structure.rb +2 -4
- data/lib/cardio/migration/import.rb +2 -2
- data/lib/cardio/migration/import/import_data.rb +1 -0
- data/lib/cardio/mod.rb +1 -0
- data/lib/cardio/mod/load_strategy.rb +2 -4
- data/lib/cardio/mod/loader/set_loader.rb +2 -1
- data/lib/cardio/mod/module_template.rb +1 -0
- data/lib/cardio/modfiles.rb +2 -4
- data/lib/cardio/schema.rb +2 -4
- data/lib/cardio/utils.rb +1 -0
- data/lib/generators/card/format/format_generator.rb +1 -1
- data/lib/generators/card/migration/migration_generator.rb +2 -1
- data/lib/generators/card/mod/mod_generator.rb +3 -2
- data/lib/generators/card/set/set_generator.rb +3 -3
- data/lib/generators/card/template/template_generator.rb +1 -1
- data/mod/admin/set/self/admin.rb +6 -3
- data/mod/admin/set/self/trash.rb +1 -0
- data/mod/admin/spec/set/self/admin_spec.rb +4 -4
- data/mod/core/set/all/abort.rb +5 -5
- data/mod/core/set/all/assign_attributes.rb +5 -8
- data/mod/core/set/all/codename.rb +1 -0
- data/mod/core/set/all/collection.rb +4 -6
- data/mod/core/set/all/content.rb +3 -2
- data/mod/core/set/all/contextual_content.rb +2 -4
- data/mod/core/set/all/name_events.rb +13 -6
- data/mod/core/set/all/reference_events.rb +2 -0
- data/mod/core/set/all/states.rb +3 -3
- data/mod/core/set/all/subcards.rb +1 -1
- data/mod/core/set/all/trash.rb +5 -1
- data/mod/core/set/all/type.rb +4 -2
- data/mod/core/set/all/utils.rb +1 -1
- data/mod/core/spec/set/all/assign_attributes_spec.rb +10 -9
- data/mod/core/spec/set/all/clean_me_spec.rb +19 -4
- data/mod/core/spec/set/all/collection_spec.rb +1 -1
- data/mod/core/spec/set/all/export_spec.rb +1 -0
- data/mod/core/spec/set/all/initialize_spec.rb +11 -11
- metadata +4 -4
data/lib/card/rule/all.rb
CHANGED
data/lib/card/rule/cache.rb
CHANGED
@@ -39,12 +39,14 @@ class Card
|
|
39
39
|
def lookup_hash
|
40
40
|
rows.each_with_object({}) do |row, hash|
|
41
41
|
next unless (key = lookup_key row)
|
42
|
+
|
42
43
|
hash[key] = row["rule_id"].to_i
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
46
47
|
def lookup_key row
|
47
48
|
return false unless (setting_code = setting_code(row))
|
49
|
+
|
48
50
|
anchor_id = row["anchor_id"]
|
49
51
|
return false unless (pattern_code = pattern_code(anchor_id, row))
|
50
52
|
|
@@ -10,8 +10,8 @@ class Card
|
|
10
10
|
def ensure_set &block
|
11
11
|
set_module = yield
|
12
12
|
set_module = card_set_module_const_get(set_module) unless set_module.is_a?(Module)
|
13
|
-
rescue NameError =>
|
14
|
-
define_set_from_error
|
13
|
+
rescue NameError => e
|
14
|
+
define_set_from_error e
|
15
15
|
# try again - there might be another submodule that doesn't exist
|
16
16
|
ensure_set(&block)
|
17
17
|
else
|
@@ -21,6 +21,7 @@ class Card
|
|
21
21
|
def define_set_from_error error
|
22
22
|
match = error.message.match(/uninitialized constant (?:Card::Set::)?(.+)$/)
|
23
23
|
return unless match
|
24
|
+
|
24
25
|
define_set match[1]
|
25
26
|
end
|
26
27
|
|
data/lib/card/set/event.rb
CHANGED
@@ -156,8 +156,8 @@ class Card
|
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
159
|
-
def rescuing_if_integration is_integration
|
160
|
-
is_integration ? rescuing_integration
|
159
|
+
def rescuing_if_integration is_integration, &block
|
160
|
+
is_integration ? rescuing_integration(&block) : yield
|
161
161
|
end
|
162
162
|
|
163
163
|
# one failed integration event should not harm others.
|
data/lib/card/set/event/all.rb
CHANGED
@@ -31,6 +31,7 @@ class Card
|
|
31
31
|
# @param old_sets [True/False] whether to use the old_sets
|
32
32
|
def set_condition_card old_sets
|
33
33
|
return self if old_sets || no_current_action?
|
34
|
+
|
34
35
|
@set_condition_card ||=
|
35
36
|
updating_sets? ? set_condition_card_with_new_set_modules : self
|
36
37
|
end
|
@@ -57,8 +58,10 @@ class Card
|
|
57
58
|
|
58
59
|
def changed_condition_applies? _event, db_columns
|
59
60
|
return true unless action == :update
|
61
|
+
|
60
62
|
db_columns = Array(db_columns).compact
|
61
63
|
return true if db_columns.empty?
|
64
|
+
|
62
65
|
db_columns.any? { |col| single_changed_condition_applies? col }
|
63
66
|
end
|
64
67
|
alias_method :changing_condition_applies?, :changed_condition_applies?
|
@@ -73,11 +76,13 @@ class Card
|
|
73
76
|
|
74
77
|
def single_changed_condition_applies? db_column
|
75
78
|
return true unless db_column
|
79
|
+
|
76
80
|
send "#{db_column}_is_changing?"
|
77
81
|
end
|
78
82
|
|
79
83
|
def wrong_stage opts
|
80
84
|
return false if director.stage_ok? opts
|
85
|
+
|
81
86
|
if !stage
|
82
87
|
"phase method #{method} called outside of event phases"
|
83
88
|
else
|
@@ -87,6 +92,7 @@ class Card
|
|
87
92
|
|
88
93
|
def wrong_action actn
|
89
94
|
return false if on_condition_applies?(nil, actn)
|
95
|
+
|
90
96
|
"on: #{actn} method #{method} called on #{action}"
|
91
97
|
end
|
92
98
|
end
|
@@ -59,9 +59,9 @@ class Card
|
|
59
59
|
|
60
60
|
def handle_perform
|
61
61
|
yield
|
62
|
-
rescue StandardError =>
|
63
|
-
Card::Error.report
|
64
|
-
raise
|
62
|
+
rescue StandardError => e
|
63
|
+
Card::Error.report e, @card
|
64
|
+
raise e
|
65
65
|
ensure
|
66
66
|
Director.expire
|
67
67
|
end
|
@@ -121,7 +121,7 @@ class Card
|
|
121
121
|
end
|
122
122
|
|
123
123
|
def serialize_hash_value value
|
124
|
-
value.
|
124
|
+
value.transform_values { |v| serialize_value(v) }
|
125
125
|
end
|
126
126
|
|
127
127
|
def deserialize_value val, type
|
@@ -138,8 +138,8 @@ class Card
|
|
138
138
|
end
|
139
139
|
|
140
140
|
def deserialize_hash_value value
|
141
|
-
value.
|
142
|
-
|
141
|
+
value.transform_values do |v|
|
142
|
+
deserialize_value v[:value], v[:type]
|
143
143
|
end
|
144
144
|
end
|
145
145
|
end
|
@@ -73,6 +73,7 @@ class Card
|
|
73
73
|
stage = opts.delete :stage
|
74
74
|
after_subcards = opts.delete :after_subcards
|
75
75
|
return if opts[:after] || opts[:before] || opts[:around] || !(@stage = stage)
|
76
|
+
|
76
77
|
# after, before, or around will override stage configuration
|
77
78
|
|
78
79
|
opts[:after] = callback_name stage, after_subcards
|
data/lib/card/set/i18n_scope.rb
CHANGED
@@ -6,6 +6,7 @@ class Card
|
|
6
6
|
# return scope for I18n
|
7
7
|
def scope backtrace
|
8
8
|
return "lib" unless (parts = path_parts backtrace)
|
9
|
+
|
9
10
|
index = path_set_index parts
|
10
11
|
mod = mod_from_parts parts, index
|
11
12
|
mod || "lib"
|
@@ -33,15 +34,16 @@ class Card
|
|
33
34
|
end
|
34
35
|
|
35
36
|
def mod_without_version_suffix mod
|
36
|
-
mod.gsub(/-[\d
|
37
|
+
mod.gsub(/-[\d.]+$/, "")
|
37
38
|
end
|
38
39
|
|
39
40
|
def mod_without_tmp_prefix mod
|
40
|
-
mod.gsub(/^[^-]
|
41
|
+
mod.gsub(/^[^-]*-/, "")
|
41
42
|
end
|
42
43
|
|
43
44
|
def path_parts backtrace
|
44
45
|
return unless (path = find_set_path backtrace)
|
46
|
+
|
45
47
|
parts = path.split File::SEPARATOR
|
46
48
|
parts[-1] = parts.last.split(".").first
|
47
49
|
parts
|
data/lib/card/set/inheritance.rb
CHANGED
data/lib/card/set/loader.rb
CHANGED
@@ -7,6 +7,7 @@ class Card
|
|
7
7
|
|
8
8
|
def initialize card
|
9
9
|
return if self.class.anchorless?
|
10
|
+
|
10
11
|
@anchor_name = self.class.anchor_name(card).to_name
|
11
12
|
@anchor_id = find_anchor_id card
|
12
13
|
end
|
@@ -17,6 +18,7 @@ class Card
|
|
17
18
|
|
18
19
|
def module_key
|
19
20
|
return @module_key if defined? @module_key
|
21
|
+
|
20
22
|
@module_key = self.class.module_key anchor_codenames
|
21
23
|
end
|
22
24
|
|
@@ -35,8 +37,7 @@ class Card
|
|
35
37
|
|
36
38
|
def anchor_codenames
|
37
39
|
anchor_parts.map do |part|
|
38
|
-
|
39
|
-
Card::Codename[part_id] || break
|
40
|
+
part.cardname&.code || break
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
@@ -35,7 +35,7 @@ class Card
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def pattern_applies? card
|
38
|
-
junction_only? ? card.name.
|
38
|
+
junction_only? ? card.name.compound? : true
|
39
39
|
end
|
40
40
|
|
41
41
|
def anchor_parts_count
|
@@ -63,7 +63,7 @@ class Card
|
|
63
63
|
def quick_type name
|
64
64
|
if name.present?
|
65
65
|
card = Card.fetch name, skip_modules: true, new: {}
|
66
|
-
card.include_set_modules if card.new? && name.to_name.
|
66
|
+
card.include_set_modules if card.new? && name.to_name.compound?
|
67
67
|
card&.type_name
|
68
68
|
else
|
69
69
|
"RichText"
|
@@ -29,6 +29,7 @@ class Card
|
|
29
29
|
|
30
30
|
def define_field_test
|
31
31
|
return unless (test = event_test)
|
32
|
+
|
32
33
|
method_name = field_test_name
|
33
34
|
field_set.class_exec do
|
34
35
|
define_method method_name do
|
@@ -39,13 +40,15 @@ class Card
|
|
39
40
|
|
40
41
|
def field_test_name
|
41
42
|
return unless event_test
|
43
|
+
|
42
44
|
"_when_left_#{event_test}".to_sym
|
43
45
|
end
|
44
46
|
|
45
47
|
def event_test
|
46
48
|
return @event_test unless @event_test.nil?
|
49
|
+
|
47
50
|
test = options[:when]
|
48
|
-
@event_test = test
|
51
|
+
@event_test = test.is_a?(Symbol) ? test : false
|
49
52
|
end
|
50
53
|
|
51
54
|
def field_set
|
data/lib/card/setting.rb
CHANGED
@@ -9,6 +9,7 @@ class Card
|
|
9
9
|
# O = Card['*create'] (object)
|
10
10
|
# accessible in E
|
11
11
|
attr_accessor :codename
|
12
|
+
|
12
13
|
# accessible in E and M
|
13
14
|
mattr_accessor :groups, :preferences
|
14
15
|
|
@@ -78,6 +79,7 @@ class Card
|
|
78
79
|
|
79
80
|
def applies_to_prototype? prototype
|
80
81
|
return true unless applies
|
82
|
+
|
81
83
|
applies.call(prototype)
|
82
84
|
end
|
83
85
|
|
@@ -114,6 +116,7 @@ class Card
|
|
114
116
|
|
115
117
|
def permitted_type_ids types
|
116
118
|
return unless types
|
119
|
+
|
117
120
|
type_ids = Array.wrap(types).flatten.map do |cardtype|
|
118
121
|
Card::Codename.id cardtype
|
119
122
|
end
|
data/lib/card/subcards.rb
CHANGED
@@ -16,6 +16,7 @@ class Card
|
|
16
16
|
include Relate
|
17
17
|
|
18
18
|
attr_accessor :context_card, :keys
|
19
|
+
|
19
20
|
def initialize context_card
|
20
21
|
@context_card = context_card
|
21
22
|
@keys = ::Set.new
|
@@ -73,10 +74,8 @@ class Card
|
|
73
74
|
end.compact
|
74
75
|
end
|
75
76
|
|
76
|
-
def each_card
|
77
|
-
cards.each
|
78
|
-
yield card
|
79
|
-
end
|
77
|
+
def each_card &block
|
78
|
+
cards.each(&block)
|
80
79
|
end
|
81
80
|
|
82
81
|
alias_method :each, :each_card
|
@@ -2,15 +2,13 @@ class Card
|
|
2
2
|
class FileCardCreator
|
3
3
|
# Helper methods to write to files and the console.
|
4
4
|
module OutputHelper
|
5
|
-
def write_to_mod rel_dir, filename
|
5
|
+
def write_to_mod rel_dir, filename, &block
|
6
6
|
dir = File.join "mod", @mod, rel_dir
|
7
7
|
FileUtils.mkdir_p(dir) unless Dir.exist?(dir)
|
8
8
|
|
9
9
|
path = File.join dir, filename
|
10
10
|
log_file_action path do
|
11
|
-
File.open(path, "w")
|
12
|
-
yield(opened_file)
|
13
|
-
end
|
11
|
+
File.open(path, "w", &block)
|
14
12
|
end
|
15
13
|
end
|
16
14
|
|
@@ -24,7 +24,7 @@ def reset_column_information mod=false
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def load_mod_lib
|
27
|
-
Dir.glob(Cardio.root.join("mod/*/lib/*.rb")).each { |x| require x }
|
27
|
+
Dir.glob(Cardio.root.join("mod/*/lib/*.rb")).sort.each { |x| require x }
|
28
28
|
end
|
29
29
|
|
30
30
|
def without_dumping
|
@@ -100,7 +100,7 @@ namespace :card do
|
|
100
100
|
|
101
101
|
Cardio.schema_mode args[:type] do
|
102
102
|
version = ActiveRecord::Migrator.current_version
|
103
|
-
if version.to_i
|
103
|
+
if version.to_i.positive? && (file = ::File.open(stamp_file, "w"))
|
104
104
|
puts ">> writing version: #{version} to #{stamp_file}"
|
105
105
|
file.puts version
|
106
106
|
end
|
data/lib/card/view/cache.rb
CHANGED
@@ -194,8 +194,8 @@ class Card
|
|
194
194
|
# those stubs.
|
195
195
|
#
|
196
196
|
# @return [String (usually)] rendered view
|
197
|
-
def cache_render
|
198
|
-
cached_view = cache_fetch
|
197
|
+
def cache_render &block
|
198
|
+
cached_view = cache_fetch(&block)
|
199
199
|
cache_active? ? cached_view : format.stub_render(cached_view)
|
200
200
|
end
|
201
201
|
|
@@ -212,18 +212,16 @@ class Card
|
|
212
212
|
|
213
213
|
# If view is cached, retrieve it. Otherwise render and store it.
|
214
214
|
# Uses the primary cache API.
|
215
|
-
def cache_fetch
|
215
|
+
def cache_fetch &block
|
216
216
|
caching do
|
217
217
|
ensure_cache_key
|
218
|
-
self.class.cache.fetch cache_key
|
219
|
-
yield
|
220
|
-
end
|
218
|
+
self.class.cache.fetch cache_key, &block
|
221
219
|
end
|
222
220
|
end
|
223
221
|
|
224
222
|
# keep track of nested cache fetching
|
225
|
-
def caching
|
226
|
-
self.class.caching(self)
|
223
|
+
def caching &block
|
224
|
+
self.class.caching(self, &block)
|
227
225
|
end
|
228
226
|
|
229
227
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
@@ -14,12 +14,11 @@ class Card
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def log_cache_action
|
17
|
-
|
17
|
+
yield
|
18
18
|
# TODO: make configurable
|
19
19
|
# ...or better yet, integrate into performance logger...
|
20
20
|
# Rails.logger.warn "VIEW CACHE #{cache_active? ? '-->' : ''}[#{action}] "\
|
21
21
|
# "(#{card.name}##{requested_view})"
|
22
|
-
action
|
23
22
|
end
|
24
23
|
|
25
24
|
# @return [Symbol] :off, :active, or :free
|
data/lib/card/view/cache/stub.rb
CHANGED
data/lib/card/view/options.rb
CHANGED
@@ -51,11 +51,11 @@ class Card
|
|
51
51
|
:structure, # overrides the content of the card
|
52
52
|
:title, # overrides the name of the card
|
53
53
|
:variant, # override the canonical version of the name with a different
|
54
|
-
|
54
|
+
# variant
|
55
55
|
:input_type, # inline_nests makes a form within standard content (Symbol)
|
56
56
|
:type, # set the default type of new cards
|
57
57
|
:size, # set an image size
|
58
|
-
|
58
|
+
# (also used for character limit in one_line_content)
|
59
59
|
:params, # parameters for add button. deprecated!
|
60
60
|
:items, # options for items (Hash)
|
61
61
|
:cache, # change view cache behaviour
|
@@ -71,7 +71,7 @@ class Card
|
|
71
71
|
:layout #
|
72
72
|
]
|
73
73
|
}
|
74
|
-
#
|
74
|
+
# NOTE: option values are strings unless otherwise noted
|
75
75
|
|
76
76
|
class << self
|
77
77
|
attr_reader :keymap
|