card 1.101.0 → 1.101.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (287) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/config/i18n-tasks.yml +0 -5
  4. data/config/initializers/01_core_extensions/array.rb +2 -1
  5. data/config/initializers/01_core_extensions/hash.rb +1 -0
  6. data/config/initializers/01_core_extensions/object.rb +15 -11
  7. data/config/initializers/02_patches/active_job.rb +1 -1
  8. data/config/initializers/02_patches/active_record.rb +2 -4
  9. data/config/initializers/02_patches/better_errors.rb +1 -3
  10. data/config/initializers/02_patches/kaminari.rb +2 -2
  11. data/config/initializers/deck_config.rb +1 -1
  12. data/config/initializers/inflections.rb +1 -0
  13. data/config/initializers/internationalization.rb +23 -21
  14. data/config/initializers/mime_types.rb +1 -0
  15. data/config/initializers/notification.rb +1 -0
  16. data/config/initializers/patches.rb +6 -5
  17. data/config/locales/en.yml +137 -525
  18. data/db/migrate/20110511221913_require_earlier_migrations.rb +1 -0
  19. data/db/migrate/20121111025347_require_1_10_migrations.rb +1 -0
  20. data/db/migrate/20121118114000_split_link_type.rb +1 -0
  21. data/db/migrate/20121118115000_update_link_type.rb +1 -0
  22. data/db/migrate/20130106052640_table_cleanup.rb +2 -2
  23. data/db/migrate/20130109015336_trunk_left.rb +1 -0
  24. data/db/migrate/20130411210957_update_codenames.rb +1 -0
  25. data/db/migrate/20140822073704_create_new_revision_tables.rb +1 -0
  26. data/db/migrate/20141001105348_move_revisions_to_actions.rb +9 -3
  27. data/db/migrate/20141216053032_better_index_names.rb +9 -6
  28. data/db/migrate/20170908114442_create_delayed_jobs.rb +1 -1
  29. data/db/migrate/20170908114452_increase_text_size_for_delayed_jobs.rb +1 -1
  30. data/db/migrate/20180514152037_add_card_virtuals_table.rb +1 -1
  31. data/db/migrate_core_cards/20120611203506_rails_inflection_updates.rb +3 -2
  32. data/db/migrate_core_cards/20130411191151_renaming_for_menu.rb +9 -9
  33. data/db/migrate_core_cards/20130419215612_import_help_text.rb +3 -2
  34. data/db/migrate_core_cards/20130823192433_add_style_cards.rb +5 -5
  35. data/db/migrate_core_cards/20130910183318_move_styles_to_content.rb +3 -2
  36. data/db/migrate_core_cards/20130920291703_update_stylesheets.rb +2 -4
  37. data/db/migrate_core_cards/20131016172445_common_css_patch.rb +1 -3
  38. data/db/migrate_core_cards/20140110193325_reset_account_request_type.rb +1 -3
  39. data/db/migrate_core_cards/20140307231621_user_data_to_cards.rb +12 -8
  40. data/db/migrate_core_cards/20140317035504_account_requests_to_signups.rb +2 -4
  41. data/db/migrate_core_cards/20140512155840_add_script_cards.rb +16 -9
  42. data/db/migrate_core_cards/20140629222005_add_email_cards.rb +19 -11
  43. data/db/migrate_core_cards/20140725180118_config_card_updates.rb +1 -1
  44. data/db/migrate_core_cards/20141115034214_config_descriptions_etc.rb +1 -1
  45. data/db/migrate_core_cards/20141119001955_make_symlinks_relative.rb +1 -1
  46. data/db/migrate_core_cards/20141204061304_watchers_to_following.rb +2 -0
  47. data/db/migrate_core_cards/20141216155251_add_more_following_cards.rb +4 -2
  48. data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +2 -2
  49. data/db/migrate_core_cards/20150220134731_following_to_follow_rule.rb +3 -4
  50. data/db/migrate_core_cards/20150317162412_bootstrap_themes.rb +8 -4
  51. data/db/migrate_core_cards/20150326205655_bootswatch_themes.rb +14 -7
  52. data/db/migrate_core_cards/20150429090551_search_card_context.rb +6 -4
  53. data/db/migrate_core_cards/20150508212032_menu_compatibility.rb +4 -2
  54. data/db/migrate_core_cards/20150510031118_fix_skin_codenames.rb +2 -1
  55. data/db/migrate_core_cards/20150601133433_add_recent_setting_session_card.rb +3 -3
  56. data/db/migrate_core_cards/20150610171702_add_debugger_session_card.rb +2 -1
  57. data/db/migrate_core_cards/20150610180019_add_recaptcha_key_and_admin_info_cards.rb +4 -3
  58. data/db/migrate_core_cards/20150724123438_update_file_and_image_cards.rb +6 -2
  59. data/db/migrate_core_cards/20150807205221_create_references_for_search_cards.rb +1 -1
  60. data/db/migrate_core_cards/20150824135418_update_file_history.rb +2 -0
  61. data/db/migrate_core_cards/20160804112510_reorganize_scripts.rb +1 -1
  62. data/db/migrate_core_cards/20160811115836_rename_stats_to_admin.rb +1 -0
  63. data/db/migrate_core_cards/20160914132636_fix_mod_files.rb +2 -0
  64. data/db/migrate_core_cards/20161102202156_tweak_recaptcha_setting_cards.rb +6 -6
  65. data/db/migrate_core_cards/20161103154836_update_keys.rb +2 -1
  66. data/db/migrate_core_cards/20170209132834_email_test_context.rb +2 -0
  67. data/db/migrate_core_cards/20170314175313_add_notification_event_card.rb +3 -3
  68. data/db/migrate_core_cards/20170515101262_add_advanced_edit_cards.rb +1 -1
  69. data/db/migrate_core_cards/20170608200649_add_input_options_codename.rb +1 -1
  70. data/db/migrate_core_cards/20180712042655_head_rule.rb +3 -4
  71. data/db/migrate_core_cards/20180905061537_migrate_layouts.rb +4 -4
  72. data/db/migrate_core_cards/20181120200937_update_layout.rb +1 -1
  73. data/db/migrate_core_cards/20190320091257_upgrade_recaptcha_to_v3.rb +7 -7
  74. data/db/migrate_core_cards/20190424100531_update_credit_image.rb +1 -0
  75. data/db/migrate_core_cards/20190502130029_add_shark_and_help_desk_role.rb +15 -14
  76. data/db/migrate_core_cards/20190503122739_update_pristine_data.rb +1 -1
  77. data/db/migrate_core_cards/20190625153616_pointer_overhaul.rb +9 -5
  78. data/db/migrate_core_cards/20190718140126_add_guides.rb +3 -3
  79. data/db/migrate_core_cards/20190822093633_move_help_text_to_code.rb +1 -2
  80. data/db/migrate_core_cards/20190823220018_cleanup_for_decko_1_0.rb +1 -1
  81. data/db/migrate_core_cards/20190829093961_cardtype_grouping.rb +7 -7
  82. data/db/migrate_core_cards/20190902193208_input_type.rb +1 -3
  83. data/db/migrate_core_cards/20190909104250_add_cardtype_input_types.rb +2 -2
  84. data/db/migrate_core_cards/20191028135243_add_link_editor_to_tiny_mce_config.rb +1 -0
  85. data/db/migrate_core_cards/20191115160748_history_cleanup.rb +0 -1
  86. data/db/migrate_core_cards/20191118145629_codename_fixes.rb +1 -2
  87. data/db/migrate_core_cards/20200821231558_add_nest_list_type.rb +1 -1
  88. data/db/migrate_core_cards/data/decko_logo.svg +1 -59
  89. data/db/seed/new/card_actions.yml +2153 -2145
  90. data/db/seed/new/card_acts.yml +3 -3
  91. data/db/seed/new/card_references.yml +900 -858
  92. data/db/seed/new/cards.yml +4869 -4848
  93. data/db/seed/new/schema_migrations_deck_cards.yml +2 -0
  94. data/db/seed/test/fixtures/card_actions.yml +3563 -3547
  95. data/db/seed/test/fixtures/card_acts.yml +675 -675
  96. data/db/seed/test/fixtures/card_changes.yml +103 -103
  97. data/db/seed/test/fixtures/card_references.yml +2165 -2123
  98. data/db/seed/test/fixtures/cards.yml +7862 -7751
  99. data/db/seed/test/fixtures/rails.gif +0 -0
  100. data/db/seed/test/fixtures/schema_migrations_deck_cards.yml +2 -0
  101. data/db/test_seed.rb +33 -34
  102. data/lib/card.rb +18 -1
  103. data/lib/card/auth.rb +5 -2
  104. data/lib/card/auth/current.rb +39 -100
  105. data/lib/card/auth/proxy.rb +36 -16
  106. data/lib/card/auth/token.rb +8 -2
  107. data/lib/card/cache.rb +2 -1
  108. data/lib/card/cache/all.rb +88 -0
  109. data/lib/card/cache/card_class.rb +44 -0
  110. data/lib/card/cache/persistent.rb +3 -34
  111. data/lib/card/cache/persistent_class.rb +28 -0
  112. data/lib/card/codename.rb +3 -4
  113. data/lib/card/content.rb +20 -10
  114. data/lib/card/content/all.rb +59 -0
  115. data/lib/card/content/chunk.rb +1 -1
  116. data/lib/card/content/clean.rb +4 -3
  117. data/lib/card/content/diff.rb +3 -2
  118. data/lib/card/content/diff/l_c_s/processor.rb +1 -1
  119. data/lib/card/content/diff/result.rb +41 -29
  120. data/lib/card/content/parser.rb +2 -2
  121. data/lib/card/content/truncate.rb +6 -6
  122. data/lib/card/director.rb +1 -1
  123. data/lib/card/director/act_direction.rb +4 -0
  124. data/lib/card/director/all.rb +61 -0
  125. data/lib/card/director/card_class.rb +18 -0
  126. data/lib/card/director/card_methods.rb +1 -0
  127. data/lib/card/director/event_delay.rb +4 -6
  128. data/lib/card/director/phases.rb +0 -1
  129. data/lib/card/director/run.rb +2 -0
  130. data/lib/card/director/stages.rb +3 -2
  131. data/lib/card/dirty.rb +13 -3
  132. data/lib/card/env.rb +2 -2
  133. data/lib/card/env/location.rb +4 -3
  134. data/lib/card/env/success.rb +46 -103
  135. data/lib/card/env/success/target.rb +73 -0
  136. data/lib/card/error.rb +1 -2
  137. data/lib/card/fetch.rb +7 -4
  138. data/lib/card/fetch/all.rb +33 -0
  139. data/lib/card/fetch/card_class.rb +155 -0
  140. data/lib/card/fetch/results.rb +9 -0
  141. data/lib/card/fetch/retrieve.rb +2 -0
  142. data/lib/card/fetch/store.rb +1 -0
  143. data/lib/card/format.rb +1 -2
  144. data/lib/card/format/content.rb +1 -3
  145. data/lib/card/format/error.rb +8 -4
  146. data/lib/card/format/method_delegation.rb +10 -2
  147. data/lib/card/format/nest.rb +3 -2
  148. data/lib/card/format/nest/fetch.rb +3 -2
  149. data/lib/card/format/nesting/mode.rb +1 -1
  150. data/lib/card/format/nesting/subformat.rb +2 -1
  151. data/lib/card/format/render.rb +2 -2
  152. data/lib/card/format/wrapper.rb +1 -1
  153. data/lib/card/lexicon.rb +5 -4
  154. data/lib/card/mark.rb +17 -15
  155. data/lib/card/model/save_helper.rb +18 -184
  156. data/lib/card/model/save_helper/save_arguments.rb +94 -0
  157. data/lib/card/model/save_helper/save_helper_helper.rb +93 -0
  158. data/lib/card/name.rb +10 -9
  159. data/lib/card/name/all.rb +136 -0
  160. data/lib/card/name/all/descendants.rb +48 -0
  161. data/lib/card/name/all/parts.rb +67 -0
  162. data/lib/card/name/card_class.rb +28 -0
  163. data/lib/card/name/fields_and_traits.rb +4 -2
  164. data/lib/card/name/name_variants.rb +0 -1
  165. data/lib/card/query.rb +24 -19
  166. data/lib/card/query/card_query/interpretation.rb +3 -2
  167. data/lib/card/query/card_query/match_attributes.rb +2 -1
  168. data/lib/card/query/card_query/normalization.rb +1 -0
  169. data/lib/card/query/card_query/reference_attributes.rb +1 -1
  170. data/lib/card/query/card_query/sorting.rb +12 -4
  171. data/lib/card/query/join.rb +1 -1
  172. data/lib/card/query/sql_statement.rb +1 -1
  173. data/lib/card/query/value/match_value.rb +1 -0
  174. data/lib/card/reference/all.rb +136 -0
  175. data/lib/card/rule/all.rb +76 -0
  176. data/lib/card/rule/cache.rb +2 -0
  177. data/lib/card/set/advanced_api.rb +8 -4
  178. data/lib/card/set/event.rb +2 -2
  179. data/lib/card/set/event/all.rb +101 -0
  180. data/lib/card/set/event/delayed_event.rb +6 -6
  181. data/lib/card/set/event/options.rb +14 -5
  182. data/lib/card/set/event/skip_and_trigger.rb +89 -0
  183. data/lib/card/set/format.rb +16 -9
  184. data/lib/card/set/format/abstract_format/view_definition.rb +1 -0
  185. data/lib/card/set/format/abstract_format/view_opts.rb +1 -0
  186. data/lib/card/set/i18n_scope.rb +18 -13
  187. data/lib/card/set/inheritance.rb +8 -6
  188. data/lib/card/set/loader.rb +24 -13
  189. data/lib/card/set/pattern/all.rb +63 -0
  190. data/lib/card/set/pattern/base.rb +4 -74
  191. data/lib/card/set/pattern/class_methods.rb +75 -0
  192. data/lib/card/set/required_field.rb +4 -1
  193. data/lib/card/set/trait.rb +11 -8
  194. data/lib/card/setting.rb +13 -12
  195. data/lib/card/subcards.rb +3 -4
  196. data/lib/card/subcards/add.rb +3 -24
  197. data/lib/card/subcards/all.rb +103 -0
  198. data/lib/card/subcards/args.rb +42 -0
  199. data/lib/card/tasks/card/file_card_creator/abstract_file_card/ruby_file.rb +1 -1
  200. data/lib/card/tasks/card/file_card_creator/output_helper.rb +17 -14
  201. data/lib/card/tasks/card/migrate.rake +2 -2
  202. data/lib/card/view/cache.rb +6 -8
  203. data/lib/card/view/cache/cache_action.rb +1 -2
  204. data/lib/card/view/cache/stub.rb +1 -1
  205. data/lib/card/view/options.rb +5 -4
  206. data/lib/card/view/permission.rb +15 -3
  207. data/lib/cardio.rb +10 -67
  208. data/lib/cardio/defaults.yml +70 -0
  209. data/lib/cardio/migration.rb +2 -2
  210. data/lib/cardio/migration/deck_structure.rb +2 -4
  211. data/lib/cardio/migration/import.rb +3 -3
  212. data/lib/cardio/migration/import/import_data.rb +1 -0
  213. data/lib/cardio/mod.rb +1 -0
  214. data/lib/cardio/mod/dirs.rb +2 -2
  215. data/lib/cardio/mod/load_strategy.rb +2 -4
  216. data/lib/cardio/mod/loader/set_loader.rb +2 -1
  217. data/lib/cardio/mod/loader/set_pattern_loader.rb +0 -1
  218. data/lib/cardio/mod/module_template.rb +1 -0
  219. data/lib/cardio/modfiles.rb +2 -4
  220. data/lib/cardio/schema.rb +2 -4
  221. data/lib/cardio/utils.rb +9 -0
  222. data/lib/generators/card/format/format_generator.rb +1 -1
  223. data/lib/generators/card/migration/migration_generator.rb +2 -1
  224. data/lib/generators/card/mod/mod_generator.rb +3 -2
  225. data/lib/generators/card/set/set_generator.rb +3 -3
  226. data/lib/generators/card/template/template_generator.rb +1 -1
  227. data/mod/admin/set/self/admin.rb +6 -3
  228. data/mod/admin/set/self/admin_info.rb +3 -8
  229. data/mod/admin/set/self/trash.rb +3 -2
  230. data/mod/admin/spec/set/self/admin_spec.rb +4 -4
  231. data/mod/core/set/all/abort.rb +5 -5
  232. data/mod/core/set/all/assign_attributes.rb +12 -28
  233. data/mod/core/set/all/autoname.rb +17 -0
  234. data/mod/core/set/all/codename.rb +3 -2
  235. data/mod/core/set/all/collection.rb +4 -6
  236. data/mod/core/set/all/content.rb +55 -99
  237. data/mod/core/set/all/contextual_content.rb +2 -4
  238. data/mod/core/set/all/initialize.rb +9 -9
  239. data/mod/core/set/all/name_events.rb +78 -58
  240. data/mod/core/set/all/reference_events.rb +69 -0
  241. data/mod/core/set/all/states.rb +5 -5
  242. data/mod/core/set/all/subcards.rb +1 -101
  243. data/mod/core/set/all/trash.rb +16 -14
  244. data/mod/core/set/all/type.rb +11 -11
  245. data/mod/core/set/all/utils.rb +4 -1
  246. data/mod/{settings → core}/set/right/autoname.rb +0 -0
  247. data/mod/{settings → core}/set/self/autoname.rb +0 -0
  248. data/mod/core/set/type/cardtype.rb +28 -0
  249. data/mod/core/set_pattern/06_rule.rb +1 -1
  250. data/mod/core/spec/set/all/assign_attributes_spec.rb +10 -9
  251. data/mod/core/spec/set/all/{rules2_spec.rb → clean_me_spec.rb} +19 -4
  252. data/mod/core/spec/set/all/collection_spec.rb +1 -1
  253. data/mod/core/spec/set/all/export_spec.rb +1 -0
  254. data/mod/core/spec/set/all/initialize_spec.rb +11 -11
  255. data/mod/core/spec/set/all/name_events_spec.rb +204 -0
  256. data/mod/{standard → core}/spec/set/type/cardtype_spec.rb +3 -24
  257. data/mod/standard/file/logo/image-original.svg +1 -59
  258. metadata +50 -61
  259. data/config/initializers/uuid_state_file.rb +0 -3
  260. data/lib/card/mod_inflector.rb +0 -16
  261. data/mod/Modfile +0 -4
  262. data/mod/core/set/all/actify.rb +0 -68
  263. data/mod/core/set/all/cache.rb +0 -109
  264. data/mod/core/set/all/event_conditions.rb +0 -172
  265. data/mod/core/set/all/fetch.rb +0 -122
  266. data/mod/core/set/all/fetch_helper.rb +0 -35
  267. data/mod/core/set/all/i18n.rb +0 -11
  268. data/mod/core/set/all/name.rb +0 -229
  269. data/mod/core/set/all/pattern.rb +0 -54
  270. data/mod/core/set/all/references.rb +0 -191
  271. data/mod/core/set/all/rename.rb +0 -33
  272. data/mod/core/set/all/rules.rb +0 -81
  273. data/mod/core/spec/set/all/actify_spec.rb +0 -58
  274. data/mod/core/spec/set/all/content_spec.rb +0 -15
  275. data/mod/core/spec/set/all/event_conditions_spec.rb +0 -217
  276. data/mod/core/spec/set/all/fetch_helper_spec.rb +0 -65
  277. data/mod/core/spec/set/all/fetch_spec.rb +0 -338
  278. data/mod/core/spec/set/all/i18n_spec.rb +0 -17
  279. data/mod/core/spec/set/all/name_spec.rb +0 -11
  280. data/mod/core/spec/set/all/pattern_spec.rb +0 -101
  281. data/mod/core/spec/set/all/permissions/reader_rules_spec.rb +0 -166
  282. data/mod/core/spec/set/all/references_spec.rb +0 -62
  283. data/mod/core/spec/set/all/rename_spec.rb +0 -189
  284. data/mod/core/spec/set/all/rules_spec.rb +0 -100
  285. data/mod/core/spec/set/all/subcards_spec.rb +0 -102
  286. data/mod/standard/set/all/rich_html/html_views/info.rb +0 -84
  287. data/mod/standard/set/type/cardtype.rb +0 -119
