card 1.103.2 → 1.104.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (197) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/config/environments/development.rb +4 -2
  4. data/config/environments/production.rb +9 -9
  5. data/config/environments/test.rb +1 -1
  6. data/config/initializers/01_core_extensions/array.rb +4 -1
  7. data/config/initializers/01_core_extensions/object.rb +1 -1
  8. data/config/initializers/02_patches/active_record.rb +16 -17
  9. data/config/locales/de.yml +8 -564
  10. data/config/locales/es.yml +2 -3
  11. data/db/migrate/20110511221913_require_earlier_migrations.rb +1 -1
  12. data/db/migrate/20120105203350_require_1_8_migrations.rb +1 -1
  13. data/db/migrate/20121111025347_require_1_10_migrations.rb +1 -1
  14. data/db/migrate/20211128040849_virtuals_updated_at.rb +11 -0
  15. data/db/migrate_core_cards/20130411191151_renaming_for_menu.rb +0 -1
  16. data/db/migrate_core_cards/20140317035504_account_requests_to_signups.rb +0 -2
  17. data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +0 -2
  18. data/db/migrate_core_cards/20190417142612_reorganize_scripts_2.rb +1 -3
  19. data/db/migrate_core_cards/20190502130029_add_shark_and_help_desk_role.rb +1 -2
  20. data/db/migrate_core_cards/20190710090209_homepage_tweaks.rb +3 -7
  21. data/db/migrate_core_cards/20190823220018_cleanup_for_decko_1_0.rb +2 -4
  22. data/db/migrate_core_cards/20190902193208_input_type.rb +3 -8
  23. data/db/migrate_core_cards/20190904174403_token_upgrade.rb +1 -1
  24. data/db/migrate_core_cards/data/1.12_stylesheets/traditional.scss +1 -2
  25. data/db/schema.rb +19 -16
  26. data/db/seed/new/card_actions.yml +2615 -3383
  27. data/db/seed/new/card_acts.yml +3 -3
  28. data/db/seed/new/card_references.yml +1588 -1707
  29. data/db/seed/new/cards.yml +5450 -8416
  30. data/db/seed/new/schema_migrations.yml +2 -0
  31. data/db/seed/new/schema_migrations_core_cards.yml +8 -0
  32. data/db/seed/test/fixtures/card_actions.yml +4304 -5144
  33. data/db/seed/test/fixtures/card_acts.yml +780 -840
  34. data/db/seed/test/fixtures/card_changes.yml +110 -110
  35. data/db/seed/test/fixtures/card_references.yml +2908 -2992
  36. data/db/seed/test/fixtures/cards.yml +8775 -11955
  37. data/db/seed/test/fixtures/schema_migrations.yml +2 -0
  38. data/db/seed/test/fixtures/schema_migrations_core_cards.yml +8 -0
  39. data/db/test_seed.rb +2 -5
  40. data/db/version.txt +1 -1
  41. data/db/version_core_cards.txt +1 -1
  42. data/lib/card/auth/current.rb +1 -1
  43. data/lib/card/auth/permissions.rb +37 -35
  44. data/lib/card/content/all.rb +3 -3
  45. data/lib/card/content/chunk.rb +1 -1
  46. data/lib/card/content/diff/summary.rb +14 -18
  47. data/lib/card/content.rb +9 -1
  48. data/lib/card/director/act_direction.rb +6 -6
  49. data/lib/card/director/card_methods.rb +0 -1
  50. data/lib/card/director/phases.rb +1 -0
  51. data/lib/card/director/stages.rb +2 -0
  52. data/lib/card/director.rb +1 -0
  53. data/lib/card/fetch/all.rb +3 -3
  54. data/lib/card/fetch/card_class.rb +5 -11
  55. data/lib/card/fetch/results.rb +8 -8
  56. data/lib/card/{tasks/card/file_card_creator → file_card_creator}/abstract_file_card/migration_file.rb +0 -0
  57. data/lib/card/{tasks/card/file_card_creator → file_card_creator}/abstract_file_card/ruby_file.rb +0 -0
  58. data/lib/card/{tasks/card/file_card_creator → file_card_creator}/abstract_file_card/source_file.rb +0 -0
  59. data/lib/card/{tasks/card/file_card_creator → file_card_creator}/abstract_file_card.rb +0 -5
  60. data/lib/card/{tasks/card/file_card_creator → file_card_creator}/haml_card.rb +0 -0
  61. data/lib/card/{tasks/card/file_card_creator → file_card_creator}/output_helper.rb +0 -0
  62. data/lib/card/{tasks/card/file_card_creator → file_card_creator}/script_card.rb +0 -0
  63. data/lib/card/{tasks/card/file_card_creator → file_card_creator}/style_card.rb +0 -0
  64. data/lib/card/{tasks/card/file_card_creator.rb → file_card_creator.rb} +0 -5
  65. data/lib/card/format/content.rb +5 -7
  66. data/lib/card/format/error.rb +2 -2
  67. data/lib/card/format/render.rb +10 -10
  68. data/lib/card/format.rb +3 -8
  69. data/lib/card/lexicon.rb +30 -7
  70. data/lib/card/model/save_helper/save_arguments.rb +2 -2
  71. data/lib/card/model/save_helper.rb +3 -3
  72. data/lib/card/name/all/descendants.rb +9 -7
  73. data/lib/card/name/all/parts.rb +1 -1
  74. data/lib/card/name/all.rb +4 -3
  75. data/lib/card/name/card_class.rb +2 -1
  76. data/lib/card/name/fields_and_traits.rb +6 -30
  77. data/lib/card/name/name_variants.rb +5 -1
  78. data/lib/card/name.rb +6 -14
  79. data/lib/card/query/abstract_query/tie.rb +2 -3
  80. data/lib/card/query/card_query/normalization.rb +1 -1
  81. data/lib/card/query/sql_statement/order.rb +5 -6
  82. data/lib/card/query/value.rb +10 -7
  83. data/lib/card/reference/all.rb +9 -7
  84. data/lib/card/reference.rb +36 -41
  85. data/lib/card/rule/all.rb +3 -3
  86. data/lib/card/set/advanced_api.rb +5 -0
  87. data/lib/card/set/card_methods.rb +13 -0
  88. data/lib/card/set/event/delayed_event.rb +8 -1
  89. data/lib/card/set/event/skip_and_trigger.rb +8 -0
  90. data/lib/card/set/event.rb +1 -0
  91. data/lib/card/set/format/abstract_format/wrapper.rb +1 -1
  92. data/lib/card/set/format/abstract_format.rb +2 -1
  93. data/lib/card/set/format.rb +2 -3
  94. data/lib/card/set/helpers.rb +68 -0
  95. data/lib/card/set/inheritance.rb +1 -1
  96. data/lib/card/set/pattern/all.rb +20 -10
  97. data/lib/card/set/pattern/base.rb +12 -18
  98. data/lib/card/set/pattern/class_methods.rb +13 -13
  99. data/lib/card/set/pattern.rb +46 -24
  100. data/lib/card/set/registrar.rb +8 -2
  101. data/lib/card/set/trait.rb +16 -1
  102. data/lib/card/set/type.rb +3 -0
  103. data/lib/card/set.rb +14 -7
  104. data/lib/card/subcards/add.rb +1 -3
  105. data/lib/card/subcards/all.rb +30 -56
  106. data/lib/card/view/classy.rb +15 -27
  107. data/lib/card/view/options/voo_api.rb +3 -1
  108. data/lib/card/view/options.rb +7 -5
  109. data/lib/card/view/permission.rb +4 -11
  110. data/lib/card/view.rb +1 -0
  111. data/lib/card.rb +9 -11
  112. data/lib/cardio/cli.rb +1 -0
  113. data/lib/cardio/commands/custom.rb +60 -0
  114. data/lib/cardio/commands/rake_command/parser.rb +49 -48
  115. data/lib/cardio/commands/rake_command.rb +17 -15
  116. data/lib/cardio/commands/rspec_command.rb +2 -0
  117. data/lib/cardio/commands.rb +69 -69
  118. data/lib/cardio/generators/deck_helper.rb +0 -4
  119. data/lib/cardio/generators.rb +56 -3
  120. data/lib/cardio/migration/deck.rb +0 -0
  121. data/lib/cardio/migration/deck_structure.rb +2 -0
  122. data/lib/cardio/migration/import/import_data/card_content.rb +1 -1
  123. data/lib/cardio/migration/import.rb +2 -2
  124. data/lib/cardio/migration.rb +26 -2
  125. data/lib/cardio/mod/class_methods.rb +112 -0
  126. data/lib/cardio/mod/dirs.rb +15 -11
  127. data/lib/cardio/mod/eat/edibles.rb +92 -0
  128. data/lib/cardio/mod/eat.rb +81 -0
  129. data/lib/cardio/mod/load_strategy/set_tmp_files.rb +10 -4
  130. data/lib/cardio/mod/load_strategy/tmp_files.rb +1 -1
  131. data/lib/cardio/mod/load_strategy.rb +3 -4
  132. data/lib/cardio/mod/loader/set_loader.rb +13 -13
  133. data/lib/cardio/mod/loader.rb +1 -1
  134. data/lib/cardio/mod/modfile_api.rb +5 -0
  135. data/lib/cardio/mod/poop.rb +135 -0
  136. data/lib/cardio/mod.rb +20 -80
  137. data/lib/cardio/railtie.rb +24 -6
  138. data/lib/cardio/schema.rb +11 -10
  139. data/lib/cardio/version.rb +35 -0
  140. data/lib/cardio.rb +4 -0
  141. data/lib/generators/deck/deck_generator.rb +3 -2
  142. data/lib/generators/deck/templates/Gemfile.erb +1 -5
  143. data/lib/generators/deck/templates/Rakefile.erb +6 -2
  144. data/lib/generators/deck/templates/rspec.erb +1 -1
  145. data/lib/generators/deck/templates/simplecov.rb.erb +7 -11
  146. data/lib/generators/deck/templates/spec/javascripts/support/decko_jasmine.yml.erb +0 -1
  147. data/lib/generators/mod/USAGE +1 -0
  148. data/lib/{card/tasks → tasks}/card/create.rake +0 -0
  149. data/lib/{card/tasks → tasks}/card/migrate.rake +41 -1
  150. data/lib/{card/tasks → tasks}/card/mod.rake +15 -8
  151. data/lib/tasks/card.rake +65 -0
  152. data/mod/admin/locales/de.yml +4 -0
  153. data/mod/admin/set/all/admin.rb +16 -0
  154. data/mod/admin/set/self/admin.rb +12 -14
  155. data/mod/admin/set/self/admin_info.rb +2 -5
  156. data/mod/core/data/production.yml +7 -0
  157. data/mod/core/data/test.yml +30 -0
  158. data/mod/core/locales/de.yml +28 -0
  159. data/mod/core/locales/en.yml +4 -5
  160. data/mod/core/set/all/assign_attributes.rb +1 -33
  161. data/mod/core/set/all/content.rb +3 -1
  162. data/mod/core/set/all/initialize.rb +1 -4
  163. data/mod/core/set/all/name_events.rb +3 -18
  164. data/mod/core/set/all/reference_events.rb +32 -36
  165. data/mod/core/set/all/subcards.rb +6 -2
  166. data/mod/core/set/all/trash.rb +4 -6
  167. data/mod/core/set/all/type.rb +67 -18
  168. data/mod/core/set/self/version.rb +1 -1
  169. data/mod/core/spec/set/all/name_events_spec.rb +10 -10
  170. data/mod/core/spec/set/all/trash_spec.rb +1 -1
  171. data/mod/core/spec/set/self/trash_spec.rb +1 -1
  172. data/mod/standard/{file → data/files}/favicon/image-icon.png +0 -0
  173. data/mod/standard/{file → data/files}/favicon/image-large.png +0 -0
  174. data/mod/standard/{file → data/files}/favicon/image-medium.png +0 -0
  175. data/mod/standard/{file → data/files}/favicon/image-original.png +0 -0
  176. data/mod/standard/{file → data/files}/favicon/image-small.png +0 -0
  177. data/mod/standard/{file → data/files}/logo/image-original.svg +0 -0
  178. metadata +52 -42
  179. data/db/migrate_core_cards/20150605115802_add_performance_log_card.rb +0 -7
  180. data/lib/card/set/basket.rb +0 -59
  181. data/lib/card/set/code_nest.rb +0 -15
  182. data/lib/card/tasks/card/asset.rake +0 -22
  183. data/lib/card/tasks/card.rake +0 -105
  184. data/lib/card/version.rb +0 -11
  185. data/lib/cardio/commands/USAGE +0 -28
  186. data/lib/cardio/generators/class_methods.rb +0 -35
  187. data/mod/core/spec/set/all/clean_me_spec.rb +0 -258
  188. data/mod/core/spec/set/all/export_spec.rb +0 -71
  189. data/tmpsets/set_pattern/100-all.rb +0 -22
  190. data/tmpsets/set_pattern/101-all_plus.rb +0 -24
  191. data/tmpsets/set_pattern/102-type.rb +0 -40
  192. data/tmpsets/set_pattern/103-star.rb +0 -26
  193. data/tmpsets/set_pattern/104-rstar.rb +0 -28
  194. data/tmpsets/set_pattern/105-rule.rb +0 -28
  195. data/tmpsets/set_pattern/106-right.rb +0 -35
  196. data/tmpsets/set_pattern/107-type_plus_right.rb +0 -43
  197. data/tmpsets/set_pattern/108-self.rb +0 -34
