card 1.104.2 → 1.105.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (390) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -6
  3. data/VERSION +1 -1
  4. data/config/environments/development.rb +1 -1
  5. data/config/environments/test.rb +1 -0
  6. data/config/initializers/01_core_extensions/object.rb +10 -0
  7. data/config/initializers/01_core_extensions/string.rb +9 -0
  8. data/config/initializers/core_extensions.rb +1 -0
  9. data/db/migrate/{20160122153608_new_indeces.rb → 20160122153608_new_indices.rb} +2 -2
  10. data/db/migrate/{20200805200729_add_unique_pair_indeces.rb → 20200805200729_add_unique_pair_indices.rb} +1 -1
  11. data/db/migrate/20221031182227_remove_referee_key_requirement.rb +11 -0
  12. data/db/migrate_core_cards/20130920291703_update_stylesheets.rb +1 -9
  13. data/db/migrate_core_cards/20140307231621_user_data_to_cards.rb +1 -38
  14. data/db/migrate_core_cards/20161103154836_update_keys.rb +1 -1
  15. data/db/migrate_core_cards/20180905061537_migrate_layouts.rb +1 -1
  16. data/db/migrate_core_cards/20190125125150_add_script_rules_card.rb +1 -1
  17. data/db/migrate_core_cards/20190320091257_upgrade_recaptcha_to_v3.rb +1 -1
  18. data/db/migrate_core_cards/20190502130029_add_shark_and_help_desk_role.rb +2 -20
  19. data/db/migrate_core_cards/20190528131330_enabled_roles.rb +0 -3
  20. data/db/migrate_core_cards/20190625153616_pointer_overhaul.rb +0 -2
  21. data/db/migrate_core_cards/20190718140126_add_guides.rb +1 -1
  22. data/db/migrate_core_cards/20190822093633_move_help_text_to_code.rb +1 -1
  23. data/db/migrate_core_cards/20190829205148_remove_add_help.rb +1 -1
  24. data/db/migrate_core_cards/20190902193208_input_type.rb +1 -1
  25. data/db/migrate_core_cards/20190909104250_add_cardtype_input_types.rb +2 -2
  26. data/db/schema.rb +2 -2
  27. data/db/seeds.rb +14 -1
  28. data/db/version.txt +1 -1
  29. data/lib/card/auth/current.rb +4 -2
  30. data/lib/card/auth/permissions.rb +1 -1
  31. data/lib/card/auth/setup.rb +1 -1
  32. data/lib/card/auth/token.rb +1 -1
  33. data/lib/card/cache/persistent.rb +4 -1
  34. data/lib/card/codename.rb +2 -6
  35. data/lib/card/content/all.rb +2 -2
  36. data/lib/card/content/clean.rb +1 -1
  37. data/lib/card/content/parser.rb +0 -2
  38. data/lib/card/content.rb +1 -8
  39. data/lib/card/director/all.rb +67 -0
  40. data/lib/card/director/card_class.rb +158 -2
  41. data/lib/card/director/{act_direction.rb → class_methods.rb} +13 -3
  42. data/lib/card/director/phases.rb +7 -4
  43. data/lib/card/director/run.rb +51 -50
  44. data/lib/card/director/stages.rb +18 -16
  45. data/lib/card/director/store.rb +1 -1
  46. data/lib/card/director.rb +6 -7
  47. data/lib/card/env/location.rb +1 -1
  48. data/lib/card/env/serializable.rb +2 -0
  49. data/lib/card/env/serialization.rb +2 -3
  50. data/lib/card/env.rb +2 -2
  51. data/lib/card/error.rb +9 -5
  52. data/lib/card/format/error.rb +6 -12
  53. data/lib/card/format/nest.rb +1 -1
  54. data/lib/card/format/wrapper.rb +1 -1
  55. data/lib/card/format.rb +4 -0
  56. data/lib/card/model/save_helper/save_arguments.rb +0 -44
  57. data/lib/card/model/save_helper/save_helper_helper.rb +0 -37
  58. data/lib/card/model/save_helper.rb +0 -82
  59. data/lib/card/name/all.rb +1 -4
  60. data/lib/card/name/card_class.rb +0 -2
  61. data/lib/card/name/name_variants.rb +4 -0
  62. data/lib/card/name.rb +0 -5
  63. data/lib/card/query/abstract_query/query_helper.rb +3 -5
  64. data/lib/card/query/abstract_query/tie.rb +1 -1
  65. data/lib/card/query/abstract_query.rb +36 -17
  66. data/lib/card/query/card_class.rb +36 -0
  67. data/lib/card/query/card_query/custom.rb +12 -0
  68. data/lib/card/query/card_query/interpretation.rb +1 -0
  69. data/lib/card/query/card_query/normalization.rb +11 -3
  70. data/lib/card/query/card_query/reference_attributes.rb +3 -2
  71. data/lib/card/query/card_query/sorting.rb +5 -4
  72. data/lib/card/query/card_query.rb +1 -0
  73. data/lib/card/query/sql_statement/order.rb +12 -10
  74. data/lib/card/query/sql_statement/where.rb +2 -2
  75. data/lib/card/query.rb +5 -1
  76. data/lib/card/reference/all.rb +10 -10
  77. data/lib/card/set/advanced_api.rb +1 -1
  78. data/lib/card/set/event/all.rb +9 -1
  79. data/lib/card/set/event/delayed_event.rb +4 -2
  80. data/lib/card/set/event/options.rb +1 -1
  81. data/lib/card/set/event/skip_and_trigger.rb +34 -10
  82. data/lib/card/set/format/abstract_format/haml_views.rb +3 -3
  83. data/lib/card/set/format/abstract_format.rb +1 -1
  84. data/lib/card/set/format/haml_paths.rb +5 -21
  85. data/lib/card/set/inheritance.rb +4 -4
  86. data/lib/card/set/pattern/all.rb +1 -1
  87. data/lib/card/set/pattern/base.rb +1 -1
  88. data/lib/card/set/pattern/class_methods.rb +4 -4
  89. data/lib/card/set/trait.rb +1 -1
  90. data/lib/card/set/type.rb +0 -41
  91. data/lib/card/setting.rb +0 -1
  92. data/lib/card/subcards/all.rb +6 -8
  93. data/lib/card/subcards/args.rb +9 -9
  94. data/lib/card/view/cache/cache_action.rb +1 -1
  95. data/lib/card/view/options/visibility.rb +4 -0
  96. data/lib/card/view/options.rb +1 -0
  97. data/lib/card/view/permission.rb +12 -4
  98. data/lib/card/view.rb +4 -0
  99. data/lib/card.rb +18 -27
  100. data/lib/cardio/cli.rb +3 -1
  101. data/lib/cardio/command/application.rb +5 -0
  102. data/lib/cardio/{commands/command.rb → command/command_base.rb} +2 -2
  103. data/lib/cardio/{commands → command}/custom.rb +16 -13
  104. data/lib/cardio/{commands → command}/rake_command/parser.rb +3 -3
  105. data/lib/cardio/{commands → command}/rake_command.rb +4 -4
  106. data/lib/cardio/{commands → command}/rspec_command/parser.rb +2 -2
  107. data/lib/cardio/{commands → command}/rspec_command.rb +7 -9
  108. data/lib/cardio/command.rb +129 -0
  109. data/lib/cardio/commands.rb +17 -116
  110. data/lib/cardio/generators/deck_generator_loader.rb +1 -0
  111. data/lib/cardio/generators.rb +2 -2
  112. data/lib/cardio/migration.rb +3 -53
  113. data/lib/cardio/mod/class_methods.rb +26 -22
  114. data/lib/cardio/mod/dirs.rb +29 -22
  115. data/lib/cardio/mod/eat/edibles.rb +22 -15
  116. data/lib/cardio/mod/eat.rb +18 -14
  117. data/lib/cardio/mod/load_strategy/set_tmp_files.rb +1 -1
  118. data/lib/cardio/mod/load_strategy.rb +12 -2
  119. data/lib/cardio/mod/modfile_api.rb +18 -18
  120. data/lib/cardio/mod/{poop.rb → sow.rb} +10 -18
  121. data/lib/cardio/mod.rb +21 -30
  122. data/lib/cardio/railtie.rb +19 -56
  123. data/lib/cardio/schema.rb +2 -1
  124. data/lib/cardio/script_loader.rb +3 -1
  125. data/lib/cardio/seed.rb +101 -8
  126. data/lib/cardio/utils.rb +39 -1
  127. data/lib/generators/deck/deck_generator.rb +5 -2
  128. data/lib/generators/deck/templates/config/puma.rb +1 -1
  129. data/lib/generators/deck/templates/script/decko_rspec +1 -1
  130. data/lib/generators/deck/templates/simplecov.rb.erb +10 -8
  131. data/lib/generators/mod/USAGE +1 -1
  132. data/lib/generators/set/USAGE +2 -2
  133. data/mod/core/data/fixtures/real/card_actions.yml +78 -0
  134. data/{db/seed/new → mod/core/data/fixtures/real}/card_acts.yml +2 -2
  135. data/{db/seed/new → mod/core/data/fixtures/real}/card_changes.yml +0 -0
  136. data/mod/core/data/fixtures/real/card_references.yml +8 -0
  137. data/mod/core/data/fixtures/real/cards.yml +135 -0
  138. data/{db/seed/new → mod/core/data/fixtures/real}/schema_migrations.yml +0 -0
  139. data/{db/seed/new → mod/core/data/fixtures/real}/schema_migrations_core_cards.yml +0 -0
  140. data/{db/seed/new → mod/core/data/fixtures/real}/schema_migrations_deck.yml +0 -0
  141. data/{db/seed/new → mod/core/data/fixtures/real}/schema_migrations_deck_cards.yml +0 -0
  142. data/mod/core/data/real.yml +79 -0
  143. data/mod/core/data/test/cardtype.yml +38 -0
  144. data/mod/core/data/test/sample.yml +50 -0
  145. data/mod/core/data/test/user.yml +41 -0
  146. data/mod/core/data/test.yml +79 -28
  147. data/mod/core/lib/tasks/card/assets.rake +17 -0
  148. data/{lib → mod/core/lib}/tasks/card/create.rake +0 -0
  149. data/{lib → mod/core/lib}/tasks/card/migrate.rake +4 -0
  150. data/{lib → mod/core/lib}/tasks/card/mod.rake +4 -3
  151. data/mod/core/lib/tasks/card/seed.rake +58 -0
  152. data/mod/core/lib/tasks/card.rake +115 -0
  153. data/mod/core/locales/de.yml +4 -0
  154. data/mod/core/locales/en.yml +13 -0
  155. data/mod/core/set/all/admin.rb +14 -0
  156. data/mod/core/set/all/codename.rb +4 -0
  157. data/mod/core/set/all/content.rb +8 -4
  158. data/mod/core/set/all/{abort.rb → result.rb} +11 -15
  159. data/mod/core/set/all/states.rb +15 -1
  160. data/mod/core/set/all/trash.rb +25 -73
  161. data/mod/core/set/all/type.rb +2 -2
  162. data/mod/core/set/all/utils.rb +3 -87
  163. data/mod/core/set/right/autoname.rb +2 -0
  164. data/mod/core/set/self/admin/warning_alert.haml +3 -0
  165. data/mod/core/set/self/admin.rb +173 -0
  166. data/mod/core/set/type/cardtype.rb +2 -0
  167. data/mod/core/set_pattern/02_all_plus.rb +1 -1
  168. data/mod/core/set_pattern/05_rstar.rb +1 -1
  169. data/mod/core/set_pattern/06_rule.rb +1 -1
  170. data/mod/core/set_pattern/07_right.rb +1 -1
  171. data/mod/core/set_pattern/08_type_plus_right.rb +1 -1
  172. data/mod/core/spec/set/all/assign_attributes_spec.rb +3 -3
  173. data/mod/core/spec/set/all/autoname_spec.rb +25 -0
  174. data/mod/core/spec/set/all/codename_spec.rb +1 -1
  175. data/mod/core/spec/set/all/name_events_spec.rb +43 -66
  176. data/mod/core/spec/set/all/trash_spec.rb +149 -68
  177. data/mod/{admin → core}/spec/set/self/admin_spec.rb +25 -22
  178. data/mod/core/spec/set/self/trash_spec.rb +5 -0
  179. metadata +88 -251
  180. data/db/migrate_core_cards/20130411211600_delete_old_related_tab_cards.rb +0 -18
  181. data/db/migrate_core_cards/20130419215612_import_help_text.rb +0 -13
  182. data/db/migrate_core_cards/20130823192433_add_style_cards.rb +0 -100
  183. data/db/migrate_core_cards/20130910183318_move_styles_to_content.rb +0 -11
  184. data/db/migrate_core_cards/20130927191728_account_events.rb +0 -20
  185. data/db/migrate_core_cards/20131016172445_common_css_patch.rb +0 -9
  186. data/db/migrate_core_cards/20140110193325_reset_account_request_type.rb +0 -8
  187. data/db/migrate_core_cards/20140512155840_add_script_cards.rb +0 -86
  188. data/db/migrate_core_cards/20140629222005_add_email_cards.rb +0 -132
  189. data/db/migrate_core_cards/20140725180118_config_card_updates.rb +0 -9
  190. data/db/migrate_core_cards/20141111083921_delete_machine_output.rb +0 -7
  191. data/db/migrate_core_cards/20141115034214_config_descriptions_etc.rb +0 -14
  192. data/db/migrate_core_cards/20141119001955_make_symlinks_relative.rb +0 -15
  193. data/db/migrate_core_cards/20141120120605_fix_notification_html_message.rb +0 -10
  194. data/db/migrate_core_cards/20141216155251_add_more_following_cards.rb +0 -26
  195. data/db/migrate_core_cards/20141230204340_uri_codename.rb +0 -13
  196. data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +0 -76
  197. data/db/migrate_core_cards/20150317162412_bootstrap_themes.rb +0 -41
  198. data/db/migrate_core_cards/20150326205655_bootswatch_themes.rb +0 -36
  199. data/db/migrate_core_cards/20150331135745_new_card_menu.rb +0 -8
  200. data/db/migrate_core_cards/20150501010515_responsive_sidebar.rb +0 -11
  201. data/db/migrate_core_cards/20150508212032_menu_compatibility.rb +0 -24
  202. data/db/migrate_core_cards/20150528084659_add_session_cardtype.rb +0 -18
  203. data/db/migrate_core_cards/20150601133433_add_recent_setting_session_card.rb +0 -18
  204. data/db/migrate_core_cards/20150610171702_add_debugger_session_card.rb +0 -12
  205. data/db/migrate_core_cards/20150610180019_add_recaptcha_key_and_admin_info_cards.rb +0 -58
  206. data/db/migrate_core_cards/20150627205133_fix_script_bootstrap_card_type.rb +0 -7
  207. data/db/migrate_core_cards/20150702130543_remove_edit_toolbar_pinned.rb +0 -9
  208. data/db/migrate_core_cards/20150708224756_add_list_cards.rb +0 -29
  209. data/db/migrate_core_cards/20150903130006_attachment_upload_cards.rb +0 -15
  210. data/db/migrate_core_cards/20150910085603_remove_performance_log_card.rb +0 -10
  211. data/db/migrate_core_cards/20151120180631_add_token_expiration.rb +0 -7
  212. data/db/migrate_core_cards/20160801143221_change_bootstrap_card_type_to_scss.rb +0 -10
  213. data/db/migrate_core_cards/20160804112510_reorganize_scripts.rb +0 -27
  214. data/db/migrate_core_cards/20160908154210_add_trash_card.rb +0 -7
  215. data/db/migrate_core_cards/20161102202156_tweak_recaptcha_setting_cards.rb +0 -17
  216. data/db/migrate_core_cards/20170209132834_email_test_context.rb +0 -49
  217. data/db/migrate_core_cards/20170314175313_add_notification_event_card.rb +0 -20
  218. data/db/migrate_core_cards/20170515101262_add_advanced_edit_cards.rb +0 -20
  219. data/db/migrate_core_cards/20170608083819_add_full_width_layout_card.rb +0 -23
  220. data/db/migrate_core_cards/20170608200649_add_input_options_codename.rb +0 -8
  221. data/db/migrate_core_cards/20180423120222_add_mod_styles_card.rb +0 -20
  222. data/db/migrate_core_cards/20180508210903_add_json_type.rb +0 -10
  223. data/db/migrate_core_cards/20180515175726_add_codenames.rb +0 -8
  224. data/db/migrate_core_cards/20180712042655_head_rule.rb +0 -13
  225. data/db/migrate_core_cards/20181120200937_update_layout.rb +0 -7
  226. data/db/migrate_core_cards/20190204195039_add_rule_card.rb +0 -10
  227. data/db/migrate_core_cards/20190321085735_wagn_to_decko_logo.rb +0 -11
  228. data/db/migrate_core_cards/20190417142612_reorganize_scripts_2.rb +0 -17
  229. data/db/migrate_core_cards/20190424100531_update_credit_image.rb +0 -76
  230. data/db/migrate_core_cards/20190424101004_add_read_anyone_rules.rb +0 -13
  231. data/db/migrate_core_cards/20190503122739_update_pristine_data.rb +0 -18
  232. data/db/migrate_core_cards/20190605133556_tweak_config_cards.rb +0 -10
  233. data/db/migrate_core_cards/20190618110446_add_dropdown_divider.rb +0 -8
  234. data/db/migrate_core_cards/20190621143156_add_role_assign_permissions.rb +0 -9
  235. data/db/migrate_core_cards/20190710090209_homepage_tweaks.rb +0 -13
  236. data/db/migrate_core_cards/20190820155833_update_cardtype_type_structure.rb +0 -7
  237. data/db/migrate_core_cards/20190823220018_cleanup_for_decko_1_0.rb +0 -19
  238. data/db/migrate_core_cards/20190826132738_add_more_guides.rb +0 -7
  239. data/db/migrate_core_cards/20190829093961_cardtype_grouping.rb +0 -16
  240. data/db/migrate_core_cards/20190830131820_setting_settings_aside.rb +0 -17
  241. data/db/migrate_core_cards/20190902161223_add_style_media.rb +0 -7
  242. data/db/migrate_core_cards/20190918200115_ensure_description_card.rb +0 -13
  243. data/db/migrate_core_cards/20191008201046_fixture_fix.rb +0 -11
  244. data/db/migrate_core_cards/20191028135243_add_link_editor_to_tiny_mce_config.rb +0 -9
  245. data/db/migrate_core_cards/20191118145629_codename_fixes.rb +0 -5
  246. data/db/migrate_core_cards/20200821231558_add_nest_list_type.rb +0 -9
  247. data/db/migrate_core_cards/data/1.11_help_text.json +0 -410
  248. data/db/migrate_core_cards/data/1.12_stylesheets/classic_cards.scss +0 -104
  249. data/db/migrate_core_cards/data/1.12_stylesheets/common.scss +0 -228
  250. data/db/migrate_core_cards/data/1.12_stylesheets/right_sidebar.scss +0 -27
  251. data/db/migrate_core_cards/data/1.12_stylesheets/traditional.scss +0 -143
  252. data/db/migrate_core_cards/data/1.13_config_text.json +0 -32
  253. data/db/migrate_core_cards/data/1.14_config_descriptions_etc.json +0 -77
  254. data/db/migrate_core_cards/data/bootstrap_layout.json +0 -96
  255. data/db/migrate_core_cards/data/cards/Xaccount +0 -22
  256. data/db/migrate_core_cards/data/cards/Xaccount_setting-Xright-Xstructure +0 -12
  257. data/db/migrate_core_cards/data/cards/Xall-Xlayout +0 -1
  258. data/db/migrate_core_cards/data/cards/Xcredit +0 -2
  259. data/db/migrate_core_cards/data/cards/Xfooter +0 -3
  260. data/db/migrate_core_cards/data/cards/Xgetting_started +0 -31
  261. data/db/migrate_core_cards/data/cards/Xgetting_started-shark +0 -66
  262. data/db/migrate_core_cards/data/cards/Xgetting_started_link +0 -6
  263. data/db/migrate_core_cards/data/cards/Xheader +0 -19
  264. data/db/migrate_core_cards/data/cards/Xhome +0 -1
  265. data/db/migrate_core_cards/data/cards/Xlogo +0 -1
  266. data/db/migrate_core_cards/data/cards/Xmain_menu +0 -2
  267. data/db/migrate_core_cards/data/cards/Xrecaptcha_setting-Xself-Xstructure +0 -1
  268. data/db/migrate_core_cards/data/cards/Xsidebar +0 -7
  269. data/db/migrate_core_cards/data/cards/Xstructure-Xright-Xguide +0 -12
  270. data/db/migrate_core_cards/data/cards/Xtitle +0 -1
  271. data/db/migrate_core_cards/data/cards/administrator-dashboard +0 -23
  272. data/db/migrate_core_cards/data/cards/administrator-description +0 -1
  273. data/db/migrate_core_cards/data/cards/anyone_signed_in-dashboard +0 -0
  274. data/db/migrate_core_cards/data/cards/cardtype-Xtype-Xguide +0 -24
  275. data/db/migrate_core_cards/data/cards/cardtype-Xtype-Xstructure +0 -3
  276. data/db/migrate_core_cards/data/cards/default_layout +0 -6
  277. data/db/migrate_core_cards/data/cards/full_width_layout +0 -5
  278. data/db/migrate_core_cards/data/cards/help_desk-dashboard +0 -7
  279. data/db/migrate_core_cards/data/cards/help_desk-description +0 -1
  280. data/db/migrate_core_cards/data/cards/home +0 -2
  281. data/db/migrate_core_cards/data/cards/home-Xself-Xlayout +0 -1
  282. data/db/migrate_core_cards/data/cards/home-original +0 -22
  283. data/db/migrate_core_cards/data/cards/home_layout +0 -6
  284. data/db/migrate_core_cards/data/cards/left_sidebar_layout +0 -6
  285. data/db/migrate_core_cards/data/cards/menu +0 -1
  286. data/db/migrate_core_cards/data/cards/right_thin_sidebar_layout +0 -8
  287. data/db/migrate_core_cards/data/cards/role-Xtype-Xstructure +0 -2
  288. data/db/migrate_core_cards/data/cards/shark-dashboard +0 -19
  289. data/db/migrate_core_cards/data/cards/shark-description +0 -1
  290. data/db/migrate_core_cards/data/cards/shark_menu +0 -2
  291. data/db/migrate_core_cards/data/cards.yml +0 -138
  292. data/db/migrate_core_cards/data/decko_logo.svg +0 -1
  293. data/db/migrate_core_cards/data/mailer/follower_notification_email.html +0 -9
  294. data/db/migrate_core_cards/data/mailer/follower_notification_email.txt +0 -11
  295. data/db/migrate_core_cards/data/mailer/mail_config.json +0 -22
  296. data/db/migrate_core_cards/data/mailer/password_reset_email.html +0 -13
  297. data/db/migrate_core_cards/data/mailer/password_reset_email.txt +0 -11
  298. data/db/migrate_core_cards/data/mailer/signup_alert_email.html +0 -7
  299. data/db/migrate_core_cards/data/mailer/signup_alert_email.txt +0 -5
  300. data/db/migrate_core_cards/data/mailer/verification_email.html +0 -12
  301. data/db/migrate_core_cards/data/mailer/verification_email.txt +0 -9
  302. data/db/migrate_core_cards/data/skin_images.json +0 -91
  303. data/db/migrate_core_cards/data/themes/bootstrap_default/_bootswatch.scss +0 -0
  304. data/db/migrate_core_cards/data/themes/bootstrap_default/_variables.scss +0 -867
  305. data/db/migrate_core_cards/data/themes/cerulean/_bootswatch.scss +0 -125
  306. data/db/migrate_core_cards/data/themes/cerulean/_variables.scss +0 -861
  307. data/db/migrate_core_cards/data/themes/cosmo/_bootswatch.scss +0 -237
  308. data/db/migrate_core_cards/data/themes/cosmo/_variables.scss +0 -861
  309. data/db/migrate_core_cards/data/themes/cyborg/_bootswatch.scss +0 -210
  310. data/db/migrate_core_cards/data/themes/cyborg/_variables.scss +0 -861
  311. data/db/migrate_core_cards/data/themes/darkly/_bootswatch.scss +0 -330
  312. data/db/migrate_core_cards/data/themes/darkly/_variables.scss +0 -861
  313. data/db/migrate_core_cards/data/themes/flatly/_bootswatch.scss +0 -313
  314. data/db/migrate_core_cards/data/themes/flatly/_variables.scss +0 -861
  315. data/db/migrate_core_cards/data/themes/journal/_bootswatch.scss +0 -120
  316. data/db/migrate_core_cards/data/themes/journal/_variables.scss +0 -861
  317. data/db/migrate_core_cards/data/themes/lumen/_bootswatch.scss +0 -496
  318. data/db/migrate_core_cards/data/themes/lumen/_variables.scss +0 -861
  319. data/db/migrate_core_cards/data/themes/paper/_bootswatch.scss +0 -607
  320. data/db/migrate_core_cards/data/themes/paper/_variables.scss +0 -861
  321. data/db/migrate_core_cards/data/themes/readable/_bootswatch.scss +0 -174
  322. data/db/migrate_core_cards/data/themes/readable/_variables.scss +0 -861
  323. data/db/migrate_core_cards/data/themes/sandstone/_bootswatch.scss +0 -194
  324. data/db/migrate_core_cards/data/themes/sandstone/_variables.scss +0 -861
  325. data/db/migrate_core_cards/data/themes/simplex/_bootswatch.scss +0 -142
  326. data/db/migrate_core_cards/data/themes/simplex/_variables.scss +0 -861
  327. data/db/migrate_core_cards/data/themes/slate/_bootswatch.scss +0 -417
  328. data/db/migrate_core_cards/data/themes/slate/_variables.scss +0 -861
  329. data/db/migrate_core_cards/data/themes/spacelab/_bootswatch.scss +0 -137
  330. data/db/migrate_core_cards/data/themes/spacelab/_variables.scss +0 -861
  331. data/db/migrate_core_cards/data/themes/superhero/_bootswatch.scss +0 -332
  332. data/db/migrate_core_cards/data/themes/superhero/_variables.scss +0 -861
  333. data/db/migrate_core_cards/data/themes/united/_bootswatch.scss +0 -42
  334. data/db/migrate_core_cards/data/themes/united/_variables.scss +0 -861
  335. data/db/migrate_core_cards/data/themes/yeti/_bootswatch.scss +0 -437
  336. data/db/migrate_core_cards/data/themes/yeti/_variables.scss +0 -861
  337. data/db/seed/README.md +0 -2
  338. data/db/seed/new/card_actions.yml +0 -5913
  339. data/db/seed/new/card_references.yml +0 -6532
  340. data/db/seed/new/cards.yml +0 -14595
  341. data/db/seed/test/fixtures/card_actions.yml +0 -8153
  342. data/db/seed/test/fixtures/card_acts.yml +0 -1039
  343. data/db/seed/test/fixtures/card_changes.yml +0 -230
  344. data/db/seed/test/fixtures/card_references.yml +0 -8471
  345. data/db/seed/test/fixtures/cards.yml +0 -20171
  346. data/db/seed/test/fixtures/file1.txt +0 -1
  347. data/db/seed/test/fixtures/file2.txt +0 -1
  348. data/db/seed/test/fixtures/mao2.jpg +0 -0
  349. data/db/seed/test/fixtures/rails.gif +0 -0
  350. data/db/seed/test/fixtures/schema_migrations.yml +0 -67
  351. data/db/seed/test/fixtures/schema_migrations_core_cards.yml +0 -347
  352. data/db/seed/test/fixtures/schema_migrations_deck.yml +0 -1
  353. data/db/seed/test/fixtures/schema_migrations_deck_cards.yml +0 -5
  354. data/db/test_seed.rb +0 -322
  355. data/lib/card/content/truncate.rb +0 -67
  356. data/lib/card/director/card_methods.rb +0 -45
  357. data/lib/card/file_card_creator/abstract_file_card/migration_file.rb +0 -50
  358. data/lib/card/file_card_creator/abstract_file_card/ruby_file.rb +0 -30
  359. data/lib/card/file_card_creator/abstract_file_card/source_file.rb +0 -36
  360. data/lib/card/file_card_creator/abstract_file_card.rb +0 -44
  361. data/lib/card/file_card_creator/haml_card.rb +0 -42
  362. data/lib/card/file_card_creator/output_helper.rb +0 -53
  363. data/lib/card/file_card_creator/script_card.rb +0 -35
  364. data/lib/card/file_card_creator/style_card.rb +0 -25
  365. data/lib/card/file_card_creator.rb +0 -25
  366. data/lib/card/name/fields_and_traits.rb +0 -42
  367. data/lib/cardio/commands/application.rb +0 -10
  368. data/lib/cardio/migration/import/import_data/card_attributes.rb +0 -64
  369. data/lib/cardio/migration/import/import_data/card_content.rb +0 -30
  370. data/lib/cardio/migration/import/import_data.rb +0 -119
  371. data/lib/cardio/migration/import/merger.rb +0 -46
  372. data/lib/cardio/migration/import.rb +0 -125
  373. data/lib/tasks/card.rake +0 -65
  374. data/mod/admin/locales/de.yml +0 -4
  375. data/mod/admin/locales/en.yml +0 -4
  376. data/mod/admin/set/all/admin.rb +0 -16
  377. data/mod/admin/set/self/admin.rb +0 -144
  378. data/mod/admin/set/self/admin_info.rb +0 -40
  379. data/mod/admin/set/self/debugger.rb +0 -3
  380. data/mod/admin/spec/set/self/admin_info_spec.rb +0 -9
  381. data/mod/core/data/production.yml +0 -7
  382. data/mod/core/set/all/collection.rb +0 -53
  383. data/mod/core/spec/set/all/collection_spec.rb +0 -170
  384. data/mod/core/spec/set/all/utils_spec.rb +0 -5
  385. data/mod/standard/data/files/favicon/image-icon.png +0 -0
  386. data/mod/standard/data/files/favicon/image-large.png +0 -0
  387. data/mod/standard/data/files/favicon/image-medium.png +0 -0
  388. data/mod/standard/data/files/favicon/image-original.png +0 -0
  389. data/mod/standard/data/files/favicon/image-small.png +0 -0
  390. data/mod/standard/data/files/logo/image-original.svg +0 -1