File without changes
@@ -1,3 +1,5 @@
1
1
  ---
2
2
  schema_migrations_deck_cards_001:
3
3
  version: '20150116220621'
4
+ schema_migrations_deck_cards_002:
5
+ version: '20210504195646'
data/db/test_seed.rb CHANGED
@@ -12,10 +12,9 @@ class SharedData
12
12
  "Big Brother", "Optic fan", "Sunglasses fan", "Narcissist"
13
13
  ].freeze
14
14
 
15
- CARDTYPE_COUNT = 43
15
+ CARDTYPE_COUNT = 44
16
16
 
17
17
  class << self
18
-
19
18
  def create_user name, args
20
19
  args[:subcards] = account_args args if args[:email]
21
20
 
@@ -46,9 +45,10 @@ class SharedData
46
45
  # CREATE A CARD OF EACH TYPE
47
46
 
48
47
  no_samples = %w[user sign_up set number mirror_list mirrored_list file image
49
- customized_bootswatch_skin]
48
+ customized_bootswatch_skin alias]
50
49
  Card::Auth.createable_types.each do |type|
51
50
  next if no_samples.include? type.to_name.key
51
+
52
52
  create type: type, name: "Sample #{type}"
53
53
  end
54
54
 
@@ -57,7 +57,7 @@ class SharedData
57
57
  end
