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
@@ -14,16 +14,6 @@ class Card
14
14
  end
15
15
  end
16
16
 
17
- def standardize_ensure_args name_or_args, content_or_args
18
- name = name_or_args.is_a?(Hash) ? name_or_args[:name] : name_or_args
19
- args = if name_or_args.is_a?(Hash)
20
- name_or_args
21
- else
22
- hashify content_or_args, :content
23
- end
24
- [name, args]
25
- end
26
-
27
17
  def standardize_update_args name_or_args, content_or_args
28
18
  return name_or_args if name_or_args.is_a?(Hash)
29
19
 
@@ -56,40 +46,6 @@ class Card
56
46
 
57
47
  args[:name] = Card.uniquify_name args[:name], rename
58
48
  end
59
-
60
- def ensure_attributes card, args
61
- subcards = card.extract_subcard_args! args.symbolize_keys!
62
- update_args = changing_args card, args
63
-
64
- return if update_args.empty? && subcards.empty?
65
-
66
- # FIXME: use ensure_attributes for subcards
67
- card.update! update_args.merge(subcards: subcards, skip: :validate_renaming)
68
- end
69
-
70
- def changing_args card, args
71
- args.select do |key, value|
72
- case key.to_s
73
- when /^\+/
74
- changing_field_arg key, value
75
- when /name$/
76
- card.send(key).to_s != value
77
- else
78
- standard_changing_arg card, key, value
79
- end
80
- end
81
- end
82
-
83
- def changing_field_arg key, value
84
- subfields[key] = value
85
- false
86
- end
87
-
88
- def standard_changing_arg card, key, value
89
- return true if value.is_a? ::File
90
-
91
- card.send(key) != value
92
- end
93
49
  end
94
50
  end
95
51
  end
@@ -17,14 +17,6 @@ class Card
17
17
  Card.exist? name
18
18
  end
19
19
 
20
- def add_coderule_item name, prefix, type_id, to
21
- codename = "#{prefix}_#{name.tr(' ', '_').underscore}"
22
- name = "#{prefix}: #{name}"
23
-
24
- ensure_card name, type_id: type_id, codename: codename
25
- Card[to].add_item! name
26
- end
27
-
28
20
  def method_missing method, *args
29
21
  method_name, cardtype_card = extract_cardtype_from_method_name method
30
22
  return super unless method_name
@@ -51,35 +43,6 @@ class Card
51
43
  Card::Codename[type.to_sym] ? Card[type.to_sym] : Card[type]
52
44
  end
53
45
 
54
- def ensure_card_simplified name, args
55
- ensure_card_update(name, args) || Card.create!(add_name(name, args))
56
- end
57
-
58
- def ensure_card_update name, args
59
- card = Card[name]
60
- return unless card
61
-
62
- ensure_attributes card, args
63
- card
64
- rescue Card::Error::CodenameNotFound => _e
65
- false
66
- end
67
-
68
- def validate_setting setting
69
- return if Codename.exist?(setting) && Card.fetch_type_id(setting) == SettingID
70
-
71
- raise ArgumentError, "not a valid setting: #{setting}"
72
- end
73
-
74
- def normalize_trait_rule_args setting, value
75
- return value if value.is_a? Hash
76
-
77
- if Card.fetch_type_id([setting, :right, :default]) == PointerID
78
- value = Array(value).to_pointer_content
79
- end
80
- { content: value }
81
- end
82
-
83
46
  def add_name name, content_or_args
84
47
  if content_or_args.is_a?(Hash)
85
48
  content_or_args.reverse_merge name: name
@@ -37,18 +37,6 @@ class Card
37
37
  update_card name, args.reverse_merge(rename_if_conflict: :new)
38
38
  end
39
39
 
40
- def create_or_update_card name_or_args, content_or_args=nil
41
- name = name_from_args name_or_args
42
-
43
- if Card[name]
44
- args = standardize_update_args name_or_args, content_or_args
45
- update_card(name, args)
46
- else
47
- args = standardize_args name_or_args, content_or_args
48
- create_card(args)
49
- end
50
- end
51
-
52
40
  def delete_card name