@@ -27,14 +27,14 @@ module Cardio
27
27
 
28
28
  # @return [Array <Hash>]
29
29
  def mod_edibles mod
30
- environments.map { |env| items_for_environment mod, env }.compact
30
+ pod_types.map { |type| items_for_type mod, type }.compact
31
31
  end
32
32
 
33
- def items_for_environment mod, env
34
- return unless (items = items_from_yaml mod, env)
33
+ def items_for_type mod, type
34
+ return unless (items = items_from_yaml mod, type)
35
35
 
36
36
  items = items.map do |item|
37
- item.is_a?(String) ? items_from_yaml(mod, env, item) : item
37
+ item.is_a?(String) ? items_from_yaml(mod, type, item) : item
38
38
  end.flatten.compact
39
39
  interpret_items mod, items
40
40
  end
@@ -43,8 +43,8 @@ module Cardio
43
43
  each_card_hash(items) { |hash| handle_attachments mod, hash }
44
44
  end
45
45
 
46
- def items_from_yaml mod, env, filename=nil
47
- source = "#{env}#{'/' if filename.present?}#{filename}.yml"
46
+ def items_from_yaml mod, type, filename=nil
47
+ source = "#{type}#{'/' if filename.present?}#{filename}.yml"
48
48
  return unless (path = mod.subpath "data", source)