58
58
 
59
59
  create_layout_type "lay out", "Greatest {{_main|title: Callahan!; view: labeled}}"
60
- create_pointer "stacks", ["horizontal", "vertical"]
60
+ create_pointer "stacks", %w[horizontal vertical]
61
61
  create_pointer "stacks+*self+*layout", "lay out"
62
62
  create "horizontal"
63
63
  create_pointer "vertical"
@@ -75,7 +75,7 @@ class SharedData
75
75
  ["Z", "I'm here to be referenced to"],
76
76
  ["A", "Alpha [[Z]]"],
77
77
  ["B", "Beta {{Z}}"],
78
- ["T", "Theta"],
78
+ %w[T Theta],
79
79
  ["X", "[[A]] [[A+B]] [[T]]"],
80
80
  ["Y", "{{B}} {{A+B}} {{A}} {{T}}"],
81
81
  ["A+B", "AlphaBeta"],
@@ -114,7 +114,8 @@ class SharedData
114
114
  ## --------- Fruit: creatable by anyone but not readable ---
115
115
  Card.create! type: "Cardtype", name: "Fruit"
116
116
  Card.create! name: "Fruit+*type+*create", type: "Pointer", content: "[[Anyone]]"
117
- Card.create! name: "Fruit+*type+*read", type: "Pointer", content: "[[Administrator]]"
117
+ Card.create! name: "Fruit+*type+*read", type: "Pointer",
118
+ content: "[[Administrator]]"
118
119
 