53
41
  return unless Card.exist?(name)
54
42
 
@@ -63,80 +51,10 @@ class Card
63
51
  card.delete!
64
52
  end
65
53
 
66
- # create if card doesn't exist
67
- # updates existing card only if given attributes are different except the
68
- # name
69
- # @example if a card with name "under_score" exists
70
- # ensure_card "Under Score" # => no change
71
- # ensure_card "Under Score", type: :pointer # => changes the type to pointer
72
- # # but not the name
73
- def ensure_card name_or_args, content_or_args=nil
74
- name, args = standardize_ensure_args name_or_args, content_or_args
75
- ensure_card_simplified name, args
76
- end
77
-
78
- # like ensure_card but derives codename from name if no codename is given.
79
- # The derived codename is all lower case with underscores; "*" and ":" are removed
80
- def ensure_code_card name_or_args, content_or_args=nil
81
- name, args = standardize_ensure_args name_or_args, content_or_args
82
- args[:codename] = codename_from_name(name) unless args[:codename]
83
- ensure_card_simplified name, args
84
- end
85
-
86
- # create if card doesn't exist
87
- # updates existing card only if given attributes are different including
88
- # the name
89
- # For example if a card with name "under_score" exists
90
- # then `ensure_card "Under Score"` renames it to "Under Score"
91
- def ensure_card! name_or_args, content_or_args=nil
92
- name, args = standardize_ensure_args name_or_args, content_or_args
93
- ensure_card_simplified name, add_name(name, args)
94
- end
95
-
96
- # Creates or updates a trait card with codename and right rules.
97
- # Content for rules that are pointer cards by default
98
- # is converted to pointer format.
99
- # @example
100
- # ensure_trait "*a_or_b", :a_or_b,
101
- # default: { type_id: Card::PointerID },
102
- # options: ["A", "B"],
103
- # input: "radio"
104
- def ensure_trait name, codename, args={}
105
- ensure_card name, codename: codename
106
- args.each do |setting, value|
107
- ensure_trait_rule name, setting, value
108
- end
109
- end
110
-
111
- def ensure_trait_rule trait, setting, value
112
- validate_setting setting
113
- card_args = normalize_trait_rule_args setting, value
114
- ensure_card [trait, :right, setting], card_args
115
- end
116
-
117
- def create_or_update_card! name_or_args, content_or_args=nil
118
- args = standardize_args name_or_args, content_or_args
119
- create_or_update args.reverse_merge(rename_if_conflict: :new)
120
- end
121
-
122
- # TODO: this is too specific for this
123
- def add_script name, opts={}
124
- name.sub!(/^script:?\s?/, "") # in case name is given with prefix
125
- # remove it so that we don't double it
126
-
127
- add_coderule_item name, "script",
128
- opts[:type_id] || Card::CoffeeScriptID,
129
- opts[:to] || "*all+*script"
130
- end
131
-
132
54
  alias_method :create, :create_card
133
55
  alias_method :update, :update_card
134
- alias_method :create_or_update, :create_or_update_card
135
56
  alias_method :create!, :create_card!
136
57
  alias_method :update!, :update_card!
137
- alias_method :create_or_update!, :create_or_update_card!
138
- alias_method :ensure, :ensure_card
139
- alias_method :ensure!, :ensure_card!
140
58
  alias_method :delete, :delete_card
141
59
  end
142
60
  end
data/lib/card/name/all.rb CHANGED
@@ -11,6 +11,7 @@ class Card
11
11
  def name
12
12
  @name ||= left_id ? Lexicon.lex_to_name([left_id, right_id]) : super.to_name
13
13
  end
14
+ alias_method :cardname, :name
14
15
 
15
16
  def key
16
17
  @key ||= left_id ? name.key : super
@@ -71,10 +72,6 @@ class Card
71
72
  @key
72
73
  end
73
74
 