49
49
 
50
50
  YAML.load_file path
@@ -54,7 +54,7 @@ module Cardio
54
54
  def each_card_hash items
55
55
  items.each do |item|
56
56
  yield item
57
- item[:subfields]&.values&.each { |val| yield val if val.is_a? Hash }
57
+ item[:fields]&.values&.each { |val| yield val if val.is_a? Hash }
58
58
  end
59
59
  items
60
60
  end
@@ -71,20 +71,27 @@ module Cardio
71
71
  end
72
72
 
73
73
  def mod_file mod, filename
74
- File.open mod.subpath("data/files", filename)
74
+ unless (mod_file_path = mod.subpath "data/files", filename)
75
+ raise StandardError, "#{filename} not found. "\
76
+ "Should be in data/files in #{mod.name} mod."
77
+ end
78
+ File.open mod_file_path
75
79
  end
76
80
 
77
81
  def attachment_keys
78
82
  @attachment_keys ||= Card.uploaders.keys
79
83
  end
80
84
 
81
- # @return [Array <Symbol>]
82
- # holarchical. each includes the previous
83
- # production = [:production],
84
- # development = [:production, :development], etc.
85
- def environments
86
- index = DATA_ENVIRONMENTS.index(@env&.to_sym || Rails.env.to_sym) || -1
87
- DATA_ENVIRONMENTS[0..index]
85
+ def pod_types
86
+ if @pod_type == :all
87
+ %i[real test]
88
+ elsif @pod_type
89
+ [@pod_type]
90
+ elsif Rails.env.test?
91
+ %i[real test]
92
+ else
93
+ [:real]
94
+ end
88
95
  end