119
120
  # codenames for card_accessor tests
120
121
  Card.create! name: "*write", codename: :write
@@ -158,7 +159,7 @@ class SharedData
158
159
 
159
160
  def user_and_role_cards
160
161
  # Card::Auth.instant_account_activation do
161
- create_user "Joe Admin", content: "I'm number one", email: "joe@admin.com"
162
+ create_user "Joe Admin", content: "I'm number one", email: "joe@admin.com"
162
163
  create_user "Joe User", content: "I'm number two", email: "joe@user.com"
163
164
  create_user "Joe Camel", content: "Mr. Buttz", email: "joe@camel.com"
164
165
 
@@ -169,10 +170,10 @@ class SharedData
169
170
 
170
171
  # noinspection RubyResolve
171
172
  Card["Joe Admin"].fetch(:roles, new: { type_code: "pointer" })
172
- .items = [Card::AdministratorID, Card::SharkID, Card::HelpDeskID]
173
+ .items = [Card::AdministratorID, Card::SharkID, Card::HelpDeskID]
173
174
 
174
175
  Card["Joe User"].fetch(:roles, new: { type_code: "pointer" })
175
- .items = [Card::SharkID]
176
+ .items = [Card::SharkID]
176
177
 
177
178
  create_user "u1", email: "u1@user.com", password: "u1_pass"
