card 1.99.1 → 1.99.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/config/initializers/01_core_extensions/array.rb +1 -0
- data/config/initializers/01_core_extensions/persistent_identifiers.rb +1 -1
- data/config/initializers/02_patches/zeitwerk.rb +13 -0
- data/config/initializers/patches.rb +7 -0
- data/config/initializers/recaptcha.rb +1 -2
- data/config/initializers/zeitwerk.rb +5 -0
- data/config/locales/de.yml +1 -1
- data/config/locales/en.yml +1 -1
- data/config/locales/es.yml +1 -1
- data/db/migrate/20110511221913_require_earlier_migrations.rb +0 -3
- data/db/migrate/20141001105348_move_revisions_to_actions.rb +1 -1
- data/db/migrate_core_cards/20140629222005_add_email_cards.rb +5 -5
- data/db/migrate_core_cards/20141120120605_fix_notification_html_message.rb +1 -1
- data/db/migrate_core_cards/20141204061304_watchers_to_following.rb +1 -1
- data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +2 -2
- data/db/migrate_core_cards/20150317162412_bootstrap_themes.rb +4 -4
- data/db/migrate_core_cards/20150724123438_update_file_and_image_cards.rb +1 -1
- data/db/migrate_core_cards/20190204195039_add_rule_card.rb +1 -1
- data/db/migrate_core_cards/20191008201046_fixture_fix.rb +3 -1
- data/db/migrate_core_cards/20191028135243_add_link_editor_to_tiny_mce_config.rb +8 -0
- data/db/migrate_core_cards/20191115160748_history_cleanup.rb +27 -0
- data/db/migrate_core_cards/20191118145629_codename_fixes.rb +6 -0
- data/db/seed/new/card_actions.yml +874 -874
- data/db/seed/new/card_acts.yml +2 -2
- data/db/seed/new/card_references.yml +2 -2
- data/db/seed/new/cards.yml +1576 -1576
- data/db/seed/new/schema_migrations_core_cards.yml +8 -0
- data/db/seed/test/fixtures/card_actions.yml +1815 -1815
- data/db/seed/test/fixtures/card_acts.yml +499 -499
- data/db/seed/test/fixtures/card_changes.yml +66 -66
- data/db/seed/test/fixtures/card_references.yml +634 -634
- data/db/seed/test/fixtures/cards.yml +2730 -2730
- data/db/seed/test/fixtures/schema_migrations_core_cards.yml +8 -0
- data/db/test_seed.rb +10 -11
- data/lib/card.rb +9 -30
- data/lib/card/act_manager.rb +0 -2
- data/lib/card/auth.rb +0 -5
- data/lib/card/auth/current.rb +32 -59
- data/lib/card/auth/setup.rb +1 -1
- data/lib/card/codename.rb +5 -6
- data/lib/card/content.rb +5 -8
- data/lib/card/content/chunk.rb +0 -78
- data/lib/card/content/chunk/abstract.rb +88 -0
- data/lib/card/content/clean.rb +3 -3
- data/lib/card/content/diff/{lcs.rb → l_c_s.rb} +5 -7
- data/lib/card/content/diff/{processor.rb → l_c_s/processor.rb} +0 -0
- data/lib/card/content/parser.rb +1 -1
- data/lib/card/dirty.rb +25 -31
- data/lib/card/dirty/method_factory.rb +15 -0
- data/lib/card/env.rb +0 -3
- data/lib/card/error.rb +6 -2
- data/lib/card/format.rb +5 -5
- data/lib/card/format/nest/fetch.rb +2 -1
- data/lib/card/mark.rb +1 -0
- data/lib/card/migration.rb +4 -0
- data/lib/card/mod.rb +2 -5
- data/lib/card/mod/dirs.rb +1 -0
- data/lib/card/mod/load_strategy.rb +23 -12
- data/lib/card/mod/loader.rb +13 -13
- data/lib/card/mod/loader/set_loader.rb +7 -1
- data/lib/card/mod/loader/set_pattern_loader.rb +2 -2
- data/lib/card/mod/module_template.rb +1 -5
- data/lib/card/mod_inflector.rb +16 -0
- data/lib/card/model/save_helper.rb +2 -2
- data/lib/card/name.rb +2 -2
- data/lib/card/name/name_variants.rb +19 -0
- data/lib/card/query.rb +4 -2
- data/lib/card/query/card_query/reference_attributes.rb +2 -2
- data/lib/card/query/sql_statement.rb +4 -0
- data/lib/card/set.rb +18 -3
- data/lib/card/set/abstract.rb +6 -0
- data/lib/card/set/event.rb +13 -11
- data/lib/card/set/event/delayed_event.rb +2 -0
- data/lib/card/set/format.rb +3 -3
- data/lib/card/set/helpers.rb +20 -8
- data/lib/card/set/loader.rb +1 -1
- data/lib/card/set/pattern.rb +47 -0
- data/lib/card/{set_pattern.rb → set/pattern/base.rb} +11 -92
- data/lib/card/set/required_field.rb +64 -30
- data/lib/card/set/trait.rb +3 -2
- data/lib/card/set/type.rb +46 -0
- data/lib/card/subcards.rb +0 -4
- data/lib/card/tasks/card.rake +1 -0
- data/lib/card/tasks/card/migrate.rake +1 -1
- data/lib/card/view.rb +2 -7
- data/lib/card/view/cache.rb +3 -0
- data/lib/card/view/cache/stub.rb +5 -0
- data/lib/cardio.rb +73 -46
- data/mod/account/set/abstract/accountable.rb +49 -0
- data/mod/account/set/all/account.rb +3 -3
- data/mod/account/set/right/account.rb +1 -1
- data/mod/account/set/self/signin.rb +2 -2
- data/mod/account/set/type/role.rb +1 -1
- data/mod/account/set/type/signup.rb +2 -2
- data/mod/account/set/type/signup/views.rb +1 -1
- data/mod/account/set/type/user.rb +1 -1
- data/mod/account/spec/set/abstract/accountable_spec.rb +7 -0
- data/mod/account/spec/set/all/account_spec.rb +3 -3
- data/mod/account/spec/set/right/account_spec.rb +1 -1
- data/mod/account/spec/set/type/signup_spec.rb +4 -4
- data/mod/admin/set/self/admin.rb +1 -1
- data/mod/admin/set/self/admin_info.rb +2 -2
- data/mod/admin/set/self/version.rb +1 -1
- data/mod/basic_types/set/type/json.rb +4 -0
- data/mod/basic_types/spec/set/type/html_spec.rb +1 -1
- data/mod/bootstrap/db/migrate_core_cards/data/20181108181219_migrate_classic_skins_to_bootstrap.rb +2 -2
- data/mod/bootstrap/lib/bootstrap/component_loader.rb +1 -1
- data/mod/bootstrap/lib/stylesheets/style_bootstrap_cards.scss +1 -0
- data/mod/bootstrap/set/abstract/bootswatch_theme.rb +1 -1
- data/mod/bootstrap/set/all/bootstrap/tabs.rb +4 -4
- data/mod/bootstrap/set/type/customized_bootswatch_skin.rb +5 -4
- data/mod/carrierwave/config/core_initializers/carrierwave.rb +1 -3
- data/mod/carrierwave/lib/carrier_wave/{cardmount.rb → card_mount.rb} +2 -2
- data/mod/carrierwave/lib/carrier_wave/file_card_uploader.rb +27 -12
- data/mod/carrierwave/set/abstract/attachment.rb +0 -2
- data/mod/carrierwave/set/all/file_utils.rb +5 -1
- data/mod/carrierwave/set/self/admin.rb +1 -1
- data/mod/core/chunk/link.rb +99 -91
- data/mod/core/chunk/nest.rb +2 -2
- data/mod/core/chunk/query_reference.rb +79 -74
- data/mod/core/chunk/view_stub.rb +10 -1
- data/mod/core/format/html_format.rb +1 -1
- data/mod/core/set/abstract/code_file.rb +6 -6
- data/mod/core/set/all/content.rb +1 -1
- data/mod/core/set/all/event_conditions.rb +1 -2
- data/mod/core/set/all/fetch.rb +22 -19
- data/mod/core/set/all/fetch_helper.rb +7 -5
- data/mod/core/set/all/initialize.rb +35 -9
- data/mod/core/set/all/item.rb +16 -6
- data/mod/core/set/all/name.rb +19 -15
- data/mod/core/set/all/pattern.rb +4 -0
- data/mod/core/set/all/permissions.rb +13 -11
- data/mod/core/set/all/rename.rb +1 -0
- data/mod/core/set/all/rules.rb +4 -4
- data/mod/core/set/all/subcards.rb +36 -1
- data/mod/core/set/all/type.rb +1 -1
- data/mod/core/set_pattern/03_type.rb +2 -0
- data/mod/core/spec/chunk/nest_spec.rb +7 -2
- data/mod/core/spec/set/all/fetch_spec.rb +1 -1
- data/mod/core/spec/set/all/permissions_spec.rb +11 -12
- data/mod/core/spec/set/all/rules_spec.rb +3 -3
- data/mod/edit/set/all/bridge.rb +1 -3
- data/mod/edit/set/all/bridge/tab_views.rb +0 -7
- data/mod/edit/set/all/bridge/tab_visibility.rb +5 -7
- data/mod/edit/set/all/form_buttons.rb +1 -1
- data/mod/edit/set/all/form_elements.rb +1 -0
- data/mod/edit/set/all/new.rb +2 -2
- data/mod/edit/spec/set/all/bridge/tab_views_spec.rb +1 -1
- data/mod/edit/spec/set/all/{nest_editor → reference_editor/nest_editor}/nest_parser_spec.rb +1 -1
- data/mod/edit/spec/set/all/{nest_editor_spec.rb → reference_editor/nest_editor_spec.rb} +6 -3
- data/mod/edit/spec/set/all/{nest_image_spec.rb → reference_editor/nest_image_spec.rb} +1 -1
- data/mod/email/set/abstract/test_context.rb +1 -1
- data/mod/email/set/type/email_template/email_config.rb +1 -1
- data/mod/follow/set/all/notify.rb +1 -1
- data/mod/follow/set/all/notify/base_views.rb +1 -1
- data/mod/follow/set/right/account.rb +8 -6
- data/mod/follow/set/right/followers.rb +2 -5
- data/mod/follow/set/right/following.rb +1 -1
- data/mod/follow/spec/set/all/follow_spec.rb +3 -3
- data/mod/follow/spec/set/all/notify_spec.rb +1 -1
- data/mod/follow/spec/set/right/followers_spec.rb +2 -2
- data/mod/history/lib/card/act.rb +3 -1
- data/mod/history/lib/card/action.rb +3 -3
- data/mod/history/lib/card/action/admin.rb +0 -11
- data/mod/history/set/all/history_bridge.rb +1 -1
- data/mod/machines/file/all_script_machine_output/file.js +38415 -69
- data/mod/machines/file/all_style_machine_output/file.css +2 -2
- data/mod/machines/file/script_html5shiv_printshiv_machine_output/file.js +1 -1
- data/mod/machines/lib/javascript/decko/filter.js.coffee +7 -1
- data/mod/machines/lib/javascript/decko/filter_links.js.coffee +13 -2
- data/mod/machines/lib/javascript/decko/link_editor.js.coffee +64 -0
- data/mod/machines/lib/javascript/decko/mod.js.coffee +3 -0
- data/mod/machines/lib/javascript/decko/nest_editor.js.coffee +49 -29
- data/mod/machines/lib/javascript/decko/nest_editor_name.js.coffee +30 -7
- data/mod/machines/lib/javascript/decko/slot.js.coffee +4 -1
- data/mod/machines/lib/stylesheets/style_cards.scss +31 -19
- data/mod/machines/set/abstract/machine/output_cache.rb +1 -1
- data/mod/machines/set/abstract/machine/output_update.rb +1 -1
- data/mod/machines/set/all/reset_machines.rb +2 -2
- data/mod/machines/set/self/script_decko.rb +1 -0
- data/mod/media/set/abstract/media.rb +1 -1
- data/mod/media/set/type/image.rb +1 -1
- data/mod/navbar/set/abstract/account_dropdown.rb +5 -1
- data/mod/navbar/set/right/enabled_roles.rb +1 -1
- data/mod/navbar/set/self/account_links.rb +1 -1
- data/mod/pointer/set/abstract/02_pointer.rb +1 -1
- data/mod/pointer/set/abstract/02_pointer/events.rb +30 -10
- data/mod/pointer/set/abstract/02_pointer/html_views.rb +6 -2
- data/mod/pointer/set/abstract/02_pointer/html_views/autocomplete_input.haml +1 -1
- data/mod/pointer/set/abstract/02_pointer/html_views/filter.rb +1 -1
- data/mod/pointer/set/abstract/02_pointer/item_api.rb +51 -31
- data/mod/pointer/set/abstract/id_pointer.rb +21 -0
- data/mod/pointer/set/type/link_list.rb +1 -1
- data/mod/pointer/set/type/mirror_list.rb +1 -1
- data/mod/pointer/set/type/mirrored_list.rb +2 -2
- data/mod/pointer/spec/set/abstract/paging_params_spec.rb +1 -1
- data/mod/pointer/spec/set/abstract/pointer/item_api_spec.rb +1 -1
- data/mod/recaptcha/set/all/recaptcha.rb +4 -9
- data/mod/rules/set/rule/editor.rb +2 -2
- data/mod/rules/set/type/set/html_views/rule_lists.rb +1 -1
- data/mod/rules/spec/set/type/set_spec.rb +1 -1
- data/mod/search/set/abstract/03_filter/filter_form.haml +1 -1
- data/mod/search/set/abstract/03_filter/filter_form.rb +23 -2
- data/mod/search/set/abstract/03_filter/quick_filters.haml +7 -10
- data/mod/search/template/abstract/search/checkbox_item.haml +5 -6
- data/mod/settings/set/abstract/permission.rb +2 -2
- data/mod/settings/set/right/input_type.rb +3 -3
- data/mod/settings/set/right/structure.rb +1 -1
- data/mod/settings/set/right/style.rb +1 -1
- data/mod/settings/set/type/setting.rb +2 -2
- data/mod/standard/set/all/rich_html/html_views/guide.rb +1 -1
- data/mod/standard/set/all/rich_html/menu.rb +6 -5
- data/mod/standard/set/self/cardtype.rb +1 -1
- data/mod/standard/set/type/cardtype.rb +33 -17
- data/mod/standard/set/type/session.rb +12 -0
- data/mod/standard/spec/set/type/email_template/email_config_spec.rb +1 -2
- data/mod/standard/spec/set/type/email_template_spec.rb +1 -3
- data/mod/tinymce_editor/lib/javascript/script_tinymce_config.js.coffee +3 -2
- data/mod/tinymce_editor/public/assets/tinymce/plugins/nest/plugin.min.js +1 -1
- data/mod/tinymce_editor/set/all/reference_editor.rb +23 -0
- data/mod/tinymce_editor/set/all/reference_editor/_link_editor.haml +18 -0
- data/mod/tinymce_editor/set/all/reference_editor/_nest_editor.haml +17 -0
- data/mod/tinymce_editor/set/all/reference_editor/link_editor.rb +33 -0
- data/mod/tinymce_editor/set/all/reference_editor/link_editor/link_parser.rb +35 -0
- data/mod/tinymce_editor/set/all/reference_editor/nest_editor.rb +174 -0
- data/mod/{edit/set/all → tinymce_editor/set/all/reference_editor}/nest_editor/_help.haml +0 -0
- data/mod/tinymce_editor/set/all/reference_editor/nest_editor/_options.haml +12 -0
- data/mod/{edit/set/all → tinymce_editor/set/all/reference_editor}/nest_editor/_options_select.haml +0 -0
- data/mod/{edit/set/all → tinymce_editor/set/all/reference_editor}/nest_editor/_options_select_row.haml +0 -0
- data/mod/{edit/set/all → tinymce_editor/set/all/reference_editor}/nest_editor/nest_parser.rb +7 -1
- data/mod/tinymce_editor/set/all/reference_editor/nest_image.rb +70 -0
- data/mod/tinymce_editor/set/all/reference_editor/reference_editor.haml +18 -0
- metadata +39 -21
- data/mod/account/set/abstract/accounted.rb +0 -15
- data/mod/edit/set/all/bridge/account_section.rb +0 -16
- data/mod/edit/set/all/nest_editor.rb +0 -122
- data/mod/edit/set/all/nest_editor/_options.haml +0 -12
- data/mod/edit/set/all/nest_editor/nest_editor.haml +0 -31
- data/mod/edit/set/all/nest_image.rb +0 -37
@@ -6,6 +6,12 @@ class Card
|
|
6
6
|
# SetLoader can use three different strategies to load the set modules.
|
7
7
|
class SetLoader < Loader
|
8
8
|
@module_type = :set
|
9
|
+
attr_accessor :patterns
|
10
|
+
|
11
|
+
def initialize args={}
|
12
|
+
@patterns = args.delete(:patterns) || Card::Set::Pattern.loadable_codes
|
13
|
+
super
|
14
|
+
end
|
9
15
|
|
10
16
|
def load_strategy_class load_strategy
|
11
17
|
case load_strategy
|
@@ -20,7 +26,7 @@ class Card
|
|
20
26
|
|
21
27
|
def load
|
22
28
|
super
|
23
|
-
Card::Set.process_base_modules
|
29
|
+
# Card::Set.process_base_modules
|
24
30
|
Card::Set.clean_empty_modules
|
25
31
|
end
|
26
32
|
|
@@ -18,7 +18,7 @@ class Card
|
|
18
18
|
return Object if simple_load?
|
19
19
|
|
20
20
|
Card::Set.const_get_or_set(@pattern.camelize) do
|
21
|
-
Class.new(Card::Set::Pattern::
|
21
|
+
Class.new(Card::Set::Pattern::Base)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -34,7 +34,7 @@ class Card
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def module_chain
|
37
|
-
"class Card::Set::#{@pattern.camelize} < Card::Set::Pattern::
|
37
|
+
"class Card::Set::#{@pattern.camelize} < Card::Set::Pattern::Base"
|
38
38
|
end
|
39
39
|
|
40
40
|
def preamble_bits
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class ModInflector < Zeitwerk::Inflector
|
2
|
+
def camelize basename, abspath
|
3
|
+
ActiveSupport::Dependencies::ZeitwerkIntegration::Inflector.camelize(basename, abspath)
|
4
|
+
|
5
|
+
# if basename =~ /\Ahtml_(.*)/
|
6
|
+
# ActiveSupport::Dependencies::ZeitwerkIntegration::Inflector.camelize(basename, abspath)
|
7
|
+
# # "HTML" + super($1, abspath)
|
8
|
+
# else
|
9
|
+
# super
|
10
|
+
# end
|
11
|
+
end
|
12
|
+
|
13
|
+
def inflect overrides
|
14
|
+
ActiveSupport::Dependencies::ZeitwerkIntegration::Inflector.inflect(overrides)
|
15
|
+
end
|
16
|
+
end
|
@@ -199,7 +199,7 @@ class Card
|
|
199
199
|
|
200
200
|
def validate_setting setting
|
201
201
|
unless Card::Codename.exist?(setting) &&
|
202
|
-
Card.fetch_type_id(setting) == SettingID
|
202
|
+
Card.fetch_type_id(setting) == Card::SettingID
|
203
203
|
raise ArgumentError, "not a valid setting: #{setting}"
|
204
204
|
end
|
205
205
|
end
|
@@ -207,7 +207,7 @@ class Card
|
|
207
207
|
def normalize_trait_rule_args setting, value
|
208
208
|
return value if value.is_a? Hash
|
209
209
|
|
210
|
-
if Card.fetch_type_id([setting, :right, :default]) == PointerID
|
210
|
+
if Card.fetch_type_id([setting, :right, :default]) == Card::PointerID
|
211
211
|
value = Array(value).to_pointer_content
|
212
212
|
end
|
213
213
|
{ content: value }
|
data/lib/card/name.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
|
-
|
3
|
+
# require "card/env"
|
4
4
|
|
5
5
|
require "cardname"
|
6
6
|
|
@@ -11,7 +11,7 @@ class Card
|
|
11
11
|
# Card::Name adds support for deeper card integration
|
12
12
|
class Name < Cardname
|
13
13
|
include FieldsAndTraits
|
14
|
-
include
|
14
|
+
include NameVariants
|
15
15
|
|
16
16
|
self.params = Card::Env # yuck!
|
17
17
|
self.session = proc { Card::Auth.current.name } # also_yuck
|
@@ -12,6 +12,25 @@ class Card
|
|
12
12
|
@@variant_methods.include?(variant) ? name.send(variant) : name
|
13
13
|
end
|
14
14
|
end
|
15
|
+
|
16
|
+
# @return [Card::Name] standardized based on card names
|
17
|
+
def standard
|
18
|
+
self.class.compose(parts.map { |part| Card.fetch_name(part) || part })
|
19
|
+
end
|
20
|
+
|
21
|
+
def card
|
22
|
+
Card.fetch self
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [Integer] id of card with name
|
26
|
+
def card_id
|
27
|
+
Card.fetch_id self
|
28
|
+
end
|
29
|
+
|
30
|
+
# @return [Symbol] codename of card with name
|
31
|
+
def codename
|
32
|
+
Codename[card_id]
|
33
|
+
end
|
15
34
|
end
|
16
35
|
end
|
17
36
|
end
|
data/lib/card/query.rb
CHANGED
@@ -34,8 +34,10 @@ class Card
|
|
34
34
|
# Each condition is either a SQL-ready string (boo) or an Array in this form:
|
35
35
|
# [ field_string_or_sym, Card::Value::Query object ]
|
36
36
|
module Query
|
37
|
-
|
38
|
-
|
37
|
+
require "card/query/clause"
|
38
|
+
require "card/query/card_query"
|
39
|
+
require "card/query/sql_statement"
|
40
|
+
# Card::Query::CardQuery
|
39
41
|
# After conversion, ATTRIBUTES is a Hash where the key is the attribute
|
40
42
|
# and the value is the attribute type:
|
41
43
|
# { id: :basic, name: :basic, key: :basic ...}
|
@@ -33,11 +33,11 @@ class Card
|
|
33
33
|
# DEPRECATE?
|
34
34
|
|
35
35
|
def member_of val
|
36
|
-
interpret right_plus: [RolesID, refer_to: val]
|
36
|
+
interpret right_plus: [Card::RolesID, refer_to: val]
|
37
37
|
end
|
38
38
|
|
39
39
|
def member val
|
40
|
-
interpret referred_to_by: { left: val, right: RolesID }
|
40
|
+
interpret referred_to_by: { left: val, right: Card::RolesID }
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -11,6 +11,10 @@ class Card
|
|
11
11
|
# hierarchy and do little more than run "to_sql" on its parts, and in so doing
|
12
12
|
# construct a valid SQL statement.
|
13
13
|
class SqlStatement
|
14
|
+
require "card/query/sql_statement/joins"
|
15
|
+
require "card/query/sql_statement/where"
|
16
|
+
require "card/query/sql_statement/order"
|
17
|
+
|
14
18
|
include Joins
|
15
19
|
include Where
|
16
20
|
include Order
|
data/lib/card/set.rb
CHANGED
@@ -46,12 +46,22 @@ class Card
|
|
46
46
|
# b) Card::Set to provide API for the most common set methods.
|
47
47
|
#
|
48
48
|
module Set
|
49
|
+
require "card/set/event"
|
50
|
+
require "card/set/trait"
|
51
|
+
require "card/set/basket"
|
52
|
+
require "card/set/inheritance"
|
53
|
+
require "card/set/format"
|
54
|
+
require "card/set/advanced_api"
|
55
|
+
require "card/set/helpers"
|
56
|
+
require "card/set/i18n_scope"
|
57
|
+
require "card/set/loader"
|
58
|
+
|
49
59
|
include Event::Api
|
50
60
|
include Trait
|
51
61
|
include Basket
|
52
62
|
include Inheritance
|
53
63
|
|
54
|
-
include
|
64
|
+
include Format
|
55
65
|
include AdvancedApi
|
56
66
|
include Helpers
|
57
67
|
|
@@ -59,8 +69,13 @@ class Card
|
|
59
69
|
extend Loader
|
60
70
|
|
61
71
|
mattr_accessor :modules, :traits
|
62
|
-
|
63
|
-
|
72
|
+
|
73
|
+
def self.reset_modules
|
74
|
+
self.modules = { base: [], base_format: {}, nonbase: {}, nonbase_format: {},
|
75
|
+
abstract: {}, abstract_format: {} }
|
76
|
+
end
|
77
|
+
|
78
|
+
reset_modules
|
64
79
|
|
65
80
|
# SET MODULE API
|
66
81
|
#
|
data/lib/card/set/event.rb
CHANGED
@@ -96,10 +96,10 @@ class Card
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def define_standard_event_method method_name=simple_method_name
|
99
|
-
|
99
|
+
is_integration = @stage.to_s.match?(/integrate/)
|
100
100
|
@set_module.class_exec(@event) do |event_name|
|
101
101
|
define_method event_name do
|
102
|
-
|
102
|
+
rescuing_if_integration is_integration do
|
103
103
|
log_event_call event_name
|
104
104
|
run_callbacks event_name do
|
105
105
|
send method_name
|
@@ -111,15 +111,17 @@ class Card
|
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
-
def
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
114
|
+
def rescuing_if_integration is_integration
|
115
|
+
is_integration ? rescuing_integration { yield } : yield
|
116
|
+
end
|
117
|
+
|
118
|
+
# one failed integration event should not harm others.
|
119
|
+
def rescuing_integration
|
120
|
+
yield
|
121
|
+
rescue StandardError => e
|
122
|
+
Card::Error.report e, self
|
123
|
+
ensure
|
124
|
+
true
|
123
125
|
end
|
124
126
|
|
125
127
|
def log_event_call event
|
data/lib/card/set/format.rb
CHANGED
@@ -58,8 +58,8 @@ class Card
|
|
58
58
|
# {AbstractFormat#before before}) are defined in {AbstractFormat}. These methods are
|
59
59
|
# always available in format blocks.
|
60
60
|
module Format
|
61
|
-
|
62
|
-
|
61
|
+
require "card/set/format/haml_paths"
|
62
|
+
require "card/set/format/abstract_format"
|
63
63
|
|
64
64
|
# define format behavior within a set module
|
65
65
|
def format *format_names, &block
|
@@ -98,7 +98,7 @@ class Card
|
|
98
98
|
# yielding set format module, eg Card::Set::Type::Pointer::HtmlFormat
|
99
99
|
m = Module.new
|
100
100
|
register_set_format Card::Format.class_from_name(klass), m
|
101
|
-
m.extend Card::Set::AbstractFormat
|
101
|
+
m.extend Card::Set::Format::AbstractFormat
|
102
102
|
m
|
103
103
|
end
|
104
104
|
mod.class_eval(&block)
|
data/lib/card/set/helpers.rb
CHANGED
@@ -1,31 +1,43 @@
|
|
1
1
|
class Card
|
2
2
|
module Set
|
3
3
|
module Helpers
|
4
|
+
SET_PATTERN_TEST_REGEXP = /^(?<pattern>\w+)_set\?$/
|
5
|
+
|
4
6
|
def shortname
|
5
|
-
parts = name.split "::"
|
6
7
|
first = 2 # shortname eliminates Card::Set
|
7
|
-
pattern_code = parts[first].underscore.to_sym
|
8
8
|
last = first + num_set_parts(pattern_code)
|
9
|
-
|
9
|
+
set_name_parts[first..last].join "::"
|
10
10
|
end
|
11
11
|
|
12
12
|
def underscore
|
13
13
|
shortname.tr(":", "_").underscore
|
14
14
|
end
|
15
15
|
|
16
|
-
# move to Set::Pattern?
|
17
16
|
def num_set_parts pattern_code
|
18
17
|
return 1 if pattern_code == :abstract
|
19
18
|
|
20
19
|
Pattern.find(pattern_code).anchor_parts_count
|
21
20
|
end
|
22
21
|
|
23
|
-
def
|
24
|
-
name
|
22
|
+
def set_name_parts
|
23
|
+
@set_name_parts ||= name.split "::"
|
24
|
+
end
|
25
|
+
|
26
|
+
def pattern_code
|
27
|
+
@pattern_code ||= set_name_parts[2].underscore.to_sym
|
28
|
+
end
|
29
|
+
|
30
|
+
# handles all_set?, abstract_set?, type_set?, etc.
|
31
|
+
def method_missing method_name, *args
|
32
|
+
if (matches = method_name.match SET_PATTERN_TEST_REGEXP)
|
33
|
+
pattern_code == matches[:pattern].to_sym
|
34
|
+
else
|
35
|
+
super
|
36
|
+
end
|
25
37
|
end
|
26
38
|
|
27
|
-
def
|
28
|
-
|
39
|
+
def respond_to_missing? method_name, _include_private=false
|
40
|
+
method_name.match? SET_PATTERN_TEST_REGEXP
|
29
41
|
end
|
30
42
|
end
|
31
43
|
end
|
data/lib/card/set/loader.rb
CHANGED
@@ -40,7 +40,7 @@ class Card
|
|
40
40
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
41
41
|
# Organization Phase
|
42
42
|
|
43
|
-
# 'base modules' are modules that are
|
43
|
+
# 'base modules' are modules that are always included on the Card or
|
44
44
|
# Format class
|
45
45
|
# 'nonbase modules' are included dynamically on singleton_classes
|
46
46
|
def process_base_modules
|
@@ -0,0 +1,47 @@
|
|
1
|
+
class Card
|
2
|
+
module Set
|
3
|
+
class Pattern
|
4
|
+
class << self
|
5
|
+
def reset
|
6
|
+
nonbase_loadables.each do |set_pattern|
|
7
|
+
Card::Set.const_remove_if_defined set_pattern.to_s.split("::").last
|
8
|
+
end
|
9
|
+
Card.set_patterns = []
|
10
|
+
@card_keys = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def loadables
|
14
|
+
Card.set_patterns.push(Card::Set::Abstract).reverse
|
15
|
+
end
|
16
|
+
|
17
|
+
def nonbase_loadables
|
18
|
+
l = loadables
|
19
|
+
l.delete Card::Set::All
|
20
|
+
l
|
21
|
+
end
|
22
|
+
|
23
|
+
def find pattern_code
|
24
|
+
Card.set_patterns.find { |sub| sub.pattern_code == pattern_code }
|
25
|
+
end
|
26
|
+
|
27
|
+
def card_keys
|
28
|
+
@card_keys ||=
|
29
|
+
Card.set_patterns.each_with_object({}) do |set_pattern, hash|
|
30
|
+
card_key = Card.quick_fetch(set_pattern.pattern_code).key
|
31
|
+
hash[card_key] = true
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def nonbase_loadable_codes
|
36
|
+
l = loadable_codes
|
37
|
+
l.delete :all
|
38
|
+
l
|
39
|
+
end
|
40
|
+
|
41
|
+
def loadable_codes
|
42
|
+
Card.set_patterns.map(&:pattern_code).push(:abstract).reverse
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -1,31 +1,8 @@
|
|
1
1
|
class Card
|
2
2
|
module Set
|
3
3
|
class Pattern
|
4
|
-
class
|
5
|
-
|
6
|
-
Card.set_patterns = []
|
7
|
-
@card_keys = @in_load_order = nil
|
8
|
-
end
|
9
|
-
|
10
|
-
def find pattern_code
|
11
|
-
Card.set_patterns.find { |sub| sub.pattern_code == pattern_code }
|
12
|
-
end
|
13
|
-
|
14
|
-
def card_keys
|
15
|
-
@card_keys ||=
|
16
|
-
Card.set_patterns.each_with_object({}) do |set_pattern, hash|
|
17
|
-
card_key = Card.quick_fetch(set_pattern.pattern_code).key
|
18
|
-
hash[card_key] = true
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def in_load_order
|
23
|
-
@in_load_order ||=
|
24
|
-
Card.set_patterns.reverse.map(&:pattern_code).unshift :abstract
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class Abstract
|
4
|
+
# class from which set patterns inherit
|
5
|
+
class Base
|
29
6
|
class << self
|
30
7
|
attr_accessor :pattern_code, :pattern_id, :junction_only,
|
31
8
|
:assigns_type, :anchorless
|
@@ -51,7 +28,7 @@ class Card
|
|
51
28
|
end
|
52
29
|
|
53
30
|
def anchorless?
|
54
|
-
|
31
|
+
anchorless
|
55
32
|
end
|
56
33
|
|
57
34
|
def pattern
|
@@ -82,27 +59,18 @@ class Card
|
|
82
59
|
# Instance methods
|
83
60
|
|
84
61
|
def initialize card
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
end
|
89
|
-
self
|
62
|
+
return if self.class.anchorless?
|
63
|
+
@anchor_name = self.class.anchor_name(card).to_name
|
64
|
+
@anchor_id = find_anchor_id card
|
90
65
|
end
|
91
66
|
|
92
67
|
def find_anchor_id card
|
93
|
-
|
94
|
-
self.class.anchor_id card
|
95
|
-
else
|
96
|
-
Card.fetch_id @anchor_name
|
97
|
-
end
|
68
|
+
self.class.try(:anchor_id, card) || Card.fetch_id(@anchor_name)
|
98
69
|
end
|
99
70
|
|
100
71
|
def module_key
|
101
|
-
if defined? @module_key
|
102
|
-
|
103
|
-
else
|
104
|
-
@module_key = self.class.module_key(anchor_codenames)
|
105
|
-
end
|
72
|
+
return @module_key if defined? @module_key
|
73
|
+
@module_key = self.class.module_key anchor_codenames
|
106
74
|
end
|
107
75
|
|
108
76
|
def lookup_module_list modules_hash
|
@@ -121,7 +89,7 @@ class Card
|
|
121
89
|
def anchor_codenames
|
122
90
|
anchor_parts.map do |part|
|
123
91
|
part_id = Card.fetch_id part
|
124
|
-
Card::Codename[part_id] ||
|
92
|
+
Card::Codename[part_id] || break
|
125
93
|
end
|
126
94
|
end
|
127
95
|
|
@@ -155,11 +123,7 @@ class Card
|
|
155
123
|
|
156
124
|
def safe_key
|
157
125
|
caps_part = self.class.pattern_code.to_s.tr(" ", "_").upcase
|
158
|
-
|
159
|
-
caps_part
|
160
|
-
else
|
161
|
-
"#{caps_part}-#{@anchor_name.safe_key}"
|
162
|
-
end
|
126
|
+
self.class.anchorless? ? caps_part : "#{caps_part}-#{@anchor_name.safe_key}"
|
163
127
|
end
|
164
128
|
|
165
129
|
def rule_set_key
|
@@ -171,50 +135,5 @@ class Card
|
|
171
135
|
end
|
172
136
|
end
|
173
137
|
end
|
174
|
-
|
175
|
-
class Type < Pattern::Abstract
|
176
|
-
def initialize card
|
177
|
-
super
|
178
|
-
# support type inheritance
|
179
|
-
@inherit_card = card unless module_key
|
180
|
-
end
|
181
|
-
|
182
|
-
def lookup_module_list modules_hash
|
183
|
-
lookup_key = module_key || inherited_key
|
184
|
-
modules_hash[lookup_key] if lookup_key
|
185
|
-
end
|
186
|
-
|
187
|
-
private
|
188
|
-
|
189
|
-
def inherited_key
|
190
|
-
if defined?(@inherited_key)
|
191
|
-
@inherited_key
|
192
|
-
else
|
193
|
-
@inherited_key = lookup_inherited_key
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
def lookup_inherited_key
|
198
|
-
return unless @inherit_card
|
199
|
-
|
200
|
-
card = @inherit_card
|
201
|
-
@inherit_card = nil
|
202
|
-
return unless (type_code = default_type_code card)
|
203
|
-
|
204
|
-
mod_key = "Type::#{type_code.to_s.camelize}"
|
205
|
-
mod_key if mods_exist_for_key? mod_key
|
206
|
-
end
|
207
|
-
|
208
|
-
def default_type_code card
|
209
|
-
default_rule = card.rule_card :default
|
210
|
-
default_rule&.type_code
|
211
|
-
end
|
212
|
-
|
213
|
-
def mods_exist_for_key? mod_key
|
214
|
-
list_of_hashes = Card::Set.modules[:nonbase_format].values
|
215
|
-
list_of_hashes << Card::Set.modules[:nonbase]
|
216
|
-
list_of_hashes.any? { |h| h[mod_key] }
|
217
|
-
end
|
218
|
-
end
|
219
138
|
end
|
220
139
|
end
|