89
96
  end
90
97
  end
@@ -1,8 +1,6 @@
1
1
  require "timecop"
2
+ # require "pry"
2
3
 
3
- require "pry"
4
-
5
- DATA_ENVIRONMENTS = %i[production development test].freeze
6
4
  ENV["STORE_CODED_FILES"] = "true"
7
5
 
8
6
  module Cardio
@@ -11,25 +9,22 @@ module Cardio
11
9
  # (list of card attributes)
12
10
  # https://docs.google.com/document/d/13K_ynFwfpHwc3t5gnLeAkZJZHco1wK063nJNYwU8qfc/edit#
13
11
  class Eat
14
- include Card::Model::SaveHelper
15
12
  include Edibles
16
13
 
17
- def initialize mod: nil, env: nil, user: nil, verbose: nil
14
+ def initialize mod: nil, type: nil, user: nil, verbose: nil
18
15
  @mod = mod
19
- @env = env
16
+ @pod_type = type&.to_sym
20
17
  @user_id = user&.card_id
21
18
  @verbose = !verbose.nil?
22
19
  end
23
20
 
24
21
  def up
25
- Card::Cache.reset_all
26
- Card::Mailer.perform_deliveries = false
27
- Card::Auth.as_bot do
22
+ handle_up do
28
23
  edibles.each do |edible|