@@ -63,3 +63,5 @@ schema_migrations_031:
63
63
  version: '20200718051236'
64
64
  schema_migrations_032:
65
65
  version: '20200805200729'
66
+ schema_migrations_033:
67
+ version: '20211128040849'
@@ -337,3 +337,11 @@ schema_migrations_core_cards_168:
337
337
  version: '20201129140917'
338
338
  schema_migrations_core_cards_169:
339
339
  version: '20210509141814'
340
+ schema_migrations_core_cards_170:
341
+ version: '202108028112350'
342
+ schema_migrations_core_cards_171:
343
+ version: '202108028112351'
344
+ schema_migrations_core_cards_172:
345
+ version: '202108028112352'
346
+ schema_migrations_core_cards_173:
347
+ version: '20211107155032'
data/db/test_seed.rb CHANGED
@@ -13,7 +13,7 @@ class SharedData
13
13
  "Big Brother", "Optic fan", "Sunglasses fan", "Narcissist"
14
14
  ].freeze
15
15
 
16
- CARDTYPE_COUNT = 54
16
+ CARDTYPE_COUNT = 44
17
17
 
18
18
  class << self
19
19
  def create_user name, args
@@ -153,9 +153,6 @@ class SharedData
153
153
  create_pointer "items",
154
154
  content: ["Parry Hotter", "42", "Stam Broker", "First",
155
155
  "yeti skin+image", "*all+*script+*machine output"]
