card 1.16.6 → 1.16.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardoc/checksums +234 -49
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/VERSION +1 -1
- data/config/initializers/mime_types.rb +3 -3
- data/config/initializers/notification.rb +1 -1
- data/db/migrate/20121118115000_update_link_type.rb +8 -8
- data/db/migrate/20130411210957_update_codenames.rb +2 -2
- data/db/migrate/20140822073704_create_new_revision_tables.rb +12 -13
- data/db/migrate/20141001105348_move_revisions_to_actions.rb +16 -16
- data/db/migrate/20141121172918_rename_card_migration_table.rb +4 -4
- data/db/migrate_core_cards/20130419215612_import_help_text.rb +3 -3
- data/db/migrate_core_cards/20130823192433_add_style_cards.rb +45 -47
- data/db/migrate_core_cards/20130910183318_move_styles_to_content.rb +1 -1
- data/db/migrate_core_cards/20130920214038_jsonize_tinymce.rb +3 -3
- data/db/migrate_core_cards/20130920291703_update_stylesheets.rb +3 -3
- data/db/migrate_core_cards/20130927191728_account_events.rb +6 -6
- data/db/migrate_core_cards/20131016172445_common_css_patch.rb +1 -1
- data/db/migrate_core_cards/20140110193325_reset_account_request_type.rb +1 -1
- data/db/migrate_core_cards/20140307231621_user_data_to_cards.rb +19 -19
- data/db/migrate_core_cards/20140317035504_account_requests_to_signups.rb +11 -12
- data/db/migrate_core_cards/20140512155840_add_script_cards.rb +35 -36
- data/db/migrate_core_cards/20140629222005_add_email_cards.rb +55 -55
- data/db/migrate_core_cards/20140725180118_config_card_updates.rb +1 -1
- data/db/migrate_core_cards/20141111083921_delete_machine_output.rb +2 -2
- data/db/migrate_core_cards/20141115034214_config_descriptions_etc.rb +3 -3
- data/db/migrate_core_cards/20141120120605_fix_notification_html_message.rb +2 -2
- data/db/migrate_core_cards/20141204061304_watchers_to_following.rb +8 -8
- data/db/migrate_core_cards/20141208162106_add_ace_script.rb +2 -2
- data/db/migrate_core_cards/20141216155251_add_more_following_cards.rb +16 -16
- data/db/migrate_core_cards/20141230204340_uri_codename.rb +1 -1
- data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +19 -19
- data/db/migrate_core_cards/20150220134731_following_to_follow_rule.rb +3 -3
- data/db/migrate_core_cards/20150317162412_bootstrap_themes.rb +15 -15
- data/db/migrate_core_cards/20150326205655_bootswatch_themes.rb +11 -11
- data/db/migrate_core_cards/20150331135745_new_card_menu.rb +1 -1
- data/db/migrate_core_cards/20150429090551_search_card_context.rb +1 -1
- data/db/migrate_core_cards/20150508212032_menu_compatibility.rb +3 -3
- data/db/migrate_core_cards/20150510031118_fix_skin_images.rb +1 -1
- data/db/migrate_core_cards/20150528084659_add_session_cardtype.rb +4 -4
- data/db/migrate_core_cards/20150601133433_add_recent_setting_session_card.rb +5 -5
- data/db/migrate_core_cards/20150605115802_add_performance_log_card.rb +1 -1
- data/db/migrate_core_cards/20150610171702_add_debugger_session_card.rb +2 -2
- data/db/migrate_core_cards/20150611203506_rails_inflection_updates.rb +5 -5
- data/db/migrate_core_cards/20150627205133_fix_script_bootstrap_card_type.rb +1 -1
- data/db/migrate_core_cards/20150702130543_remove_edit_toolbar_pinned.rb +1 -1
- data/db/migrate_core_cards/20150724123438_update_file_and_image_cards.rb +5 -5
- data/db/migrate_core_cards/20150807205221_create_references_for_search_cards.rb +1 -1
- data/db/migrate_core_cards/20150824135418_update_file_history.rb +3 -3
- data/db/migrate_core_cards/20150903130006_attachment_upload_cards.rb +2 -2
- data/db/migrate_core_cards/20150910085603_remove_performance_log_card.rb +1 -1
- data/lib/card.rb +4 -4
- data/lib/card/active_record_ext.rb +8 -8
- data/lib/card/auth.rb +6 -6
- data/lib/card/cache.rb +1 -1
- data/lib/card/chunk.rb +1 -1
- data/lib/card/content.rb +1 -1
- data/lib/card/diff.rb +10 -10
- data/lib/card/env.rb +1 -1
- data/lib/card/format.rb +12 -12
- data/lib/card/loader.rb +1 -1
- data/lib/card/migration.rb +1 -1
- data/lib/card/name.rb +4 -4
- data/lib/card/query.rb +255 -61
- data/lib/card/query/attributes.rb +310 -0
- data/lib/card/query/clause.rb +12 -15
- data/lib/card/query/join.rb +73 -0
- data/lib/card/query/reference.rb +51 -0
- data/lib/card/query/sql_statement.rb +228 -0
- data/lib/card/query/value.rb +66 -0
- data/lib/card/reference.rb +6 -6
- data/lib/card/set.rb +12 -12
- data/lib/card/set_pattern.rb +9 -9
- data/lib/card/spec_helper.rb +5 -5
- data/lib/card/success.rb +1 -1
- data/lib/cardio.rb +7 -7
- data/lib/generators/card/format/format_generator.rb +3 -3
- data/lib/generators/card/migration/migration_generator.rb +5 -5
- data/lib/generators/card/set/set_generator.rb +4 -4
- data/mod/01_core/chunk/include.rb +4 -4
- data/mod/01_core/chunk/link.rb +5 -5
- data/mod/01_core/chunk/literal.rb +2 -2
- data/mod/01_core/chunk/query_reference.rb +8 -8
- data/mod/01_core/chunk/uri.rb +18 -18
- data/mod/01_core/format/html_format.rb +4 -4
- data/mod/01_core/set/all/active_card.rb +2 -2
- data/mod/01_core/set/all/collection.rb +21 -26
- data/mod/01_core/set/all/content.rb +2 -2
- data/mod/01_core/set/all/fetch.rb +6 -6
- data/mod/01_core/set/all/initialize.rb +4 -4
- data/mod/01_core/set/all/location_history.rb +2 -2
- data/mod/01_core/set/all/name.rb +14 -14
- data/mod/01_core/set/all/pattern.rb +1 -1
- data/mod/01_core/set/all/permissions.rb +12 -12
- data/mod/01_core/set/all/phases.rb +29 -12
- data/mod/01_core/set/all/references.rb +14 -14
- data/mod/01_core/set/all/rules.rb +8 -8
- data/mod/01_core/set/all/templating.rb +10 -9
- data/mod/01_core/set/all/tracked_attributes.rb +7 -7
- data/mod/01_core/set/all/trash.rb +6 -6
- data/mod/01_core/set/all/type.rb +7 -7
- data/mod/01_core/set/all/utils.rb +4 -4
- data/mod/01_core/set/all/view_cache.rb +1 -1
- data/mod/01_core/set_pattern/02_all_plus.rb +2 -2
- data/mod/01_core/set_pattern/03_type.rb +1 -1
- data/mod/01_core/set_pattern/04_star.rb +1 -1
- data/mod/01_core/set_pattern/05_rstar.rb +2 -2
- data/mod/01_core/set_pattern/06_right.rb +4 -4
- data/mod/01_core/set_pattern/07_type_plus_right.rb +4 -4
- data/mod/01_core/set_pattern/08_self.rb +1 -1
- data/mod/01_core/spec/chunk/uri_spec.rb +73 -73
- data/mod/01_core/spec/format/html_format_spec.rb +5 -5
- data/mod/01_core/spec/set/all/attribute_tracking_spec.rb +1 -1
- data/mod/01_core/spec/set/all/collection_spec.rb +22 -22
- data/mod/01_core/spec/set/all/content_spec.rb +1 -1
- data/mod/01_core/spec/set/all/fetch_spec.rb +24 -24
- data/mod/01_core/spec/set/all/initialize_spec.rb +9 -9
- data/mod/01_core/spec/set/all/name_spec.rb +8 -8
- data/mod/01_core/spec/set/all/pattern_spec.rb +10 -10
- data/mod/01_core/spec/set/all/permissions_spec.rb +45 -45
- data/mod/01_core/spec/set/all/references_spec.rb +1 -1
- data/mod/01_core/spec/set/all/rules2_spec.rb +15 -15
- data/mod/01_core/spec/set/all/rules_spec.rb +37 -37
- data/mod/01_core/spec/set/all/templating_spec.rb +21 -21
- data/mod/01_core/spec/set/all/tracked_attributes_spec.rb +55 -55
- data/mod/01_core/spec/set/all/trash_spec.rb +4 -4
- data/mod/01_core/spec/set/all/type_spec.rb +15 -15
- data/mod/01_history/lib/card/act.rb +2 -2
- data/mod/01_history/lib/card/action.rb +22 -22
- data/mod/01_history/lib/card/change.rb +1 -1
- data/mod/01_history/set/all/actions.rb +2 -2
- data/mod/01_history/set/all/content_history.rb +4 -4
- data/mod/01_history/set/all/history.rb +46 -46
- data/mod/02_basic_types/set/all/all_css.rb +10 -10
- data/mod/02_basic_types/set/all/all_csv.rb +7 -7
- data/mod/02_basic_types/set/all/base.rb +25 -25
- data/mod/02_basic_types/set/all/json.rb +16 -16
- data/mod/02_basic_types/set/all/rss.rb +7 -7
- data/mod/02_basic_types/set/type/html.rb +2 -2
- data/mod/02_basic_types/set/type/plain_text.rb +1 -1
- data/mod/02_basic_types/set/type/pointer.rb +39 -31
- data/mod/02_basic_types/spec/set/all/all_css_spec.rb +1 -1
- data/mod/02_basic_types/spec/set/all/all_csv_spec.rb +1 -1
- data/mod/02_basic_types/spec/set/all/base_spec.rb +18 -18
- data/mod/02_basic_types/spec/set/all/json_spec.rb +4 -4
- data/mod/02_basic_types/spec/set/all/rss_spec.rb +8 -2
- data/mod/02_basic_types/spec/set/type/plain_text_spec.rb +1 -1
- data/mod/02_basic_types/spec/set/type/pointer_spec.rb +54 -44
- data/mod/03_machines/lib/card/machine.rb +46 -29
- data/mod/03_machines/lib/card/machine_input.rb +34 -10
- data/mod/03_machines/set/type/coffee_script.rb +3 -3
- data/mod/03_machines/set/type/css.rb +8 -8
- data/mod/03_machines/set/type/java_script.rb +4 -4
- data/mod/03_machines/set/type/scss.rb +2 -2
- data/mod/03_machines/set/type/skin.rb +1 -1
- data/mod/03_machines/spec/lib/shared_machine_examples.rb +27 -27
- data/mod/03_machines/spec/lib/shared_machine_input_examples.rb +8 -8
- data/mod/03_machines/spec/set/type/coffeescript_spec.rb +6 -6
- data/mod/03_machines/spec/set/type/css_spec.rb +9 -9
- data/mod/03_machines/spec/set/type/javascript_spec.rb +6 -6
- data/mod/03_machines/spec/set/type/scss_spec.rb +5 -5
- data/mod/03_machines/spec/set/type/skin_spec.rb +25 -25
- data/mod/04_settings/lib/card/setting.rb +11 -11
- data/mod/04_settings/set/abstract/permission.rb +9 -9
- data/mod/04_settings/set/right/script.rb +1 -1
- data/mod/04_settings/set/right/structure.rb +0 -5
- data/mod/04_settings/set/right/style.rb +2 -2
- data/mod/04_settings/set/self/accountable.rb +1 -1
- data/mod/04_settings/set/self/add_help.rb +1 -1
- data/mod/04_settings/set/self/autoname.rb +1 -1
- data/mod/04_settings/set/self/captcha.rb +1 -1
- data/mod/04_settings/set/self/create.rb +1 -1
- data/mod/04_settings/set/self/default.rb +1 -1
- data/mod/04_settings/set/self/delete.rb +1 -1
- data/mod/04_settings/set/self/help.rb +1 -1
- data/mod/04_settings/set/self/input.rb +1 -1
- data/mod/04_settings/set/self/layout.rb +1 -1
- data/mod/04_settings/set/self/on_create.rb +1 -1
- data/mod/04_settings/set/self/on_delete.rb +1 -1
- data/mod/04_settings/set/self/on_update.rb +1 -1
- data/mod/04_settings/set/self/options.rb +1 -1
- data/mod/04_settings/set/self/options_label.rb +1 -1
- data/mod/04_settings/set/self/read.rb +1 -1
- data/mod/04_settings/set/self/script.rb +1 -1
- data/mod/04_settings/set/self/structure.rb +1 -1
- data/mod/04_settings/set/self/style.rb +1 -1
- data/mod/04_settings/set/self/table_of_contents.rb +1 -1
- data/mod/04_settings/set/self/thanks.rb +1 -1
- data/mod/04_settings/set/self/update.rb +1 -1
- data/mod/04_settings/set/type/setting.rb +14 -14
- data/mod/04_settings/spec/set/right/comment_spec.rb +5 -5
- data/mod/04_settings/spec/set/right/create_spec.rb +1 -1
- data/mod/04_settings/spec/set/right/script_spec.rb +5 -5
- data/mod/04_settings/spec/set/right/structure_spec.rb +4 -2
- data/mod/04_settings/spec/set/right/style_spec.rb +7 -7
- data/mod/04_settings/spec/set/type/setting_spec.rb +2 -2
- data/mod/05_email/lib/card/follow_option.rb +24 -24
- data/mod/05_email/set/all/follow.rb +24 -16
- data/mod/05_email/set/all/notify.rb +25 -23
- data/mod/05_email/set/all/observer.rb +5 -5
- data/mod/05_email/set/right/bcc.rb +8 -8
- data/mod/05_email/set/right/follow.rb +44 -17
- data/mod/05_email/set/right/follow_fields.rb +1 -1
- data/mod/05_email/set/right/following.rb +49 -40
- data/mod/05_email/set/self/always.rb +2 -2
- data/mod/05_email/set/self/created.rb +1 -1
- data/mod/05_email/set/self/edited.rb +4 -4
- data/mod/05_email/set/self/follow.rb +1 -1
- data/mod/05_email/set/self/follow_defaults.rb +9 -9
- data/mod/05_email/set/self/never.rb +1 -1
- data/mod/05_email/set/type/email_template.rb +9 -9
- data/mod/05_email/set/type_plus_right/user/follow.rb +16 -16
- data/mod/05_email/spec/set/all/follow_spec.rb +10 -10
- data/mod/05_email/spec/set/all/notify_spec.rb +82 -82
- data/mod/05_email/spec/set/all/observer_spec.rb +16 -16
- data/mod/05_email/spec/set/right/followers_spec.rb +6 -6
- data/mod/05_email/spec/set/self/follow_defaults_spec.rb +2 -2
- data/mod/05_standard/lib/carrier_wave/cardmount.rb +5 -5
- data/mod/05_standard/lib/image_uploader.rb +8 -8
- data/mod/05_standard/set/abstract/attachment.rb +18 -18
- data/mod/05_standard/set/all/account.rb +5 -5
- data/mod/05_standard/set/all/comment.rb +7 -7
- data/mod/05_standard/set/all/error.rb +25 -25
- data/mod/05_standard/set/all/event_viz.rb +1 -1
- data/mod/05_standard/set/all/links.rb +9 -9
- data/mod/05_standard/set/all/rich_html/content.rb +34 -34
- data/mod/05_standard/set/all/rich_html/editing.rb +35 -35
- data/mod/05_standard/set/all/rich_html/form.rb +20 -20
- data/mod/05_standard/set/all/rich_html/header.rb +8 -8
- data/mod/05_standard/set/all/rich_html/menu.rb +33 -33
- data/mod/05_standard/set/all/rich_html/modal.rb +16 -16
- data/mod/05_standard/set/all/rich_html/toolbar.rb +63 -63
- data/mod/05_standard/set/all/rich_html/wrapper.rb +8 -8
- data/mod/05_standard/set/right/account.rb +27 -27
- data/mod/05_standard/set/right/email.rb +5 -5
- data/mod/05_standard/set/right/password.rb +5 -5
- data/mod/05_standard/set/rstar/rules.rb +52 -52
- data/mod/05_standard/set/self/account_links.rb +27 -27
- data/mod/05_standard/set/self/all.rb +1 -1
- data/mod/05_standard/set/self/head.rb +5 -5
- data/mod/05_standard/set/self/navbox.rb +11 -11
- data/mod/05_standard/set/self/recent.rb +2 -2
- data/mod/05_standard/set/self/search.rb +13 -13
- data/mod/05_standard/set/self/signin.rb +19 -19
- data/mod/05_standard/set/self/stats.rb +2 -2
- data/mod/05_standard/set/type/basic.rb +1 -1
- data/mod/05_standard/set/type/cardtype.rb +5 -5
- data/mod/05_standard/set/type/date.rb +1 -1
- data/mod/05_standard/set/type/file.rb +7 -7
- data/mod/05_standard/set/type/image.rb +8 -8
- data/mod/05_standard/set/type/number.rb +2 -2
- data/mod/05_standard/set/type/phrase.rb +1 -1
- data/mod/05_standard/set/type/search_type.rb +27 -21
- data/mod/05_standard/set/type/session.rb +2 -2
- data/mod/05_standard/set/type/set.rb +37 -37
- data/mod/05_standard/set/type/signup.rb +25 -25
- data/mod/05_standard/set/type/uri.rb +1 -1
- data/mod/05_standard/set/type/user.rb +21 -21
- data/mod/05_standard/spec/chunk/include_spec.rb +16 -16
- data/mod/05_standard/spec/chunk/link_spec.rb +18 -18
- data/mod/05_standard/spec/chunk/query_reference_spec.rb +1 -1
- data/mod/05_standard/spec/set/all/account_spec.rb +7 -7
- data/mod/05_standard/spec/set/all/email_html_spec.rb +3 -3
- data/mod/05_standard/spec/set/all/history_spec.rb +14 -14
- data/mod/05_standard/spec/set/all/rich_html/editing_spec.rb +1 -1
- data/mod/05_standard/spec/set/all/rich_html/form_spec.rb +2 -2
- data/mod/05_standard/spec/set/right/account_spec.rb +9 -9
- data/mod/05_standard/spec/set/right/email_spec.rb +8 -8
- data/mod/05_standard/spec/set/right/password_spec.rb +9 -9
- data/mod/05_standard/spec/set/right/stats_spec.rb +1 -1
- data/mod/05_standard/spec/set/right/when_created_spec.rb +1 -1
- data/mod/05_standard/spec/set/right/when_last_edited_spec.rb +1 -1
- data/mod/05_standard/spec/set/rstar/rules_spec.rb +2 -2
- data/mod/05_standard/spec/set/self/account_links_spec.rb +2 -2
- data/mod/05_standard/spec/set/self/all_spec.rb +8 -11
- data/mod/05_standard/spec/set/self/head_spec.rb +1 -1
- data/mod/05_standard/spec/set/self/navbox_spec.rb +1 -1
- data/mod/05_standard/spec/set/self/now_spec.rb +1 -1
- data/mod/05_standard/spec/set/self/stats_spec.rb +1 -1
- data/mod/05_standard/spec/set/self/version_spec.rb +1 -1
- data/mod/05_standard/spec/set/type/email_template_spec.rb +25 -25
- data/mod/05_standard/spec/set/type/file_spec.rb +4 -4
- data/mod/05_standard/spec/set/type/html_spec.rb +3 -3
- data/mod/05_standard/spec/set/type/image_spec.rb +6 -6
- data/mod/05_standard/spec/set/type/layout_type_spec.rb +1 -1
- data/mod/05_standard/spec/set/type/search_type_spec.rb +10 -10
- data/mod/05_standard/spec/set/type/signup_spec.rb +11 -11
- data/mod/05_standard/spec/set/type/toggle_spec.rb +2 -2
- data/mod/05_standard/spec/set/type/uri_spec.rb +9 -9
- data/mod/06_bootstrap/set/all/bootstrap/helper.rb +10 -10
- data/mod/06_bootstrap/set/all/bootstrap/wrapper.rb +4 -4
- data/mod/06_bootstrap/set/all/rich_bootstrap.rb +1 -1
- data/spec/lib/card/action_spec.rb +2 -2
- data/spec/lib/card/cache_spec.rb +7 -7
- data/spec/lib/card/content_spec.rb +31 -37
- data/spec/lib/card/diff_spec.rb +56 -56
- data/spec/lib/card/format_spec.rb +11 -11
- data/spec/lib/card/query_spec.rb +382 -265
- data/spec/lib/card/reference_spec.rb +133 -140
- data/spec/lib/card/set_pattern_spec.rb +10 -9
- data/spec/lib/card/set_spec.rb +11 -11
- data/spec/lib/card/success_spec.rb +16 -8
- data/spec/mailers/mailer_spec.rb +5 -5
- data/spec/models/card/cardtype_spec.rb +20 -20
- data/spec/models/card/create_spec.rb +6 -6
- data/spec/models/card/trash_spec.rb +20 -20
- data/spec/models/card/type_transition_spec.rb +3 -3
- data/spec/models/card/validation_spec.rb +5 -5
- data/spec/models/card_spec.rb +24 -24
- data/spec/spec_helper.rb +5 -5
- data/tmpsets/set/mod001-01_core/all/active_card.rb +2 -2
- data/tmpsets/set/mod001-01_core/all/collection.rb +23 -26
- data/tmpsets/set/mod001-01_core/all/content.rb +2 -2
- data/tmpsets/set/mod001-01_core/all/fetch.rb +6 -6
- data/tmpsets/set/mod001-01_core/all/initialize.rb +8 -4
- data/tmpsets/set/mod001-01_core/all/name.rb +14 -14
- data/tmpsets/set/mod001-01_core/all/pattern.rb +1 -1
- data/tmpsets/set/mod001-01_core/all/permissions.rb +12 -12
- data/tmpsets/set/mod001-01_core/all/phases.rb +31 -13
- data/tmpsets/set/mod001-01_core/all/references.rb +14 -14
- data/tmpsets/set/mod001-01_core/all/rules.rb +8 -10
- data/tmpsets/set/mod001-01_core/all/templating.rb +10 -9
- data/tmpsets/set/mod001-01_core/all/tracked_attributes.rb +7 -7
- data/tmpsets/set/mod001-01_core/all/trash.rb +9 -8
- data/tmpsets/set/mod001-01_core/all/type.rb +7 -7
- data/tmpsets/set/mod001-01_core/all/utils.rb +16 -4
- data/tmpsets/set/mod001-01_core/all/view_cache.rb +1 -1
- data/tmpsets/set/mod002-01_history/all/actions.rb +2 -2
- data/tmpsets/set/mod002-01_history/all/content_history.rb +11 -7
- data/tmpsets/set/mod002-01_history/all/history.rb +46 -46
- data/tmpsets/set/mod003-02_basic_types/all/all_css.rb +10 -10
- data/tmpsets/set/mod003-02_basic_types/all/all_csv.rb +7 -7
- data/tmpsets/set/mod003-02_basic_types/all/base.rb +25 -25
- data/tmpsets/set/mod003-02_basic_types/all/json.rb +16 -16
- data/tmpsets/set/mod003-02_basic_types/all/rss.rb +7 -7
- data/tmpsets/set/mod003-02_basic_types/type/html.rb +2 -2
- data/tmpsets/set/mod003-02_basic_types/type/plain_text.rb +1 -1
- data/tmpsets/set/mod003-02_basic_types/type/pointer.rb +38 -31
- data/tmpsets/set/mod004-03_machines/right/machine_output.rb +4 -0
- data/tmpsets/set/mod004-03_machines/type/coffee_script.rb +3 -3
- data/tmpsets/set/mod004-03_machines/type/css.rb +8 -8
- data/tmpsets/set/mod004-03_machines/type/java_script.rb +4 -4
- data/tmpsets/set/mod004-03_machines/type/scss.rb +2 -2
- data/tmpsets/set/mod004-03_machines/type/skin.rb +1 -1
- data/tmpsets/set/mod005-04_settings/abstract/permission.rb +9 -9
- data/tmpsets/set/mod005-04_settings/right/script.rb +1 -1
- data/tmpsets/set/mod005-04_settings/right/structure.rb +0 -5
- data/tmpsets/set/mod005-04_settings/right/style.rb +2 -2
- data/tmpsets/set/mod005-04_settings/self/accountable.rb +1 -1
- data/tmpsets/set/mod005-04_settings/self/add_help.rb +1 -1
- data/tmpsets/set/mod005-04_settings/self/autoname.rb +1 -1
- data/tmpsets/set/mod005-04_settings/self/captcha.rb +1 -1
- data/tmpsets/set/mod005-04_settings/self/create.rb +1 -1
- data/tmpsets/set/mod005-04_settings/self/default.rb +1 -1
- data/tmpsets/set/mod005-04_settings/self/delete.rb +1 -1
- data/tmpsets/set/mod005-04_settings/self/help.rb +1 -1
- data/tmpsets/set/mod005-04_settings/self/input.rb +1 -1
- data/tmpsets/set/mod005-04_settings/self/layout.rb +1 -1
- data/tmpsets/set/mod005-04_settings/self/on_create.rb +1 -1
- data/tmpsets/set/mod005-04_settings/self/on_delete.rb +1 -1
- data/tmpsets/set/mod005-04_settings/self/on_update.rb +1 -1
- data/tmpsets/set/mod005-04_settings/self/options.rb +1 -1
- data/tmpsets/set/mod005-04_settings/self/options_label.rb +1 -1
- data/tmpsets/set/mod005-04_settings/self/read.rb +1 -1
- data/tmpsets/set/mod005-04_settings/self/script.rb +1 -1
- data/tmpsets/set/mod005-04_settings/self/structure.rb +1 -1
- data/tmpsets/set/mod005-04_settings/self/style.rb +1 -1
- data/tmpsets/set/mod005-04_settings/self/table_of_contents.rb +1 -1
- data/tmpsets/set/mod005-04_settings/self/thanks.rb +1 -1
- data/tmpsets/set/mod005-04_settings/self/update.rb +1 -1
- data/tmpsets/set/mod005-04_settings/type/setting.rb +14 -14
- data/tmpsets/set/mod006-05_email/all/follow.rb +24 -16
- data/tmpsets/set/mod006-05_email/all/notify.rb +25 -23
- data/tmpsets/set/mod006-05_email/all/observer.rb +8 -8
- data/tmpsets/set/mod006-05_email/right/bcc.rb +8 -8
- data/tmpsets/set/mod006-05_email/right/follow.rb +44 -17
- data/tmpsets/set/mod006-05_email/right/follow_fields.rb +1 -1
- data/tmpsets/set/mod006-05_email/right/following.rb +49 -40
- data/tmpsets/set/mod006-05_email/self/always.rb +2 -2
- data/tmpsets/set/mod006-05_email/self/created.rb +1 -1
- data/tmpsets/set/mod006-05_email/self/edited.rb +4 -4
- data/tmpsets/set/mod006-05_email/self/follow.rb +1 -1
- data/tmpsets/set/mod006-05_email/self/follow_defaults.rb +9 -9
- data/tmpsets/set/mod006-05_email/self/never.rb +1 -1
- data/tmpsets/set/mod006-05_email/type/email_template.rb +9 -9
- data/tmpsets/set/mod006-05_email/type_plus_right/user/follow.rb +17 -17
- data/tmpsets/set/mod007-05_standard/abstract/attachment.rb +98 -46
- data/tmpsets/set/mod007-05_standard/all/account.rb +5 -5
- data/tmpsets/set/mod007-05_standard/all/comment.rb +7 -7
- data/tmpsets/set/mod007-05_standard/all/error.rb +26 -26
- data/tmpsets/set/mod007-05_standard/all/event_viz.rb +1 -1
- data/tmpsets/set/mod007-05_standard/all/links.rb +10 -9
- data/tmpsets/set/mod007-05_standard/all/rich_html/content.rb +34 -34
- data/tmpsets/set/mod007-05_standard/all/rich_html/editing.rb +35 -35
- data/tmpsets/set/mod007-05_standard/all/rich_html/form.rb +20 -20
- data/tmpsets/set/mod007-05_standard/all/rich_html/header.rb +8 -8
- data/tmpsets/set/mod007-05_standard/all/rich_html/menu.rb +33 -33
- data/tmpsets/set/mod007-05_standard/all/rich_html/modal.rb +16 -16
- data/tmpsets/set/mod007-05_standard/all/rich_html/toolbar.rb +63 -63
- data/tmpsets/set/mod007-05_standard/all/rich_html/wrapper.rb +8 -8
- data/tmpsets/set/mod007-05_standard/right/account.rb +27 -27
- data/tmpsets/set/mod007-05_standard/right/email.rb +5 -5
- data/tmpsets/set/mod007-05_standard/right/password.rb +5 -5
- data/tmpsets/set/mod007-05_standard/rstar/rules.rb +52 -52
- data/tmpsets/set/mod007-05_standard/self/account_links.rb +27 -27
- data/tmpsets/set/mod007-05_standard/self/all.rb +1 -1
- data/tmpsets/set/mod007-05_standard/self/head.rb +5 -5
- data/tmpsets/set/mod007-05_standard/self/navbox.rb +11 -11
- data/tmpsets/set/mod007-05_standard/self/recent.rb +2 -2
- data/tmpsets/set/mod007-05_standard/self/search.rb +13 -13
- data/tmpsets/set/mod007-05_standard/self/signin.rb +19 -19
- data/tmpsets/set/mod007-05_standard/self/stats.rb +2 -2
- data/tmpsets/set/mod007-05_standard/type/basic.rb +1 -1
- data/tmpsets/set/mod007-05_standard/type/cardtype.rb +5 -5
- data/tmpsets/set/mod007-05_standard/type/date.rb +1 -1
- data/tmpsets/set/mod007-05_standard/type/file.rb +23 -8
- data/tmpsets/set/mod007-05_standard/type/image.rb +10 -8
- data/tmpsets/set/mod007-05_standard/type/number.rb +2 -2
- data/tmpsets/set/mod007-05_standard/type/phrase.rb +1 -1
- data/tmpsets/set/mod007-05_standard/type/search_type.rb +21 -19
- data/tmpsets/set/mod007-05_standard/type/session.rb +2 -2
- data/tmpsets/set/mod007-05_standard/type/set.rb +37 -37
- data/tmpsets/set/mod007-05_standard/type/signup.rb +25 -25
- data/tmpsets/set/mod007-05_standard/type/uri.rb +1 -1
- data/tmpsets/set/mod007-05_standard/type/user.rb +21 -21
- data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/helper.rb +10 -10
- data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/wrapper.rb +4 -4
- data/tmpsets/set/mod008-06_bootstrap/all/rich_bootstrap.rb +1 -1
- data/tmpsets/set_pattern/101-all_plus.rb +2 -2
- data/tmpsets/set_pattern/102-type.rb +1 -1
- data/tmpsets/set_pattern/103-star.rb +1 -1
- data/tmpsets/set_pattern/104-rstar.rb +2 -2
- data/tmpsets/set_pattern/105-right.rb +4 -4
- data/tmpsets/set_pattern/106-type_plus_right.rb +4 -4
- data/tmpsets/set_pattern/107-self.rb +1 -1
- metadata +7 -5
- data/lib/card/query/card_clause.rb +0 -528
- data/lib/card/query/ref_clause.rb +0 -47
- data/lib/card/query/value_clause.rb +0 -65
@@ -4,10 +4,10 @@ format :html do
|
|
4
4
|
|
5
5
|
def frame args={}, &block
|
6
6
|
args.reverse_merge!(
|
7
|
-
:
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
7
|
+
panel_class: 'panel panel-default',
|
8
|
+
header_class: 'panel-heading',
|
9
|
+
title_class: 'panel-title',
|
10
|
+
body_class: 'panel-body'
|
11
11
|
)
|
12
12
|
super args
|
13
13
|
end
|
@@ -4,14 +4,14 @@ class Card::AllPlusSet < Card::SetPattern
|
|
4
4
|
class << self
|
5
5
|
# ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set_pattern/02_all_plus.rb ~~~~~~~~~~~
|
6
6
|
|
7
|
-
@@options = { :
|
7
|
+
@@options = { junction_only: true }
|
8
8
|
|
9
9
|
def label name
|
10
10
|
'All "+" cards'
|
11
11
|
end
|
12
12
|
|
13
13
|
def prototype_args anchor
|
14
|
-
{ :
|
14
|
+
{ name: '+' }
|
15
15
|
end
|
16
16
|
|
17
17
|
def follow_label name
|
@@ -4,14 +4,14 @@ class Card::RstarSet < Card::SetPattern
|
|
4
4
|
class << self
|
5
5
|
# ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set_pattern/05_rstar.rb ~~~~~~~~~~~
|
6
6
|
|
7
|
-
@@options = { :
|
7
|
+
@@options = { junction_only: true }
|
8
8
|
|
9
9
|
def label name
|
10
10
|
'All "+*" cards'
|
11
11
|
end
|
12
12
|
|
13
13
|
def prototype_args anchor
|
14
|
-
{ :
|
14
|
+
{ name: '*dummy+*dummy' }
|
15
15
|
end
|
16
16
|
|
17
17
|
def pattern_applies? card
|
@@ -4,9 +4,9 @@ class Card::RightSet < Card::SetPattern
|
|
4
4
|
class << self
|
5
5
|
# ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set_pattern/06_right.rb ~~~~~~~~~~~
|
6
6
|
|
7
|
-
@@options = {
|
8
|
-
:
|
9
|
-
:
|
7
|
+
@@options = {
|
8
|
+
junction_only: true,
|
9
|
+
assigns_type: true
|
10
10
|
}
|
11
11
|
|
12
12
|
def label name
|
@@ -14,7 +14,7 @@ def label name
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def prototype_args anchor
|
17
|
-
{ :
|
17
|
+
{ name: "*dummy+#{anchor}" }
|
18
18
|
end
|
19
19
|
|
20
20
|
def anchor_name card
|
@@ -5,9 +5,9 @@ class Card::TypePlusRightSet < Card::SetPattern
|
|
5
5
|
# ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set_pattern/07_type_plus_right.rb ~~~~~~~~~~~
|
6
6
|
|
7
7
|
@@options = {
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
8
|
+
junction_only: true,
|
9
|
+
assigns_type: true,
|
10
|
+
anchor_parts_count: 2
|
11
11
|
}
|
12
12
|
|
13
13
|
def label name
|
@@ -15,7 +15,7 @@ def label name
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def prototype_args anchor
|
18
|
-
{ :
|
18
|
+
{ name: "+#{anchor.tag}", supercard: Card.new( name: '*dummy', type: anchor.trunk_name ) }
|
19
19
|
end
|
20
20
|
|
21
21
|
def anchor_name card
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: card
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.16.
|
4
|
+
version: 1.16.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ethan McCutchen
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-
|
14
|
+
date: 2015-10-02 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: smartname
|
@@ -397,10 +397,12 @@ files:
|
|
397
397
|
- lib/card/migration.rb
|
398
398
|
- lib/card/name.rb
|
399
399
|
- lib/card/query.rb
|
400
|
-
- lib/card/query/
|
400
|
+
- lib/card/query/attributes.rb
|
401
401
|
- lib/card/query/clause.rb
|
402
|
-
- lib/card/query/
|
403
|
-
- lib/card/query/
|
402
|
+
- lib/card/query/join.rb
|
403
|
+
- lib/card/query/reference.rb
|
404
|
+
- lib/card/query/sql_statement.rb
|
405
|
+
- lib/card/query/value.rb
|
404
406
|
- lib/card/reference.rb
|
405
407
|
- lib/card/set.rb
|
406
408
|
- lib/card/set_pattern.rb
|
@@ -1,528 +0,0 @@
|
|
1
|
-
|
2
|
-
class Card
|
3
|
-
class Query
|
4
|
-
class CardClause < Clause
|
5
|
-
PLUS_ATTRIBUTES = %w{ plus left_plus right_plus }
|
6
|
-
|
7
|
-
ATTRIBUTES = {
|
8
|
-
:basic => %w{ name type_id content id key updater_id left_id right_id creator_id updater_id codename },
|
9
|
-
:relational => %w{ type part left right editor_of edited_by last_editor_of last_edited_by creator_of created_by member_of member },
|
10
|
-
:plus_relational => PLUS_ATTRIBUTES,
|
11
|
-
:ref_relational => %w{ refer_to referred_to_by link_to linked_to_by include included_by },
|
12
|
-
:conjunction => %w{ and or all any },
|
13
|
-
:special => %w{ found_by not sort match complete extension_type },
|
14
|
-
:ignore => %w{ prepend append view params vars size }
|
15
|
-
}.inject({}) {|h,pair| pair[1].each {|v| h[v.to_sym]=pair[0] }; h }
|
16
|
-
|
17
|
-
DEFAULT_ORDER_DIRS = { :update => "desc", :relevance => "desc" }
|
18
|
-
CONJUNCTIONS = { :any=>:or, :in=>:or, :or=>:or, :all=>:and, :and=>:and }
|
19
|
-
|
20
|
-
attr_reader :sql, :query, :rawclause, :selfname
|
21
|
-
attr_accessor :joins, :join_count
|
22
|
-
|
23
|
-
class << self
|
24
|
-
def build query
|
25
|
-
cardclause = self.new query
|
26
|
-
cardclause.merge cardclause.rawclause
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def initialize query
|
31
|
-
@mods = MODIFIERS.clone
|
32
|
-
@clause, @joins = {}, {}
|
33
|
-
@selfname, @parent = '', nil
|
34
|
-
@sql = SqlStatement.new
|
35
|
-
|
36
|
-
@query = query.clone
|
37
|
-
@query.merge! @query.delete(:params) if @query[:params]
|
38
|
-
@vars = @query.delete(:vars) || {}
|
39
|
-
@vars.symbolize_keys!
|
40
|
-
@query = clean(@query)
|
41
|
-
@rawclause = @query.deep_clone
|
42
|
-
|
43
|
-
@sql.distinct = 'DISTINCT' if @parent
|
44
|
-
|
45
|
-
self
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
50
|
-
# QUERY CLEANING - strip strings, absolutize names, interpret contextual parameters
|
51
|
-
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
52
|
-
|
53
|
-
|
54
|
-
def clean query
|
55
|
-
query = query.symbolize_keys
|
56
|
-
if s = query.delete(:context) then @selfname = s end
|
57
|
-
if p = query.delete(:_parent) then @parent = p end
|
58
|
-
query.each do |key,val|
|
59
|
-
query[key] = clean_val val
|
60
|
-
end
|
61
|
-
query
|
62
|
-
end
|
63
|
-
|
64
|
-
def clean_val val
|
65
|
-
case val
|
66
|
-
when String
|
67
|
-
if val =~ /^\$(\w+)$/
|
68
|
-
val = @vars[$1.to_sym].to_s.strip
|
69
|
-
end
|
70
|
-
absolute_name val
|
71
|
-
when Card::Name ; clean_val val.s
|
72
|
-
when Hash ; clean val
|
73
|
-
when Array ; val.map { |v| clean_val v }
|
74
|
-
when Integer, Float, Symbol ; val
|
75
|
-
else ; raise BadQuery, "unknown WQL value type: #{val.class}"
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def root
|
80
|
-
@parent ? @parent.root : self
|
81
|
-
end
|
82
|
-
|
83
|
-
def absolute_name name
|
84
|
-
name =~ /\b_/ ? name.to_name.to_absolute(root.selfname) : name
|
85
|
-
end
|
86
|
-
|
87
|
-
|
88
|
-
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
89
|
-
# MERGE - reduce query to basic attributes and SQL subconditions
|
90
|
-
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
91
|
-
|
92
|
-
|
93
|
-
def merge s
|
94
|
-
s = hashify s
|
95
|
-
translate_to_attributes s
|
96
|
-
ready_to_sqlize s
|
97
|
-
@clause.merge! s
|
98
|
-
self
|
99
|
-
end
|
100
|
-
|
101
|
-
def hashify s
|
102
|
-
case s
|
103
|
-
when String; { :key => s.to_name.key }
|
104
|
-
when Integer; { :id => s }
|
105
|
-
when Hash; s
|
106
|
-
else; raise BadQuery, "Invalid cardclause args #{s.inspect}"
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def translate_to_attributes clause
|
111
|
-
content = nil
|
112
|
-
clause.each do |key,val|
|
113
|
-
if key == :_parent
|
114
|
-
@parent = clause.delete(key)
|
115
|
-
elsif OPERATORS.has_key?(key.to_s) && !ATTRIBUTES[key]
|
116
|
-
clause.delete(key)
|
117
|
-
content = [key,val]
|
118
|
-
elsif MODIFIERS.has_key?(key)
|
119
|
-
next if clause[key].is_a? Hash
|
120
|
-
val = clause.delete key
|
121
|
-
@mods[key] = Array === val ? val : val.to_s
|
122
|
-
end
|
123
|
-
end
|
124
|
-
clause[:content] = content if content
|
125
|
-
end
|
126
|
-
|
127
|
-
|
128
|
-
def ready_to_sqlize clause
|
129
|
-
clause.each do |key,val|
|
130
|
-
keyroot = field_root(key).to_sym
|
131
|
-
if keyroot==:cond # internal SQL cond (already ready)
|
132
|
-
elsif ATTRIBUTES[keyroot] == :basic # sqlize knows how to handle these keys; just process value
|
133
|
-
clause[key] = ValueClause.new(val, self)
|
134
|
-
else # keys need additional processing
|
135
|
-
val = clause.delete key
|
136
|
-
is_array = Array===val
|
137
|
-
case ATTRIBUTES[keyroot]
|
138
|
-
when :ignore #noop
|
139
|
-
when :relational, :special, :conjunction ; relate is_array, keyroot, val, :send
|
140
|
-
when :ref_relational ; relate is_array, keyroot, val, :refclause
|
141
|
-
when :plus_relational
|
142
|
-
# Arrays can have multiple interpretations for these, so we have to look closer...
|
143
|
-
subcond = is_array && ( Array===val.first || conjunction(val.first) )
|
144
|
-
|
145
|
-
relate subcond, keyroot, val, :send
|
146
|
-
else ; raise BadQuery, "Invalid attribute #{key}"
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
end
|
152
|
-
|
153
|
-
def relate subcond, key, val, method
|
154
|
-
if subcond
|
155
|
-
conj = conjunction( val.first ) ? conjunction( val.shift ) : :and
|
156
|
-
if conj == current_conjunction # same conjunction as container, no need for subcondition
|
157
|
-
val.each { |v| send method, key, v }
|
158
|
-
else
|
159
|
-
send conj, val.inject({}) { |h,v| h[field key] = v; h } # subcondition
|
160
|
-
end
|
161
|
-
else
|
162
|
-
send method, key, val
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
def refclause key, val
|
167
|
-
add_join :ref, RefClause.new( key, val, self ).to_sql, :id, :ref_id
|
168
|
-
end
|
169
|
-
|
170
|
-
|
171
|
-
def conjunction val
|
172
|
-
if [String, Symbol].member? val.class
|
173
|
-
CONJUNCTIONS[val.to_sym]
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
|
178
|
-
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
179
|
-
# ATTRIBUTE METHODS - called during merge
|
180
|
-
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
181
|
-
|
182
|
-
|
183
|
-
#~~~~~~ RELATIONAL
|
184
|
-
|
185
|
-
def type val
|
186
|
-
restrict :type_id, val
|
187
|
-
end
|
188
|
-
|
189
|
-
def part val
|
190
|
-
right = Integer===val ? val : val.clone
|
191
|
-
subcondition :left=>val, :right=>right, :conj=>:or
|
192
|
-
end
|
193
|
-
|
194
|
-
|
195
|
-
def left val
|
196
|
-
restrict :left_id, val
|
197
|
-
end
|
198
|
-
|
199
|
-
def right val
|
200
|
-
restrict :right_id, val
|
201
|
-
end
|
202
|
-
|
203
|
-
def editor_of val
|
204
|
-
action_clause :actor_id, "card_actions.card_id", val
|
205
|
-
end
|
206
|
-
|
207
|
-
def edited_by val
|
208
|
-
action_clause "card_actions.card_id", :actor_id, val
|
209
|
-
end
|
210
|
-
|
211
|
-
def last_editor_of val
|
212
|
-
restrict_by_join :id, val, :return=>'updater_id'
|
213
|
-
end
|
214
|
-
|
215
|
-
def last_edited_by val
|
216
|
-
restrict :updater_id, val
|
217
|
-
end
|
218
|
-
|
219
|
-
def creator_of val
|
220
|
-
restrict_by_join :id, val, :return=>'creator_id'
|
221
|
-
end
|
222
|
-
|
223
|
-
def created_by val
|
224
|
-
restrict :creator_id, val
|
225
|
-
end
|
226
|
-
|
227
|
-
def member_of val
|
228
|
-
merge field(:right_plus) => [RolesID, {:refer_to=>val}]
|
229
|
-
end
|
230
|
-
|
231
|
-
def member val
|
232
|
-
merge field(:referred_to_by) => {:left=>val, :right=>RolesID }
|
233
|
-
end
|
234
|
-
|
235
|
-
|
236
|
-
#~~~~~~ PLUS RELATIONAL
|
237
|
-
|
238
|
-
def left_plus val
|
239
|
-
junction :left, val
|
240
|
-
end
|
241
|
-
|
242
|
-
def right_plus val
|
243
|
-
junction :right, val
|
244
|
-
end
|
245
|
-
|
246
|
-
def plus val
|
247
|
-
any( { :left_plus=>val, :right_plus=>val.deep_clone } )
|
248
|
-
end
|
249
|
-
|
250
|
-
def junction side, val
|
251
|
-
part_clause, junction_clause = val.is_a?(Array) ? val : [ val, {} ]
|
252
|
-
restrict_by_join :id, junction_clause, side=>part_clause, :return=>"#{ side==:left ? :right : :left}_id"
|
253
|
-
end
|
254
|
-
|
255
|
-
|
256
|
-
#~~~~~~~ CONJUNCTION
|
257
|
-
|
258
|
-
def and val
|
259
|
-
subcondition val
|
260
|
-
end
|
261
|
-
alias :all :and
|
262
|
-
|
263
|
-
def or val
|
264
|
-
subcondition val, :conj=>:or
|
265
|
-
end
|
266
|
-
alias :any :or
|
267
|
-
|
268
|
-
#~~~~~~ SPECIAL
|
269
|
-
|
270
|
-
|
271
|
-
def found_by val
|
272
|
-
|
273
|
-
cards = if Hash===val
|
274
|
-
Query.new(val).run
|
275
|
-
else
|
276
|
-
Array.wrap(val).map do |v|
|
277
|
-
Card.fetch absolute_name(val), :new=>{}
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
cards.each do |c|
|
282
|
-
unless c && [SearchTypeID,SetID].include?(c.type_id)
|
283
|
-
raise BadQuery, %{"found_by" value needs to be valid Search, but #{c.name} is a #{c.type_name}}
|
284
|
-
end
|
285
|
-
restrict_by_join :id, CardClause.new(c.get_query).rawclause
|
286
|
-
end
|
287
|
-
end
|
288
|
-
|
289
|
-
def not val
|
290
|
-
subselect = CardClause.build(:return=>:id, :_parent=>self).merge(val).to_sql
|
291
|
-
join_alias = add_join :not, subselect, :id, :id, :side=>'LEFT'
|
292
|
-
merge field(:cond) => SqlCond.new("#{join_alias}.id is null")
|
293
|
-
end
|
294
|
-
|
295
|
-
def sort val
|
296
|
-
return nil if @parent
|
297
|
-
val[:return] = val[:return] ? safe_sql(val[:return]) : 'db_content'
|
298
|
-
item = val.delete(:item) || 'left'
|
299
|
-
|
300
|
-
if val[:return] == 'count'
|
301
|
-
cs_args = { :return=>'count', :group=>'sort_join_field', :_parent=>self }
|
302
|
-
@mods[:sort] = "coalesce(count,0)" # needed for postgres
|
303
|
-
case item
|
304
|
-
when 'referred_to'
|
305
|
-
join_field = 'id'
|
306
|
-
cs = CardClause.build cs_args.merge( field(:cond)=>SqlCond.new("referer_id in #{CardClause.build( val.merge(:return=>'id')).to_sql}") )
|
307
|
-
cs.add_join :wr, :card_references, :id, :referee_id
|
308
|
-
else
|
309
|
-
raise BadQuery, "count with item: #{item} not yet implemented"
|
310
|
-
end
|
311
|
-
else
|
312
|
-
join_field = case item
|
313
|
-
when 'left' ; 'left_id'
|
314
|
-
when 'right' ; 'right_id'
|
315
|
-
else ; raise BadQuery, "sort item: #{item} not yet implemented"
|
316
|
-
end
|
317
|
-
cs = CardClause.build(val)
|
318
|
-
end
|
319
|
-
|
320
|
-
cs.sql.fields << "#{cs.table_alias}.#{join_field} as sort_join_field"
|
321
|
-
join_table = add_join :sort, cs.to_sql, :id, :sort_join_field, :side=>'LEFT'
|
322
|
-
@mods[:sort] ||= "#{join_table}.#{val[:return]}"
|
323
|
-
|
324
|
-
end
|
325
|
-
|
326
|
-
def match(val)
|
327
|
-
cxn, val = match_prep val
|
328
|
-
val.gsub! /[^#{Card::Name::OK4KEY_RE}]+/, ' '
|
329
|
-
return nil if val.strip.empty?
|
330
|
-
|
331
|
-
|
332
|
-
cond = begin
|
333
|
-
val_list = val.split(/\s+/).map do |v|
|
334
|
-
name_or_content = ["replace(#{self.table_alias}.name,'+',' ')","#{self.table_alias}.db_content"].map do |field|
|
335
|
-
%{#{field} #{ cxn.match quote("[[:<:]]#{v}[[:>:]]") }}
|
336
|
-
end
|
337
|
-
"(#{name_or_content.join ' OR '})"
|
338
|
-
end
|
339
|
-
"(#{val_list.join ' AND '})"
|
340
|
-
end
|
341
|
-
|
342
|
-
merge field(:cond)=>SqlCond.new(cond)
|
343
|
-
end
|
344
|
-
|
345
|
-
|
346
|
-
def complete(val)
|
347
|
-
no_plus_card = (val=~/\+/ ? '' : "and right_id is null") #FIXME -- this should really be more nuanced -- it breaks down after one plus
|
348
|
-
merge field(:cond) => SqlCond.new(" lower(name) LIKE lower(#{quote(val.to_s+'%')}) #{no_plus_card}")
|
349
|
-
end
|
350
|
-
|
351
|
-
def extension_type val
|
352
|
-
# DEPRECATED LONG AGO!!!
|
353
|
-
Rails.logger.info "using DEPRECATED extension_type in WQL"
|
354
|
-
merge field(:right_plus) => AccountID
|
355
|
-
end
|
356
|
-
|
357
|
-
|
358
|
-
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
359
|
-
# ATTRIBUTE METHOD HELPERS - called by attribute methods above
|
360
|
-
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
361
|
-
|
362
|
-
|
363
|
-
def table_alias
|
364
|
-
case
|
365
|
-
when @mods[:return]=='condition'
|
366
|
-
@parent ? @parent.table_alias : "t"
|
367
|
-
when @parent
|
368
|
-
@parent.table_alias + "x"
|
369
|
-
else
|
370
|
-
"t"
|
371
|
-
end
|
372
|
-
end
|
373
|
-
|
374
|
-
def add_join(name, table, cardfield, otherfield, opts={})
|
375
|
-
root.join_count = root.join_count.to_i + 1
|
376
|
-
join_alias = "#{name}_#{root.join_count}"
|
377
|
-
on = "#{table_alias}.#{cardfield} = #{join_alias}.#{otherfield}"
|
378
|
-
#is_subselect = !table.is_a?( Symbol )
|
379
|
-
|
380
|
-
if @mods[:conj] == 'or' #and is_subselect
|
381
|
-
opts[:side] ||= 'LEFT'
|
382
|
-
merge field(:cond) => SqlCond.new(on)
|
383
|
-
end
|
384
|
-
@joins[join_alias] = ["\n ", opts[:side], 'JOIN', table, 'AS', join_alias, 'ON', on, "\n"].compact.join ' '
|
385
|
-
join_alias
|
386
|
-
end
|
387
|
-
|
388
|
-
def field name
|
389
|
-
@fields ||= {}
|
390
|
-
@fields[name] ||= 0
|
391
|
-
@fields[name] += 1
|
392
|
-
"#{ name }_#{ @fields[name] }"
|
393
|
-
end
|
394
|
-
|
395
|
-
def field_root key
|
396
|
-
key.to_s.gsub /\_\d+/, ''
|
397
|
-
end
|
398
|
-
|
399
|
-
def subcondition(val, args={})
|
400
|
-
args = { :return=>:condition, :_parent=>self }.merge(args)
|
401
|
-
cardclause = CardClause.build( args )
|
402
|
-
merge field(:cond) => cardclause.merge(val)
|
403
|
-
self.joins.merge! cardclause.joins
|
404
|
-
end
|
405
|
-
|
406
|
-
def action_clause(field, linkfield, val)
|
407
|
-
card_select = CardClause.build(:_parent=>self, :return=>'id').merge(val).to_sql
|
408
|
-
sql = "(SELECT DISTINCT #{field} AS join_card_id FROM card_acts INNER JOIN card_actions ON card_acts.id = card_act_id "
|
409
|
-
sql += " JOIN (#{card_select}) AS ss ON #{linkfield}=ss.id AND (draft is not true))"
|
410
|
-
add_join :ac, sql, :id, :join_card_id
|
411
|
-
end
|
412
|
-
|
413
|
-
def id_from_clause clause
|
414
|
-
case clause
|
415
|
-
when Integer ; clause
|
416
|
-
when String ; Card.fetch_id(clause)
|
417
|
-
end
|
418
|
-
end
|
419
|
-
|
420
|
-
def restrict id_field, val, opts={}
|
421
|
-
if id = id_from_clause(val)
|
422
|
-
merge field(id_field) => id
|
423
|
-
else
|
424
|
-
restrict_by_join id_field, val, opts
|
425
|
-
end
|
426
|
-
end
|
427
|
-
|
428
|
-
def restrict_by_join id_field, val, opts={}
|
429
|
-
opts.reverse_merge!(:return=>:id, :_parent=>self)
|
430
|
-
subselect = CardClause.build(opts).merge(val).to_sql
|
431
|
-
add_join "card_#{id_field}", subselect, id_field, opts[:return]
|
432
|
-
end
|
433
|
-
|
434
|
-
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
435
|
-
# SQL GENERATION - translate merged hash into complete SQL statement.
|
436
|
-
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
437
|
-
|
438
|
-
|
439
|
-
def to_sql *args
|
440
|
-
sql.conditions << basic_conditions
|
441
|
-
|
442
|
-
if @mods[:return]=='condition'
|
443
|
-
conds = sql.conditions.last
|
444
|
-
return conds.blank? ? nil : "(#{conds})"
|
445
|
-
end
|
446
|
-
|
447
|
-
if pconds = permission_conditions
|
448
|
-
sql.conditions << pconds
|
449
|
-
end
|
450
|
-
|
451
|
-
sql.fields.unshift fields_to_sql
|
452
|
-
sql.order = sort_to_sql # has side effects!
|
453
|
-
sql.tables = "cards #{table_alias}"
|
454
|
-
sql.joins += @joins.values
|
455
|
-
|
456
|
-
sql.conditions << "#{table_alias}.trash is false"
|
457
|
-
|
458
|
-
sql.group = "GROUP BY #{safe_sql(@mods[:group])}" if !@mods[:group].blank?
|
459
|
-
unless @parent or @mods[:return]=='count'
|
460
|
-
if @mods[:limit].to_i > 0
|
461
|
-
sql.limit = "LIMIT #{ @mods[:limit ].to_i }"
|
462
|
-
sql.offset = "OFFSET #{ @mods[:offset].to_i }" if !@mods[:offset].blank?
|
463
|
-
end
|
464
|
-
end
|
465
|
-
|
466
|
-
sql.to_s
|
467
|
-
end
|
468
|
-
|
469
|
-
def basic_conditions
|
470
|
-
@clause.map { |key, val| val.to_sql field_root(key) }.compact.join " #{ current_conjunction } "
|
471
|
-
end
|
472
|
-
|
473
|
-
def current_conjunction
|
474
|
-
@mods[:conj].blank? ? :and : @mods[:conj]
|
475
|
-
end
|
476
|
-
|
477
|
-
def permission_conditions
|
478
|
-
unless Auth.always_ok? #or ( Card::Query.root_perms_only && !root? )
|
479
|
-
read_rules = Auth.as_card.read_rules
|
480
|
-
read_rule_list = read_rules.nil? ? 1 : read_rules.join(',')
|
481
|
-
"(#{table_alias}.read_rule_id IN (#{ read_rule_list }))"
|
482
|
-
end
|
483
|
-
end
|
484
|
-
|
485
|
-
def fields_to_sql
|
486
|
-
field = @mods[:return]
|
487
|
-
case (field.blank? ? :card : field.to_sym)
|
488
|
-
when :raw; "#{table_alias}.*"
|
489
|
-
when :card; "#{table_alias}.name"
|
490
|
-
when :count; "coalesce(count(*),0) as count"
|
491
|
-
when :content; "#{table_alias}.db_content"
|
492
|
-
else
|
493
|
-
ATTRIBUTES[field.to_sym]==:basic ? "#{table_alias}.#{field}" : safe_sql(field)
|
494
|
-
end
|
495
|
-
end
|
496
|
-
|
497
|
-
def sort_to_sql
|
498
|
-
#fail "order_key = #{@mods[:sort]}, class = #{order_key.class}"
|
499
|
-
|
500
|
-
return nil if @parent or @mods[:return]=='count' #FIXME - extend to all root-only clauses
|
501
|
-
order_key ||= @mods[:sort].blank? ? "update" : @mods[:sort]
|
502
|
-
|
503
|
-
order_directives = [order_key].flatten.map do |key|
|
504
|
-
dir = @mods[:dir].blank? ? (DEFAULT_ORDER_DIRS[key.to_sym]||'asc') : safe_sql(@mods[:dir]) #wonky
|
505
|
-
sort_field key, @mods[:sort_as], dir
|
506
|
-
end.join ', '
|
507
|
-
"ORDER BY #{order_directives}"
|
508
|
-
|
509
|
-
end
|
510
|
-
|
511
|
-
def sort_field key, as, dir
|
512
|
-
order_field = case key
|
513
|
-
when "id"; "#{table_alias}.id"
|
514
|
-
when "update"; "#{table_alias}.updated_at"
|
515
|
-
when "create"; "#{table_alias}.created_at"
|
516
|
-
when /^(name|alpha)$/; "LOWER( #{table_alias}.key )"
|
517
|
-
when 'content'; "#{table_alias}.db_content"
|
518
|
-
when "relevance"; "#{table_alias}.updated_at" #deprecated
|
519
|
-
else
|
520
|
-
safe_sql(key)
|
521
|
-
end
|
522
|
-
order_field = "CAST(#{order_field} AS #{cast_type(as)})" if as
|
523
|
-
"#{order_field} #{dir}"
|
524
|
-
|
525
|
-
end
|
526
|
-
end
|
527
|
-
end
|
528
|
-
end
|