card 1.16.6 → 1.16.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (440) hide show
  1. checksums.yaml +4 -4
  2. data/.yardoc/checksums +234 -49
  3. data/.yardoc/object_types +0 -0
  4. data/.yardoc/objects/root.dat +0 -0
  5. data/VERSION +1 -1
  6. data/config/initializers/mime_types.rb +3 -3
  7. data/config/initializers/notification.rb +1 -1
  8. data/db/migrate/20121118115000_update_link_type.rb +8 -8
  9. data/db/migrate/20130411210957_update_codenames.rb +2 -2
  10. data/db/migrate/20140822073704_create_new_revision_tables.rb +12 -13
  11. data/db/migrate/20141001105348_move_revisions_to_actions.rb +16 -16
  12. data/db/migrate/20141121172918_rename_card_migration_table.rb +4 -4
  13. data/db/migrate_core_cards/20130419215612_import_help_text.rb +3 -3
  14. data/db/migrate_core_cards/20130823192433_add_style_cards.rb +45 -47
  15. data/db/migrate_core_cards/20130910183318_move_styles_to_content.rb +1 -1
  16. data/db/migrate_core_cards/20130920214038_jsonize_tinymce.rb +3 -3
  17. data/db/migrate_core_cards/20130920291703_update_stylesheets.rb +3 -3
  18. data/db/migrate_core_cards/20130927191728_account_events.rb +6 -6
  19. data/db/migrate_core_cards/20131016172445_common_css_patch.rb +1 -1
  20. data/db/migrate_core_cards/20140110193325_reset_account_request_type.rb +1 -1
  21. data/db/migrate_core_cards/20140307231621_user_data_to_cards.rb +19 -19
  22. data/db/migrate_core_cards/20140317035504_account_requests_to_signups.rb +11 -12
  23. data/db/migrate_core_cards/20140512155840_add_script_cards.rb +35 -36
  24. data/db/migrate_core_cards/20140629222005_add_email_cards.rb +55 -55
  25. data/db/migrate_core_cards/20140725180118_config_card_updates.rb +1 -1
  26. data/db/migrate_core_cards/20141111083921_delete_machine_output.rb +2 -2
  27. data/db/migrate_core_cards/20141115034214_config_descriptions_etc.rb +3 -3
  28. data/db/migrate_core_cards/20141120120605_fix_notification_html_message.rb +2 -2
  29. data/db/migrate_core_cards/20141204061304_watchers_to_following.rb +8 -8
  30. data/db/migrate_core_cards/20141208162106_add_ace_script.rb +2 -2
  31. data/db/migrate_core_cards/20141216155251_add_more_following_cards.rb +16 -16
  32. data/db/migrate_core_cards/20141230204340_uri_codename.rb +1 -1
  33. data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +19 -19
  34. data/db/migrate_core_cards/20150220134731_following_to_follow_rule.rb +3 -3
  35. data/db/migrate_core_cards/20150317162412_bootstrap_themes.rb +15 -15
  36. data/db/migrate_core_cards/20150326205655_bootswatch_themes.rb +11 -11
  37. data/db/migrate_core_cards/20150331135745_new_card_menu.rb +1 -1
  38. data/db/migrate_core_cards/20150429090551_search_card_context.rb +1 -1
  39. data/db/migrate_core_cards/20150508212032_menu_compatibility.rb +3 -3
  40. data/db/migrate_core_cards/20150510031118_fix_skin_images.rb +1 -1
  41. data/db/migrate_core_cards/20150528084659_add_session_cardtype.rb +4 -4
  42. data/db/migrate_core_cards/20150601133433_add_recent_setting_session_card.rb +5 -5
  43. data/db/migrate_core_cards/20150605115802_add_performance_log_card.rb +1 -1
  44. data/db/migrate_core_cards/20150610171702_add_debugger_session_card.rb +2 -2
  45. data/db/migrate_core_cards/20150611203506_rails_inflection_updates.rb +5 -5
  46. data/db/migrate_core_cards/20150627205133_fix_script_bootstrap_card_type.rb +1 -1
  47. data/db/migrate_core_cards/20150702130543_remove_edit_toolbar_pinned.rb +1 -1
  48. data/db/migrate_core_cards/20150724123438_update_file_and_image_cards.rb +5 -5
  49. data/db/migrate_core_cards/20150807205221_create_references_for_search_cards.rb +1 -1
  50. data/db/migrate_core_cards/20150824135418_update_file_history.rb +3 -3
  51. data/db/migrate_core_cards/20150903130006_attachment_upload_cards.rb +2 -2
  52. data/db/migrate_core_cards/20150910085603_remove_performance_log_card.rb +1 -1
  53. data/lib/card.rb +4 -4
  54. data/lib/card/active_record_ext.rb +8 -8
  55. data/lib/card/auth.rb +6 -6
  56. data/lib/card/cache.rb +1 -1
  57. data/lib/card/chunk.rb +1 -1
  58. data/lib/card/content.rb +1 -1
  59. data/lib/card/diff.rb +10 -10
  60. data/lib/card/env.rb +1 -1
  61. data/lib/card/format.rb +12 -12
  62. data/lib/card/loader.rb +1 -1
  63. data/lib/card/migration.rb +1 -1
  64. data/lib/card/name.rb +4 -4
  65. data/lib/card/query.rb +255 -61
  66. data/lib/card/query/attributes.rb +310 -0
  67. data/lib/card/query/clause.rb +12 -15
  68. data/lib/card/query/join.rb +73 -0
  69. data/lib/card/query/reference.rb +51 -0
  70. data/lib/card/query/sql_statement.rb +228 -0
  71. data/lib/card/query/value.rb +66 -0
  72. data/lib/card/reference.rb +6 -6
  73. data/lib/card/set.rb +12 -12
  74. data/lib/card/set_pattern.rb +9 -9
  75. data/lib/card/spec_helper.rb +5 -5
  76. data/lib/card/success.rb +1 -1
  77. data/lib/cardio.rb +7 -7
  78. data/lib/generators/card/format/format_generator.rb +3 -3
  79. data/lib/generators/card/migration/migration_generator.rb +5 -5
  80. data/lib/generators/card/set/set_generator.rb +4 -4
  81. data/mod/01_core/chunk/include.rb +4 -4
  82. data/mod/01_core/chunk/link.rb +5 -5
  83. data/mod/01_core/chunk/literal.rb +2 -2
  84. data/mod/01_core/chunk/query_reference.rb +8 -8
  85. data/mod/01_core/chunk/uri.rb +18 -18
  86. data/mod/01_core/format/html_format.rb +4 -4
  87. data/mod/01_core/set/all/active_card.rb +2 -2
  88. data/mod/01_core/set/all/collection.rb +21 -26
  89. data/mod/01_core/set/all/content.rb +2 -2
  90. data/mod/01_core/set/all/fetch.rb +6 -6
  91. data/mod/01_core/set/all/initialize.rb +4 -4
  92. data/mod/01_core/set/all/location_history.rb +2 -2
  93. data/mod/01_core/set/all/name.rb +14 -14
  94. data/mod/01_core/set/all/pattern.rb +1 -1
  95. data/mod/01_core/set/all/permissions.rb +12 -12
  96. data/mod/01_core/set/all/phases.rb +29 -12
  97. data/mod/01_core/set/all/references.rb +14 -14
  98. data/mod/01_core/set/all/rules.rb +8 -8
  99. data/mod/01_core/set/all/templating.rb +10 -9
  100. data/mod/01_core/set/all/tracked_attributes.rb +7 -7
  101. data/mod/01_core/set/all/trash.rb +6 -6
  102. data/mod/01_core/set/all/type.rb +7 -7
  103. data/mod/01_core/set/all/utils.rb +4 -4
  104. data/mod/01_core/set/all/view_cache.rb +1 -1
  105. data/mod/01_core/set_pattern/02_all_plus.rb +2 -2
  106. data/mod/01_core/set_pattern/03_type.rb +1 -1
  107. data/mod/01_core/set_pattern/04_star.rb +1 -1
  108. data/mod/01_core/set_pattern/05_rstar.rb +2 -2
  109. data/mod/01_core/set_pattern/06_right.rb +4 -4
  110. data/mod/01_core/set_pattern/07_type_plus_right.rb +4 -4
  111. data/mod/01_core/set_pattern/08_self.rb +1 -1
  112. data/mod/01_core/spec/chunk/uri_spec.rb +73 -73
  113. data/mod/01_core/spec/format/html_format_spec.rb +5 -5
  114. data/mod/01_core/spec/set/all/attribute_tracking_spec.rb +1 -1
  115. data/mod/01_core/spec/set/all/collection_spec.rb +22 -22
  116. data/mod/01_core/spec/set/all/content_spec.rb +1 -1
  117. data/mod/01_core/spec/set/all/fetch_spec.rb +24 -24
  118. data/mod/01_core/spec/set/all/initialize_spec.rb +9 -9
  119. data/mod/01_core/spec/set/all/name_spec.rb +8 -8
  120. data/mod/01_core/spec/set/all/pattern_spec.rb +10 -10
  121. data/mod/01_core/spec/set/all/permissions_spec.rb +45 -45
  122. data/mod/01_core/spec/set/all/references_spec.rb +1 -1
  123. data/mod/01_core/spec/set/all/rules2_spec.rb +15 -15
  124. data/mod/01_core/spec/set/all/rules_spec.rb +37 -37
  125. data/mod/01_core/spec/set/all/templating_spec.rb +21 -21
  126. data/mod/01_core/spec/set/all/tracked_attributes_spec.rb +55 -55
  127. data/mod/01_core/spec/set/all/trash_spec.rb +4 -4
  128. data/mod/01_core/spec/set/all/type_spec.rb +15 -15
  129. data/mod/01_history/lib/card/act.rb +2 -2
  130. data/mod/01_history/lib/card/action.rb +22 -22
  131. data/mod/01_history/lib/card/change.rb +1 -1
  132. data/mod/01_history/set/all/actions.rb +2 -2
  133. data/mod/01_history/set/all/content_history.rb +4 -4
  134. data/mod/01_history/set/all/history.rb +46 -46
  135. data/mod/02_basic_types/set/all/all_css.rb +10 -10
  136. data/mod/02_basic_types/set/all/all_csv.rb +7 -7
  137. data/mod/02_basic_types/set/all/base.rb +25 -25
  138. data/mod/02_basic_types/set/all/json.rb +16 -16
  139. data/mod/02_basic_types/set/all/rss.rb +7 -7
  140. data/mod/02_basic_types/set/type/html.rb +2 -2
  141. data/mod/02_basic_types/set/type/plain_text.rb +1 -1
  142. data/mod/02_basic_types/set/type/pointer.rb +39 -31
  143. data/mod/02_basic_types/spec/set/all/all_css_spec.rb +1 -1
  144. data/mod/02_basic_types/spec/set/all/all_csv_spec.rb +1 -1
  145. data/mod/02_basic_types/spec/set/all/base_spec.rb +18 -18
  146. data/mod/02_basic_types/spec/set/all/json_spec.rb +4 -4
  147. data/mod/02_basic_types/spec/set/all/rss_spec.rb +8 -2
  148. data/mod/02_basic_types/spec/set/type/plain_text_spec.rb +1 -1
  149. data/mod/02_basic_types/spec/set/type/pointer_spec.rb +54 -44
  150. data/mod/03_machines/lib/card/machine.rb +46 -29
  151. data/mod/03_machines/lib/card/machine_input.rb +34 -10
  152. data/mod/03_machines/set/type/coffee_script.rb +3 -3
  153. data/mod/03_machines/set/type/css.rb +8 -8
  154. data/mod/03_machines/set/type/java_script.rb +4 -4
  155. data/mod/03_machines/set/type/scss.rb +2 -2
  156. data/mod/03_machines/set/type/skin.rb +1 -1
  157. data/mod/03_machines/spec/lib/shared_machine_examples.rb +27 -27
  158. data/mod/03_machines/spec/lib/shared_machine_input_examples.rb +8 -8
  159. data/mod/03_machines/spec/set/type/coffeescript_spec.rb +6 -6
  160. data/mod/03_machines/spec/set/type/css_spec.rb +9 -9
  161. data/mod/03_machines/spec/set/type/javascript_spec.rb +6 -6
  162. data/mod/03_machines/spec/set/type/scss_spec.rb +5 -5
  163. data/mod/03_machines/spec/set/type/skin_spec.rb +25 -25
  164. data/mod/04_settings/lib/card/setting.rb +11 -11
  165. data/mod/04_settings/set/abstract/permission.rb +9 -9
  166. data/mod/04_settings/set/right/script.rb +1 -1
  167. data/mod/04_settings/set/right/structure.rb +0 -5
  168. data/mod/04_settings/set/right/style.rb +2 -2
  169. data/mod/04_settings/set/self/accountable.rb +1 -1
  170. data/mod/04_settings/set/self/add_help.rb +1 -1
  171. data/mod/04_settings/set/self/autoname.rb +1 -1
  172. data/mod/04_settings/set/self/captcha.rb +1 -1
  173. data/mod/04_settings/set/self/create.rb +1 -1
  174. data/mod/04_settings/set/self/default.rb +1 -1
  175. data/mod/04_settings/set/self/delete.rb +1 -1
  176. data/mod/04_settings/set/self/help.rb +1 -1
  177. data/mod/04_settings/set/self/input.rb +1 -1
  178. data/mod/04_settings/set/self/layout.rb +1 -1
  179. data/mod/04_settings/set/self/on_create.rb +1 -1
  180. data/mod/04_settings/set/self/on_delete.rb +1 -1
  181. data/mod/04_settings/set/self/on_update.rb +1 -1
  182. data/mod/04_settings/set/self/options.rb +1 -1
  183. data/mod/04_settings/set/self/options_label.rb +1 -1
  184. data/mod/04_settings/set/self/read.rb +1 -1
  185. data/mod/04_settings/set/self/script.rb +1 -1
  186. data/mod/04_settings/set/self/structure.rb +1 -1
  187. data/mod/04_settings/set/self/style.rb +1 -1
  188. data/mod/04_settings/set/self/table_of_contents.rb +1 -1
  189. data/mod/04_settings/set/self/thanks.rb +1 -1
  190. data/mod/04_settings/set/self/update.rb +1 -1
  191. data/mod/04_settings/set/type/setting.rb +14 -14
  192. data/mod/04_settings/spec/set/right/comment_spec.rb +5 -5
  193. data/mod/04_settings/spec/set/right/create_spec.rb +1 -1
  194. data/mod/04_settings/spec/set/right/script_spec.rb +5 -5
  195. data/mod/04_settings/spec/set/right/structure_spec.rb +4 -2
  196. data/mod/04_settings/spec/set/right/style_spec.rb +7 -7
  197. data/mod/04_settings/spec/set/type/setting_spec.rb +2 -2
  198. data/mod/05_email/lib/card/follow_option.rb +24 -24
  199. data/mod/05_email/set/all/follow.rb +24 -16
  200. data/mod/05_email/set/all/notify.rb +25 -23
  201. data/mod/05_email/set/all/observer.rb +5 -5
  202. data/mod/05_email/set/right/bcc.rb +8 -8
  203. data/mod/05_email/set/right/follow.rb +44 -17
  204. data/mod/05_email/set/right/follow_fields.rb +1 -1
  205. data/mod/05_email/set/right/following.rb +49 -40
  206. data/mod/05_email/set/self/always.rb +2 -2
  207. data/mod/05_email/set/self/created.rb +1 -1
  208. data/mod/05_email/set/self/edited.rb +4 -4
  209. data/mod/05_email/set/self/follow.rb +1 -1
  210. data/mod/05_email/set/self/follow_defaults.rb +9 -9
  211. data/mod/05_email/set/self/never.rb +1 -1
  212. data/mod/05_email/set/type/email_template.rb +9 -9
  213. data/mod/05_email/set/type_plus_right/user/follow.rb +16 -16
  214. data/mod/05_email/spec/set/all/follow_spec.rb +10 -10
  215. data/mod/05_email/spec/set/all/notify_spec.rb +82 -82
  216. data/mod/05_email/spec/set/all/observer_spec.rb +16 -16
  217. data/mod/05_email/spec/set/right/followers_spec.rb +6 -6
  218. data/mod/05_email/spec/set/self/follow_defaults_spec.rb +2 -2
  219. data/mod/05_standard/lib/carrier_wave/cardmount.rb +5 -5
  220. data/mod/05_standard/lib/image_uploader.rb +8 -8
  221. data/mod/05_standard/set/abstract/attachment.rb +18 -18
  222. data/mod/05_standard/set/all/account.rb +5 -5
  223. data/mod/05_standard/set/all/comment.rb +7 -7
  224. data/mod/05_standard/set/all/error.rb +25 -25
  225. data/mod/05_standard/set/all/event_viz.rb +1 -1
  226. data/mod/05_standard/set/all/links.rb +9 -9
  227. data/mod/05_standard/set/all/rich_html/content.rb +34 -34
  228. data/mod/05_standard/set/all/rich_html/editing.rb +35 -35
  229. data/mod/05_standard/set/all/rich_html/form.rb +20 -20
  230. data/mod/05_standard/set/all/rich_html/header.rb +8 -8
  231. data/mod/05_standard/set/all/rich_html/menu.rb +33 -33
  232. data/mod/05_standard/set/all/rich_html/modal.rb +16 -16
  233. data/mod/05_standard/set/all/rich_html/toolbar.rb +63 -63
  234. data/mod/05_standard/set/all/rich_html/wrapper.rb +8 -8
  235. data/mod/05_standard/set/right/account.rb +27 -27
  236. data/mod/05_standard/set/right/email.rb +5 -5
  237. data/mod/05_standard/set/right/password.rb +5 -5
  238. data/mod/05_standard/set/rstar/rules.rb +52 -52
  239. data/mod/05_standard/set/self/account_links.rb +27 -27
  240. data/mod/05_standard/set/self/all.rb +1 -1
  241. data/mod/05_standard/set/self/head.rb +5 -5
  242. data/mod/05_standard/set/self/navbox.rb +11 -11
  243. data/mod/05_standard/set/self/recent.rb +2 -2
  244. data/mod/05_standard/set/self/search.rb +13 -13
  245. data/mod/05_standard/set/self/signin.rb +19 -19
  246. data/mod/05_standard/set/self/stats.rb +2 -2
  247. data/mod/05_standard/set/type/basic.rb +1 -1
  248. data/mod/05_standard/set/type/cardtype.rb +5 -5
  249. data/mod/05_standard/set/type/date.rb +1 -1
  250. data/mod/05_standard/set/type/file.rb +7 -7
  251. data/mod/05_standard/set/type/image.rb +8 -8
  252. data/mod/05_standard/set/type/number.rb +2 -2
  253. data/mod/05_standard/set/type/phrase.rb +1 -1
  254. data/mod/05_standard/set/type/search_type.rb +27 -21
  255. data/mod/05_standard/set/type/session.rb +2 -2
  256. data/mod/05_standard/set/type/set.rb +37 -37
  257. data/mod/05_standard/set/type/signup.rb +25 -25
  258. data/mod/05_standard/set/type/uri.rb +1 -1
  259. data/mod/05_standard/set/type/user.rb +21 -21
  260. data/mod/05_standard/spec/chunk/include_spec.rb +16 -16
  261. data/mod/05_standard/spec/chunk/link_spec.rb +18 -18
  262. data/mod/05_standard/spec/chunk/query_reference_spec.rb +1 -1
  263. data/mod/05_standard/spec/set/all/account_spec.rb +7 -7
  264. data/mod/05_standard/spec/set/all/email_html_spec.rb +3 -3
  265. data/mod/05_standard/spec/set/all/history_spec.rb +14 -14
  266. data/mod/05_standard/spec/set/all/rich_html/editing_spec.rb +1 -1
  267. data/mod/05_standard/spec/set/all/rich_html/form_spec.rb +2 -2
  268. data/mod/05_standard/spec/set/right/account_spec.rb +9 -9
  269. data/mod/05_standard/spec/set/right/email_spec.rb +8 -8
  270. data/mod/05_standard/spec/set/right/password_spec.rb +9 -9
  271. data/mod/05_standard/spec/set/right/stats_spec.rb +1 -1
  272. data/mod/05_standard/spec/set/right/when_created_spec.rb +1 -1
  273. data/mod/05_standard/spec/set/right/when_last_edited_spec.rb +1 -1
  274. data/mod/05_standard/spec/set/rstar/rules_spec.rb +2 -2
  275. data/mod/05_standard/spec/set/self/account_links_spec.rb +2 -2
  276. data/mod/05_standard/spec/set/self/all_spec.rb +8 -11
  277. data/mod/05_standard/spec/set/self/head_spec.rb +1 -1
  278. data/mod/05_standard/spec/set/self/navbox_spec.rb +1 -1
  279. data/mod/05_standard/spec/set/self/now_spec.rb +1 -1
  280. data/mod/05_standard/spec/set/self/stats_spec.rb +1 -1
  281. data/mod/05_standard/spec/set/self/version_spec.rb +1 -1
  282. data/mod/05_standard/spec/set/type/email_template_spec.rb +25 -25
  283. data/mod/05_standard/spec/set/type/file_spec.rb +4 -4
  284. data/mod/05_standard/spec/set/type/html_spec.rb +3 -3
  285. data/mod/05_standard/spec/set/type/image_spec.rb +6 -6
  286. data/mod/05_standard/spec/set/type/layout_type_spec.rb +1 -1
  287. data/mod/05_standard/spec/set/type/search_type_spec.rb +10 -10
  288. data/mod/05_standard/spec/set/type/signup_spec.rb +11 -11
  289. data/mod/05_standard/spec/set/type/toggle_spec.rb +2 -2
  290. data/mod/05_standard/spec/set/type/uri_spec.rb +9 -9
  291. data/mod/06_bootstrap/set/all/bootstrap/helper.rb +10 -10
  292. data/mod/06_bootstrap/set/all/bootstrap/wrapper.rb +4 -4
  293. data/mod/06_bootstrap/set/all/rich_bootstrap.rb +1 -1
  294. data/spec/lib/card/action_spec.rb +2 -2
  295. data/spec/lib/card/cache_spec.rb +7 -7
  296. data/spec/lib/card/content_spec.rb +31 -37
  297. data/spec/lib/card/diff_spec.rb +56 -56
  298. data/spec/lib/card/format_spec.rb +11 -11
  299. data/spec/lib/card/query_spec.rb +382 -265
  300. data/spec/lib/card/reference_spec.rb +133 -140
  301. data/spec/lib/card/set_pattern_spec.rb +10 -9
  302. data/spec/lib/card/set_spec.rb +11 -11
  303. data/spec/lib/card/success_spec.rb +16 -8
  304. data/spec/mailers/mailer_spec.rb +5 -5
  305. data/spec/models/card/cardtype_spec.rb +20 -20
  306. data/spec/models/card/create_spec.rb +6 -6
  307. data/spec/models/card/trash_spec.rb +20 -20
  308. data/spec/models/card/type_transition_spec.rb +3 -3
  309. data/spec/models/card/validation_spec.rb +5 -5
  310. data/spec/models/card_spec.rb +24 -24
  311. data/spec/spec_helper.rb +5 -5
  312. data/tmpsets/set/mod001-01_core/all/active_card.rb +2 -2
  313. data/tmpsets/set/mod001-01_core/all/collection.rb +23 -26
  314. data/tmpsets/set/mod001-01_core/all/content.rb +2 -2
  315. data/tmpsets/set/mod001-01_core/all/fetch.rb +6 -6
  316. data/tmpsets/set/mod001-01_core/all/initialize.rb +8 -4
  317. data/tmpsets/set/mod001-01_core/all/name.rb +14 -14
  318. data/tmpsets/set/mod001-01_core/all/pattern.rb +1 -1
  319. data/tmpsets/set/mod001-01_core/all/permissions.rb +12 -12
  320. data/tmpsets/set/mod001-01_core/all/phases.rb +31 -13
  321. data/tmpsets/set/mod001-01_core/all/references.rb +14 -14
  322. data/tmpsets/set/mod001-01_core/all/rules.rb +8 -10
  323. data/tmpsets/set/mod001-01_core/all/templating.rb +10 -9
  324. data/tmpsets/set/mod001-01_core/all/tracked_attributes.rb +7 -7
  325. data/tmpsets/set/mod001-01_core/all/trash.rb +9 -8
  326. data/tmpsets/set/mod001-01_core/all/type.rb +7 -7
  327. data/tmpsets/set/mod001-01_core/all/utils.rb +16 -4
  328. data/tmpsets/set/mod001-01_core/all/view_cache.rb +1 -1
  329. data/tmpsets/set/mod002-01_history/all/actions.rb +2 -2
  330. data/tmpsets/set/mod002-01_history/all/content_history.rb +11 -7
  331. data/tmpsets/set/mod002-01_history/all/history.rb +46 -46
  332. data/tmpsets/set/mod003-02_basic_types/all/all_css.rb +10 -10
  333. data/tmpsets/set/mod003-02_basic_types/all/all_csv.rb +7 -7
  334. data/tmpsets/set/mod003-02_basic_types/all/base.rb +25 -25
  335. data/tmpsets/set/mod003-02_basic_types/all/json.rb +16 -16
  336. data/tmpsets/set/mod003-02_basic_types/all/rss.rb +7 -7
  337. data/tmpsets/set/mod003-02_basic_types/type/html.rb +2 -2
  338. data/tmpsets/set/mod003-02_basic_types/type/plain_text.rb +1 -1
  339. data/tmpsets/set/mod003-02_basic_types/type/pointer.rb +38 -31
  340. data/tmpsets/set/mod004-03_machines/right/machine_output.rb +4 -0
  341. data/tmpsets/set/mod004-03_machines/type/coffee_script.rb +3 -3
  342. data/tmpsets/set/mod004-03_machines/type/css.rb +8 -8
  343. data/tmpsets/set/mod004-03_machines/type/java_script.rb +4 -4
  344. data/tmpsets/set/mod004-03_machines/type/scss.rb +2 -2
  345. data/tmpsets/set/mod004-03_machines/type/skin.rb +1 -1
  346. data/tmpsets/set/mod005-04_settings/abstract/permission.rb +9 -9
  347. data/tmpsets/set/mod005-04_settings/right/script.rb +1 -1
  348. data/tmpsets/set/mod005-04_settings/right/structure.rb +0 -5
  349. data/tmpsets/set/mod005-04_settings/right/style.rb +2 -2
  350. data/tmpsets/set/mod005-04_settings/self/accountable.rb +1 -1
  351. data/tmpsets/set/mod005-04_settings/self/add_help.rb +1 -1
  352. data/tmpsets/set/mod005-04_settings/self/autoname.rb +1 -1
  353. data/tmpsets/set/mod005-04_settings/self/captcha.rb +1 -1
  354. data/tmpsets/set/mod005-04_settings/self/create.rb +1 -1
  355. data/tmpsets/set/mod005-04_settings/self/default.rb +1 -1
  356. data/tmpsets/set/mod005-04_settings/self/delete.rb +1 -1
  357. data/tmpsets/set/mod005-04_settings/self/help.rb +1 -1
  358. data/tmpsets/set/mod005-04_settings/self/input.rb +1 -1
  359. data/tmpsets/set/mod005-04_settings/self/layout.rb +1 -1
  360. data/tmpsets/set/mod005-04_settings/self/on_create.rb +1 -1
  361. data/tmpsets/set/mod005-04_settings/self/on_delete.rb +1 -1
  362. data/tmpsets/set/mod005-04_settings/self/on_update.rb +1 -1
  363. data/tmpsets/set/mod005-04_settings/self/options.rb +1 -1
  364. data/tmpsets/set/mod005-04_settings/self/options_label.rb +1 -1
  365. data/tmpsets/set/mod005-04_settings/self/read.rb +1 -1
  366. data/tmpsets/set/mod005-04_settings/self/script.rb +1 -1
  367. data/tmpsets/set/mod005-04_settings/self/structure.rb +1 -1
  368. data/tmpsets/set/mod005-04_settings/self/style.rb +1 -1
  369. data/tmpsets/set/mod005-04_settings/self/table_of_contents.rb +1 -1
  370. data/tmpsets/set/mod005-04_settings/self/thanks.rb +1 -1
  371. data/tmpsets/set/mod005-04_settings/self/update.rb +1 -1
  372. data/tmpsets/set/mod005-04_settings/type/setting.rb +14 -14
  373. data/tmpsets/set/mod006-05_email/all/follow.rb +24 -16
  374. data/tmpsets/set/mod006-05_email/all/notify.rb +25 -23
  375. data/tmpsets/set/mod006-05_email/all/observer.rb +8 -8
  376. data/tmpsets/set/mod006-05_email/right/bcc.rb +8 -8
  377. data/tmpsets/set/mod006-05_email/right/follow.rb +44 -17
  378. data/tmpsets/set/mod006-05_email/right/follow_fields.rb +1 -1
  379. data/tmpsets/set/mod006-05_email/right/following.rb +49 -40
  380. data/tmpsets/set/mod006-05_email/self/always.rb +2 -2
  381. data/tmpsets/set/mod006-05_email/self/created.rb +1 -1
  382. data/tmpsets/set/mod006-05_email/self/edited.rb +4 -4
  383. data/tmpsets/set/mod006-05_email/self/follow.rb +1 -1
  384. data/tmpsets/set/mod006-05_email/self/follow_defaults.rb +9 -9
  385. data/tmpsets/set/mod006-05_email/self/never.rb +1 -1
  386. data/tmpsets/set/mod006-05_email/type/email_template.rb +9 -9
  387. data/tmpsets/set/mod006-05_email/type_plus_right/user/follow.rb +17 -17
  388. data/tmpsets/set/mod007-05_standard/abstract/attachment.rb +98 -46
  389. data/tmpsets/set/mod007-05_standard/all/account.rb +5 -5
  390. data/tmpsets/set/mod007-05_standard/all/comment.rb +7 -7
  391. data/tmpsets/set/mod007-05_standard/all/error.rb +26 -26
  392. data/tmpsets/set/mod007-05_standard/all/event_viz.rb +1 -1
  393. data/tmpsets/set/mod007-05_standard/all/links.rb +10 -9
  394. data/tmpsets/set/mod007-05_standard/all/rich_html/content.rb +34 -34
  395. data/tmpsets/set/mod007-05_standard/all/rich_html/editing.rb +35 -35
  396. data/tmpsets/set/mod007-05_standard/all/rich_html/form.rb +20 -20
  397. data/tmpsets/set/mod007-05_standard/all/rich_html/header.rb +8 -8
  398. data/tmpsets/set/mod007-05_standard/all/rich_html/menu.rb +33 -33
  399. data/tmpsets/set/mod007-05_standard/all/rich_html/modal.rb +16 -16
  400. data/tmpsets/set/mod007-05_standard/all/rich_html/toolbar.rb +63 -63
  401. data/tmpsets/set/mod007-05_standard/all/rich_html/wrapper.rb +8 -8
  402. data/tmpsets/set/mod007-05_standard/right/account.rb +27 -27
  403. data/tmpsets/set/mod007-05_standard/right/email.rb +5 -5
  404. data/tmpsets/set/mod007-05_standard/right/password.rb +5 -5
  405. data/tmpsets/set/mod007-05_standard/rstar/rules.rb +52 -52
  406. data/tmpsets/set/mod007-05_standard/self/account_links.rb +27 -27
  407. data/tmpsets/set/mod007-05_standard/self/all.rb +1 -1
  408. data/tmpsets/set/mod007-05_standard/self/head.rb +5 -5
  409. data/tmpsets/set/mod007-05_standard/self/navbox.rb +11 -11
  410. data/tmpsets/set/mod007-05_standard/self/recent.rb +2 -2
  411. data/tmpsets/set/mod007-05_standard/self/search.rb +13 -13
  412. data/tmpsets/set/mod007-05_standard/self/signin.rb +19 -19
  413. data/tmpsets/set/mod007-05_standard/self/stats.rb +2 -2
  414. data/tmpsets/set/mod007-05_standard/type/basic.rb +1 -1
  415. data/tmpsets/set/mod007-05_standard/type/cardtype.rb +5 -5
  416. data/tmpsets/set/mod007-05_standard/type/date.rb +1 -1
  417. data/tmpsets/set/mod007-05_standard/type/file.rb +23 -8
  418. data/tmpsets/set/mod007-05_standard/type/image.rb +10 -8
  419. data/tmpsets/set/mod007-05_standard/type/number.rb +2 -2
  420. data/tmpsets/set/mod007-05_standard/type/phrase.rb +1 -1
  421. data/tmpsets/set/mod007-05_standard/type/search_type.rb +21 -19
  422. data/tmpsets/set/mod007-05_standard/type/session.rb +2 -2
  423. data/tmpsets/set/mod007-05_standard/type/set.rb +37 -37
  424. data/tmpsets/set/mod007-05_standard/type/signup.rb +25 -25
  425. data/tmpsets/set/mod007-05_standard/type/uri.rb +1 -1
  426. data/tmpsets/set/mod007-05_standard/type/user.rb +21 -21
  427. data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/helper.rb +10 -10
  428. data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/wrapper.rb +4 -4
  429. data/tmpsets/set/mod008-06_bootstrap/all/rich_bootstrap.rb +1 -1
  430. data/tmpsets/set_pattern/101-all_plus.rb +2 -2
  431. data/tmpsets/set_pattern/102-type.rb +1 -1
  432. data/tmpsets/set_pattern/103-star.rb +1 -1
  433. data/tmpsets/set_pattern/104-rstar.rb +2 -2
  434. data/tmpsets/set_pattern/105-right.rb +4 -4
  435. data/tmpsets/set_pattern/106-type_plus_right.rb +4 -4
  436. data/tmpsets/set_pattern/107-self.rb +1 -1
  437. metadata +7 -5
  438. data/lib/card/query/card_clause.rb +0 -528
  439. data/lib/card/query/ref_clause.rb +0 -47
  440. data/lib/card/query/value_clause.rb +0 -65