178
179
  create_user "u2", email: "u2@user.com", password: "u2_pass"
@@ -188,19 +189,18 @@ class SharedData
188
189
  Card["u3"].fetch(:roles, new: {}).items = [r1, r4, Card::AdministratorID]
189
190
  end
190
191
 
191
-
192
192
  def cardtype_cards
193
193
  # for cql & permissions
194
- %w[A+C A+D A+E C+A D+A F+A A+B+C].each {|name| create name}
194
+ %w[A+C A+D A+E C+A D+A F+A A+B+C].each { |name| create name }
195
195
  ("A".."F").each do |ch|
196
196
  create "Cardtype #{ch}", type_code: "cardtype",
197
- codename: "cardtype_#{ch.downcase}"
197
+ codename: "cardtype_#{ch.downcase}"
198
198
  end
199
199
  Card::Codename.reset_cache
200
200
 
201
201
  ("a".."f").each do |ch|
202
202
  create "type-#{ch}-card", type_code: "cardtype_#{ch}",
203
- content: "type_#{ch}_content"
203
+ content: "type_#{ch}_content"
204
204
  end
205
205
 
206
206
  create_pointer "Cardtype B+*type+*create", "[[r3]]"
@@ -210,7 +210,6 @@ class SharedData
210
210
  create "Cardtype E+*type+*default"