156
- # Card['*all+*style' ].ensure_machine_output
157
- # Card['*all+*script'].ensure_machine_output
158
- # (ie9 = Card[:script_html5shiv_printshiv]) && ie9.ensure_machine_output
159
156
  end
160
157
 
161
158
  def user_and_role_cards
@@ -216,7 +213,7 @@ class SharedData
216
213
  end
217
214
 
218
215
  def notification_cards
219
- Timecop.freeze(Cardio.future_stamp - 1.day) do
216
+ Timecop.freeze(future_stamp - 1.day) do
220
217
  # fwiw Timecop is apparently limited by ruby Time object,
221
218
  # which goes only to 2037 and back to 1900 or so.
222
219
  # whereas DateTime can represent all dates.
data/db/version.txt CHANGED
@@ -1 +1 @@
1
- 20200805200729
1
+ 20211128040849
@@ -1 +1 @@
1
- 201905021300268
1
+ 202108028112352
@@ -43,7 +43,7 @@ class Card
43
43
  end
44
44
 
45
45
  # set current from token, api_key, or session
46
- def signin_with _opts={}
46
+ def signin_with opts={}
47
47
  if opts[:token]
48
48
  signin_with_token opts[:token]
49
49
  else
@@ -5,39 +5,14 @@ class Card
5
5
  # user has "root" permissions