29
24
  track edible do
30
25
  current_user edible.delete(:user)
31
26
  time_machine edible.delete(:time) do
32
- ensure_card edible
27
+ Card.ensure edible
33
28
  end
34
29
  end
35
30
  end
@@ -38,21 +33,30 @@ module Cardio
38
33
 
39
34
  private
40
35
 
36
+ # if output mod given,
37
+ def handle_up
38
+ Card::Cache.reset_all
39
+ Card::Mailer.perform_deliveries = false
40
+ Card::Auth.as_bot { yield }
41
+ :success
42
+ rescue StandardError => e
43
+ e.message
44
+ end
45
+
41
46
  def track edible
42
47
  rescuing edible do
43
- # puts "eat: #{edible}" if @verbose
48
+ # puts "eating: #{edible}" if @verbose
44
49
  card = yield
45
- puts "eaten: #{card.name}".green # if @verbose
50
+ puts "eaten: #{card.name}".cyan if @verbose
46
51
  end
47
52
  end
48
53
 
49
54
  def rescuing edible
50
55
  yield
51
56
  rescue StandardError => e
52
- # binding.pry
53
57
  puts edible
54
58
  puts e.message.red
55
- puts e.backtrace.join("\n") if @verbose
59
+ puts e.backtrace[0..10].join("\n") if @verbose
56
60
  end