211
211
  end
212
212
 
213
-
214
213
  def notification_cards
215
214
  Timecop.freeze(Cardio.future_stamp - 1.day) do
216
215
  # fwiw Timecop is apparently limited by ruby Time object,
@@ -231,7 +230,7 @@ class SharedData
231
230
 
232
231
  followers.each do |name, _follow|
233
232
  create_user name, email: "#{name.parameterize}@user.com",
234
- password: "#{name.parameterize}_pass"
233
+ password: "#{name.parameterize}_pass"
235
234
  end
236
235
 
237
236
  create "All Eyes On Me"
@@ -252,7 +251,8 @@ class SharedData
252
251
 
253
252
  Card::Auth.signin Card::WagnBotID
254
253
  create "Google glass+*self+*follow_fields", ""
255
- create "Sunglasses+*self+*follow_fields", "[[#{:nests.cardname}]]\n[[_self+price]]\n[[_self+producer]]"
254
+ create "Sunglasses+*self+*follow_fields",
255
+ "[[#{:nests.cardname}]]\n[[_self+price]]\n[[_self+producer]]"
256
256
  create "Sunglasses+tint"
257
257
  create "Sunglasses+price"
258
258
 
@@ -277,7 +277,7 @@ class SharedData
277
277
  ["card with fields", "field 1", "field 2"],
278
278
  ["card with fields and admin fields", "field 1", "admin field 1"],
279
279
  ["admin card with fields and admin fields", "field 1", "admin field 1"],
280
- ["admin card with admin fields", "admin field 1", "admin field 2"],
280
+ ["admin card with admin fields", "admin field 1", "admin field 2"]
281
281
  ].each do |name, f1, f2|
282
282
  create name,
283
283
  content: "main content {{+#{f1}}} {{+#{f2}}}",
@@ -297,25 +297,24 @@ class SharedData
297
297
  end
298
298
  create ["field 1", :right, :read], type: "Pointer", content: "[[Anyone]]"
299
299
  end
300
-
301
300
  end
302
301
  end
303
302
 
304
- TEXT = <<-TXT.strip_heredoc.freeze
305
- Far out in the uncharted backwaters of the unfashionable end of
306
- the western spiral arm of the Galaxy lies a small unregarded
307
- yellow sun.
308
-
309
- Orbiting this at a distance of roughly ninety-two million miles
310
- is an utterly insignificant little blue green planet whose ape-
311
- descended life forms are so amazingly primitive that they still
312
- think digital watches are a pretty neat idea.
313
-
314
- This planet has - or rather had - a problem, which was this: most
315
- of the people living on it were unhappy for pretty much of the time.
316
- Many solutions were suggested for this problem, but most of these
317
- were largely concerned with the movements of small green pieces
318
- of paper, which is odd because on the whole it wasn't the small
319
- green pieces of paper that were unhappy.
303
+ TEXT = <<~TXT.strip_heredoc.freeze
304
+ Far out in the uncharted backwaters of the unfashionable end of
305
+ the western spiral arm of the Galaxy lies a small unregarded
306
+ yellow sun.
307
+ #{' '}
308
+ Orbiting this at a distance of roughly ninety-two million miles
309
+ is an utterly insignificant little blue green planet whose ape-
310
+ descended life forms are so amazingly primitive that they still
311
+ think digital watches are a pretty neat idea.
312
+ #{' '}
313
+ This planet has - or rather had - a problem, which was this: most
314
+ of the people living on it were unhappy for pretty much of the time.
315
+ Many solutions were suggested for this problem, but most of these
316
+ were largely concerned with the movements of small green pieces
317
+ of paper, which is odd because on the whole it wasn't the small
318
+ green pieces of paper that were unhappy.
320
319
  TXT
321
320
  end
data/lib/card.rb CHANGED
@@ -113,9 +113,24 @@ ActiveSupport.run_load_hooks(:before_card, self)
113
113
  class Card < ApplicationRecord
114
114
  extend Mark
115
115
  extend Dirty::MethodFactory
116
+ extend Name::CardClass
117
+ extend Cache::CardClass
118
+ extend Director::CardClass
119
+ extend Fetch::CardClass
120
+
116
121
  include Dirty
117
122
  include DirtyNames
118
123
  include Director::CardMethods
124
+ include Name::All
125
+ include Content::All
126
+ include Set::Event::All
127
+ include Set::Pattern::All
128
+ include Cache::All
129
+ include Director::All
130
+ include Reference::All
131
+ include Rule::All
132
+ include Fetch::All
133
+ include Subcards::All
119
134
 
120
135
  Card::Cache # trigger autoload