6
6
  # @return [true/false]
7
7
  def always_ok?
8
- usr_id = as_id
9
- case usr_id
10
- when Card::WagnBotID then true # cannot disable
11
- when nil then false
8
+ case as_id
9
+ when WagnBotID then true # cannot disable
10
+ when nil then false
12
11
  else
13
- always_ok_usr_id? usr_id
12
+ always_ok_cached?
14
13
  end
15
14
  end
16
15
 
17
- # specified user has root permission
18
- # @param usr_id [Integer]
19
- # @return [true/false]
20
- def always_ok_usr_id? usr_id, force_cache_update=false
21
- always = always_cache
22
- if always[usr_id].nil? || force_cache_update
23
- update_always_cache usr_id, admin?(usr_id)
24
- else
25
- always[usr_id]
26
- end
27
- end
28
-
29
- def update_always_cache usr_id, value
30
- always = always_cache
31
- always = always.dup if always.frozen?
32
- always[usr_id] = value
33
- Card.cache.write "ALWAYS", always
34
- value
35
- end
36
-
37
- def always_cache
38
- Card.cache.read("ALWAYS") || {}
39
- end
40
-
41
16
  # list of names of cardtype cards that current user has perms to create
42
17
  # @return [Array of strings]
43
18
  def createable_types