57
61
 
58
62
  def current_user item_user
@@ -9,7 +9,7 @@ module Cardio
9
9
  return unless prepare_tmp_dir "tmp/set"
10
10
 
11
11
  mod_dirs.each_with_tmp(:set) do |mod_dir, mod_tmp_dir|
12
- Dir.mkdir mod_tmp_dir
12
+ FileUtils.mkdir_p mod_tmp_dir
13
13
  Dir.glob("#{mod_dir}/**/*.rb").each do |abs_path|
14
14
  rel_path = abs_path.sub "#{mod_dir}/", ""
15
15
  tmp_filename = File.join mod_tmp_dir, rel_path
@@ -1,5 +1,15 @@
1
1
  module Cardio
2
2
  class Mod
3
+ # The main way to enhance cards' appearance and behavior is through the card set DSL.
4
+ #
5
+ # The default mechanism for loading DSL code is live evaluation, or Eval. Eval is
6
+ # fast and efficient and preferred for a wide range of scenarios, including
7
+ # production and live debugging. But Eval is problematic for generating both test
8
+ # coverage reports with Simplecov and documentation sites with YARD.
9
+ #
10
+ # For those two reasons, we make it possible to load the DSL code by generating
11
+ # fully explicit ruby modules in tmp files.
12
+ #
3
13
  # Shared code for the three different load strategies: Eval, TmpFiles and BindingMagic
4
14
  class LoadStrategy
5
15
  class << self
@@ -7,9 +17,9 @@ module Cardio
7
17
 
8
18
  def class_for_set strategy
9
19
  case strategy
10
- when :tmp_files then SetTmpFiles
20
+ when :tmp_files then SetTmpFiles
11
21
  when :binding_magic then SetBindingMagic
12
- else Eval
22
+ else Eval
13
23
  end
14
24
  end
15
25
 
@@ -2,26 +2,26 @@ module Cardio
2
2
  class Mod
3
3
  # Methods used via "eval" in Modfiles
4
4
  module ModfileApi
5
- def mod mod_name, path=nil
6
- @dirs.add_mod mod_name, path
5
+ def mod *args
6
+ @dirs.add_mod(*args)
7
7
  end
8
8
 
9
- def gem_mod name
10
- deps = Mod.dependencies name
11
- unknown_gem_mod!(name) if deps.blank?
12
- deps.each { |spec| @dirs.add_gem_mod spec.name, spec.full_gem_path }
13
- end
14
-
15
- # load all gem mods
16
- def gem_mods
17
- @dirs.load_from_gemfile
18
- end
19
-
20
- private
21
-
22
- def unknown_gem_mod! name
23
- raise Card::Error, %(Unknown gem "#{name}". Make sure it is in your Gemfile.)
24
- end
9
+ # def gem_mod name
10
+ # deps = Mod.dependencies name
11
+ # unknown_gem_mod!(name) if deps.blank?
12
+ # deps.each { |spec| @dirs.add_gem_mod spec.name, spec.full_gem_path }
13
+ # end
14
+ #
15
+ # # add all gem mods
16
+ # def gem_mods
17
+ # @dirs.add_from_gemfile
18
+ # end
19
+ #
20
+ # private
21
+ #
22
+ # def unknown_gem_mod! name
23
+ # raise Card::Error, %(Unknown gem "#{name}". Make sure it is in your Gemfile.)
24
+ # end
25
25
  end
26
26
  end
27
27
  end
@@ -1,18 +1,15 @@
1
1
  module Cardio
2
2
  class Mod
3
- # POOP (or Plain Old OutPut) is our nickname for our standard card YAML,
4
- # used to define cards associated with mods.
5
- #
6
- # Monkeys throw it around, and Sharks can eat it (if you believe this guy:
7
- # https://www.youtube.com/watch?v=VvEa4NSqw7I).
3
+ # The Sow class is for exporting data to mods' data directories so that they can
4
+ # be used as seed data when the mod is installed.
8
5
  #
9
6
  # https://docs.google.com/document/d/13K_ynFwfpHwc3t5gnLeAkZJZHco1wK063nJNYwU8qfc/edit#
10
- class Poop
7
+ class Sow
11
8
  def initialize **args
12
9
  @mod = args[:mod]
13
10
  @name = args[:name]
14
11
  @cql = args[:cql]
15
- @env = args[:env] || Rails.env
12
+ @env = args[:env] || (Rails.env.test? ? :test : :production)
16
13
  @items = args[:items]
17
14
  @field_tags = args[:field_tags]
18
15
  end
@@ -65,17 +62,14 @@ module Cardio
65
62
 
66
63
  def cards_from_name
67
64
  case @items
68
- when :only
69
- item_cards
70
- when true
71
- main_cards + item_cards
72
- else
73
- main_cards
65
+ when :only then item_cards
66
+ when true then main_cards + item_cards
67
+ else main_cards
74
68
  end
75
69
  end
76
70
 
77
71
  def item_cards
78
- main_cards.map { |mc| mc.item_cards }.flatten
72
+ main_cards.map(&:item_cards).flatten
79
73
  end
80
74
 
81
75
  def main_cards
@@ -116,13 +110,11 @@ module Cardio
116
110
  end
117
111
 
118
112
  def target
119
- @target ||= old_data
113
+ @target ||= (old_data || nil)
120
114
  end
121
115
 
122
116
  def old_data
123
- return nil unless File.exist? filename
124
-
125
- YAML.safe_load File.read(filename), [Symbol]
117
+ YAML.safe_load File.read(filename), [Symbol] if File.exist? filename
126
118
  end
127
119
 
128
120
  # @return Path
data/lib/cardio/mod.rb CHANGED
@@ -10,17 +10,16 @@ module Cardio
10
10
  #