@@ -17,12 +17,12 @@ describe Card::Diff do
17
17
  def diff old_s, new_s, opts=@opts
18
18
  Card::Diff.complete(old_s, new_s, opts)
19
19
  end
20
-
20
+
21
21
  def summary old_s, new_s, opts=@opts
22
22
  Card::Diff.summary(old_s, new_s, opts)
23
23
  end
24
-
25
-
24
+
25
+
26
26
  old_p = '<p>old</p>'
27
27
  new_p = '<p>new</p>'
28
28
  new_h = '<h1>new</h1>'
@@ -33,111 +33,111 @@ describe Card::Diff do
33
33
  describe 'traffic light' do
34
34
  it 'is green for addition' do
35
35
  a = "a"
36
- b = "a b"
36
+ b = "a b"
37
37
  db = Card::Diff::DiffBuilder.new(a,b)
38
38
  expect(db.green?).to be_truthy
39
39
  expect(db.red?).to be_falsey
40
40
  end
41
41
  it 'is red for deletion' do
42
42
  a = "a"
43
- b = ""
43
+ b = ""
44
44
  db = Card::Diff::DiffBuilder.new(a,b)
45
45
  expect(db.green?).to be_falsey
46
46
  expect(db.red?).to be_truthy
47
47
  end
48
48
  it 'is green and red for change' do