74
- def field tag, opts={}
75
- Card.fetch name.field(tag), opts
76
- end
77
-
78
75
  private
79
76
 
80
77
  def assign_side_ids
@@ -17,8 +17,6 @@ class Card
17
17
  name
18
18
  end
19
19
 
20
- private
21
-
22
20
  def generate_alternative_name name
23
21
  uniq_name = "#{name} 1"
24
22
  uniq_name.next! while Card.exists?(uniq_name)
@@ -34,6 +34,10 @@ class Card
34
34
  def codename_or_string
35
35
  codename || s
36
36
  end
37
+
38
+ def alternative
39
+ Card.generate_alternative_name self
40
+ end
37
41
  end
38
42
  end
39
43
  end
data/lib/card/name.rb CHANGED
@@ -10,7 +10,6 @@ class Card
10
10
  #
11
11
  # Card::Name adds support for deeper card integration
12
12
  class Name < Cardname
13
- include FieldsAndTraits
14
13
  include NameVariants
15
14
 
16
15
  class << self
@@ -72,9 +71,5 @@ class Card
72
71
  def rstar?
73
72
  right && right[0, 1] == "*"
74
73
  end
75
-
76
- def code
77
- Card::Codename[card_id]
78
- end
79
74
  end
80
75
  end
@@ -23,15 +23,13 @@ class Card
23
23
  if fasten == :direct
24
24
  @superquery.table_alias
25
25
  else
26
- "#{table_prefix}#{next_table_suffix}"
26
+ "#{table_prefix}#{root.table_seq}#{@table_suffix}"
27
27
  end
28
28
  end
29
29
  end
30
30
 
31
- def next_table_suffix
32
- return root.next_table_suffix unless root?
33
-
34
- @table_suffix = (@table_suffix || -1) + 1
31
+ def table_seq
32
+ @table_seq = @table_seq ? (@table_seq + 1) : 0
35
33
  end
36
34
 
37
35
  def fld field_name
@@ -84,7 +84,7 @@ class Card
84
84
  end
85
85
 
86
86
  def restrict id_field, val
87
- if (id = id_from_val(val))
87
+ if (id = id_from_val val)
88
88
  interpret id_field => id
89
89
  else
90
90
  tie :card, val, from: id_field
@@ -17,7 +17,9 @@ class Card
17
17
  include QueryHelper
18
18
  include Tie
19
19
 
20
- attr_reader :statement, :mods, :conditions, :vars,
20
+ ROOT_VAR_DEFAULTS = { vars: {}, table_suffix: "" }.freeze
21
+
22
+ attr_reader :statement, :mods, :conditions, :vars, :table_suffix,
21
23
  :subqueries, :superquery, :comment, :negate
22
24
  attr_accessor :joins, :conditions_on_join
23
25
 
@@ -29,23 +31,10 @@ class Card
29
31
 
30
32
  @statement = statement.clone
31
33
  init_instance_vars :context, :superquery, :fasten, :negate
32
- @vars = init_query_vars
34
+ init_root_vars
33
35
  table_alias
34
36
  end
35
37
 
36
- def init_instance_vars *varnames
37
- varnames.each do |varname|
38
- instance_variable_set "@#{varname}", (@statement.delete(varname) || nil)
39
- end
40
- end
41
-
42
- def init_query_vars
43
- if (v = @statement.delete :vars) then v.symbolize_keys
44
- elsif @superquery then @superquery.vars
45
- else {}
46
- end
47
- end
48
-
49
38
  def interpret hash
50
39
  hash.each do |action, card|
51
40
  send action, card
@@ -57,11 +46,17 @@ class Card
57
46
  end
58
47
 
59
48
  def sql
60
- @sql ||= Query::SqlStatement.new(self).build.to_s
49
+ @sql ||= sql_statement.build.to_s
50
+ end
51
+
52
+ def sql_statement
53
+ SqlStatement.new self
61
54
  end
62
55
 
63
56
  def root