11
11
  # decko generate card:mod MOD_NAME
12
12
  #
13
- # This will create the following directories:
13
+ # This will create a directory following the pattern `DECK_NAME/mod/MOD_NAME`. This
14
+ # directory contains all the specifications of your mod. By default that includes
15
+ # a README.md file and the following subdirectories:
14
16
  #
15
- # DECK_NAME/mod/MOD_NAME
16
- # DECK_NAME/mod/MOD_NAME/lib
17
- # DECK_NAME/mod/MOD_NAME/public
18
- # DECK_NAME/mod/MOD_NAME/set
19
- #
20
- # The lib directory contains libraries, of course. And files in the public directory
21
- # are public and served directly.
22
- #
23
- # But in most mods, the focal point is the *set* directory.
17
+ # - **assets** - for JavaScript, CSS, and variants (CoffeeScript, SCSS, etc)
18
+ # - **data** - for seed and test data. see {file:SEEDME.md}.
19
+ # - **lib** - for standard code libraries
20
+ # - **public** - accessible via the web at DECK_URL_ROOT/mod/MOD_NAME/
21
+ # - **set** - the mod's focal point where card sets are configured (see below)
22
+ # - **spec** - for rspec tests
24
23
  #
25
24
  # ## Set Modules
26
25
  #
@@ -64,16 +63,17 @@ module Cardio
64
63
  class Mod
65
64
  extend ClassMethods
66
65
 
67
- attr_reader :name, :path, :index
66
+ attr_reader :name, :path, :group, :index
68
67
 
69
- def initialize name, path, index
68
+ def initialize name, path, group, index
70
69
  @name = Mod.normalize_name name
71
70
  @path = required_path path
71
+ @group = group || :custom
72
72
  @index = index
73
73
  end
74
74
 
75
75
  def mod_card_name
76
- "mod: #{name}"
76
+ "mod: #{name.tr '_', ' '}"
77
77
  end
78
78
 
79
79
  def codename
@@ -86,16 +86,17 @@ module Cardio
86
86
  end
87
87
 
88
88
  def tmp_dir type
89
- File.join Cardio.paths["tmp/#{type}"].first,
89
+ File.join Cardio.paths["tmp/#{type}"].first, @group.to_s,
90
90
  "mod#{'%03d' % (@index + 1)}-#{@name}"
91
91
  end
92
92
 
93
- def ensure
94
- Card::Auth.as_bot do
95
- card = ensure_card
96
- card.ensure_mod_script_card
97
- card.ensure_mod_style_card
98
- Card::Cache.reset_all
93
+ def ensure_card
94
+ if Card::Codename.exists? codename
95
+ card = Card.fetch codename.to_sym
96
+ card.update type: :mod unless card.type_code == :mod
97
+ card
98
+ else
99
+ Card.create name: mod_card_name, type: :mod, codename: codename
99
100
  end
100
101
  end
101
102
 
@@ -106,15 +107,5 @@ module Cardio
106
107
 
107
108
  raise Card::Error::NotFound, "mod not found: #{@name}"
108
109
  end
109
-
110
- def ensure_card
111
- if Card::Codename.exists? codename
112
- card = Card.fetch codename.to_sym
113
- card.update type: :mod unless card.type_code == :mod
114
- card
115
- else
116
- Card.create name: mod_card_name, type: :mod, codename: codename
117
- end
118
- end
119
110
  end
120
111
  end
@@ -1,67 +1,30 @@
1
1
  module Cardio
2
2
  # primary railtie for cards
3
3
  class Railtie < Rails::Railtie
4
+ config.encoding = "utf-8"
5
+
6
+ config.seed_mods = [:core]
7
+ config.seed_type = :real
8
+ config.extra_seed_tables = []
9
+
4
10
  # if you disable inline styles tinymce's formatting options stop working
5
11
  config.allow_inline_styles = true
6
12
  config.token_expiry = 2.days
7
13
 
8
- config.recaptcha_public_key = nil # deprecated; use recaptcha_site_key instead
9
- config.recaptcha_private_key = nil # deprecated; use recaptcha_secret_key instead
10
-
11
- config.recaptcha_proxy = nil
12
- config.recaptcha_site_key = nil
13
- config.recaptcha_secret_key = nil
14
- config.recaptcha_minimum_score = 0.5
15
-
16
- config.google_analytics_key = nil
17
- config.google_analytics_tracker_key = nil
18
- config.google_analytics_four_key = nil
19
-
20
14
  config.no_authentication = false
21
- config.files_web_path = "files"
22
15
 
23
16
  config.max_char_count = 200
24
17
  config.max_depth = 20
25
18
  config.email_defaults = nil
26
19
 
27
- config.acts_per_page = 10
28
20
  config.space_last_in_multispace = true
29
- config.closed_search_limit = 10
30
- config.paging_limit = 20
31
-
32
- config.delaying = false
33
- config.active_job.queue_adapter = :delayed_job
34
-
35
- config.non_createable_types = %w[
36
- signup
37
- setting
38
- set
39
- session
40
- bootswatch_skin
41
- customized_bootswatch_skin
42
- local_folder_group
43
- local_manifest_group
44
- local_script_folder_group
45
- local_script_manifest_group
46
- local_style_folder_group
47
- local_style_manifest_group
48
- remote_manifest_group
49
- mod
50
- ]
51
21
 
52
22
  config.view_cache = false
53
- config.rss_enabled = false
54
- config.double_click = :signed_in
55
23
 
56
- config.encoding = "utf-8"
57
24
  config.request_logger = false
58
25
  config.performance_logger = false
59
26
  config.sql_comments = false
60
27
 
61
- config.file_storage = :local
62
- config.file_buckets = {}
63
- config.file_default_bucket = nil
64
-
65
28
  config.deck_origin = nil
66
29
 
67
30
  config.rich_text_editor = :tinymce
@@ -74,13 +37,12 @@ module Cardio
74
37
  config.allow_irreversible_admin_tasks = false
75
38
  config.raise_all_rendering_errors = false
76
39
  config.rescue_all_in_controller = true
77
- config.navbox_match_start_only = true
78
40
 
79
41
  config.cache_set_module_list = false
80
42
 
81
43
  config.i18n.enforce_available_locales = true
82
44
  config.read_only = !ENV["DECKO_READ_ONLY"].nil?
83
- config.load_strategy = (ENV["REPO_TMPSETS"] || ENV["TMPSETS"] ? :tmp_files : :eval)
45
+ config.load_strategy = ENV["CARD_LOAD_STRATEGY"]&.to_sym || :eval
84
46
 
85
47
  # TODO: support mod-specific railties
86
48
 
@@ -98,8 +60,7 @@ module Cardio
98
60
 
99
61
  p["lib/tasks"] << "#{card_root}/lib/tasks"
100
62
 
101
- p.add "mod", with: "#{card_root}/mod"
102
- p["mod"] << "mod"
63
+ p.add "mod"
103
64
  p.add "files"
104
65
 
105
66
  p.add "lib/graph_q_l/types/query.rb"
