card 1.103.1 → 1.104.0
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/environments/development.rb +4 -2
- data/config/environments/production.rb +9 -9
- data/config/environments/test.rb +1 -1
- data/config/initializers/01_core_extensions/array.rb +4 -1
- data/config/initializers/01_core_extensions/object.rb +1 -1
- data/config/initializers/02_patches/active_record.rb +16 -17
- data/config/locales/de.yml +8 -564
- data/config/locales/es.yml +2 -3
- data/db/migrate/20110511221913_require_earlier_migrations.rb +1 -1
- data/db/migrate/20120105203350_require_1_8_migrations.rb +1 -1
- data/db/migrate/20121111025347_require_1_10_migrations.rb +1 -1
- data/db/migrate/20211128040849_virtuals_updated_at.rb +11 -0
- data/db/migrate_core_cards/20130411191151_renaming_for_menu.rb +0 -1
- data/db/migrate_core_cards/20140317035504_account_requests_to_signups.rb +0 -2
- data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +0 -2
- data/db/migrate_core_cards/20190417142612_reorganize_scripts_2.rb +1 -3
- data/db/migrate_core_cards/20190502130029_add_shark_and_help_desk_role.rb +1 -2
- data/db/migrate_core_cards/20190710090209_homepage_tweaks.rb +3 -7
- data/db/migrate_core_cards/20190823220018_cleanup_for_decko_1_0.rb +2 -4
- data/db/migrate_core_cards/20190902193208_input_type.rb +3 -8
- data/db/migrate_core_cards/20190904174403_token_upgrade.rb +1 -1
- data/db/migrate_core_cards/data/1.12_stylesheets/traditional.scss +1 -2
- data/db/schema.rb +19 -16
- data/db/seed/new/card_actions.yml +2615 -3383
- data/db/seed/new/card_acts.yml +3 -3
- data/db/seed/new/card_references.yml +1588 -1707
- data/db/seed/new/cards.yml +5450 -8416
- data/db/seed/new/schema_migrations.yml +2 -0
- data/db/seed/new/schema_migrations_core_cards.yml +8 -0
- data/db/seed/test/fixtures/card_actions.yml +4304 -5144
- data/db/seed/test/fixtures/card_acts.yml +780 -840
- data/db/seed/test/fixtures/card_changes.yml +110 -110
- data/db/seed/test/fixtures/card_references.yml +2908 -2992
- data/db/seed/test/fixtures/cards.yml +8775 -11955
- data/db/seed/test/fixtures/schema_migrations.yml +2 -0
- data/db/seed/test/fixtures/schema_migrations_core_cards.yml +8 -0
- data/db/test_seed.rb +2 -5
- data/db/version.txt +1 -1
- data/db/version_core_cards.txt +1 -1
- data/lib/card/auth/current.rb +1 -1
- data/lib/card/auth/permissions.rb +37 -35
- data/lib/card/content/all.rb +3 -3
- data/lib/card/content/chunk.rb +1 -1
- data/lib/card/content/diff/summary.rb +14 -18
- data/lib/card/content.rb +9 -1
- data/lib/card/director/act_direction.rb +6 -6
- data/lib/card/director/card_methods.rb +0 -1
- data/lib/card/director/phases.rb +1 -0
- data/lib/card/director/stages.rb +2 -0
- data/lib/card/director.rb +1 -0
- data/lib/card/fetch/all.rb +3 -3
- data/lib/card/fetch/card_class.rb +5 -11
- data/lib/card/fetch/results.rb +8 -8
- data/lib/card/{tasks/card/file_card_creator → file_card_creator}/abstract_file_card/migration_file.rb +0 -0
- data/lib/card/{tasks/card/file_card_creator → file_card_creator}/abstract_file_card/ruby_file.rb +0 -0
- data/lib/card/{tasks/card/file_card_creator → file_card_creator}/abstract_file_card/source_file.rb +0 -0
- data/lib/card/{tasks/card/file_card_creator → file_card_creator}/abstract_file_card.rb +0 -5
- data/lib/card/{tasks/card/file_card_creator → file_card_creator}/haml_card.rb +0 -0
- data/lib/card/{tasks/card/file_card_creator → file_card_creator}/output_helper.rb +0 -0
- data/lib/card/{tasks/card/file_card_creator → file_card_creator}/script_card.rb +0 -0
- data/lib/card/{tasks/card/file_card_creator → file_card_creator}/style_card.rb +0 -0
- data/lib/card/{tasks/card/file_card_creator.rb → file_card_creator.rb} +0 -5
- data/lib/card/format/content.rb +5 -7
- data/lib/card/format/render.rb +10 -10
- data/lib/card/format.rb +3 -8
- data/lib/card/lexicon.rb +30 -7
- data/lib/card/model/save_helper.rb +3 -3
- data/lib/card/name/all/descendants.rb +9 -7
- data/lib/card/name/all/parts.rb +1 -1
- data/lib/card/name/all.rb +4 -3
- data/lib/card/name/card_class.rb +2 -1
- data/lib/card/name/fields_and_traits.rb +6 -30
- data/lib/card/name/name_variants.rb +5 -1
- data/lib/card/name.rb +6 -14
- data/lib/card/query/abstract_query/tie.rb +2 -3
- data/lib/card/query/card_query/normalization.rb +1 -1
- data/lib/card/query/sql_statement/order.rb +5 -6
- data/lib/card/query/value.rb +10 -7
- data/lib/card/reference/all.rb +9 -7
- data/lib/card/reference.rb +36 -41
- data/lib/card/rule/all.rb +3 -3
- data/lib/card/set/advanced_api.rb +5 -0
- data/lib/card/set/card_methods.rb +13 -0
- data/lib/card/set/event/delayed_event.rb +8 -1
- data/lib/card/set/event/skip_and_trigger.rb +8 -0
- data/lib/card/set/event.rb +1 -0
- data/lib/card/set/format/abstract_format/wrapper.rb +1 -1
- data/lib/card/set/format/abstract_format.rb +2 -1
- data/lib/card/set/format.rb +2 -3
- data/lib/card/set/helpers.rb +68 -0
- data/lib/card/set/inheritance.rb +1 -1
- data/lib/card/set/pattern/all.rb +20 -10
- data/lib/card/set/pattern/base.rb +12 -18
- data/lib/card/set/pattern/class_methods.rb +13 -13
- data/lib/card/set/pattern.rb +46 -24
- data/lib/card/set/registrar.rb +8 -2
- data/lib/card/set/trait.rb +16 -1
- data/lib/card/set/type.rb +3 -0
- data/lib/card/set.rb +14 -7
- data/lib/card/subcards/add.rb +1 -3
- data/lib/card/subcards/all.rb +30 -56
- data/lib/card/view/classy.rb +15 -27
- data/lib/card/view/options/voo_api.rb +3 -1
- data/lib/card/view/options.rb +7 -5
- data/lib/card/view.rb +1 -0
- data/lib/card.rb +9 -11
- data/lib/cardio/cli.rb +1 -0
- data/lib/cardio/commands/custom.rb +60 -0
- data/lib/cardio/commands/rake_command/parser.rb +49 -48
- data/lib/cardio/commands/rake_command.rb +17 -15
- data/lib/cardio/commands/rspec_command.rb +2 -0
- data/lib/cardio/commands.rb +69 -69
- data/lib/cardio/generators/deck_helper.rb +0 -4
- data/lib/cardio/generators.rb +56 -3
- data/lib/cardio/migration/deck.rb +0 -0
- data/lib/cardio/migration/deck_structure.rb +2 -0
- data/lib/cardio/migration/import/import_data/card_content.rb +1 -1
- data/lib/cardio/migration/import.rb +2 -2
- data/lib/cardio/migration.rb +26 -2
- data/lib/cardio/mod/class_methods.rb +112 -0
- data/lib/cardio/mod/dirs.rb +15 -11
- data/lib/cardio/mod/eat/edibles.rb +92 -0
- data/lib/cardio/mod/eat.rb +81 -0
- data/lib/cardio/mod/load_strategy/set_tmp_files.rb +10 -4
- data/lib/cardio/mod/load_strategy/tmp_files.rb +1 -1
- data/lib/cardio/mod/load_strategy.rb +3 -4
- data/lib/cardio/mod/loader/set_loader.rb +13 -13
- data/lib/cardio/mod/loader.rb +1 -1
- data/lib/cardio/mod/modfile_api.rb +5 -0
- data/lib/cardio/mod/poop.rb +135 -0
- data/lib/cardio/mod.rb +20 -80
- data/lib/cardio/railtie.rb +21 -5
- data/lib/cardio/schema.rb +11 -10
- data/lib/cardio/version.rb +35 -0
- data/lib/cardio.rb +4 -0
- data/lib/generators/deck/templates/Gemfile.erb +1 -5
- data/lib/generators/deck/templates/Rakefile.erb +6 -2
- data/lib/generators/deck/templates/rspec.erb +1 -1
- data/lib/generators/deck/templates/simplecov.rb.erb +7 -11
- data/lib/generators/deck/templates/spec/javascripts/support/decko_jasmine.yml.erb +0 -1
- data/lib/generators/mod/USAGE +1 -0
- data/lib/{card/tasks → tasks}/card/create.rake +0 -0
- data/lib/{card/tasks → tasks}/card/migrate.rake +41 -1
- data/lib/{card/tasks → tasks}/card/mod.rake +15 -8
- data/lib/tasks/card.rake +65 -0
- data/mod/admin/locales/de.yml +4 -0
- data/mod/admin/set/all/admin.rb +16 -0
- data/mod/admin/set/self/admin.rb +12 -14
- data/mod/admin/set/self/admin_info.rb +2 -5
- data/mod/core/data/production.yml +7 -0
- data/mod/core/data/test.yml +30 -0
- data/mod/core/locales/de.yml +28 -0
- data/mod/core/locales/en.yml +4 -5
- data/mod/core/set/all/assign_attributes.rb +1 -33
- data/mod/core/set/all/content.rb +3 -1
- data/mod/core/set/all/initialize.rb +1 -4
- data/mod/core/set/all/name_events.rb +3 -18
- data/mod/core/set/all/reference_events.rb +32 -36
- data/mod/core/set/all/subcards.rb +6 -2
- data/mod/core/set/all/trash.rb +4 -6
- data/mod/core/set/all/type.rb +67 -18
- data/mod/core/set/self/version.rb +1 -1
- data/mod/core/spec/set/all/name_events_spec.rb +10 -10
- data/mod/core/spec/set/all/trash_spec.rb +1 -1
- data/mod/core/spec/set/self/trash_spec.rb +1 -1
- data/mod/standard/{file → data/files}/favicon/image-icon.png +0 -0
- data/mod/standard/{file → data/files}/favicon/image-large.png +0 -0
- data/mod/standard/{file → data/files}/favicon/image-medium.png +0 -0
- data/mod/standard/{file → data/files}/favicon/image-original.png +0 -0
- data/mod/standard/{file → data/files}/favicon/image-small.png +0 -0
- data/mod/standard/{file → data/files}/logo/image-original.svg +0 -0
- metadata +66 -56
- data/db/migrate_core_cards/20150605115802_add_performance_log_card.rb +0 -7
- data/lib/card/set/basket.rb +0 -59
- data/lib/card/set/code_nest.rb +0 -15
- data/lib/card/tasks/card/asset.rake +0 -22
- data/lib/card/tasks/card.rake +0 -105
- data/lib/card/version.rb +0 -11
- data/lib/cardio/commands/USAGE +0 -28
- data/lib/cardio/generators/class_methods.rb +0 -35
- data/mod/core/spec/set/all/clean_me_spec.rb +0 -258
- data/mod/core/spec/set/all/export_spec.rb +0 -71
- data/tmpsets/set_pattern/100-all.rb +0 -22
- data/tmpsets/set_pattern/101-all_plus.rb +0 -24
- data/tmpsets/set_pattern/102-type.rb +0 -40
- data/tmpsets/set_pattern/103-star.rb +0 -26
- data/tmpsets/set_pattern/104-rstar.rb +0 -28
- data/tmpsets/set_pattern/105-rule.rb +0 -28
- data/tmpsets/set_pattern/106-right.rb +0 -35
- data/tmpsets/set_pattern/107-type_plus_right.rb +0 -43
- data/tmpsets/set_pattern/108-self.rb +0 -34
data/lib/card/set/pattern/all.rb
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
class Card
|
2
2
|
module Set
|
3
|
-
|
3
|
+
module Pattern
|
4
4
|
# pattern-related Card instance methods
|
5
5
|
module All
|
6
6
|
def patterns?
|
7
7
|
defined? @patterns
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
11
|
-
@
|
10
|
+
def concrete_patterns
|
11
|
+
@concrete_patterns ||= Pattern.concrete.map { |sub| sub.new self }.compact
|
12
12
|
end
|
13
13
|
|
14
14
|
# new cards do not
|
15
15
|
def patterns
|
16
|
-
@patterns ||= (new_card? ?
|
16
|
+
@patterns ||= (new_card? ? concrete_patterns[1..-1] : concrete_patterns)
|
17
17
|
end
|
18
18
|
|
19
19
|
def reset_patterns
|
20
20
|
# Rails.logger.info "resetting patterns: #{name}"
|
21
|
-
@patterns = @
|
21
|
+
@patterns = @concrete_patterns = nil
|
22
22
|
@template = @virtual = nil
|
23
|
-
@set_mods_loaded = @set_modules = @set_names = @
|
23
|
+
@set_mods_loaded = @set_modules = @set_names = @rule_lookup_keys = nil
|
24
24
|
@junction_only = nil # only applies to set cards
|
25
25
|
true
|
26
26
|
end
|
@@ -30,13 +30,14 @@ class Card
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def set_modules
|
33
|
-
@set_modules ||=
|
33
|
+
@set_modules ||=
|
34
|
+
concrete_patterns[0..-2].reverse.map(&:module_list).flatten.compact
|
34
35
|
end
|
35
36
|
|
36
37
|
def set_format_modules klass
|
37
38
|
@set_format_modules ||= {}
|
38
39
|
@set_format_modules[klass] =
|
39
|
-
|
40
|
+
concrete_patterns[0..-2].reverse.map do |pattern|
|
40
41
|
pattern.format_module_list klass
|
41
42
|
end.flatten.compact
|
42
43
|
end
|
@@ -50,13 +51,22 @@ class Card
|
|
50
51
|
patterns.map(&:module_key).include? set_module.shortname
|
51
52
|
end
|
52
53
|
|
53
|
-
def
|
54
|
-
@
|
54
|
+
def rule_lookup_keys
|
55
|
+
@rule_lookup_keys ||= patterns.map(&:rule_lookup_key).compact
|
55
56
|
end
|
56
57
|
|
57
58
|
def include_module? set
|
58
59
|
singleton_class&.include? set
|
59
60
|
end
|
61
|
+
|
62
|
+
def each_type_assigning_module_key
|
63
|
+
patterns.each do |p|
|
64
|
+
next unless p.assigns_type
|
65
|
+
|
66
|
+
module_key = p.module_key
|
67
|
+
yield module_key if module_key
|
68
|
+
end
|
69
|
+
end
|
60
70
|
end
|
61
71
|
end
|
62
72
|
end
|
@@ -1,19 +1,21 @@
|
|
1
1
|
class Card
|
2
2
|
module Set
|
3
|
-
|
3
|
+
module Pattern
|
4
4
|
# class from which set patterns inherit
|
5
5
|
class Base
|
6
6
|
extend ClassMethods
|
7
|
+
delegate :pattern_code, :pattern, :anchorless?, :anchor_parts_count,
|
8
|
+
:assigns_type, to: :class
|
7
9
|
|
8
10
|
def initialize card
|
9
|
-
return if
|
11
|
+
return if anchorless?
|
10
12
|
|
11
13
|
@anchor_name = self.class.anchor_name(card).to_name
|
12
14
|
@anchor_id = find_anchor_id card
|
13
15
|
end
|
14
16
|
|
15
17
|
def find_anchor_id card
|
16
|
-
self.class.try(:anchor_id, card) ||
|
18
|
+
self.class.try(:anchor_id, card) || @anchor_name.card_id
|
17
19
|
end
|
18
20
|
|
19
21
|
def module_key
|
@@ -53,16 +55,8 @@ class Card
|
|
53
55
|
end
|
54
56
|
end
|
55
57
|
|
56
|
-
def anchor_parts_count
|
57
|
-
self.class.anchor_parts_count
|
58
|
-
end
|
59
|
-
|
60
|
-
def pattern
|
61
|
-
@pattern ||= self.class.pattern
|
62
|
-
end
|
63
|
-
|
64
58
|
def to_s
|
65
|
-
|
59
|
+
anchorless? ? pattern.s : "#{@anchor_name}+#{pattern}"
|
66
60
|
end
|
67
61
|
|
68
62
|
def inspect
|
@@ -70,15 +64,15 @@ class Card
|
|
70
64
|
end
|
71
65
|
|
72
66
|
def safe_key
|
73
|
-
caps_part =
|
74
|
-
|
67
|
+
caps_part = pattern_code.to_s.tr(" ", "_").upcase
|
68
|
+
anchorless? ? caps_part : "#{caps_part}-#{@anchor_name.safe_key}"
|
75
69
|
end
|
76
70
|
|
77
|
-
def
|
78
|
-
if
|
79
|
-
|
71
|
+
def rule_lookup_key
|
72
|
+
if anchorless?
|
73
|
+
pattern_code.to_s
|
80
74
|
elsif @anchor_id
|
81
|
-
"#{@anchor_id}+#{
|
75
|
+
"#{@anchor_id}+#{pattern_code}"
|
82
76
|
end
|
83
77
|
end
|
84
78
|
end
|
@@ -1,10 +1,9 @@
|
|
1
1
|
class Card
|
2
2
|
module Set
|
3
|
-
|
3
|
+
module Pattern
|
4
4
|
# methods for Set::Pattern classes
|
5
5
|
module ClassMethods
|
6
|
-
attr_accessor :pattern_code, :
|
7
|
-
:assigns_type, :anchorless
|
6
|
+
attr_accessor :pattern_code, :junction_only, :assigns_type, :anchorless
|
8
7
|
attr_writer :anchor_parts_count
|
9
8
|
|
10
9
|
def new card
|
@@ -12,14 +11,10 @@ class Card
|
|
12
11
|
end
|
13
12
|
|
14
13
|
def register pattern_code, opts={}
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
opts.each { |key, val| send "#{key}=", val }
|
20
|
-
else
|
21
|
-
warn "no codename for pattern_code #{pattern_code}"
|
22
|
-
end
|
14
|
+
self.pattern_code = pattern_code
|
15
|
+
Pattern.concrete.insert opts.delete(:index).to_i, self
|
16
|
+
self.anchorless = !respond_to?(:anchor_name)
|
17
|
+
opts.each { |key, val| send "#{key}=", val }
|
23
18
|
end
|
24
19
|
|
25
20
|
def junction_only?
|
@@ -30,8 +25,13 @@ class Card
|
|
30
25
|
anchorless
|
31
26
|
end
|
32
27
|
|
28
|
+
def pattern_id
|
29
|
+
pattern_code.card_id
|
30
|
+
end
|
31
|
+
|
32
|
+
# TODO: change to #name or #pattern_name
|
33
33
|
def pattern
|
34
|
-
|
34
|
+
pattern_id.cardname
|
35
35
|
end
|
36
36
|
|
37
37
|
def pattern_applies? card
|
@@ -44,7 +44,7 @@ class Card
|
|
44
44
|
|
45
45
|
def module_key anchor_codes
|
46
46
|
return pattern_code.to_s.camelize if anchorless?
|
47
|
-
return unless anchor_codes #
|
47
|
+
return unless anchor_codes # not all anchors have codenames
|
48
48
|
|
49
49
|
([pattern_code] + anchor_codes).map { |code| code.to_s.camelize }.join "::"
|
50
50
|
end
|
data/lib/card/set/pattern.rb
CHANGED
@@ -1,43 +1,65 @@
|
|
1
1
|
class Card
|
2
2
|
module Set
|
3
|
-
|
3
|
+
# Each deck can have countless sets of cards, each of which follows one of a small
|
4
|
+
# list of patterns. This module provides methods for managing those patterns.
|
5
|
+
module Pattern
|
4
6
|
class << self
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
# Pattern classes all the patterns except for Abstract.
|
8
|
+
# They are concrete because they are defined on a set of cards
|
9
|
+
# (while abstract sets must be included on them explicitly).
|
10
|
+
#
|
11
|
+
# @return [Array <Class>]
|
12
|
+
def concrete
|
13
|
+
@concrete ||= []
|
11
14
|
end
|
12
15
|
|
13
|
-
|
14
|
-
|
16
|
+
# Pattern classes that can be reloaded without reloading Card
|
17
|
+
# (everything but all)
|
18
|
+
# @return [Array <Class>]
|
19
|
+
def reloadables
|
20
|
+
concrete - [Set::All] + Abstract
|
15
21
|
end
|
16
22
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
23
|
+
# remove reloadable sets and prepare for reloading
|
24
|
+
def reset
|
25
|
+
reloadables.each do |set_pattern|
|
26
|
+
Set.const_remove_if_defined set_pattern.to_s.split("::").last
|
27
|
+
end
|
28
|
+
@concrete = @codes = @type_assigner_codes = @nonbase_codes = @ids = nil
|
21
29
|
end
|
22
30
|
|
31
|
+
# finds pattern class associated with codename
|
32
|
+
# e.g. find(:type) returns `Card::Set::Type`
|
33
|
+
#
|
34
|
+
# @return [Class] pattern class
|
23
35
|
def find pattern_code
|
24
|
-
|
36
|
+
concrete.find { |sub| sub.pattern_code == pattern_code }
|
25
37
|
end
|
26
38
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
hash[card_key] = true
|
32
|
-
end
|
39
|
+
# list of codenames of pattern cards
|
40
|
+
# @return [Array <Symbol>]
|
41
|
+
def codes
|
42
|
+
@codes ||= concrete.map(&:pattern_code).to_set
|
33
43
|
end
|
34
44
|
|
35
|
-
|
36
|
-
|
45
|
+
# list of lists of codenames in pattern load order
|
46
|
+
# @return [Array <Array <Symbol>>]
|
47
|
+
def grouped_codes with_all: true
|
48
|
+
g = [[:abstract], nonbase_codes.reverse]
|
49
|
+
g.unshift [:all] if with_all
|
50
|
+
g
|
37
51
|
end
|
38
52
|
|
39
|
-
|
40
|
-
|
53
|
+
# list of ids of pattern cards
|
54
|
+
# @return [Array <Integer>]
|
55
|
+
def ids
|
56
|
+
@ids ||= concrete.map(&:pattern_id)
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def nonbase_codes
|
62
|
+
@nonbase_codes ||= codes.to_a - [:all]
|
41
63
|
end
|
42
64
|
end
|
43
65
|
end
|
data/lib/card/set/registrar.rb
CHANGED
@@ -48,6 +48,14 @@ class Card
|
|
48
48
|
base_modules.clear
|
49
49
|
end
|
50
50
|
|
51
|
+
def finalize_load
|
52
|
+
# basket.freeze
|
53
|
+
# basket.each_value(&:freeze)
|
54
|
+
clean_empty_modules
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
51
59
|
def clean_empty_modules
|
52
60
|
clean_empty_module_from_hash modules[:nonbase]
|
53
61
|
modules[:nonbase_format].each_value do |hash|
|
@@ -62,8 +70,6 @@ class Card
|
|
62
70
|
end
|
63
71
|
end
|
64
72
|
|
65
|
-
private
|
66
|
-
|
67
73
|
# makes sets ready for dynamic loading via #include_set_modules
|
68
74
|
def register_set_of_type set_module, set_type
|
69
75
|
mods = modules[set_type]
|
data/lib/card/set/trait.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Card
|
2
2
|
module Set
|
3
|
-
#
|
3
|
+
# accessing plus cards as attributes
|
4
4
|
module Trait
|
5
5
|
def card_accessor *args
|
6
6
|
options = args.extract_options!
|
@@ -45,11 +45,25 @@ class Card
|
|
45
45
|
define_trait_card trait, new_opts
|
46
46
|
define_trait_reader trait if options[:reader]
|
47
47
|
define_trait_writer trait if options[:writer]
|
48
|
+
assign_trait_type trait, options[:type]
|
48
49
|
|
49
50
|
mod_traits[trait.to_sym] = options
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
54
|
+
def assign_trait_type trait, type
|
55
|
+
return unless type && (parts = trait_module_key_parts trait)
|
56
|
+
assign_type type, normalize_const(parts)
|
57
|
+
end
|
58
|
+
|
59
|
+
def trait_module_key_parts trait
|
60
|
+
if all_set?
|
61
|
+
[:right, trait]
|
62
|
+
elsif type_set?
|
63
|
+
[:type_plus_right, set_name_parts.last, trait]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
53
67
|
def new_trait_opts options
|
54
68
|
%i[type default_content].each_with_object({}).each do |key, hash|
|
55
69
|
hash[key] = options[key] if options[key]
|
@@ -58,6 +72,7 @@ class Card
|
|
58
72
|
|
59
73
|
def define_trait_card trait, opts
|
60
74
|
define_method "#{trait}_card" do
|
75
|
+
# opts = opts.clone.merge supercard: card
|
61
76
|
fetch trait.to_sym, new: opts.clone, eager_cache: true
|
62
77
|
end
|
63
78
|
end
|
data/lib/card/set/type.rb
CHANGED
data/lib/card/set.rb
CHANGED
@@ -48,7 +48,6 @@ class Card
|
|
48
48
|
module Set
|
49
49
|
include Event::Api
|
50
50
|
include Trait
|
51
|
-
include Basket
|
52
51
|
include Inheritance
|
53
52
|
|
54
53
|
include Format
|
@@ -58,15 +57,23 @@ class Card
|
|
58
57
|
extend I18nScope
|
59
58
|
extend Registrar
|
60
59
|
|
61
|
-
|
60
|
+
class << self
|
61
|
+
attr_accessor :modules, :traits, :basket
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
63
|
+
def reset
|
64
|
+
self.modules = {
|
65
|
+
base: [], base_format: {},
|
66
|
+
nonbase: {}, nonbase_format: {},
|
67
|
+
abstract: {}, abstract_format: {}
|
68
|
+
}
|
69
|
+
|
70
|
+
self.basket = {}
|
71
|
+
end
|
67
72
|
end
|
68
73
|
|
69
|
-
|
74
|
+
delegate :basket, to: Set
|
75
|
+
|
76
|
+
reset
|
70
77
|
|
71
78
|
# SET MODULE API
|
72
79
|
#
|
data/lib/card/subcards/add.rb
CHANGED
@@ -53,9 +53,7 @@ class Card
|
|
53
53
|
|
54
54
|
def new_by_card card
|
55
55
|
card.supercard = @context_card
|
56
|
-
|
57
|
-
card.superleft = @context_card
|
58
|
-
end
|
56
|
+
card.update_superleft card.name
|
59
57
|
@keys << card.key
|
60
58
|
Card.write_to_soft_cache card
|
61
59
|
card.director = @context_card.director.subdirectors.add card
|
data/lib/card/subcards/all.rb
CHANGED
@@ -2,18 +2,6 @@ class Card
|
|
2
2
|
class Subcards
|
3
3
|
# subcard-related Card instance methods
|
4
4
|
module All
|
5
|
-
def subcard card_name
|
6
|
-
subcards.card card_name
|
7
|
-
end
|
8
|
-
|
9
|
-
def subfield field_name
|
10
|
-
subcards.field field_name
|
11
|
-
end
|
12
|
-
|
13
|
-
def field? tag
|
14
|
-
field(tag) || subfield(tag)
|
15
|
-
end
|
16
|
-
|
17
5
|
def subcards
|
18
6
|
@subcards ||= Card::Subcards.new self
|
19
7
|
end
|
@@ -22,66 +10,50 @@ class Card
|
|
22
10
|
subcards.present?
|
23
11
|
end
|
24
12
|
|
25
|
-
def
|
26
|
-
subcards.
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
subcards.add name_or_card, args
|
33
|
-
end
|
34
|
-
alias_method :attach_subcard, :add_subcard
|
35
|
-
|
36
|
-
def add_subcard! name_or_card, args={}
|
37
|
-
subcard = subcards.add name_or_card, args
|
38
|
-
subcard.director.reset_stage
|
39
|
-
subcard
|
13
|
+
def subcard card_name, args={}
|
14
|
+
if (sc = subcards.card card_name)
|
15
|
+
sc.assign_attributes args
|
16
|
+
sc
|
17
|
+
else
|
18
|
+
subcards.add card_name, args
|
19
|
+
end
|
40
20
|
end
|
41
|
-
alias_method :attach_subcard!, :add_subcard!
|
42
21
|
|
43
|
-
|
44
|
-
|
45
|
-
subcards.add_field name_or_card, args
|
22
|
+
def subcard_content card_name
|
23
|
+
subcards.card(card_name)&.content
|
46
24
|
end
|
47
|
-
alias_method :add_subfield, :attach_subfield
|
48
25
|
|
49
|
-
def
|
50
|
-
|
51
|
-
subcard.director.reset_stage
|
52
|
-
subcard
|
26
|
+
def subcard? card_name
|
27
|
+
subcards.card(card_name).present?
|
53
28
|
end
|
54
29
|
|
55
|
-
def
|
56
|
-
subcards.
|
30
|
+
def subfield field_name, args={}
|
31
|
+
if (sf = subcards.field field_name)
|
32
|
+
sf.assign_attributes args
|
33
|
+
sf
|
34
|
+
else
|
35
|
+
subcards.add_field field_name, args
|
36
|
+
end
|
57
37
|
end
|
58
|
-
alias_method :remove_subcard, :detach_subcard
|
59
38
|
|
60
|
-
def
|
61
|
-
subcards.
|
39
|
+
def subfield_content field_name
|
40
|
+
subcards.field(field_name)&.content
|
62
41
|
end
|
63
|
-
alias_method :remove_subfield, :detach_subfield
|
64
42
|
|
65
|
-
def
|
66
|
-
subcards.
|
43
|
+
def subfield? field_name
|
44
|
+
subcards.field(field_name).present?
|
67
45
|
end
|
68
46
|
|
69
|
-
|
70
|
-
|
71
|
-
def ensure_subfield field_name, args={}
|
72
|
-
if subfield_present? field_name
|
73
|
-
subfield field_name
|
74
|
-
else
|
75
|
-
add_subfield field_name, args
|
76
|
-
end
|
47
|
+
def field? tag
|
48
|
+
field(tag) || subfield?(tag)
|
77
49
|
end
|
78
50
|
|
79
|
-
def
|
80
|
-
|
51
|
+
def drop_subcard name_or_card
|
52
|
+
subcards.remove name_or_card
|
81
53
|
end
|
82
54
|
|
83
|
-
def
|
84
|
-
subcards.
|
55
|
+
def drop_subfield name_or_card
|
56
|
+
subcards.remove_field name_or_card
|
85
57
|
end
|
86
58
|
|
87
59
|
def handle_subcard_errors
|
@@ -93,6 +65,8 @@ class Card
|
|
93
65
|
end
|
94
66
|
end
|
95
67
|
|
68
|
+
private
|
69
|
+
|
96
70
|
def subcard_error subcard, error
|
97
71
|
msg = error.message
|
98
72
|
msg = "#{error.attribute} #{msg}" unless %i[content abort].member? error.attribute
|
data/lib/card/view/classy.rb
CHANGED
@@ -24,9 +24,7 @@ class Card
|
|
24
24
|
# :single_use the same as :nests but is removed after the first use
|
25
25
|
# :global always everywhere
|
26
26
|
def class_up klass, classier, scope=:subviews
|
27
|
-
|
28
|
-
|
29
|
-
storage_voo(scope).add_extra_classes klass, classier, scope
|
27
|
+
storage_voo(scope).add_extra_classes klass.to_s, classier, scope
|
30
28
|
end
|
31
29
|
|
32
30
|
def class_down klass, classier
|
@@ -55,10 +53,8 @@ class Card
|
|
55
53
|
end
|
56
54
|
|
57
55
|
def add_extra_classes key, classier, scope
|
58
|
-
|
59
|
-
|
60
|
-
class_list(type)[key] =
|
61
|
-
[class_list(type)[key], classier].flatten.compact.join(" ")
|
56
|
+
list = class_list class_list_type(scope)
|
57
|
+
list[key] = [list[key], classier].flatten.compact.join " "
|
62
58
|
end
|
63
59
|
|
64
60
|
# remove classes everywhere where they are visible for the given scope
|
@@ -83,9 +79,7 @@ class Card
|
|
83
79
|
|
84
80
|
def extra_classes klass
|
85
81
|
klass = klass.first if klass.is_a?(Array)
|
86
|
-
|
87
|
-
|
88
|
-
deep_extra_classes klass, :self
|
82
|
+
deep_extra_classes klass.to_s, :self
|
89
83
|
end
|
90
84
|
|
91
85
|
# recurse through voos and formats to find all extra classes
|
@@ -135,33 +129,27 @@ class Card
|
|
135
129
|
end
|
136
130
|
|
137
131
|
def class_list type=:private
|
138
|
-
|
139
|
-
when :private, :format_private, :public, :single_use
|
140
|
-
@class_list ||= {}
|
141
|
-
@class_list[type] ||= {}
|
142
|
-
else
|
132
|
+
unless type.in? %i[private format_private public single_use]
|
143
133
|
raise ArgumentError, "#{type} not a valid class list"
|
144
134
|
end
|
135
|
+
@class_list ||= {}
|
136
|
+
@class_list[type] ||= {}
|
145
137
|
end
|
146
138
|
|
139
|
+
CLASS_LIST_TYPE = { view: :private,
|
140
|
+
format: :format_private,
|
141
|
+
subviews: :format_private,
|
142
|
+
nests: :public,
|
143
|
+
global: :public,
|
144
|
+
single_use: :single_use }.freeze
|
145
|
+
|
147
146
|
# Translates scopes to the privacy types used to manage the class lists.
|
148
147
|
# A #classy calls looks in the following class_lists:
|
149
148
|
# private - only in the same voo
|
150
149
|
# format_private - the same voo and all parent voos in the same format
|
151
150
|
# public - in all voos in all parent formats
|
152
151
|
def class_list_type scope
|
153
|
-
|
154
|
-
when :view
|
155
|
-
:private
|
156
|
-
when :format, :subviews
|
157
|
-
:format_private
|
158
|
-
when :nests, :global
|
159
|
-
:public
|
160
|
-
when :single_use
|
161
|
-
:single_use
|
162
|
-
else
|
163
|
-
raise ArgumentError, "invalid class_up scope: #{scope}"
|
164
|
-
end
|
152
|
+
CLASS_LIST_TYPE[scope] || raise(ArgumentError, "invalid class_up scope: #{scope}")
|
165
153
|
end
|
166
154
|
end
|
167
155
|
end
|
@@ -49,7 +49,9 @@ class Card
|
|
49
49
|
# because they can get changed after. current solution is a compromise.
|
50
50
|
# @return [Hash]
|
51
51
|
def slot_options
|
52
|
-
normalized_options.merge(view: requested_view)
|
52
|
+
normalized_options.merge(view: requested_view)
|
53
|
+
.merge(normalized_visibility_options)
|
54
|
+
.slice(*Options.slot_keys)
|
53
55
|
end
|
54
56
|
|
55
57
|
# ACCESSOR_HELPERS
|
data/lib/card/view/options.rb
CHANGED
@@ -40,6 +40,7 @@ class Card
|
|
40
40
|
heir: [
|
41
41
|
:main, # format object is page's "main" object (Boolean)
|
42
42
|
:home_view, # view for slot to return to when no view specified
|
43
|
+
:buttons_view,
|
43
44
|
:edit_structure, # use a different structure for editing (Array)
|
44
45
|
:cql, # contextual cql alterations for search cards (Hash)
|
45
46
|
:action_id, # a Card::Action id (Integer)
|
@@ -50,20 +51,21 @@ class Card
|
|
50
51
|
:help, # cue text when editing
|
51
52
|
:structure, # overrides the content of the card
|
52
53
|
:title, # overrides the name of the card
|
53
|
-
:variant, # override the
|
54
|
-
# variant
|
54
|
+
:variant, # override the standard name with a different 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
|
-
#
|
59
|
-
:params, # parameters for add button. deprecated!
|
58
|
+
# (also used for character limit in one_line_content)
|
60
59
|
:items, # options for items (Hash)
|
61
60
|
:cache, # change view cache behaviour
|
62
61
|
# (Symbol<:always, :standard, :never>)
|
63
62
|
:edit, # edit mode
|
64
63
|
# (Symbol<:inline, :standard, :full>)
|
65
64
|
:separator, # item separator in certain lists
|
66
|
-
:filter
|
65
|
+
:filter,
|
66
|
+
|
67
|
+
# DEPRECATED
|
68
|
+
:params # parameters for add button
|
67
69
|
],
|
68
70
|
none: [
|
69
71
|
:skip_perms, # do not check permissions for this view (Boolean)
|