@@ -56,16 +31,43 @@ class Card
56
31
  end
57
32
 
58
33
  # test whether user is an administrator
59
- # @param user_id [Integer]
34
+ # @param user_mark [Cardish]
60
35
  # @return [true/false]
61
- def admin? user_id
62
- has_role? user_id, Card::AdministratorID
36
+ def admin? user_mark=nil
37
+ user_mark ||= as_id
38
+ has_role? Card::AdministratorID, user_mark
63
39
  end
64
40
 
65
- def has_role? user_id, role_id
66
- return false unless user_id && role_id
41
+ def has_role? role_mark, user_mark=nil
42
+ user_mark ||= as_id
43
+ return false unless (role_id = role_mark&.card_id)
67
44
 
68
- Card[user_id].all_enabled_roles.include? role_id
45
+ Card[user_mark].all_enabled_roles.include? role_id
46
+ end
47
+
48
+ def update_always_cache value
49
+ always = always_cache
50
+ always = always.dup if always.frozen?
51
+ always[as_id] = value
52
+ Card.cache.write "ALWAYS", always
53
+ value
54
+ end
55
+
56
+ private
57
+
58
+ # specified user has root permission
59
+ # @return [true/false]
60
+ def always_ok_cached?
61
+ always = always_cache
62
+ if always[as_id].nil?
63
+ update_always_cache admin?
64
+ else
65
+ always[as_id]
66
+ end
67
+ end
68
+
69
+ def always_cache
70
+ Card.cache.read("ALWAYS") || {}
69
71
  end
70
72
  end
71
73
  end
@@ -5,10 +5,10 @@ class Card
5
5
  def content
6
6
  structured_content || standard_content
7
7
  end
8
- alias_method :raw_content, :content # DEPRECATED!
8
+ # alias_method :raw_content, :content # DEPRECATED!
9
9
 
10
10
  def content= value
11
- self.db_content = standardize_content(value)
11
+ self.db_content = standardize_content value
12
12
  end
13
13
 
14
14
  def content?
@@ -20,7 +20,7 @@ class Card
20
20
  end
21
21
 
22
22
  def standardize_content value