64
- @root ||= @superquery ? @superquery.root : self
57
+ return @root unless @root.nil?
58
+
59
+ @root = @superquery ? @superquery.root : self
65
60
  end
66
61
 
67
62
  def root?
@@ -90,6 +85,30 @@ class Card
90
85
  else superquery.depth + 1
91
86
  end
92
87
  end
88
+
89
+ private
90
+
91
+ def init_instance_vars *varnames
92
+ varnames.each do |varname|
93
+ instance_variable_set "@#{varname}", (@statement.delete(varname) || nil)
94
+ end
95
+ end
96
+
97
+ def init_root_vars
98
+ ROOT_VAR_DEFAULTS.each do |varname, default|
99
+ val = root_var_value varname, default
100
+ val = val.symbolize_keys if varname == :vars
101
+ instance_variable_set "@#{varname}", val
102
+ end
103
+ end
104
+
105
+ def root_var_value varname, default
106
+ if root?
107
+ @statement.delete(varname) || default
108
+ else
109
+ root.send varname
110
+ end
111
+ end
93
112
  end
94
113
  end
95
114
  end
@@ -0,0 +1,36 @@
1
+ class Card
2
+ module Query
3
+ module CardClass
4
+ def search spec, comment=nil, &block
5
+ results = ::Card::Query.run(spec, comment)
6
+ results.each(&block) if block_given? && results.is_a?(Array)
7
+ results
8
+ end
9
+
10
+ def count_by_cql spec
11
+ spec = spec.clone
12
+ spec.delete(:offset)
13
+ search spec.merge(return: "count")
14
+ end
15
+
16
+ def find_each **options, &block
17
+ # this is a copy from rails (3.2.16) and is needed because this
18
+ # is performed by a relation (ActiveRecord::Relation)
19
+ find_in_batches(**options) do |records|
20
+ records.each(&block)
21
+ end
22
+ end
23
+
24
+ def find_in_batches **options
25
+ if block_given?
26
+ super do |records|
27
+ yield(records)
28
+ Card::Cache.reset_soft
29
+ end
30
+ else
31
+ super
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,12 @@
1
+ class Card
2
+ module Query
3
+ class CardQuery
4
+ # for query attributes requiring custom handling
5
+ module Custom
6
+ def compound val
7
+ add_condition "left_id IS #{'NOT' if val} NULL"
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -6,6 +6,7 @@ class Card
6
6
  INTERPRET_METHOD = { basic: :add_condition,
7
7
  relational: :relate,
8
8
  plus_relational: :relate_compound,
9
+ custom: :send,
9
10
  conjunction: :send }.freeze
10
11
 
11
12
  # normalize and extract meaning from a clause
@@ -3,6 +3,14 @@ class Card
3
3
  class CardQuery
4
4
  # normalize clause's keys and values.
5
5
  module Normalization
6
+ private
7
+
8
+ OK_VALUE_CLASSES = [
9
+ Integer, Float, Hash, Symbol,
10
+ TrueClass, FalseClass, NilClass,
11
+ ActiveRecord::Relation
12
+ ].freeze
13
+
6
14
  def normalize_clause clause
7
15
  clause = clause_to_hash clause
8
16
  clause.symbolize_keys!
@@ -28,9 +36,9 @@ class Card
28
36
 
29
37
  def normalize_value val
30
38
  case val
31
- when Integer, Float, Hash, Symbol, NilClass, ActiveRecord::Relation then val
32
- when String then normalize_string_value val
33
- when Array then normalize_array_value val
39
+ when String then normalize_string_value val
40
+ when Array then normalize_array_value val
41
+ when *OK_VALUE_CLASSES then val
34
42
  else raise Error::BadQuery, "Invalid value type: #{val.class} (#{val.inspect})"
35
43
  end
36
44
  end
@@ -33,11 +33,12 @@ class Card
33
33
  # DEPRECATE?
34
34
 
35
35
  def member_of val
36
- interpret right_plus: [Card::RolesID, { refer_to: val }]
36
+ interpret referred_to_by: { left: val, right: { codename: "members" } }
37
37
  end