49
49
  a = "a"
50
- b = "b"
50
+ b = "b"
51
51
  db = Card::Diff::DiffBuilder.new(a,b)
52
52
  expect(db.green?).to be_truthy
53
53
  expect(db.red?).to be_truthy
54
54
  end
55
55
  it 'is off for no change' do
56
56
  a = "a"
57
- b = "a"
57
+ b = "a"
58
58
  db = Card::Diff::DiffBuilder.new(a,b)
59
59
  expect(db.green?).to be_falsey
60
60
  expect(db.red?).to be_falsey
61
61
  end
62
62
  end
63
-
64
-
63
+
64
+
65
65
  describe 'summary' do
66
66
  before(:all) do
67
- @opts = {:format=>:html}
67
+ @opts = {format: :html}
68
68
  end
69
-
69
+
70
70
  it 'omits unchanged text' do
71
71
  a = "<p>this was the original string</p>"
72
- b = "<p>this is the new string</p>"
72
+ b = "<p>this is the new string</p>"
73
73
  expect(summary a, b).to eq(
74
74
  "...#{del 'was'}#{ins 'is'}...#{del 'original'}#{ins 'new'}..."
75
75
  )
76
76
  end
77
-
77
+
78
78
  it 'no ellipsis if changes fit exactly' do