121
136
 
@@ -143,7 +158,6 @@ class Card < ApplicationRecord
143
158
  :skip_in_action, # skip event for just this card
144
159
  :trigger, # trigger event(s) for all cards in act
145
160
  :trigger_in_action, # trigger event for just this card
146
-
147
161
  :comment, # obviated soon
148
162
 
149
163
  # TODO: refactor following to use skip/trigger
@@ -154,6 +168,9 @@ class Card < ApplicationRecord
154
168
 
155
169
  attr_accessor(*action_specific_attributes)
156
170
 
171
+ self.action_specific_attributes +=
172
+ %i[skip_hash full_skip_hash trigger_hash full_trigger_hash]
173
+
157
174
  define_callbacks :select_action, :show_page, :act
158
175
 
159
176
  ActiveSupport.run_load_hooks :card, self
data/lib/card/auth.rb CHANGED
@@ -10,8 +10,7 @@ class Card
10
10
  extend Proxy
11
11
  extend Setup
12
12
  extend Current
13
-
14
- @as_card = @as_id = @current_id = @current = nil
13
+ extend Token
15
14
 
16
15
  class << self
17
16
  # authenticate a user by their login name and unencrypted password.
@@ -40,6 +39,10 @@ class Card
40
39
  def encrypt password, salt
41
40
  Digest::SHA1.hexdigest "#{salt}--#{password}--"
42
41
  end
42
+
43
+ def serialize
44
+ { as_id: as_id, current_id: current_id }
45
+ end
43
46
  end
44
47
  end
45
48
  end
@@ -2,114 +2,66 @@ class Card
2
2
  module Auth
3
3
  # methods for setting current account
4
4
  module Current
5
- # set current user in process and session
6
- def signin cardish
7
- signin_id = Card.id(cardish) || Card::AnonymousID
8
- self.current_id = signin_id
9
- set_session_user signin_id
10
- end
11
-
12
- # current user is not anonymous
13
- # @return [true/false]
14
- def signed_in?
15
- current_id != Card::AnonymousID
16
- end
17
-
18
5
  # id of current user card.
19
6
  # @return [Integer]
20
7
  def current_id
21
8
  @current_id ||= Card::AnonymousID
22
9
  end
23
10
 
11
+ # set the id of the current user.
12
+ # @return [Integer]
13
+ def current_id= card_id
14
+ reset
15
+ card_id = card_id.to_i if card_id.present?
16
+ @current_id = card_id
17
+ end
18
+
24
19
  # current accounted card (must have +\*account)
25
20
  # @return [Card]
26
- def current
27
- if @current && @current.id == current_id
28
- @current
29
- else
30
- @current = Card[current_id]
31
- end
21
+ def current_card
22
+ return @current_card if @current_card&.id == current_id
23
+
24
+ @current_card = Card[current_id]
32
25
  end
26
+ alias_method :current, :current_card
33
27
 
34
28
  def current_roles
35
29
  @current_roles ||= [Card.fetch_name(:anyone_signed_in),
36
30
  current.fetch(:roles)&.item_names].flatten.compact
37
31
  end
38
32
 
39
- def serialize
40
- { as_id: as_id, current_id: current_id }
41
- end
42
-
43
- # @param auth_data [Integer|Hash] user id, user name, or a hash
44
- # @option auth_data [Integer] current_id
45
- # @option auth_data [Integer] as_id
46
- def with auth_data
47
- if auth_data.is_a?(Integer) || auth_data.is_a?(String)
48
- auth_data = { current_id: Card.id(auth_data) }
49
- end
50
-
51
- tmp_current_id = current_id
52
- tmp_as_id = as_id
53
- tmp_current = @current
54
- tmp_as_card = @as_card
55
- tmp_current_roles = @current_roles
56
-
57
- # resets @as and @as_card
58
- self.current_id = auth_data[:current_id]
59
- @as_id = auth_data[:as_id] if auth_data[:as_id]
60
- yield
61
- ensure
62
- @current_id = tmp_current_id
63
- @as_id = tmp_as_id
64
- @current = tmp_current
65
- @as_card = tmp_as_card
66
- @current_roles = tmp_current_roles
33
+ # set current user in process and session
34
+ def signin cardish
35
+ session[session_user_key] =
36
+ self.current_id = Card.id(cardish) || Card::AnonymousID
67
37
  end
68
38
 
69
- # get session object from Env
70
- # return [Session]
71
- def session
72
- Card::Env.session
39
+ # current user is not anonymous
40
+ # @return [true/false]
41
+ def signed_in?
42
+ current_id != Card::AnonymousID
73
43
  end
74
44
 
75
45
  # set current from token, api_key, or session
76
- def signin_with opts={}
46
+ def signin_with _opts={}
77
47
  if opts[:token]
78
48
  signin_with_token opts[:token]
79
- elsif opts[:api_key]
80
- signin_with_api_key opts[:api_key]
81
49
  else
82
50
  signin_with_session
83
51
  end
84
52
  end
85
53
 