38
38
 
39
39
  def member val
40
- interpret referred_to_by: { left: val, right: Card::RolesID }
40
+ interpret type_id: Card::RoleID,
41
+ right_plus: [{ codename: "members" }, refer_to: val]
41
42
  end
42
43
  end
43
44
  end
@@ -2,6 +2,7 @@ class Card
2
2
  module Query
3
3
  class CardQuery
4
4
  # handle relational (not simple) CQL sort values
5
+ # (see #interpret_as_modifier? and #order_directives)
5
6
  #
6
7
  # sorting with subqueries is not fully supported; only a few experimental
7
8
  # examples have been attempted, and even for those the syntax is likely
@@ -14,7 +15,7 @@ class Card
14
15
  SORT_BY_ITEM_JOIN_MAP = { left: "left_id", right: "right_id" }.freeze
15
16
 
16
17
  def sort val
17
- return nil unless full?
18
+ return nil unless full? # eg, no sorting on simple count queries
18
19
 
19
20
  interpret_sort_hash val do |value, item, sort_field|
20
21
  sort_by value, item, sort_field
@@ -34,7 +35,7 @@ class Card
34
35
  join = join_cards val, to_field: join_field,
35
36
  side: "LEFT",
36
37
  conditions_on_join: true
37
- @mods[:sort] ||= "#{join.table_alias}.#{sort_field}"
38
+ @mods[:sort_by] ||= "#{join.table_alias}.#{sort_field}"
38
39
  end
39
40
 
40
41
  def sort_by_item_join_field item
@@ -42,7 +43,7 @@ class Card
42
43
  end
43
44
 
44
45
  # EXPERIMENTAL!
45
- # sort: { referred_to_by { right: "*follow" }, return count }
46
+ # sort_by: { referred_to_by { right: "*follow" }, return count }
46
47
 
47
48
  def sort_by_count val, item
48
49
  method_name = "sort_by_count_#{item}"
@@ -55,7 +56,7 @@ class Card
55
56
  end
56
57
 
57
58
  def sort_by_count_referred_to val
58
- @mods[:sort] = "coalesce(count,0)" # needed for postgres
59
+ @mods[:sort_by] = "coalesce(count,0)" # needed for postgres
59
60
  sort_query = count_sort_query
60
61
  sort_query.add_condition "referer_id in (#{count_subselect(val).sql})"
61
62
  # FIXME: - SQL generated before SQL phase
@@ -12,6 +12,7 @@ class Card
12
12
  include Normalization
13
13
  include Sorting
14
14
  include Conjunctions
15
+ include Custom
15
16
  # Query Execution
16
17
 
17
18
  # By default a query returns card objects. This is accomplished by returning
@@ -1,8 +1,8 @@
1
1
  class Card
2
2
  module Query
3
3
  # convert @query sort rep into order by statement
4
- # order information is stored in @mods[:sort], @mods[:sort_as], and
5
- # @mods[:dir]
4
+ # order information is stored in @mods[:sort_by], @mods[:sort_as], and
5
+ # @mods[:sort_dir]
6
6
  class SqlStatement