79
79
  a = "123"
80
- b = "456"
81
- expect(summary a, b, :summary=>{:length=>6}).to eq(
80
+ b = "456"
81
+ expect(summary a, b, summary: {length: 6}).to eq(
82
82
  "#{del '123'}#{ins '456'}"
83
83
  )
84
84
  end
85
-
85
+
86
86
  it 'green ellipsis if added text does not fit' do
87
87
  a = "123"
88
- b = "5678"
89
- expect(summary a, b, :summary=>{:length=>6}).to eq(
88
+ b = "5678"
89
+ expect(summary a, b, summary: {length: 6}).to eq(
90
90
  "#{del '123'}#{ins '...'}"
91
91
  )
92
92
  end
93
-
93
+
94
94
  it 'neutral ellipsis if complete change does not fit' do
95
95
  a = "123 123"
96
- b = "456 456"
97
- expect(summary a, b, :summary=>{:length=>9}).to eq(
96
+ b = "456 456"
97
+ expect(summary a, b, summary: {length: 9}).to eq(
98
98
  "#{del '123'}#{ins '456'}..."
99
99
  )
100
100
  end
101
-
101
+
102
102
  it 'red ellipsis if deleted text partially fits' do
103
103
  a = "123456"
104
- b = "567"
105
- expect(summary a, b, :summary=>{:length=>4}).to eq(
104
+ b = "567"
105
+ expect(summary a, b, summary: {length: 4}).to eq(
106
106
  "#{del '1...'}"
107
107
  )
108
108
  end
109
-
109
+
110
110
  it 'green ellipsis if added text partially fits' do
111
111
  a = "1234"
112
- b = "56789"
113
- expect(summary a, b, :summary=>{:length=>8}).to eq(
112
+ b = "56789"
113
+ expect(summary a, b, summary: {length: 8}).to eq(
114
114
  "#{del '1234'}#{ins '5...'}"
115
115
  )
116
116
  end
117
-
117
+
118
118
  it 'removes html tags' do
119
119
  a = "<a>A</a>"
120
- b = "<b>B</b>"
121
- expect(summary a, b, :format=>:html).to eq(
120
+ b = "<b>B</b>"
121
+ expect(summary a, b, format: :html).to eq(
122
122
  "#{del 'A'}#{ins 'B'}"
123
123
  )
124
124
  end
125
-
125
+
126
126
  it 'with html tags in raw format' do
127
127
  a = "<a>1</a>"
128
- b = "<b>1</b>"
129
- expect(summary a, b, :format=>:raw).to eq(
128
+ b = "<b>1</b>"
129
+ expect(summary a, b, format: :raw).to eq(
130
130
  "#{del( tag 'a' )}#{ins(tag 'b')}...#{del( tag '/a' )}#{ins(tag '/b')}"
131
131
  )
132
132
  end
133
-
133
+
134
134
  end
135
-
135
+
136
136
  context "html format" do
137
137
  before(:all) do
138
- @opts = {:format=>:html}
138
+ @opts = {format: :html}
139
139
  end
140
-
140
+
141
141
  it "doesn't change a text without changes" do
142
142
  text = "Hello World!\n How are you?"
143
143
  expect(diff text, text).to eq(text)
@@ -148,10 +148,10 @@ describe Card::Diff do
148
148
  it 'ignores html changes' do
149
149
  expect(diff old_p, new_h).to eq("<h1>#{del 'old'}#{ins 'new'}</h1>")
150
150
  end
151
-
151
+
152
152
  it 'diff with multiple paragraphs' do
153
153
  a = "<p>this was the original string</p>"
154
- b = "<p>this is</p>\n<p> the new string</p>\n<p>around the world</p>"
154
+ b = "<p>this is</p>\n<p> the new string</p>\n<p>around the world</p>"
155
155
 
156
156
  expect(diff a, b).to eq(
157
157
  "<p>this #{del 'was'}#{ins 'is'}</p>"+
@@ -162,49 +162,49 @@ describe Card::Diff do
162
162
  )
163
163
  end
164
164
  end
165
-
165
+
166
166
  context "text format" do
167
167
  before(:all) do
168
- @opts = {:format=>:text}
168
+ @opts = {format: :text}
169
169
  end
170
-
170
+
171
171
  it 'removes html' do
172
172
  expect(p_diff).to eq("#{del 'old'}#{ins 'new'}")
173
173
  end
174
-
174
+
175
175
  it 'compares complete links' do
176
- diff = Card::Diff.complete("[[A]]\n[[B]]", "[[A]]\n[[C]]", :format=>:html)
176
+ diff = Card::Diff.complete("[[A]]\n[[B]]", "[[A]]\n[[C]]", format: :html)
177
177
  expect(diff).to eq( "[[A]]\n#{del '[[B]]'}#{ins '[[C]]'}")
178
178
  end
179
-
179
+
180
180
  it 'compares complete inclusions' do
181
- diff = Card::Diff.complete("{{A}}\n{{B}}", "{{A}}\n{{C}}", :format=>:html)
181
+ diff = Card::Diff.complete("{{A}}\n{{B}}", "{{A}}\n{{C}}", format: :html)
182
182
  expect(diff).to eq( "{{A}}\n#{del '{{B}}'}#{ins '{{C}}'}")
183
183
  end
184
-
184
+
185
185
  end
186
-
186
+
187
187
  context "raw format" do
188
188
  before(:all) do
189
- @opts = {:format=>:raw}
189
+ @opts = {format: :raw}
190
190
  end
191
-
191
+
192
192
  it 'excapes html' do
193
193
  expect(p_diff).to eq("#{tag 'p'}#{del 'old'}#{ins 'new'}#{tag '/p'}")
194
194
  end
195
-
195
+
196
196
  it 'diff for tag change' do
197
197
  expect(diff old_p, new_h).to eq( del("#{tag 'p'}old#{tag '/p'}") + ins("#{tag 'h1'}new#{tag '/h1'}") )
198
- end
198
+ end
199
199
  end
200
-
200
+
201
201
  context 'pointer format' do
202
202
  before(:all) do
203
- @opts = {:format=>:pointer}
203
+ @opts = {format: :pointer}
204
204
  end
205
-
205
+
206
206
  it 'removes square brackets' do
207
207
  expect(diff "[[Hello]]", "[[Hi]]").to eq( del('Hello') + ins('Hi') )
208
- end
208
+ end
209
209
  end
210
210
  end
@@ -6,26 +6,26 @@ describe Card::Format do
6
6
  let(:format) { described_class.new Card.new }
7
7
 
8
8
  it "should respect defaults" do
9
- expect(format.show_view?( :menu, :default_visibility=>:show )).to be_truthy
10
- expect(format.show_view?( :menu, :default_visibility=>:hide )).to be_falsey
9
+ expect(format.show_view?( :menu, default_visibility: :show )).to be_truthy
10
+ expect(format.show_view?( :menu, default_visibility: :hide )).to be_falsey
11
11
  expect(format.show_view?( :menu, {} )).to be_truthy
12
12
  end
13
13
 
14
14
  it "should respect developer default overrides" do
15
- expect(format.show_view?( :menu, :optional_menu=>:show, :default_visibility=>:hide )).to be_truthy
16
- expect(format.show_view?( :menu, :optional_menu=>:hide, :default_visibility=>:show )).to be_falsey
17
- expect(format.show_view?( :menu, :optional_menu=>:hide )).to be_falsey
15
+ expect(format.show_view?( :menu, optional_menu: :show, default_visibility: :hide )).to be_truthy
16
+ expect(format.show_view?( :menu, optional_menu: :hide, default_visibility: :show )).to be_falsey
17
+ expect(format.show_view?( :menu, optional_menu: :hide )).to be_falsey
18
18
  end
19
19
 
20
20
  it "should handle args from inclusions" do
21
- expect(format.show_view?( :menu, :show=>'menu', :default_visibility=>:hide )).to be_truthy
22
- expect(format.show_view?( :menu, :hide=>'menu, paging', :default_visibility=>:show )).to be_falsey
23
- expect(format.show_view?( :menu, :show=>'menu', :optional_menu=>:hide )).to be_truthy
21
+ expect(format.show_view?( :menu, show: 'menu', default_visibility: :hide )).to be_truthy
22
+ expect(format.show_view?( :menu, hide: 'menu, paging', default_visibility: :show )).to be_falsey
23
+ expect(format.show_view?( :menu, show: 'menu', optional_menu: :hide )).to be_truthy
24
24
  end
25
25
 
26
26
  it "should handle hard developer overrides" do
27
- expect(format.show_view?( :menu, :optional_menu=>:always, :hide=>'menu' )).to be_truthy
28
- expect(format.show_view?( :menu, :optional_menu=>:never, :show=>'menu' )).to be_falsey
27
+ expect(format.show_view?( :menu, optional_menu: :always, hide: 'menu' )).to be_truthy
28
+ expect(format.show_view?( :menu, optional_menu: :never, show: 'menu' )).to be_falsey
29
29
  end
30
30
 
31
31
  end
@@ -71,7 +71,7 @@ describe Card::Format do
71
71
  it "formats page_path" do
72
72
  expect(text_format.page_path card.cardname).to eq '/'+card.name
73
73
  expect(html_format.page_path card.cardname).to eq '/'+card.name
74
- expect(text_format.page_path card.cardname, :format => 'txt', :opt1 => 11, :opt2 => 'foo').to eq "/#{card.name}.txt?opt1=11&opt2=foo"
74
+ expect(text_format.page_path card.cardname, format: 'txt', opt1: 11, opt2: 'foo').to eq "/#{card.name}.txt?opt1=11&opt2=foo"
75
75
  end
76
76
 
77
77
  it "fomats full path and url" do
@@ -1,456 +1,573 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- A_JOINEES = ["B", "C", "D", "E", "F"]
4
-
5
- CARDS_MATCHING_TWO = ["Two","One+Two","One+Two+Three","Joe User"].sort
3
+ A_JOINEES = %w( B C D E F )
4
+ CARDS_MATCHING_TWO = ['Joe User', 'One+Two', 'One+Two+Three', 'Two']
6
5
 
7
6
  describe Card::Query do
7
+ subject do
8
+ Card::Query.run @query.reverse_merge return: :name, sort: :name
9
+ end
8
10
 
9
11
  describe 'append' do
10
- it "should find real cards" do
11
- expect(Card::Query.new(:name=>[:in, 'C', 'D', 'F'], :append=>'A' ).run.map(&:name).sort).to eq(["C+A", "D+A", "F+A"])
12
+ it 'should find real cards' do
13
+ @query = {
14
+ name: [:in, 'C', 'D', 'F'],
15
+ append: 'A'
16
+ }
17
+ is_expected.to eq(%w( C+A D+A F+A ))
18
+ end
19
+
20
+ it 'should absolutize names' do
21
+ @query = {
22
+ name: [:in, 'C', 'D', 'F'],
23
+ append: '_right',
24
+ context: 'B+A'
25
+ }
26
+ is_expected.to eq(%w( C+A D+A F+A ))
27
+ end
28
+
29
+ it 'should find virtual cards' do
30
+ @query = {
31
+ name: [:in, 'C', 'D'],
32
+ append: '*plus cards'
33
+ }
34
+ is_expected.to eq(['C+*plus cards', 'D+*plus cards'])
12
35
  end
36
+ end
13
37
 
14
- it "should absolutize names" do
15
- expect(Card::Query.new(:name=>[:in, 'C', 'D', 'F'], :append=>'_right', :context=>'B+A' ).run.map(&:name).sort).to eq(["C+A", "D+A", "F+A"])
38
+ describe 'in' do
39
+ it 'should work for content options' do
40
+ @query = { in: %w( AlphaBeta Theta ) }
41
+ is_expected.to eq(%w( A+B T ))
16
42
  end
17
43
 
18
- it "should find virtual cards" do
19
- expect(Card::Query.new(:name=>[:in, 'C', 'D'], :append=>'*plus cards' ).run.map(&:name).sort).to eq(["C+*plus cards", "D+*plus cards"])
44
+ it 'should find the same thing in full syntax' do
45
+ @query = { content: [:in, 'Theta', 'AlphaBeta'] }
46
+ is_expected.to eq(%w( A+B T ))
20
47
  end
21
- end
22
48
 
23
- describe "in" do
24
- it "should work for content options" do
25
- expect(Card::Query.new(:in=>['AlphaBeta', 'Theta']).run.map(&:name).sort).to eq(%w(A+B T))
49
+ it 'should work on types' do
50
+ @query = { type: [:in, 'Cardtype E', 'Cardtype F'] }
51
+ is_expected.to eq(%w(type-e-card type-f-card))
26
52
  end
53
+ end
27
54
 
28
- it "should find the same thing in full syntax" do
29
- expect(Card::Query.new(:content=>[:in,'Theta','AlphaBeta']).run.map(&:name).sort).to eq(%w(A+B T))
55
+ describe 'member_of/member' do
56
+ it 'member_of should find members' do
57
+ @query = { member_of: 'r1' }
58
+ is_expected.to eq(%w(u1 u2 u3))
30
59
  end
31
60
 
32
- it "should work on types" do
33
- expect(Card::Query.new(:type=>[:in,'Cardtype E', 'Cardtype F']).run.map(&:name).sort).to eq(%w(type-e-card type-f-card))
61
+ it 'member should find roles' do
62
+ @query = { member: { match: 'u1' } }
63
+ is_expected.to eq(%w(r1 r2 r3))
34
64
  end
35
65
  end
36
66
 
37
- describe "symbolization" do
38
- it "should handle array values" do
39
- query = {'plus'=>['tags',{'refer_to'=>'cookies'}]}
40
- expect(Card::Query.new(query).query).to eq({:plus=>['tags',{:refer_to=>'cookies'}]})
67
+ describe 'not' do
68
+ it 'should exclude cards matching not criteria' do
69
+ Card::Auth.as_bot
70
+ @query = { plus: 'A', not: { plus: 'A+B' } }
71
+ is_expected.to eq(%w( B D E F ))
41
72
  end
42
73
  end
43
74
 
75
+ describe 'multiple values' do
76
+ it 'should handle :all as the first element of an Array' do
77
+ @query = { member_of: [:all, { name: 'r1' }, { key: 'r2' }] }
78
+ is_expected.to eq(%w( u1 u2 ))
79
+ end
44
80
 
81
+ it 'should handle act like :all by default' do
82
+ @query = { member_of: [{ name: 'r1' }, { key: 'r2' }] }
83
+ is_expected.to eq(%w( u1 u2 ))
84
+ end
45
85
 
86
+ it 'should handle :any as the first element of an Array' do
87
+ @query = { member_of: [:any, { name: 'r1' }, { key: 'r2' }] }
88
+ is_expected.to eq(%w( u1 u2 u3 ))
89
+ end
46
90
 
47
-
48
- describe "member_of/member" do
49
- it "member_of should find members" do
50
- expect(Card::Query.new( :member_of => "r1" ).run.map(&:name).sort).to eq(%w(u1 u2 u3))
91
+ it 'should handle :any as a relationship' do
92
+ @query = { member_of: { any: [{ name: 'r1' }, { key: 'r2' }] } }
93
+ is_expected.to eq(%w( u1 u2 u3 ))
51
94
  end
52
- it "member should find roles" do
53
- expect(Card::Query.new( :member => {:match=>"u1"} ).run.map(&:name).sort).to eq(%w(r1 r2 r3))
95
+
96
+ it 'should handle explicit conjunctions in plus_relational keys' do
97
+ @query = { right_plus: [:all, 'e', 'c'] }
98
+ is_expected.to eq(%w( A ))
54
99
  end
55
- end
56
100
 
101
+ it 'should handle multiple values for right_part in compound relations' do
102
+ @query = { right_plus: [['e', {}], 'c'] }
103
+ is_expected.to eq(%w( A )) # first element is array
104
+ end
57
105
 
58
- describe "not" do
59
- it "should exclude cards matching not criteria" do
60
- expect(Card::Query.new(:plus=>"A", :not=>{:plus=>"A+B"}).run.map(&:name).sort).to eq(%w{ B D E F })
106
+ it 'should not interpret simple arrays as multi values for plus' do
107
+ @query = { right_plus: %w( e c ) }
108
+ is_expected.to eq([]) # NOT interpreted as multi-value
61
109
  end
62
- end
63
-
64
-
65
- describe "multiple values" do
66
- it "should handle multiple values for relational keys" do
67
- expect(Card::Query.new( :member_of=>[:all, {:name=>'r1'}, {:key=>'r2'} ], :return=>:name).run.sort).to eq(%w{ u1 u2 })
68
- expect(Card::Query.new( :member_of=>[ {:name=>'r1'}, {:key=>'r2'} ], :return=>:name).run.sort).to eq(%w{ u1 u2 })
69
- expect(Card::Query.new( :member_of=>[:any, {:name=>'r1'}, {:key=>'r2'} ], :return=>:name).run.sort).to eq(%w{ u1 u2 u3 })
110
+
111
+ it 'should handle :and for references' do
112
+ @query = { refer_to: [:and, 'a', 'b'] }
113
+ is_expected.to eq(%w( Y ))
70
114
  end
71
115
 
72
- it "should handle multiple values for plus_relational keys" do
73
- expect(Card::Query.new( :right_plus=>[ :all, 'e', 'c' ], :return=>:name ).run.sort).to eq(%w{ A }) #explicit conjunction
74
- expect(Card::Query.new( :right_plus=>[ ['e',{}], 'c' ], :return=>:name ).run.sort).to eq(%w{ A }) # first element is array
75
- expect(Card::Query.new( :right_plus=>[ 'e', 'c' ], :return=>:name ).run.sort).to eq([]) # NOT interpreted as multi-value
116
+ it 'should handle :or for references' do
117
+ @query = { refer_to: [:or, 'b', 'z'] }
118
+ is_expected.to eq(%w( A B Y))
76
119
  end
77
120
 
78
- it "should handle multiple values for plus_relational keys" do
79
- expect(Card::Query.new( :refer_to=>[ :and, 'a', 'b' ], :return=>:name ).run.sort).to eq(%w{ Y })
80
- expect(Card::Query.new( :refer_to=>[ 'a', 'T' ], :return=>:name ).run.sort).to eq(%w{ X Y })
81
- expect(Card::Query.new( :refer_to=>[ :or, 'b', 'z' ], :return=>:name ).run.sort).to eq(%w{ A B Y})
121
+ it 'should handle treat simple arrays like :all for references' do
122
+ @query = { refer_to: %w( A T ) }
123
+ is_expected.to eq(%w( X Y ))
82
124
  end
83
-
84
125
  end
85
126
 
86
-
87
- describe "edited_by/editor_of" do
88
- it "should find card edited by joe using subquery" do
89
- expect(Card::Query.new(:edited_by=>{:match=>"Joe User"}, :sort=>"name").run).to include(Card["JoeLater"], Card["JoeNow"])
127
+ describe 'edited_by/editor_of' do
128
+ it 'should find card edited by joe using subquery' do
129
+ @query = { edited_by: { match: 'Joe User' } }
130
+ is_expected.to eq(%w( JoeLater JoeNow ))
90
131
  end
91
- it "should find card edited by Wagn Bot" do
92
- #this is a weak test, since it gives the name, but different sorting mechanisms in other db setups
93
- #was having it return *account in some cases and "A" in others
94
- expect(Card::Query.new(:edited_by=>"Wagn Bot", :name=>'A', :return=>'name', :limit=>1).run.first).to eq("A")
132
+
133
+ it 'should find card edited by Wagn Bot' do
134
+ # this is a weak test, since it gives the name, but different sorting
135
+ # mechanisms in other db setups
136
+ # was having it return *account in some cases and 'A' in others
137
+ @query = { edited_by: 'Wagn Bot', name: 'A' }
138
+ is_expected.to eq(%w( A ))
95
139
  end
96
- it "should fail gracefully if user isn't there" do
97
- expect(Card::Query.new(:edited_by=>"Joe LUser", :sort=>"name", :limit=>1).run).to eq([])
140
+
141
+ it 'should fail gracefully if user isn\'t there' do
142
+ @query = { edited_by: 'Joe LUser' }
143
+ is_expected.to eq([])
98
144
  end
99
145
 
100
- it "should not give duplicate results for multiple edits" do
101
- c=Card["JoeNow"]
102
- c.content="testagagin"
146
+ it 'should not give duplicate results for multiple edits' do
147
+ c = Card['JoeNow']
148
+ c.content = 'testagagin'
103
149
  c.save
104
- c.content="test3"
150
+ c.content = 'test3'
105
151
  c.save!
106
- expect(Card::Query.new(:edited_by=>"Joe User").run.map(&:name).count("JoeNow")).to eq 1
152
+ @query = { edited_by: 'Joe User' }
153
+ is_expected.to eq(%w( JoeLater JoeNow ))
107
154
  end
108
155
 
109
- it "should find joe user among card's editors" do
110
- expect(Card::Query.new(:editor_of=>'JoeLater').run.map(&:name)).to eq(['Joe User'])
156
+ it 'should find joe user among card\'s editors' do
157
+ @query = { editor_of: 'JoeLater' }
158
+ is_expected.to eq(['Joe User'])
111
159
  end
112
160
  end
113
161
 
114
- describe "created_by/creator_of" do
162
+ describe 'created_by/creator_of' do
115
163
  before do
116
- Card.create :name=>'Create Test', :content=>'sufficiently distinctive'
164
+ Card.create name: 'Create Test', content: 'sufficiently distinctive'
117
165
  end
118
166
 
119
167
  it "should find Joe User as the card's creator" do
120
- c = Card.fetch 'Create Test'
121
- expect(Card::Query.new(:creator_of=>'Create Test').run.first.name).to eq('Joe User')
168
+ @query = { creator_of: 'Create Test' }
169
+ is_expected.to eq(['Joe User'])
122
170
  end
123
171
 
124
- it "should find card created by Joe User" do
125
- expect(Card::Query.new(:created_by=>'Joe User', :eq=>'sufficiently distinctive').run.first.name).to eq('Create Test')
172
+ it 'should find card created by Joe User' do
173
+ @query = { created_by: 'Joe User', eq: 'sufficiently distinctive' }
174
+ is_expected.to eq(['Create Test'])
126
175
  end
127
176
  end
128
177
 
129
- describe "last_edited_by/last_editor_of" do
178
+ describe 'last_edited_by/last_editor_of' do
130
179
  before do
131
- c=Card.fetch('A')
132
- c.content='peculicious'
180
+ c = Card.fetch('A')
181
+ c.content = 'peculicious'
133
182
  c.save!
134
183
  end
135
184
 
136
185
  it "should find Joe User as the card's last editor" do
137
- expect(Card::Query.new(:last_editor_of=>'A').run.first.name).to eq('Joe User')
186
+ @query = { last_editor_of: 'A' }
187
+ is_expected.to eq(['Joe User'])
188
+ end
189
+
190
+ it 'should find card created by Joe User' do
191
+ @query = { last_edited_by: 'Joe User', eq: 'peculicious' }
192
+ is_expected.to eq(['A'])
138
193
  end
194
+ end
139
195
 
140
- it "should find card created by Joe User" do
141
- expect(Card::Query.new(:last_edited_by=>'Joe User', :eq=>'peculicious').run.first.name).to eq('A')
196
+ describe 'keyword' do
197
+ it 'should escape nonword characters' do
198
+ @query = { match: 'two :(!' }
199
+ is_expected.to eq(CARDS_MATCHING_TWO)
142
200
  end
143
201
  end
144
202
 
145
- describe "keyword" do
146
- it "should escape nonword characters" do
147
- expect(Card::Query.new( :match=>"two :(!").run.map(&:name).sort).to eq(CARDS_MATCHING_TWO)
203
+ describe 'search count' do
204
+ it 'should return integer' do
205
+ search = Card.create!(
206
+ name: 'tmpsearch',
207
+ type: 'Search',
208
+ content: '{"match":"two"}'
209
+ )
210
+ expect(search.count).to eq(CARDS_MATCHING_TWO.length + 1)
148
211
  end
149
212
  end
150
213
 
151
- describe "search count" do
152
- it "should count search" do
153
- s = Card.create! :name=>"ksearch", :type=>'Search', :content=>'{"match":"$keyword"}'
154
- expect(s.count(:vars=>{:keyword=>"two"})).to eq(CARDS_MATCHING_TWO.length)
214
+ describe 'cgi_params' do
215
+ it 'should match content from cgi' do
216
+ @query = { match: '$keyword', vars: { keyword: 'two' } }
217
+ is_expected.to eq(CARDS_MATCHING_TWO)
155
218
  end
156
219
  end
157
220
 
221
+ describe 'content equality' do
222
+ it 'should match content explicitly' do
223
+ @query = { content: ['=', "I'm number two"] }
224
+ is_expected.to eq(['Joe User'])
225
+ end
158
226
 
159
- describe "cgi_params" do
160
- it "should match content from cgi" do
161
- expect(Card::Query.new( :match=>"$keyword", :vars=>{:keyword=>"two"}).run.map(&:name).sort).to eq(CARDS_MATCHING_TWO)
227
+ it 'should match via shortcut' do
228
+ @query = { '=' => "I'm number two" }
229
+ is_expected.to eq(['Joe User'])
162
230
  end
163
231
  end
164
232
 
233
+ describe 'links' do
234
+ it 'should handle refer_to' do
235
+ @query = { refer_to: 'Z' }
236
+ is_expected.to eq(%w( A B ))
237
+ end
165
238
 
239
+ it 'should handle link_to' do
240
+ @query = { link_to: 'Z' }
241
+ is_expected.to eq(%w( A ))
242
+ end
166
243
 
167
- describe "content equality" do
168
- it "should match content explicitly" do
169
- expect(Card::Query.new( :content=>['=',"I'm number two"] ).run.map(&:name)).to eq(["Joe User"])
244
+ it 'should handle include' do
245
+ @query = { include: 'Z' }
246
+ is_expected.to eq(%w( B ))
170
247
  end
171
- it "should match via shortcut" do
172
- expect(Card::Query.new( '='=>"I'm number two" ).run.map(&:name)).to eq(["Joe User"])
248
+
249
+ it 'should handle linked_to_by' do
250
+ @query = { linked_to_by: 'A' }
251
+ is_expected.to eq(%w( Z ))
173
252
  end
174
- end
175
253
 
254
+ it 'should handle included_by' do
255
+ @query = { included_by: 'B' }
256
+ is_expected.to eq(%w( Z ))
257
+ end
176
258
 
177
- describe "links" do
259
+ it 'should handle referred_to_by' do
260
+ @query = { referred_to_by: 'X' }
261
+ is_expected.to eq(%w( A A+B T ))
262
+ end
263
+ end
178
264
 
179
- it("should handle refer_to") { expect(Card::Query.new( :refer_to=>'Z').run.map(&:name).sort).to eq(%w{ A B }) }
180
- it("should handle link_to") { expect(Card::Query.new( :link_to=>'Z').run.map(&:name)).to eq(%w{ A }) }
181
- it("should handle include" ) { expect(Card::Query.new( :include=>'Z').run.map(&:name)).to eq(%w{ B }) }
182
- it("should handle linked_to_by") { expect(Card::Query.new( :linked_to_by=>'A').run.map(&:name)).to eq(%w{ Z }) }
183
- it("should handle included_by") { expect(Card::Query.new( :included_by=>'B').run.map(&:name)).to eq(%w{ Z }) }
184
- it("should handle referred_to_by") { expect(Card::Query.new( :referred_to_by=>'X').run.map(&:name).sort).to eq(%w{ A A+B T }) }
265
+ describe 'compound relationships' do
266
+ it 'right_plus should handle subqueries' do
267
+ @query = { right_plus: ['*create', refer_to: 'Anyone']}
268
+ is_expected.to eq(['Fruit+*type', 'Sign up+*type'])
269
+ end
270
+
271
+ it 'plus should handle subqueries' do # albeit more slowly :)
272
+ @query = { plus: ['*create', refer_to: 'Anyone']}
273
+ is_expected.to eq(['Fruit+*type', 'Sign up+*type'])
274
+ end
185
275
  end
186
276
 
187
- describe "relative links" do
188
- it("should handle relative refer_to") { expect(Card::Query.new( :refer_to=>'_self', :context=>'Z').run.map(&:name).sort).to eq(%w{ A B }) }
277
+ describe 'relative links' do
278
+ it 'should handle relative refer_to' do
279
+ @query = { refer_to: '_self', context: 'Z' }
280
+ is_expected.to eq(%w( A B ))
281
+ end
189
282
  end
190
283
 
191
- describe "permissions" do
192
- it "should not find cards not in group" do
193
- Card::Auth.as_bot do
194
- Card.create :name=>"C+*self+*read", :type=>'Pointer', :content=>"[[R1]]"
284
+ describe 'permissions' do
285
+ it 'should not find cards not in group' do
286
+ Card::Auth.as_bot do
287
+ Card.create name: 'C+*self+*read', type: 'Pointer', content: '[[R1]]'
195
288
  end
196
- expect(Card::Query.new( :plus=>"A" ).run.map(&:name).sort).to eq(%w{ B D E F })
289
+ @query = { plus: 'A' }
290
+ is_expected.to eq(%w( B D E F ))
197
291
  end
198
292
  end
199
293
 
200
- describe "basics" do
201
- it "should be case insensitive for name" do
202
- expect(Card::Query.new( :name=>"a" ).run.first.name).to eq('A')
294
+ describe 'basics' do
295
+ it 'should be case insensitive for name' do
296
+ @query = { name: 'a' }
297
+ is_expected.to eq(['A'])
203
298
  end
204
299
 
205
- it "should find plus cards" do
206
- expect(Card::Query.new( :plus=>"A" ).run.map(&:name).sort).to eq(A_JOINEES)
300
+ it 'should find plus cards' do
301
+ @query = { plus: 'A' }
302
+ is_expected.to eq(A_JOINEES)
207
303
  end
208
304
 
209
- it "should find connection cards" do
210
- expect(Card::Query.new( :part=>"A" ).run.map(&:name).sort).to eq(["A+B", "A+C", "A+D", "A+E", "C+A", "D+A", "F+A"])
305
+ it 'should find connection cards' do
306
+ @query = { part: 'A' }
307
+ is_expected.to eq(%w( A+B A+C A+D A+E C+A D+A F+A ))
211
308
  end
212
309
 
213
- it "should find left connection cards" do
214
- expect(Card::Query.new( :left=>"A" ).run.map(&:name).sort).to eq(["A+B", "A+C", "A+D", "A+E"])
310
+ it 'should find left connection cards' do
311
+ @query = { left: 'A' }
312
+ is_expected.to eq(%w( A+B A+C A+D A+E ))
215
313
  end
216
314
 
217
- it "should find right connection cards" do
218
- expect(Card::Query.new( :right=>"A" ).run.map(&:name).sort).to eq(["C+A", "D+A", "F+A"])
315
+ it 'should find right connection cards based on name' do
316
+ @query = { right: 'A' }
317
+ is_expected.to eq(%w( C+A D+A F+A ))
219
318
  end
220
319
 
221
- it "should return count" do
222
- expect(Card.count_by_wql( :part=>"A" )).to eq(7)
320
+ it 'should find right connection cards based on content' do
321
+ @query = { right: { content: 'Alpha [[Z]]' } }
322
+ is_expected.to eq(%w( C+A D+A F+A ))
223
323
  end
224
324
 
225
-
325
+ it 'should return count' do
326
+ expect(Card.count_by_wql part: 'A').to eq(7)
327
+ end
226
328
  end
227
329
 
228
- describe "limit and offset" do
229
- it "should return limit" do
230
- expect(Card::Query.new( :part=>"A", :limit=>5 ).run.size).to eq(5)
330
+ describe 'limit and offset' do
331
+ it 'should return limit' do
332
+ @query = { part: 'A', limit: 5 }
333
+ expect(subject.size).to eq(5)
231
334
  end
232
335
 
233
- it "should not break if offset but no limit" do
234
- expect(Card::Query.new( :part=>"A", :offset=>5 ).run.size).not_to eq(0)
336
+ it 'should not break if offset but no limit' do
337
+ @query = { part: 'A', offset: 5 }
338
+ expect(subject.size).not_to eq(0)
235
339
  end
236
340
 
341
+ it 'should not break count' do
342
+ query = { match: 'two', offset: 1 }
343
+ expect(Card.count_by_wql(query)).to eq(CARDS_MATCHING_TWO.length)
344
+ end
237
345
  end
238
346
 
239
- describe "type" do
240
- user_cards = ["Big Brother", "Joe Admin", "Joe Camel", "Joe User", "John", "Narcissist", "No Count", "Optic fan", "Sample User", "Sara", "Sunglasses fan", "u1", "u2", "u3"].sort
347
+ describe 'type' do
348
+ user_cards = [
349
+ 'Big Brother', 'Joe Admin', 'Joe Camel', 'Joe User', 'John',
350
+ 'Narcissist', 'No Count', 'Optic fan', 'Sample User', 'Sara',
351
+ 'Sunglasses fan', 'u1', 'u2', 'u3'
352
+ ].sort
241
353
 
242
- it "should find cards of this type" do
243
- expect(Card::Query.new( :type=>"_self", :context=>'User').run.map(&:name).sort).to eq(user_cards)
354
+ it 'should find cards of this type' do
355
+ @query = { type: '_self', context: 'User' }
356
+ is_expected.to eq(user_cards)
244
357
  end
245
358
 
246
- it "should find User cards " do
247
- expect(Card::Query.new( :type=>"User" ).run.map(&:name).sort).to eq(user_cards)
359
+ it 'should find User cards ' do
360
+ @query = { type: 'User' }
361
+ is_expected.to eq(user_cards)
248
362
  end
249
363
 
250
- it "should handle casespace variants" do
251
- expect(Card::Query.new( :type=>"users" ).run.map(&:name).sort).to eq(user_cards)
364
+ it 'should handle casespace variants' do
365
+ @query = { type: 'users' }
366
+ is_expected.to eq(user_cards)
252
367
  end
253
-
254
368
  end
255
369
 
256
-
257
- describe "trash handling" do
258
- it "should not find cards in the trash" do
259
- Card["A+B"].delete!
260
- expect(Card::Query.new( :left=>"A" ).run.map(&:name).sort).to eq(["A+C", "A+D", "A+E"])
370
+ describe 'trash handling' do
371
+ it 'should not find cards in the trash' do
372
+ Card['A+B'].delete!
373
+ @query = { left: 'A' }
374
+ is_expected.to eq(['A+C', 'A+D', 'A+E'])
261
375
  end
262
376
  end
263
377
 
264
-
265
-
266
-
267
- describe "order" do
268
- it "should sort by create" do
269
- Card.create! :name=>"classic bootstrap skin head"
270
- # classic skin head is created more recently than classic skin, which is in the seed data
271
- wql = { :sort=>"create", :name=>[:match,'classic bootstrap skin']}
272
- expect( Card::Query.new(wql).run.map(&:name) ).to eq( ["classic bootstrap skin","classic bootstrap skin head"] )
378
+ describe 'order' do
379
+ it 'should sort by create' do
380
+ Card.create! name: 'classic bootstrap skin head'
381
+ # classic skin head is created more recently than classic skin,
382
+ # which is in the seed data
383
+ @query = { sort: 'create', name: [:match, 'classic bootstrap skin'] }
384
+ is_expected.to eq(
385
+ ['classic bootstrap skin', 'classic bootstrap skin head']
386
+ )
273
387
  end
274
388
 
275
- it "should sort by name" do
276
- expect(Card::Query.new( :name=> %w{ in B Z A Y C X }, :sort=>"alpha", :dir=>"desc" ).run.map(&:name)).to eq(%w{ Z Y X C B A })
277
- expect(Card::Query.new( :name=> %w{ in B Z A Y C X }, :sort=>"name", :dir=>"desc" ).run.map(&:name)).to eq(%w{ Z Y X C B A })
278
- #Card.create! :name => 'the alphabet'
279
- #Card::Query.new( :name=>["in", "B", "C", "the alphabet"], :sort=>"name").run.map(&:name).should == ["the alphabet", "B", "C"]
389
+ it 'should sort by name' do
390
+ @query = { name: %w( in B Z A Y C X ), sort: 'name', dir: 'desc' }
391
+ is_expected.to eq(%w( Z Y X C B A ))
280
392
  end
281
393
 
282
- it "should sort by content" do
283
- expect(Card::Query.new( :name=> %w{ in Z T A }, :sort=>"content").run.map(&:name)).to eq(%w{ A Z T })
394
+ it 'should sort by content' do
395
+ @query = { name: %w( in Z T A ), sort: 'content' }
396
+ is_expected.to eq(%w( A Z T ))
284
397
  end
285
398
 
286
- it "should play nice with match" do
287
- expect(Card::Query.new( :match=>'Z', :type=>'Basic', :sort=>"content").run.map(&:name)).to eq(%w{ A B Z })
399
+ it 'should play nice with match' do
400
+ @query = { match: 'Z', type: 'Basic', sort: 'content' }
401
+ is_expected.to eq(%w( A B Z ))
288
402
  end
289
403
 
290
- it "should sort by plus card content" do
404
+ it 'should sort by plus card content' do
291
405
  Card::Auth.as_bot do
292
406
  c = Card.fetch('Setting+*self+*table of contents')
293
407
  c.content = '10'
294
408
  c.save
295
- c = Card.create! :name=>'Basic+*type+*table of contents', :content=>'3'
296
-
297
- w = Card::Query.new( :right_plus=>'*table of contents', :sort=>{ :right=>'*table_of_contents'}, :sort_as=>'integer' )
298
- #warn "sql from new wql = #{w.sql}"
299
- expect(w.run.map(&:name)).to eq(%w{ *all Basic+*type Setting+*self })
409
+ Card.create! name: 'Basic+*type+*table of contents', content: '3'
410
+
411
+ @query = {
412
+ right_plus: '*table of contents',
413
+ sort: { right: '*table_of_contents' },
414
+ sort_as: 'integer'
415
+ }
416
+ is_expected.to eq(%w( *all Basic+*type Setting+*self ))
300
417
  end
301
418
  end
302
419
 
303
- it "should sort by count" do
420
+ it 'should sort by count' do
304
421
  Card::Auth.as_bot do
305
- w = Card::Query.new( :name=>[:in,'*always','*never','*edited'], :sort=>{ :right=>'*follow', :item=>'referred_to', :return=>'count' } )
306
- expect(w.run.map(&:name)).to eq(['*never','*edited','*always'])
422
+ @query = {
423
+ name: [:in, '*always', '*never', '*edited'],
424
+ sort: { right: '*follow', item: 'referred_to', return: 'count' }
425
+ }
426
+ is_expected.to eq(['*never', '*edited', '*always'])
307
427
  end
308
428
  end
309
429
 
310
- # it "should sort by update" do
311
- # # do this on a restricted set so it won't change every time we add a card..
312
- # Card::Query.new( :match=>"two", :sort=>"update", :dir=>"desc").run.map(&:name).should == ["One+Two+Three", "One+Two","Two","Joe User"]
313
- # Card["Two"].update_attributes! :content=>"new bar"
314
- # Card::Query.new( :match=>"two", :sort=>"update", :dir=>"desc").run.map(&:name).should == ["Two","One+Two+Three", "One+Two","Joe User"]
315
- # end
316
- #
317
-
430
+ # it 'should sort by update' do
431
+ # # do this on a restricted set so it won't change every time we
432
+ # # add a card..
433
+ # Card::Query.run(
434
+ # match: 'two', sort: 'update', dir: 'desc'
435
+ # ).map(&:name).should == ['One+Two+Three', 'One+Two','Two','Joe User']
436
+ # Card['Two'].update_attributes! content: 'new bar'
437
+ # Card::Query.run(
438
+ # match: 'two', sort: 'update', dir: 'desc'
439
+ # ).map(&:name).should == ['Two','One+Two+Three', 'One+Two','Joe User']
440
+ # end
318
441
  end
319
442
 
320
- describe "params" do
321
- it "should merge in params as normal WQL" do
322
- expect(Card::Query.new( :params=>{:name=>"two"}).run.first.name).to eq('Two')
443
+ describe 'match' do
444
+ it 'should reach content and name via shortcut' do
445
+ @query = { match: 'two' }
446
+ is_expected.to eq(CARDS_MATCHING_TWO)
323
447
  end
324
- end
325
-
326
448
 
327
- describe "match" do
328
- it "should reach content and name via shortcut" do
329
- expect(Card::Query.new( :match=>"two").run.map(&:name).sort).to eq(CARDS_MATCHING_TWO)
449
+ it 'should get only content when content is explicit' do
450
+ @query = { content: [:match, 'two'] }
451
+ is_expected.to eq(['Joe User'])
330
452
  end
331
453
 
332
- it "should get only content when content is explicit" do
333
- expect(Card::Query.new( :content=>[:match, "two"] ).run.map(&:name).sort).to eq(["Joe User"])
454
+ it 'should get only name when name is explicit' do
455
+ @query = { name: [:match, 'two'] }
456
+ is_expected.to eq(['One+Two', 'One+Two+Three', 'Two'])
334
457
  end
458
+ end
335
459
 
336
- it "should get only name when name is explicit" do
337
- expect(Card::Query.new( :name=>[:match, "two"] ).run.map(&:name).sort).to eq(["One+Two","One+Two+Three","Two"].sort)
460
+ describe 'and' do
461
+ it 'should act as a simple passthrough with operators' do
462
+ @query = { and: { match: 'two' } }
463
+ is_expected.to eq(CARDS_MATCHING_TWO)
338
464
  end
339
- end
340
465
 
341
- describe "and" do
342
- it "should act as a simple passthrough" do
343
- expect(Card::Query.new(:and=>{:match=>'two'}).run.map(&:name).sort).to eq(CARDS_MATCHING_TWO)
344
- expect(Card::Query.new(:and=>{}, :type=>"Cardtype E").run.first.name).to eq('type-e-card')
466
+ it 'should act as a simple passthrough with relationships' do
467
+ @query = { and: {}, type: 'Cardtype E' }
468
+ is_expected.to eq(['type-e-card'])
345
469
  end
346
-
347
-
348
- it "should work within 'or'" do
349
- results = Card::Query.new(:or=>{:name=>'Z', :and=>{:left=>'A', :right=>'C'}}).run
350
- expect(results.length).to eq(2)
351
- expect(results.map(&:name).sort).to eq(['A+C','Z'])
470
+
471
+ it 'should work within "or"' do
472
+ @query = { or: { name: 'Z', and: { left: 'A', right: 'C' } } }
473
+ is_expected.to eq(['A+C', 'Z'])
352
474
  end
353
475
  end
354
476
 
355
- describe "any/or" do
356
- it "should work with :plus" do
357
- expect(Card::Query.new(:plus=>"A", :or =>{:name=>'B', :match=>'K'}, :return=>'name').run.sort).to eq(%w{ B })
358
- expect(Card::Query.new(:plus=>"A", :any=>{:name=>'B', :match=>'K'}, :return=>'name').run.sort).to eq(%w{ B })
359
- expect(Card::Query.new(:or=>{:right_plus=>"A", :plus=>'B'}, :return=>'name').run.sort).to eq(%w{ A C D F })
477
+ describe 'any' do
478
+ it 'should work with :plus' do
479
+ @query = { plus: 'A', any: { name: 'B', match: 'K' } }
480
+ is_expected.to eq(['B'])
360
481
  end
361
- end
362
482
 
363
- describe "offset" do
364
- it "should not break count" do
365
- expect(Card.count_by_wql({:match=>'two', :offset=>1})).to eq(CARDS_MATCHING_TWO.length)
483
+ it 'should work with multiple plusses' do
484
+ @query = { or: { right_plus: 'A', plus: 'B' } }
485
+ is_expected.to eq(%w( A C D F ))
366
486
  end
367
487
  end
368
488
 
369
-
370
- #=end
371
- describe "found_by" do
489
+ describe 'found_by' do
372
490
  before do
373
- Card::Auth.current_id = Card::WagnBotID
374
- c = Card.create(:name=>'Simple Search', :type=>'Search', :content=>'{"name":"A"}')
491
+ Card::Auth.as_bot
492
+ Card.create(
493
+ name: 'Simple Search', type: 'Search', content: '{"name":"A"}'
494
+ )
375
495
  end
376
496
 
377
- it "should find cards returned by search of given name" do
378
- expect(Card::Query.new(:found_by=>'Simple Search').run.first.name).to eq('A')
497
+ it 'should find cards returned by search of given name' do
498
+ @query = { found_by: 'Simple Search' }
499
+ is_expected.to eq(['A'])
379
500
  end
380
- it "should find cards returned by virtual cards" do
381
- expect(Card::Query.new(:found_by=>'Image+*type+by name').run.map(&:name).sort).to eq(Card.search(:type=>'Image').map(&:name).sort)
501
+
502
+ it 'should find cards returned by virtual cards' do
503
+ image_cards = Card.search type: 'Image', return: :name, sort: :name
504
+ @query = { found_by: 'Image+*type+by name' }
505
+ is_expected.to eq(image_cards)
382
506
  end
383
- it "should play nicely with other properties and relationships" do
384
- expect(Card::Query.new(:plus=>{:found_by=>'Simple Search'}).run.map(&:name).sort).to eq(Card::Query.new(:plus=>{:name=>'A'}).run.map(&:name).sort)
385
- expect(Card::Query.new(:found_by=>'A+*self', :plus=>'C').run.map(&:name)).to eq(%w{ A })
386
-
507
+
508
+ it 'should play nicely with other properties and relationships' do
509
+ explicit_query = { plus: { name: 'A' }, return: :name, sort: :name }
510
+ @query = { plus: { found_by: 'Simple Search' } }
511
+ is_expected.to eq(Card::Query.run(explicit_query))
387
512
  end
388
- it "should be able to handle _self" do
389
- expect(Card::Query.new(:context=>'Simple Search', :left=>{:found_by=>'_self'}, :right=>'B').run.first.name).to eq('A+B')
513
+
514
+ it 'should play work with virtual cards' do
515
+ @query = { found_by: 'A+*self', plus: 'C' }
516
+ is_expected.to eq(['A'])
390
517
  end
391
518
 
519
+ it 'should be able to handle _self' do
520
+ @query = {
521
+ context: 'Simple Search',
522
+ left: { found_by: '_self' },
523
+ right: 'B',
524
+ return: :name
525
+ }
526
+ is_expected.to eq(['A+B'])
527
+ end
392
528
  end
393
529
 
394
-
395
-
396
- #=end
397
-
398
- describe "relative" do
399
- it "should clean wql" do
400
- wql = Card::Query.new( :part=>"_self",:context=>'A' )
401
- expect(wql.query[:part]).to eq('A')
530
+ describe 'relative' do
531
+ it 'should clean wql' do
532
+ query = Card::Query.new(part: '_self', context: 'A')
533
+ expect(query.statement[:part]).to eq('A')
402
534
  end
403
535
 
404
- it "should find connection cards" do
405
- expect(Card::Query.new( :part=>"_self", :context=>'A' ).run.map(&:name).sort).to eq(["A+B", "A+C", "A+D", "A+E", "C+A", "D+A", "F+A"])
536
+ it 'should find connection cards' do
537
+ @query = { part: '_self', context: 'A' }
538
+ is_expected.to eq(%w( A+B A+C A+D A+E C+A D+A F+A ))
406
539
  end
407
540
 
408
- it "should be able to use parts of nonexistent cards in search" do
541
+ it 'should be able to use parts of nonexistent cards in search' do
409
542
  expect(Card['B+A']).to be_nil
410
- expect(Card::Query.new( :left=>'_right', :right=>'_left', :context=>'B+A' ).run.map(&:name)).to eq(['A+B'])
543
+ @query = { left: '_right', right: '_left', context: 'B+A' }
544
+ is_expected.to eq(['A+B'])
411
545
  end
412
546
 
413
- it "should find plus cards for _self" do
414
- expect(Card::Query.new( :plus=>"_self", :context=>"A" ).run.map(&:name).sort).to eq(A_JOINEES)
547
+ it 'should find plus cards for _self' do
548
+ @query = { plus: '_self', context: 'A' }
549
+ is_expected.to eq(A_JOINEES)
415
550
  end
416
551
 
417
- it "should find plus cards for _left" do
418
- expect(Card::Query.new( :plus=>"_left", :context=>"A+B" ).run.map(&:name).sort).to eq(A_JOINEES)
552
+ it 'should find plus cards for _left' do
553
+ @query = { plus: '_left', context: 'A+B' }
554
+ is_expected.to eq(A_JOINEES)
419
555
  end
420
556
 
421
- it "should find plus cards for _right" do
422
- expect(Card::Query.new( :plus=>"_right", :context=>"C+A" ).run.map(&:name).sort).to eq(A_JOINEES)
557
+ it 'should find plus cards for _right' do
558
+ @query = { plus: '_right', context: 'C+A' }
559
+ is_expected.to eq(A_JOINEES)
423
560
  end
424
-
425
561
  end
426
562
 
427
-
428
- describe "nested permissions" do
429
- it "are generated by default" do
563
+ describe 'nested permissions' do
564
+ it 'are generated by default' do
430
565
  perm_count = 0
431
- Card::Query.new( { :left=>{:name=>"X"}}).sql.scan( /read_rule_id IN \([\d\,]+\)/ ) do |m|
432
- perm_count+=1
566
+ sql = Card::Query.new(left: { name: 'X' }).sql
567
+ sql.scan(/read_rule_id IN \([\d\,]+\)/) do
568
+ perm_count += 1
433
569
  end
434
570
  expect(perm_count).to eq(2)
435
571
  end
436
-
437
- # it "are not generated inside .without_nested_permissions block" do
438
- # perm_count = 0
439
- # Card::Query.without_nested_permissions do
440
- # Card::Query.new( { :left=>{:name=>"X"}}).sql.scan( /read_rule_id IN \([\d\,]+\)/ ) do |m|
441
- # perm_count+=1
442
- # end
443
- # end
444
- # perm_count.should == 1
445
- # end
446
572
  end
447
-
448
- #describe "return values" do
449
- # # FIXME: should do other return thingies here
450
- # it "returns name_content" do
451
- # Card::Query.new( { :name => "A+B", :return => "name_content" } ).run.should == {
452
- # "A+B" => "AlphaBeta"
453
- # }
454
- # end
455
- #end
456
573
  end