card 1.103.2 → 1.103.3
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/production.rb +9 -9
- 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 -1
- 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/seed/new/card_actions.yml +2381 -2381
- data/db/seed/new/card_acts.yml +3 -3
- data/db/seed/new/card_references.yml +1026 -1033
- data/db/seed/new/cards.yml +5291 -5293
- data/db/seed/test/fixtures/cards.yml +6 -6
- data/lib/card/content/chunk.rb +0 -1
- data/lib/card/content/diff/summary.rb +14 -18
- data/lib/card/content.rb +9 -1
- data/lib/card/director/act_direction.rb +5 -3
- data/lib/card/director/stages.rb +2 -0
- data/lib/card/fetch/results.rb +6 -6
- 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 +1 -1
- data/lib/card/name/card_class.rb +1 -1
- data/lib/card/name.rb +6 -6
- data/lib/card/set/card_methods.rb +13 -0
- data/lib/card/set/event/skip_and_trigger.rb +8 -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 +55 -0
- data/lib/card/set/inheritance.rb +1 -1
- data/lib/card/set/pattern/all.rb +7 -6
- data/lib/card/set/pattern/class_methods.rb +2 -2
- data/lib/card/set/pattern.rb +30 -19
- data/lib/card/set/registrar.rb +8 -2
- data/lib/card/set.rb +14 -7
- data/lib/card/view/classy.rb +15 -27
- data/lib/card/view/options/voo_api.rb +3 -1
- data/lib/card/view.rb +1 -0
- data/lib/card.rb +9 -11
- data/lib/cardio/generators/deck_helper.rb +0 -4
- data/lib/cardio/mod/load_strategy/set_tmp_files.rb +10 -4
- 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/railtie.rb +6 -2
- data/lib/generators/deck/templates/Gemfile.erb +1 -1
- data/lib/generators/deck/templates/Rakefile.erb +6 -2
- data/lib/generators/deck/templates/simplecov.rb.erb +7 -11
- data/lib/{card/tasks → tasks}/card/asset.rake +0 -0
- data/lib/{card/tasks → tasks}/card/create.rake +0 -0
- data/lib/{card/tasks → tasks}/card/migrate.rake +0 -0
- data/lib/{card/tasks → tasks}/card/mod.rake +0 -0
- data/lib/{card/tasks → tasks}/card.rake +0 -0
- data/mod/admin/set/all/admin.rb +16 -0
- data/mod/admin/set/self/admin.rb +2 -6
- data/mod/admin/set/self/admin_info.rb +2 -5
- data/mod/core/locales/en.yml +4 -5
- data/mod/core/set/all/name_events.rb +1 -1
- data/mod/core/set/all/reference_events.rb +5 -10
- data/mod/core/set/all/trash.rb +2 -3
- data/mod/core/spec/set/all/name_events_spec.rb +10 -10
- data/mod/core/spec/set/all/trash_spec.rb +1 -1
- metadata +20 -19
- data/lib/card/set/basket.rb +0 -59
@@ -1486,8 +1486,8 @@ cards_072:
|
|
1486
1486
|
references_expired:
|
1487
1487
|
trash: false
|
1488
1488
|
type_id: 3
|
1489
|
-
db_content: "<p>Searches return a list of cards using [[http://decko.org/
|
1490
|
-
the Wagn Query Language]]. See the [[http://decko.org/
|
1489
|
+
db_content: "<p>Searches return a list of cards using [[http://decko.org/WQL|WQL,
|
1490
|
+
the Wagn Query Language]]. See the [[http://decko.org/WQL syntax|syntax documentation]].</p>"
|
1491
1491
|
cards_073:
|
1492
1492
|
id: 184
|
1493
1493
|
name: by name
|
@@ -1595,7 +1595,7 @@ cards_078:
|
|
1595
1595
|
references_expired:
|
1596
1596
|
trash: false
|
1597
1597
|
type_id: 3
|
1598
|
-
db_content: "<p>These cards allow unrestricted HTML. [[http://decko.org/
|
1598
|
+
db_content: "<p>These cards allow unrestricted HTML. [[http://decko.org/HTML|more]]</p>"
|
1599
1599
|
cards_079:
|
1600
1600
|
id: 205
|
1601
1601
|
name:
|
@@ -1667,7 +1667,7 @@ cards_082:
|
|
1667
1667
|
references_expired:
|
1668
1668
|
trash: false
|
1669
1669
|
type_id: 3
|
1670
|
-
db_content: "<p>Toggles simply indicate yes or no. [[http://decko.org/
|
1670
|
+
db_content: "<p>Toggles simply indicate yes or no. [[http://decko.org/Toggle|more]].</p>"
|
1671
1671
|
cards_083:
|
1672
1672
|
id: 213
|
1673
1673
|
name:
|
@@ -2397,7 +2397,7 @@ cards_122:
|
|
2397
2397
|
references_expired:
|
2398
2398
|
trash: false
|
2399
2399
|
type_id: 3
|
2400
|
-
db_content: "<div>Sets define a group of cards to which settings can apply. [[http://www.decko.org/
|
2400
|
+
db_content: "<div>Sets define a group of cards to which settings can apply. [[http://www.decko.org/Setting|Learn
|
2401
2401
|
more about settings.]]</div>"
|
2402
2402
|
cards_123:
|
2403
2403
|
id: 298
|
@@ -2419,7 +2419,7 @@ cards_123:
|
|
2419
2419
|
db_content: |-
|
2420
2420
|
<div>Settings affect how cards look and behave. Settings are available under each card's Options tab.</div>
|
2421
2421
|
<p> </p>
|
2422
|
-
<div><em>[[http://www.decko.org/
|
2422
|
+
<div><em>[[http://www.decko.org/Setting|Learn more about settings.]]</em></div>
|
2423
2423
|
cards_124:
|
2424
2424
|
id: 300
|
2425
2425
|
name:
|
data/lib/card/content/chunk.rb
CHANGED
@@ -7,21 +7,11 @@ class Card
|
|
7
7
|
opts ||= {}
|
8
8
|
@remaining_chars = opts[:length] || 50
|
9
9
|
@joint = opts[:joint] || "..."
|
10
|
-
|
11
|
-
@summary = nil
|
12
10
|
@chunks = []
|
13
|
-
@content_omitted = false
|
14
11
|
end
|
15
12
|
|
16
13
|
def rendered
|
17
|
-
@
|
18
|
-
begin
|
19
|
-
truncate_overlap
|
20
|
-
@chunks.map do |chunk|
|
21
|
-
@content_omitted ||= chunk[:action] == :ellipsis
|
22
|
-
render_chunk chunk[:action], chunk[:text]
|
23
|
-
end.join
|
24
|
-
end
|
14
|
+
@rendered ||= render
|
25
15
|
end
|
26
16
|
|
27
17
|
def add text
|
@@ -44,6 +34,14 @@ class Card
|
|
44
34
|
|
45
35
|
private
|
46
36
|
|
37
|
+
def render
|
38
|
+
truncate_overlap
|
39
|
+
@chunks.map do |chunk|
|
40
|
+
@content_omitted ||= chunk[:action] == :ellipsis
|
41
|
+
render_chunk chunk[:action], chunk[:text]
|
42
|
+
end.join
|
43
|
+
end
|
44
|
+
|
47
45
|
def add_chunk text, action
|
48
46
|
return unless @remaining_chars.positive?
|
49
47
|
|
@@ -119,16 +117,14 @@ class Card
|
|
119
117
|
@chunks[index][:text] += @joint
|
120
118
|
end
|
121
119
|
|
120
|
+
JOINT_REPLACEMENT = { added: :ellipis, deleted: :added }.freeze
|
121
|
+
|
122
122
|
def replace_with_joint index
|
123
123
|
@chunks.pop
|
124
|
-
return unless index.positive?
|
124
|
+
return unless index.positive? &&
|
125
|
+
(previous_action = JOINT_REPLACEMENT[@chunks[index - 1][:action]])
|
125
126
|
|
126
|
-
|
127
|
-
when :added
|
128
|
-
add_chunk_to_list @joint, :ellipsis
|
129
|
-
when :deleted
|
130
|
-
add_chunk_to_list @joint, :added
|
131
|
-
end
|
127
|
+
add_chunk_to_list @joint, previous_action
|
132
128
|
end
|
133
129
|
end
|
134
130
|
end
|
data/lib/card/content.rb
CHANGED
@@ -104,7 +104,7 @@ class Card
|
|
104
104
|
end
|
105
105
|
|
106
106
|
def without_references &block
|
107
|
-
without_chunks Chunk::Nest, Chunk::Link, &block
|
107
|
+
without_chunks Chunk::Nest, Chunk::Link, Chunk::EscapedLiteral, &block
|
108
108
|
end
|
109
109
|
|
110
110
|
def without_chunks *chunk_classes
|
@@ -114,6 +114,14 @@ class Card
|
|
114
114
|
unstash_chunks processed, stash
|
115
115
|
end
|
116
116
|
|
117
|
+
def strip_nests
|
118
|
+
strip_chunks Chunk::Nest
|
119
|
+
end
|
120
|
+
|
121
|
+
def strip_chunks chunk_type
|
122
|
+
chunks.reject! { |c| c.is_a? chunk_type }
|
123
|
+
end
|
124
|
+
|
117
125
|
private
|
118
126
|
|
119
127
|
def interpret_chunk_type chunk_type
|
data/lib/card/director/stages.rb
CHANGED
data/lib/card/fetch/results.rb
CHANGED
@@ -28,7 +28,7 @@ class Card
|
|
28
28
|
elsif opts[:skip_virtual]
|
29
29
|
return nil
|
30
30
|
else
|
31
|
-
|
31
|
+
assign_name mark
|
32
32
|
end
|
33
33
|
yield
|
34
34
|
end
|
@@ -53,9 +53,9 @@ class Card
|
|
53
53
|
def quick_renew
|
54
54
|
return false unless quick_renew?
|
55
55
|
|
56
|
-
# Rails.logger.info "QUICK renewing: #{mark}, #{new_opts}"
|
57
56
|
update_supercard
|
58
|
-
|
57
|
+
opts_name = new_opts[:name]
|
58
|
+
assign_name(opts_name.present? ? opts_name : mark)
|
59
59
|
true
|
60
60
|
end
|
61
61
|
|
@@ -123,11 +123,11 @@ class Card
|
|
123
123
|
@new_opts ||= opts[:new]
|
124
124
|
end
|
125
125
|
|
126
|
-
def
|
126
|
+
def assign_name requested
|
127
127
|
return if opts[:local_only]
|
128
|
-
return unless
|
128
|
+
return unless requested&.to_s != card.name
|
129
129
|
|
130
|
-
card.name =
|
130
|
+
card.name = requested.to_s
|
131
131
|
end
|
132
132
|
end
|
133
133
|
end
|
File without changes
|
data/lib/card/{tasks/card/file_card_creator → file_card_creator}/abstract_file_card/ruby_file.rb
RENAMED
File without changes
|
data/lib/card/{tasks/card/file_card_creator → file_card_creator}/abstract_file_card/source_file.rb
RENAMED
File without changes
|
@@ -1,8 +1,3 @@
|
|
1
|
-
require_relative "./output_helper"
|
2
|
-
require_relative "./abstract_file_card/source_file"
|
3
|
-
require_relative "./abstract_file_card/ruby_file"
|
4
|
-
require_relative "./abstract_file_card/migration_file"
|
5
|
-
|
6
1
|
class Card
|
7
2
|
class FileCardCreator
|
8
3
|
# A template class for generating cards that are linked to source files.
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,8 +1,3 @@
|
|
1
|
-
require_relative "./file_card_creator/script_card"
|
2
|
-
require_relative "./file_card_creator/style_card"
|
3
|
-
require_relative "./file_card_creator/haml_card"
|
4
|
-
require_relative "./file_card_creator/abstract_file_card"
|
5
|
-
|
6
1
|
class Card
|
7
2
|
# A Factory class
|
8
3
|
# It chooses the class to create the file card according to the given type.
|
data/lib/card/format/content.rb
CHANGED
@@ -7,14 +7,12 @@ class Card
|
|
7
7
|
content_obj.to_s
|
8
8
|
end
|
9
9
|
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
10
|
+
# 1. Break out references (nests / links) into separate chunks
|
11
|
+
# 2. yields the other (non-ref) content
|
12
|
+
# 3. processes references
|
13
13
|
def safe_process_content override_content=nil, content_opts=nil, &block
|
14
|
-
content_obj =
|
15
|
-
|
16
|
-
result = content_obj.without_references(&block)
|
17
|
-
process_content result, content_opts
|
14
|
+
content_obj = content_object override_content, chunk_list: :references
|
15
|
+
process_content content_obj.without_references(&block), content_opts
|
18
16
|
end
|
19
17
|
|
20
18
|
# nested by another card's content
|
data/lib/card/format/render.rb
CHANGED
@@ -8,11 +8,9 @@ class Card
|
|
8
8
|
voo = View.new self, view, view_options, @voo
|
9
9
|
with_voo voo do
|
10
10
|
voo.process do |final_view|
|
11
|
-
|
11
|
+
wrap_and_render final_view
|
12
12
|
end
|
13
13
|
end
|
14
|
-
rescue StandardError => e
|
15
|
-
rescue_view e, view
|
16
14
|
end
|
17
15
|
|
18
16
|
def with_voo voo
|
@@ -38,13 +36,15 @@ class Card
|
|
38
36
|
end
|
39
37
|
|
40
38
|
def final_render view
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
39
|
+
method = view_method view
|
40
|
+
rendered = final_render_call method
|
41
|
+
add_debug_info view, method, rendered
|
42
|
+
end
|
43
|
+
|
44
|
+
def wrap_and_render view
|
45
|
+
current_view(view) { with_wrapper { final_render view } }
|
46
|
+
rescue StandardError => e
|
47
|
+
rescue_view e, view
|
48
48
|
end
|
49
49
|
|
50
50
|
def final_render_call method
|
data/lib/card/format.rb
CHANGED
@@ -33,6 +33,9 @@ class Card
|
|
33
33
|
attr_reader :card, :parent, :main_opts, :modal_opts
|
34
34
|
attr_accessor :form, :error_status, :rendered
|
35
35
|
|
36
|
+
delegate :basket, to: Set
|
37
|
+
delegate :session, :params, to: Env
|
38
|
+
|
36
39
|
def self.view_caching?
|
37
40
|
true
|
38
41
|
end
|
@@ -66,18 +69,10 @@ class Card
|
|
66
69
|
end
|
67
70
|
end
|
68
71
|
|
69
|
-
def params
|
70
|
-
Env.params
|
71
|
-
end
|
72
|
-
|
73
72
|
def controller
|
74
73
|
@controller || Env[:controller] ||= CardController.new
|
75
74
|
end
|
76
75
|
|
77
|
-
def session
|
78
|
-
Env.session
|
79
|
-
end
|
80
|
-
|
81
76
|
def mime_type
|
82
77
|
"text/plain"
|
83
78
|
end
|
data/lib/card/lexicon.rb
CHANGED
@@ -28,15 +28,9 @@ class Card
|
|
28
28
|
Card::Cache[Lexicon]
|
29
29
|
end
|
30
30
|
|
31
|
-
def add card
|
32
|
-
lex = card.lex
|
33
|
-
cache.write card.id.to_s, lex
|
34
|
-
cache.write cache_key(lex), card.id
|
35
|
-
end
|
36
|
-
|
37
31
|
def update card
|
38
32
|
add card
|
39
|
-
|
33
|
+
expire_lex card.lex_before_act
|
40
34
|
end
|
41
35
|
|
42
36
|
# def delete card
|
@@ -50,8 +44,37 @@ class Card
|
|
50
44
|
lex.map { |side_id| name side_id or return }.join(Card::Name.joint).to_name
|
51
45
|
end
|
52
46
|
|
47
|
+
# this is to address problems whereby renaming errors leave the lexicon broken.
|
48
|
+
# NEEDS TESTING
|
49
|
+
def rescuing
|
50
|
+
@act_lexes = []
|
51
|
+
@act_ids = []
|
52
|
+
yield
|
53
|
+
rescue StandardError => e
|
54
|
+
@act_lexes.each { |lex| expire_lex lex }
|
55
|
+
@act_ids.each { |id| expire_id id }
|
56
|
+
@act_lexes = @act_ids = nil
|
57
|
+
raise e
|
58
|
+
end
|
59
|
+
|
53
60
|
private
|
54
61
|
|
62
|
+
def add card
|
63
|
+
lex = card.lex
|
64
|
+
@act_lexes << lex
|
65
|
+
@act_ids << card.id
|
66
|
+
cache.write card.id.to_s, lex
|
67
|
+
cache.write cache_key(lex), card.id
|
68
|
+
end
|
69
|
+
|
70
|
+
def expire_lex lex
|
71
|
+
cache.delete cache_key(lex)
|
72
|
+
end
|
73
|
+
|
74
|
+
def expire_id id
|
75
|
+
cache.delete id.to_s
|
76
|
+
end
|
77
|
+
|
55
78
|
def id_to_lex id
|
56
79
|
cache.fetch id.to_s do
|
57
80
|
result = Card.where(id: id).pluck(:name, :left_id, :right_id).first
|
data/lib/card/name/card_class.rb
CHANGED
data/lib/card/name.rb
CHANGED
@@ -19,7 +19,7 @@ class Card
|
|
19
19
|
case cardish
|
20
20
|
when Card then cardish.name
|
21
21
|
when Symbol, Integer then Card.fetch_name(cardish)
|
22
|
-
when Array then
|
22
|
+
when Array then compose cardish
|
23
23
|
when String, NilClass then new cardish
|
24
24
|
else
|
25
25
|
raise ArgumentError, "#{cardish.class} not supported as name identifier"
|
@@ -40,7 +40,7 @@ class Card
|
|
40
40
|
str = str.to_s
|
41
41
|
|
42
42
|
if !validated_parts && str.include?(joint)
|
43
|
-
|
43
|
+
string_compose Cardname.split_parts(str)
|
44
44
|
elsif (id = Card.id_from_string str) # handles ~[id] and :[codename]
|
45
45
|
Card.name_from_id_from_string id, str
|
46
46
|
else
|
@@ -49,16 +49,16 @@ class Card
|
|
49
49
|
end
|
50
50
|
|
51
51
|
# interprets symbols/integers as codenames/ids
|
52
|
-
def
|
52
|
+
def compose parts
|
53
53
|
new_from_parts(parts) { |part| self[part] }
|
54
54
|
end
|
55
55
|
|
56
|
-
|
56
|
+
private
|
57
|
+
|
58
|
+
def string_compose parts
|
57
59
|
new_from_parts(parts) { |part| new part }
|
58
60
|
end
|
59
61
|
|
60
|
-
private
|
61
|
-
|
62
62
|
def new_from_parts parts, &block
|
63
63
|
name_parts = parts.flatten.map(&block)
|
64
64
|
new name_parts.join(joint), true
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Card
|
2
|
+
module Set
|
3
|
+
# Set-related methods included in card class
|
4
|
+
# (note: Card::Set::All would follow our naming convention but is in use by the
|
5
|
+
# "all" set)
|
6
|
+
module CardMethods
|
7
|
+
include Event::All
|
8
|
+
include Pattern::All
|
9
|
+
|
10
|
+
delegate :basket, to: Set
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -34,6 +34,14 @@ class Card
|
|
34
34
|
@trigger_hash ||= hash_with_value trigger, true
|
35
35
|
end
|
36
36
|
|
37
|
+
def skip_event? event
|
38
|
+
full_skip_hash.key? event.to_s
|
39
|
+
end
|
40
|
+
|
41
|
+
def trigger_event? event
|
42
|
+
full_trigger_hash.key? event.to_s
|
43
|
+
end
|
44
|
+
|
37
45
|
private
|
38
46
|
|
39
47
|
# "applies always means event can run
|
@@ -75,7 +75,7 @@ class Card
|
|
75
75
|
def define_wrap_with_method wrapper_name, wrapper_method_name
|
76
76
|
class_exec(self) do |_format|
|
77
77
|
define_method "wrap_with_#{wrapper_name}" do |*args, &interior|
|
78
|
-
|
78
|
+
voo.interior, opts = interior ? [interior.call, args.first] : args
|
79
79
|
send_wrapper_method wrapper_method_name, opts
|
80
80
|
end
|
81
81
|
end
|
@@ -7,12 +7,13 @@ class Card
|
|
7
7
|
# Whenever you create a format block in a set module in a {Cardio::Mod mod}, you
|
8
8
|
# create a format module that is extended with AbstractFormat.
|
9
9
|
module AbstractFormat
|
10
|
-
include Set::Basket
|
11
10
|
include ViewOpts
|
12
11
|
include ViewDefinition
|
13
12
|
include HamlViews
|
14
13
|
include Wrapper
|
15
14
|
|
15
|
+
delegate :basket, to: Set
|
16
|
+
|
16
17
|
# _Views_ are the primary way that both sharks and monkeys interact with cards.
|
17
18
|
# Sharks select views to use in _nests_. Monkeys can define and tweak those
|
18
19
|
# views. These docs will introduce the basics of view definition.
|
data/lib/card/set/format.rb
CHANGED
@@ -114,13 +114,12 @@ class Card
|
|
114
114
|
|
115
115
|
# make mod ready to include in base (non-set-specific) format classes
|
116
116
|
def register_all_set_format format_class, mod
|
117
|
-
add_to_array_val modules[:base_format], format_class, mod
|
117
|
+
add_to_array_val Set.modules[:base_format], format_class, mod
|
118
118
|
end
|
119
119
|
|
120
120
|
def register_standard_set_format format_class, mod
|
121
|
-
format_type = abstract_set? ? :abstract_format : :nonbase_format
|
122
121
|
# ready to include dynamically in set members' format singletons
|
123
|
-
format_hash = modules[
|
122
|
+
format_hash = Set.modules[set_format_type_key][format_class] ||= {}
|
124
123
|
add_to_array_val format_hash, shortname, mod
|
125
124
|
end
|
126
125
|
|
data/lib/card/set/helpers.rb
CHANGED
@@ -19,6 +19,20 @@ class Card
|
|
19
19
|
Pattern.find(pattern_code).anchor_parts_count
|
20
20
|
end
|
21
21
|
|
22
|
+
def set_format_type_key
|
23
|
+
:"#{set_type_key}_format"
|
24
|
+
end
|
25
|
+
|
26
|
+
def set_type_key
|
27
|
+
if all_set?
|
28
|
+
:base
|
29
|
+
elsif abstract_set?
|
30
|
+
:abstract
|
31
|
+
else
|
32
|
+
:nonbase
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
22
36
|
def set_name_parts
|
23
37
|
@set_name_parts ||= name.split "::"
|
24
38
|
end
|
@@ -39,6 +53,47 @@ class Card
|
|
39
53
|
def respond_to_missing? method_name, _include_private=false
|
40
54
|
method_name.match? SET_PATTERN_TEST_REGEXP
|
41
55
|
end
|
56
|
+
|
57
|
+
def modules
|
58
|
+
if all_set?
|
59
|
+
[self]
|
60
|
+
elsif abstract_set?
|
61
|
+
[test_set]
|
62
|
+
else
|
63
|
+
Set.modules[:nonbase][shortname] || []
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def format_modules format_sym
|
68
|
+
type_key = set_format_type_key
|
69
|
+
if !type_key || type_key == :base_format
|
70
|
+
[format_module(format_sym)]
|
71
|
+
elsif abstract_set?
|
72
|
+
[test_set.format_module(format_sym)]
|
73
|
+
else
|
74
|
+
format_class = Card::Format.format_class format: format_sym
|
75
|
+
Card::Set.modules[type_key][format_class][shortname] || []
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def format_module format_sym
|
80
|
+
const_get Card::Format.format_class_name(format_sym)
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_set
|
84
|
+
# rubocop:disable Lint/Eval
|
85
|
+
::Card::Set::Self.const_remove_if_defined :TestSet
|
86
|
+
eval <<-RUBY, binding, __FILE__, __LINE__ + 1
|
87
|
+
class ::Card::Set::Self
|
88
|
+
module TestSet
|
89
|
+
extend Card::Set
|
90
|
+
include_set #{name}
|
91
|
+
end
|
92
|
+
end
|
93
|
+
RUBY
|
94
|
+
::Card::Set::Self::TestSet
|
95
|
+
# rubocop:enable Lint/Eval
|
96
|
+
end
|
42
97
|
end
|
43
98
|
end
|
44
99
|
end
|
data/lib/card/set/inheritance.rb
CHANGED
@@ -74,7 +74,7 @@ class Card
|
|
74
74
|
def each_format_with_mods set
|
75
75
|
set_type = set.abstract_set? ? :abstract : :nonbase
|
76
76
|
format_type = "#{set_type}_format".to_sym
|
77
|
-
modules[format_type].each_pair { |*args| yield(*args) }
|
77
|
+
Set.modules[format_type].each_pair { |*args| yield(*args) }
|
78
78
|
end
|
79
79
|
|
80
80
|
def applicable_format? format, except, only
|
data/lib/card/set/pattern/all.rb
CHANGED
@@ -7,18 +7,18 @@ class Card
|
|
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
23
|
@set_mods_loaded = @set_modules = @set_names = @rule_set_keys = nil
|
24
24
|
@junction_only = nil # only applies to set cards
|
@@ -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
|
@@ -14,11 +14,11 @@ class Card
|
|
14
14
|
def register pattern_code, opts={}
|
15
15
|
if (self.pattern_id = Card::Codename.id(pattern_code))
|
16
16
|
self.pattern_code = pattern_code
|
17
|
-
|
17
|
+
Pattern.concrete.insert opts.delete(:index).to_i, self
|
18
18
|
self.anchorless = !respond_to?(:anchor_name)
|
19
19
|
opts.each { |key, val| send "#{key}=", val }
|
20
20
|
else
|
21
|
-
warn "no codename for
|
21
|
+
warn "no codename for pattern code: #{pattern_code}"
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|