86
- # set the current user based on token
87
- def signin_with_token token
88
- payload = Token.validate! token
89
- signin payload[:anonymous] ? Card::AnonymousID : payload[:user_id]
90
- end
91
-
92
- # set the current user based on api_key
93
- def signin_with_api_key api_key
94
- account = find_account_by_api_key api_key
95
- unless account&.validate_api_key! api_key
96
- raise Card::Error::PermissionDenied, "API key authentication failed"
97
- end
98
-
99
- signin account.left_id
100
- end
101
-
102
54
  # get :user id from session and set Auth.current_id
103
55
  def signin_with_session
104
- card_id = session_user
105
- signin(card_id && Card.exists?(card_id) ? card_id : nil)
56
+ card_id = session[session_user_key]
57
+ card_id = nil unless Card.exists? card_id
58
+ signin card_id
106
59
  end
107
60
 
108
- # find +\*account card by +\*api card
109
- # @param api_key [String]
110
- # @return [+*account card, nil]
111
- def find_account_by_api_key api_key
112
- find_account_by :api_key, api_key.strip
61
+ # get session object from Env
62
+ # return [Session]
63
+ def session
64
+ Card::Env.session
113
65
  end
114
66
 
115
67
  # find +\*account card by +\*email card
@@ -119,6 +71,16 @@ class Card
119
71
  find_account_by :email, email.strip.downcase
120
72
  end
121
73
 
74
+ def reset
75
+ @as_id = @as_card = @current_id = @current_card = @current_roles = nil
76
+ end
77
+
78
+ def session_user_key
79
+ "user_#{Cardio.database_name.underscore}".to_sym
80
+ end
81
+
82
+ private
83
+
122
84
  # general pattern for finding +\*account card based on field cards
123
85
  # @param fieldcode [Symbol] code of account field
124
86
  # @param value [String] content of field
@@ -130,29 +92,6 @@ class Card
130
92
  "find +:account with +#{fieldcode} (#{value})").first
131
93
  end
132
94
  end
133
-
134
- def session_user
135
- session[session_user_key]
136
- end
137
-
138
- def set_session_user card_id
139
- session[session_user_key] = card_id
140
- end
141
-
142
- def session_user_key
143
- "user_#{database.underscore}".to_sym
144
- end
145
-
146
- def database
147
- Rails.configuration.database_configuration.dig Rails.env, "database"
148
- end
149
-
150
- # set the id of the current user.
151
- def current_id= card_id
152
- @current = @as_id = @as_card = @current_roles = nil
153
- card_id = card_id.to_i if card_id.present?
154
- @current_id = card_id
155
- end
156
95
  end
157
96
  end
158
97
  end
@@ -4,10 +4,10 @@ class Card
4
4
  module Proxy
5
5
  # operate with the permissions of another "proxy" user
6
6
  def as given_user
7
- tmp_id = @as_id
7
+ tmp_id = @as_id
8
8
  tmp_card = @as_card
9
9
 
10
- @as_id = get_user_id(given_user)
10
+ @as_id = Card.id given_user
11
11
  @as_card = nil
12
12
  # we could go ahead and set as_card if given a card...
13
13
 
@@ -18,7 +18,7 @@ class Card
18
18
  yield
19
19
  ensure
20
20
  if block_given?
21
- @as_id = tmp_id
21
+ @as_id = tmp_id
22
22
  @as_card = tmp_card
23
23
  end
24
24
  end
@@ -37,22 +37,42 @@ class Card
37
37
  # proxy user card
38
38
  # @return [Card]
39
39
  def as_card
40
- if @as_card && @as_card.id == as_id
41
- @as_card
42
- else
43
- @as_card = Card[as_id]
44
- end
40
+ return @as_card if @as_card&.id == as_id
41
+
42
+ @as_card = Card[as_id]
45
43
  end
46
44
 
47
- # get card id from args of unknown type
48
- # @todo replace with general mechanism, eg #quick_fetch
49
- def get_user_id user
50
- case user
51
- when NilClass then nil
52
- when Card then user.id
53
- when Integer then user
54
- else Card.fetch_id(user)
45
+ # @param auth_data [Integer|Hash] user id, user name, or a hash
46
+ # @option auth_data [Integer] current_id
47
+ # @option auth_data [Integer] as_id
48
+ def with auth_data
49
+ if auth_data.is_a?(Integer) || auth_data.is_a?(String)
50
+ auth_data = { current_id: Card.id(auth_data) }
55
51
  end
52
+
53
+ temporarily do
54
+ # resets @as and @as_card
55
+ self.current_id = auth_data[:current_id]
56
+ @as_id = auth_data[:as_id] if auth_data[:as_id]
57
+ yield
58
+ end
59
+ end
60
+
61
+ private
62
+
63
+ def temporarily
64
+ tmp_current_id = current_id
65
+ tmp_as_id = as_id
66
+ tmp_current_card = @current_card
67
+ tmp_as_card = @as_card
68
+ tmp_current_roles = @current_roles
69
+ yield
70
+ ensure
71
+ @current_id = tmp_current_id
72
+ @as_id = tmp_as_id
73
+ @current = tmp_current_card
74
+ @as_card = tmp_as_card
75
+ @current_roles = tmp_current_roles
56
76
  end
57
77
  end
58
78
  end