@@ -113,7 +74,7 @@ module Cardio
113
74
  p.add "db/migrate_deck", with: "db/migrate"
114
75
  p.add "db/migrate_deck_cards", with: "db/migrate_cards"
115
76
 
116
- Cardio::Mod.each_path do |mod_path|
77
+ Cardio::Mod.dirs.each do |mod_path|
117
78
  c.autoload_paths += Dir["#{mod_path}/lib"]
118
79
  c.watchable_dirs["#{mod_path}/set"] = %i[rb haml]
119
80
 
@@ -121,11 +82,12 @@ module Cardio
121
82
  "#{mod_path}/lib/graph_q_l/types/query.rb"
122
83
  p["config/initializers"] << "#{mod_path}/init/early"
123
84
  p["late/initializers"] << "#{mod_path}/init/late"
124
- p["config/locales"] << "#{mod_path}/locales"
125
85
  p["lib/tasks"] << "#{mod_path}/lib/tasks"
126
86
  p["mod-data"] << "#{mod_path}/data"
87
+ p["config/locales"] << "#{mod_path}/locales"
127
88
  end
128
89
 
90
+ # Card doesn't use these rails patterns
129
91
  p["app/models"] = []
130
92
  p["app/mailers"] = []
131
93
  p["app/controllers"] = []
@@ -136,15 +98,16 @@ module Cardio
136
98
  config.before_initialize do |app|
137
99
  app.config.tap do |c|
138
100
  if c.load_strategy == :tmp_files
139
- %w[set set_pattern].each do |dir|
140
- if ENV["REPO_TMPSETS"]
141
- c.paths.add "tmp/#{dir}", with: "#{Cardio.gem_root}/tmpsets/#{dir}"
142
- else
143
- c.paths.add "tmp/#{dir}"
144
- end
145
- end
101
+ %w[set set_pattern].each { |dir| c.paths.add "tmp/#{dir}" }
146
102
  end
147
103
  end
148
104
  end
105
+
106
+ def self.require_mod_gem mod_name
107
+ require mod_name.name.to_s.tr("-", "/")
108
+ rescue LoadError
109
+ end
110
+
111
+ Cardio::Mod.gem_specs.each_value { |mod_name| require_mod_gem mod_name }
149
112
  end
150
113
  end
data/lib/cardio/schema.rb CHANGED
@@ -31,7 +31,8 @@ module Cardio
31
31
  end
32
32
 
33
33
  def version type=nil
34
- File.read(stamp_path(type)).strip
34
+ path = stamp_path type
35
+ File.exist?(path) ? File.read(path).strip : nil
35
36
  end
36
37
 
37
38
  def stamp_path type
@@ -8,8 +8,10 @@ module Cardio
8
8
  RUBY = File.join(*RbConfig::CONFIG.values_at("bindir", "ruby_install_name")) +
9
9
  RbConfig::CONFIG["EXEEXT"]
10
10
 
11
+ attr_accessor :script_name
12
+
11
13
  def script
12
- File.join("script", "card")
14
+ File.join "script", script_name
13
15
  end
14
16
 
15
17
  def exec!
data/lib/cardio/seed.rb CHANGED
@@ -6,16 +6,109 @@ module Cardio
6
6
  schema_migrations_deck schema_migrations_deck_cards].freeze
7
7
 
8
8
  class << self
9
- attr_accessor :path, :test_path, :test_script_path
9
+ def default_path
10
+ db_path Cardio.config.seed_type, 0
11
+ end
10
12
 
11
- def db_path *args
12
- parts = [Cardio.gem_root, "db"] + args
13
- File.join(*parts)
13
+ def path
14
+ if update_seed?
15
+ db_path :real, (Rails.env.test? ? 0 : 1)
16
+ else
17
+ default_path
18
+ end
19
+ end
20
+
21
+ def load
22
+ ActiveRecord::FixtureSet.create_fixtures path, load_tables
23
+
24
+ return unless update_seed?
25
+
26
+ Cardio::Migration.assume_current
27
+ Cardio::Migration::Core.assume_current
28
+ Cardio::Migration::DeckStructure.assume_current
29
+ # Cardio::Migration::Core.assume_current
30
+ end
31
+
32
+ def dump
33
+ dump_tables.each do |table|
34
+ i = "000" # TODO: use card keys instead (this is just a label)
35
+ write_seed_file table do
36
+ yamlize_records table do |record, hash|
37
+ hash["#{table}_#{i.succ!}"] = record
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ def clean
44
+ Card::Act.update_all actor_id: author_id
45
+ clean_history
46
+ clean_time_and_user_stamps
47
+ end
48
+
49
+ private
50
+
51
+ def update_seed?
52
+ ENV["CARD_UPDATE_SEED"]
53
+ end
54
+
55
+ # TODO: make this more robust. only handles simple case of extra seed tables
56
+ def load_tables
57
+ update_seed? && !Rails.env.test? ? TABLES : dump_tables
58
+ end
59
+
60
+ def dump_tables
61
+ TABLES + Cardio.config.extra_seed_tables
14
62
  end
15
- end
16
63
 
17
- self.path = db_path "seed", "new"
18
- self.test_path = db_path "seed", "test", "fixtures"
19
- self.test_script_path = db_path "test_seed.rb"
64
+ def db_path env, index
65
+ Mod.fetch(Cardio.config.seed_mods[index]).subpath "data", "fixtures", env.to_s
66
+ end
67
+
68
+ def write_seed_file table
69
+ filename = File.join default_path, "#{table}.yml"
70
+ File.open(filename, "w") { |file| file.write yield }
71
+ end
72
+
73
+ def yamlize_records table
74
+ data = ActiveRecord::Base.connection.select_all "select * from #{table}"
75
+ YAML.dump(
76
+ data.each_with_object({}) do |record, hash|
77
+ try "clean_#{table}_record", record
78
+ yield record, hash
79
+ end
80
+ )
81
+ end
82
+
83
+ def clean_card_actions_record record
84
+ record["draft"] = false # needed?
85
+ end
86
+
87
+ def clean_card_record record
88
+ record["trash"] = false # needed?
89
+ %w[created_at updated_at current_revision_id references_expired].each do |key|
90
+ record.delete key
91
+ end
92
+ end
93
+
94
+ def clean_history
95
+ puts "clean history"
96
+ act = Card::Act.create! actor_id: author_id, card_id: author_id
97
+ Card::Action.make_current_state_the_initial_state act
98
+ Card::Act.where("id <> #{act.id}").delete_all
99
+ ActiveRecord::Base.connection.execute("truncate sessions")
100
+ end
101
+
102
+ def clean_time_and_user_stamps
103
+ puts "clean time and user stamps"
104
+ conn = ActiveRecord::Base.connection
105
+ conn.update "UPDATE cards SET creator_id=#{author_id}, updater_id=#{author_id}"
106
+ conn.update "UPDATE card_acts SET actor_id=#{author_id}"
107
+ end
108
+
109
+ def author_id
110
+ Card::WagnBotID
111
+ end
112
+ end
20
113
  end
21
114
  end