23
- value.is_a?(Array) ? value.join("\n") : value
23
+ value.is_a?(Array) ? items_content(value) : value
24
24
  end
25
25
 
26
26
  def structured_content
@@ -89,7 +89,7 @@ class Card
89
89
  register_list :nest_only, [:Nest]
90
90
  register_list :query, [:QueryReference]
91
91
  register_list :stub, [:ViewStub]
92
- register_list :references_keep_escaping, %i[KeepEscapedLiteral Nest Link]
92
+ register_list :none, []
93
93
  end
94
94
  end
95
95
  end
@@ -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
- @summary ||=
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
- case @chunks[index - 1][:action]
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
@@ -4,9 +4,7 @@ class Card
4
4
  attr_accessor :act, :act_card
5
5
 
6
6
  def act_director
7
- return unless act_card
8
-
9
- act_card.director
7
+ act_card&.director
10
8
  end
11
9
 
12
10
  def directors
@@ -14,9 +12,11 @@ class Card
14
12
  end
15
13
 
16
14
  def run_act card
17
- self.act_card = card
18
- # add new_director(card)
19
- yield
15
+ Lexicon.rescuing do
16
+ self.act_card = card
17
+ # add new_director(card)
18
+ yield
19
+ end
20
20
  ensure
21
21
  clear
22
22
  end
@@ -12,7 +12,6 @@ class Card
12
12
 
13
13
  def prepare_for_phases
14
14
  reset_patterns
15
- identify_action
16
15
  include_set_modules
17
16
  end
18
17
 
@@ -16,6 +16,7 @@ class Card
16
16
 
17
17
  def prepare_for_phases
18
18
  @card.prepare_for_phases unless running?
19
+ @card.identify_action
19
20
  @running = true
20
21
  @subdirectors.each(&:prepare_for_phases)
21
22
  end
@@ -26,6 +26,8 @@ class Card
26
26
  STAGE_INDEX[stage]
27
27
  when Integer
28
28
  stage
29
+ when nil
30
+ -1
29
31
  else
30
32
  raise Card::Error, "not a valid stage: #{stage}"
31
33
  end
data/lib/card/director.rb CHANGED
@@ -180,6 +180,7 @@ class Card
180
180
  @subdirectors.clear
181
181
  @stage = nil
182
182
  @action = nil
183
+ @running = false
183
184
  end
184
185
 
185
186
  def appoint card
@@ -3,10 +3,10 @@ class Card
3
3
  # fetch-related Card instance methods
4
4
  module All
5
5
  # fetching from the context of a card
6
- def fetch traits, opts={}
6
+ def fetch field_marks, opts={}
7
7
  opts[:new][:supercard] = self if opts[:new]
8
- Array.wrap(traits).inject(self) do |card, trait|
9
- Card.fetch card.name.trait(trait), opts
8
+ Array.wrap(field_marks).inject(self) do |card, mark|
9
+ Card.fetch card.name.field(mark.cardname), opts
10
10
  end
11
11
  end
12
12
 
@@ -26,7 +26,7 @@ class Card
26
26
  # new: { opts for Card#new } Return a new card when not found
27
27
  # @return [Card]
28
28
  def fetch *args
29
- f = Card::Fetch.new(*args)
29
+ f = Fetch.new(*args)
30
30
  f.retrieve_or_new
31
31
  rescue ActiveModel::RangeError => _e
32
32
  Card.new name: "card id out of range: #{f.mark}"
@@ -65,19 +65,13 @@ class Card
65
65
  def id cardish
66
66
  case cardish
67
67
  when Integer then cardish
68
- when Card then cardish.id
69
- when Symbol then Card::Codename.id cardish
70
- else fetch_id cardish
68
+ when Card then cardish.id
69
+ when Symbol then Codename.id cardish
70
+ when String then Lexicon.id cardish
71
+ else quick_fetch(cardish)&.id
71
72
  end
72
73
  end
73
74
 