7
7
  ORDER_MAP = {
8
8
  "id" => "id",
@@ -24,17 +24,18 @@ class Card
24
24
  end
25
25
 
26
26
  def order_directives
27
- return if @mods[:sort].blank?
27
+ sort_mod = @mods[:sort_by] || @mods[:sort]
28
+ return if sort_mod.blank?
28
29
 
29
- Array.wrap(@mods[:sort]).map do |order_key|
30
- order_directive order_key
30
+ Array.wrap(sort_mod).map.with_index do |order_key, index|
31
+ order_directive order_key, index
31
32
  end
32
33
  end
33
34
 
34
- def order_directive order_key
35
+ def order_directive order_key, index
35
36
  field = order_field order_key
36
37
  @fields += ", #{field}"
37
- "#{field} #{order_dir order_key}"
38
+ "#{field} #{order_dir order_key, index}"
38
39
  end
39
40
 
40
41
  def order_field order_key
@@ -54,11 +55,12 @@ class Card
54
55
  "CAST(#{field} AS #{cast_type(safe_sql(as))})"
55
56
  end
56
57
 
57
- def order_dir order_key
58
- if @mods[:dir].blank?
58
+ def order_dir order_key, index
59
+ dir = @mods[:sort_dir] || @mods[:dir] # dir is DEPRECATED
60
+ if dir.blank?
59
61
  DEFAULT_ORDER_DIRS[order_key.to_sym] || "asc"
60
62
  else
61
- safe_sql @mods[:dir]
63
+ safe_sql Array.wrap(dir)[index]
62
64
  end
63
65
  end
64
66
  end
@@ -3,10 +3,10 @@ class Card
3
3
  class SqlStatement
4
4
  # handle where clause in SqlStatement
5
5
  module Where
6
- def where
6
+ def where explicit=true
7
7
  conditions = [explicit_conditions(@query), implicit_conditions(@query)]
8
8
  conditions = conditions.reject(&:blank?).join " AND "
9
- "WHERE #{conditions}" unless conditions.blank?
9
+ "#{'WHERE ' if explicit}#{conditions}" unless conditions.blank?
10
10
  end
11
11
 
12
12
  # conditions explicitly specified in the query object
data/lib/card/query.rb CHANGED
@@ -68,6 +68,7 @@ class Card
68
68
 
69
69
  plus_relational: %i[plus left_plus right_plus],
70
70
  conjunction: %i[and or all any],
71
+ custom: [:compound],
71
72
  ignore: %i[prepend append vars],
72
73
  deprecated: %i[view params size]
73
74
  }.each_with_object({}) do |pair, h|
@@ -76,7 +77,10 @@ class Card
76
77
 
77
78
  CONJUNCTIONS = { any: :or, in: :or, or: :or, all: :and, and: :and }.freeze
78
79
 
79
- MODIFIERS = %i[conj return sort sort_as group dir limit offset]
80
+ # "dir" is DEPRECATED in favor of sort_dir
81
+ # "sort" is DEPRECATED in favor of sort_by, except in cases where sort's value
82
+ # is a hash
83
+ MODIFIERS = %i[conj return sort_by sort_as sort_dir sort dir group limit offset]
80
84
  .each_with_object({}) { |v, h| h[v] = nil }
81
85
 
82
86
  OPERATORS =
@@ -73,16 +73,6 @@ class Card
73
73
 
74
74
  private
75
75
 
76
- def with_normalized_referee referee_name
77
- return unless referee_name # eg commented nest has no referee_name
78
-
79
- referee_name = referee_name.to_name
80
- referee_key = referee_name.key
81
- return if referee_key == key # don't create self reference
82
-
83
- yield referee_name, referee_key, Lexicon.id(referee_name)
84
- end
85
-
86
76
  # interpretation phase helps to prevent duplicate references
87
77
  # results in hash like:
88
78
  # { referee1_key: [referee1_id, referee1_type2],
@@ -96,6 +86,16 @@ class Card
96
86
  end
97
87
  end
98
88
 
89
+ def with_normalized_referee referee_name
90
+ return unless referee_name # eg commented nest has no referee_name
91
+
92
+ referee_name = referee_name.to_name
93
+ referee_key = referee_name.key
94
+ return if referee_key == key # don't create self reference
95
+
96
+ yield referee_name, referee_key, Lexicon.id(referee_name)
97
+ end
98
+
99
99
  # translate interpreted reference hash into values array,
100
100
  # removing duplicate and unnecessary ref_types
101
101
  def reference_values_array ref_hash
@@ -4,7 +4,7 @@ class Card
4
4
  module AdvancedApi
5
5
  def assign_type type, module_key=nil
6
6
  module_key ||= shortname
7
- Type.assignment[module_key] = type.card_id
7
+ Type.assignment[module_key] = type
8
8
  end
9
9
 
10
10
  def setting_opts opts