74
- # @param mark_parts - see #fetch
75
- # @return [Integer]
76
- def fetch_id *mark_parts
77
- mark = Card::Fetch.new(*mark_parts)&.mark
78
- mark.is_a?(Integer) ? mark : quick_fetch(mark.to_s)&.id
79
- end
80
-
81
75
  # @param mark - see #fetch
82
76
  # @return [Card::Name]
83
77
  def fetch_name *mark, &block
@@ -28,7 +28,7 @@ class Card
28
28
  elsif opts[:skip_virtual]
29
29
  return nil
30
30
  else
31
- assign_name_from_mark
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
- assign_name_from_mark
57
+ opts_name = new_opts[:name]
58
+ assign_name(opts_name.present? ? opts_name : mark)
59
59
  true
60
60
  end
61
61
 
@@ -63,7 +63,7 @@ class Card
63
63
  return unless (sc = new_opts[:supercard])
64
64
 
65
65
  @card.supercard = sc
66
- @card.update_superleft @card.name
66
+ @card.update_superleft
67
67
  end
68
68
 
69
69
  def quick_renew?
@@ -116,18 +116,18 @@ class Card
116
116
  def supercard_might_change_type?
117
117
  # ...via type_plus_right rule
118
118
  sc = new_opts[:supercard]
119
- @force_type_lookup = sc&.new? && (sc.type_id != sc.default_type_id)
119
+ @force_type_lookup = sc&.new? && (sc.type_id != Card.default_type_id)
120
120
  end
121
121
 
122
122
  def new_opts
123
123
  @new_opts ||= opts[:new]
124
124
  end
125
125
 
126
- def assign_name_from_mark
126
+ def assign_name requested
127
127
  return if opts[:local_only]
128
- return unless mark&.to_s != card.name
128
+ return unless requested&.to_s != card.name
129
129
 
130
- card.name = mark.to_s
130
+ card.name = requested.to_s
131
131
  end
132
132
  end
133
133
  end
@@ -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.
@@ -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.
@@ -7,14 +7,12 @@ class Card
7
7
  content_obj.to_s
8
8
  end
9
9
 
10
- # Preserves the syntax in all nests. The content is yielded with placeholders
11
- # for all nests. After executing the given block the original nests are put back in.
12
- # Placeholders are numbers in double curly brackets like {{2}}.
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
- content_object override_content, chunk_list: :references_keep_escaping
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
@@ -14,12 +14,12 @@ class Card
14
14
  @anyone_can[task]
15
15
  end
16
16
 
17
- def view_for_unknown _view
17
+ def view_for_unknown setting_view
18
18
  if main?
19
19
  root.error_status = 404
20
20
  :not_found
21
21
  else
22
- :unknown
22
+ setting_view || :unknown
23
23
  end
24
24
  end
25
25
 
@@ -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
- final_render final_view
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
- current_view(view) do
42
- with_wrapper do
43
- method = view_method view
44
- rendered = final_render_call method
45
- add_debug_info view, method, rendered
46
- end
47
- end
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
- cache.delete cache_key(card.lex_before_act)
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
@@ -72,8 +72,8 @@ class Card
72
72
  case key.to_s
73
73
  when /^\+/
74
74
  changing_field_arg key, value
75
- when "name"
76
- card.name.to_s != value
75
+ when /name$/
76
+ card.send(key).to_s != value
77
77
  else
78
78
  standard_changing_arg card, key, value
79
79
  end
@@ -13,7 +13,7 @@ class Card
13
13
  include SaveArguments
14
14
 
15
15
  def with_user user_name, &block
16
- Card::Auth.with(current_id: Card.fetch_id(user_name), &block)
16
+ Card::Auth.with(current_id: user_name.card_id, &block)
17
17
  end
18
18
 
19
19
  def create_card name_or_args, content_or_args=nil
@@ -59,8 +59,8 @@ class Card
59
59
  return unless delete_code_card? name
60
60
 
61
61
  card = Card[name]
62
- card.update! codename: nil
63
- card.delete! update_referers: true
62
+ card.update! codename: ""
63
+ card.delete!
64
64
  end
65
65
 
66
66
  # create if card doesn't exist