card 1.16.1 → 1.16.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (372) hide show
  1. checksums.yaml +4 -4
  2. data/.yardoc/checksums +60 -0
  3. data/.yardoc/object_types +0 -0
  4. data/.yardoc/objects/root.dat +0 -0
  5. data/.yardoc/proxy_types +0 -0
  6. data/.yardopts +6 -0
  7. data/README_Developers.rdoc +100 -0
  8. data/VERSION +1 -1
  9. data/card.gemspec +18 -18
  10. data/db/migrate/20150724210803_add_comment_to_actions.rb +5 -0
  11. data/db/migrate_core_cards/20150724123438_update_file_and_image_cards.rb +70 -0
  12. data/db/migrate_core_cards/20150807205221_create_references_for_search_cards.rb +10 -0
  13. data/db/migrate_core_cards/data/1.12_stylesheets/common.scss +4 -2
  14. data/db/schema.rb +2 -1
  15. data/db/seed/new/card_actions.yml +2334 -12538
  16. data/db/seed/new/card_acts.yml +1 -1
  17. data/db/seed/new/card_changes.yml +7384 -38929
  18. data/db/seed/new/card_references.yml +207 -207
  19. data/db/seed/new/cards.yml +1364 -1440
  20. data/db/seed/test/fixtures/card_actions.yml +3285 -13219
  21. data/db/seed/test/fixtures/card_acts.yml +107 -107
  22. data/db/seed/test/fixtures/card_changes.yml +10830 -42375
  23. data/db/seed/test/fixtures/card_references.yml +393 -393
  24. data/db/seed/test/fixtures/cards.yml +1701 -1777
  25. data/db/version.txt +1 -1
  26. data/db/version_core_cards.txt +1 -1
  27. data/lib/card.rb +13 -3
  28. data/lib/card/chunk.rb +22 -15
  29. data/lib/card/content.rb +9 -8
  30. data/lib/card/diff.rb +79 -79
  31. data/lib/card/loader.rb +33 -33
  32. data/lib/card/name.rb +8 -0
  33. data/lib/card/set.rb +44 -17
  34. data/lib/card/set_pattern.rb +8 -0
  35. data/lib/cardio.rb +19 -3
  36. data/mod/01_core/chunk/link.rb +7 -6
  37. data/mod/01_core/chunk/query_reference.rb +65 -0
  38. data/mod/01_core/set/all/content.rb +1 -1
  39. data/mod/01_core/set/all/fetch.rb +15 -7
  40. data/mod/01_core/set/all/initialize.rb +4 -3
  41. data/mod/01_core/set/all/phases.rb +12 -8
  42. data/mod/01_core/set/all/references.rb +12 -6
  43. data/mod/01_core/set/all/rules.rb +14 -11
  44. data/mod/01_core/set/all/states.rb +2 -1
  45. data/mod/01_core/set/all/tracked_attributes.rb +14 -0
  46. data/mod/01_core/spec/set/all/collection_spec.rb +5 -5
  47. data/mod/01_core/spec/set/all/name_spec.rb +6 -6
  48. data/mod/01_history/lib/card/act.rb +2 -2
  49. data/mod/01_history/lib/card/action.rb +11 -2
  50. data/mod/01_history/set/all/actions.rb +4 -3
  51. data/mod/01_history/set/all/content_history.rb +1 -1
  52. data/mod/01_history/set/all/history.rb +55 -66
  53. data/mod/02_basic_types/set/all/file.rb +26 -3
  54. data/mod/02_basic_types/set/type/pointer.rb +13 -14
  55. data/mod/02_basic_types/spec/set/all/file_spec.rb +0 -1
  56. data/mod/03_machines/lib/card/machine.rb +4 -4
  57. data/mod/03_machines/lib/javascript/wagn_mod.js.coffee +4 -17
  58. data/mod/03_machines/lib/stylesheets/style_cards.scss +5 -0
  59. data/mod/03_machines/set/right/machine_input.rb +3 -0
  60. data/mod/03_machines/set/right/machine_output.rb +4 -0
  61. data/mod/04_settings/lib/card/setting.rb +2 -1
  62. data/mod/04_settings/set/abstract/permission.rb +95 -0
  63. data/mod/04_settings/set/right/comment.rb +2 -90
  64. data/mod/04_settings/set/right/create.rb +2 -2
  65. data/mod/04_settings/set/right/delete.rb +2 -3
  66. data/mod/04_settings/set/right/read.rb +3 -2
  67. data/mod/04_settings/set/right/update.rb +3 -2
  68. data/mod/04_settings/set/self/recent_settings.rb +3 -0
  69. data/mod/04_settings/set/type/setting.rb +9 -1
  70. data/mod/05_email/set/all/notify.rb +2 -1
  71. data/mod/05_email/set/type/email_template.rb +17 -17
  72. data/mod/05_standard/file/credit_image/image-icon.png +0 -0
  73. data/mod/05_standard/file/credit_image/image-large.png +0 -0
  74. data/mod/05_standard/file/credit_image/image-medium.png +0 -0
  75. data/mod/05_standard/file/credit_image/image-original.png +0 -0
  76. data/mod/05_standard/file/credit_image/image-small.png +0 -0
  77. data/mod/05_standard/file/favicon/{icon-image.png → image-icon.png} +0 -0
  78. data/mod/05_standard/file/favicon/{large-image.png → image-large.png} +0 -0
  79. data/mod/05_standard/file/favicon/{medium-image.png → image-medium.png} +0 -0
  80. data/mod/05_standard/file/favicon/{original-image.png → image-original.png} +0 -0
  81. data/mod/05_standard/file/favicon/{small-image.png → image-small.png} +0 -0
  82. data/mod/05_standard/file/logo/{icon-image.png → image-icon.png} +0 -0
  83. data/mod/05_standard/file/logo/{large-image.png → image-large.png} +0 -0
  84. data/mod/05_standard/file/logo/{medium-image.png → image-medium.png} +0 -0
  85. data/mod/05_standard/file/logo/{original-image.png → image-original.png} +0 -0
  86. data/mod/05_standard/file/logo/{small-image.png → image-small.png} +0 -0
  87. data/mod/05_standard/lib/carrier_wave/cardmount.rb +79 -0
  88. data/mod/05_standard/lib/file_uploader.rb +127 -0
  89. data/mod/05_standard/lib/image_uploader.rb +35 -0
  90. data/mod/05_standard/set/abstract/attachment.rb +85 -0
  91. data/mod/05_standard/set/all/error.rb +1 -18
  92. data/mod/05_standard/set/all/event_viz.rb +17 -14
  93. data/mod/05_standard/set/all/rich_html/editing.rb +10 -10
  94. data/mod/05_standard/set/all/rich_html/toolbar.rb +44 -37
  95. data/mod/05_standard/set/right/account.rb +1 -1
  96. data/mod/05_standard/set/right/password.rb +9 -10
  97. data/mod/05_standard/set/self/recent.rb +1 -1
  98. data/mod/05_standard/set/type/file.rb +43 -31
  99. data/mod/05_standard/set/type/image.rb +22 -6
  100. data/mod/05_standard/set/type/search_type.rb +4 -2
  101. data/mod/05_standard/set/type/session.rb +7 -5
  102. data/mod/05_standard/set/type/set.rb +3 -1
  103. data/mod/05_standard/spec/set/all/history_spec.rb +1 -1
  104. data/mod/05_standard/spec/set/type/cardtype_spec.rb +3 -3
  105. data/mod/05_standard/spec/set/type/file_spec.rb +85 -1
  106. data/mod/05_standard/spec/set/type/image_spec.rb +89 -5
  107. data/mod/05_standard/spec/set/type/search_type_spec.rb +16 -1
  108. data/mod/06_bootstrap/file/{cerulean_skin/icon-image.png → cerulean_skin_image/image-icon.png} +0 -0
  109. data/mod/06_bootstrap/file/{cerulean_skin/large-image.png → cerulean_skin_image/image-large.png} +0 -0
  110. data/mod/06_bootstrap/file/{cerulean_skin/medium-image.png → cerulean_skin_image/image-medium.png} +0 -0
  111. data/mod/06_bootstrap/file/{cerulean_skin/original-image.png → cerulean_skin_image/image-original.png} +0 -0
  112. data/mod/06_bootstrap/file/{cerulean_skin/small-image.png → cerulean_skin_image/image-small.png} +0 -0
  113. data/mod/06_bootstrap/file/{cosmo_skin/icon-image.png → cosmo_skin_image/image-icon.png} +0 -0
  114. data/mod/06_bootstrap/file/{cosmo_skin/large-image.png → cosmo_skin_image/image-large.png} +0 -0
  115. data/mod/06_bootstrap/file/{cosmo_skin/medium-image.png → cosmo_skin_image/image-medium.png} +0 -0
  116. data/mod/06_bootstrap/file/{cosmo_skin/original-image.png → cosmo_skin_image/image-original.png} +0 -0
  117. data/mod/06_bootstrap/file/{cosmo_skin/small-image.png → cosmo_skin_image/image-small.png} +0 -0
  118. data/mod/06_bootstrap/file/{cyborg_skin/icon-image.png → cyborg_skin_image/image-icon.png} +0 -0
  119. data/mod/06_bootstrap/file/{cyborg_skin/large-image.png → cyborg_skin_image/image-large.png} +0 -0
  120. data/mod/06_bootstrap/file/{cyborg_skin/medium-image.png → cyborg_skin_image/image-medium.png} +0 -0
  121. data/mod/06_bootstrap/file/{cyborg_skin/original-image.png → cyborg_skin_image/image-original.png} +0 -0
  122. data/mod/06_bootstrap/file/{cyborg_skin/small-image.png → cyborg_skin_image/image-small.png} +0 -0
  123. data/mod/06_bootstrap/file/{darkly_skin/icon-image.png → darkly_skin_image/image-icon.png} +0 -0
  124. data/mod/06_bootstrap/file/{darkly_skin/large-image.png → darkly_skin_image/image-large.png} +0 -0
  125. data/mod/06_bootstrap/file/{darkly_skin/medium-image.png → darkly_skin_image/image-medium.png} +0 -0
  126. data/mod/06_bootstrap/file/{darkly_skin/original-image.png → darkly_skin_image/image-original.png} +0 -0
  127. data/mod/06_bootstrap/file/{darkly_skin/small-image.png → darkly_skin_image/image-small.png} +0 -0
  128. data/mod/06_bootstrap/file/{flatly_skin/icon-image.png → flatly_skin_image/image-icon.png} +0 -0
  129. data/mod/06_bootstrap/file/{flatly_skin/large-image.png → flatly_skin_image/image-large.png} +0 -0
  130. data/mod/06_bootstrap/file/{flatly_skin/medium-image.png → flatly_skin_image/image-medium.png} +0 -0
  131. data/mod/06_bootstrap/file/{flatly_skin/original-image.png → flatly_skin_image/image-original.png} +0 -0
  132. data/mod/06_bootstrap/file/{flatly_skin/small-image.png → flatly_skin_image/image-small.png} +0 -0
  133. data/mod/06_bootstrap/file/{journal_skin/icon-image.png → journal_skin_image/image-icon.png} +0 -0
  134. data/mod/06_bootstrap/file/{journal_skin/large-image.png → journal_skin_image/image-large.png} +0 -0
  135. data/mod/06_bootstrap/file/{journal_skin/medium-image.png → journal_skin_image/image-medium.png} +0 -0
  136. data/mod/06_bootstrap/file/{journal_skin/original-image.png → journal_skin_image/image-original.png} +0 -0
  137. data/mod/06_bootstrap/file/{journal_skin/small-image.png → journal_skin_image/image-small.png} +0 -0
  138. data/mod/06_bootstrap/file/{lumen_skin/icon-image.png → lumen_skin_image/image-icon.png} +0 -0
  139. data/mod/06_bootstrap/file/{lumen_skin/large-image.png → lumen_skin_image/image-large.png} +0 -0
  140. data/mod/06_bootstrap/file/{lumen_skin/medium-image.png → lumen_skin_image/image-medium.png} +0 -0
  141. data/mod/06_bootstrap/file/{lumen_skin/original-image.png → lumen_skin_image/image-original.png} +0 -0
  142. data/mod/06_bootstrap/file/{lumen_skin/small-image.png → lumen_skin_image/image-small.png} +0 -0
  143. data/mod/06_bootstrap/file/{paper_skin/icon-image.png → paper_skin_image/image-icon.png} +0 -0
  144. data/mod/06_bootstrap/file/{paper_skin/large-image.png → paper_skin_image/image-large.png} +0 -0
  145. data/mod/06_bootstrap/file/{paper_skin/medium-image.png → paper_skin_image/image-medium.png} +0 -0
  146. data/mod/06_bootstrap/file/{paper_skin/original-image.png → paper_skin_image/image-original.png} +0 -0
  147. data/mod/06_bootstrap/file/{paper_skin/small-image.png → paper_skin_image/image-small.png} +0 -0
  148. data/mod/06_bootstrap/file/{readable_skin/icon-image.png → readable_skin_image/image-icon.png} +0 -0
  149. data/mod/06_bootstrap/file/{readable_skin/large-image.png → readable_skin_image/image-large.png} +0 -0
  150. data/mod/06_bootstrap/file/{readable_skin/medium-image.png → readable_skin_image/image-medium.png} +0 -0
  151. data/mod/06_bootstrap/file/{readable_skin/original-image.png → readable_skin_image/image-original.png} +0 -0
  152. data/mod/06_bootstrap/file/{readable_skin/small-image.png → readable_skin_image/image-small.png} +0 -0
  153. data/mod/06_bootstrap/file/{sandstone_skin/icon-image.png → sandstone_skin_image/image-icon.png} +0 -0
  154. data/mod/06_bootstrap/file/{sandstone_skin/large-image.png → sandstone_skin_image/image-large.png} +0 -0
  155. data/mod/06_bootstrap/file/{sandstone_skin/medium-image.png → sandstone_skin_image/image-medium.png} +0 -0
  156. data/mod/06_bootstrap/file/{sandstone_skin/original-image.png → sandstone_skin_image/image-original.png} +0 -0
  157. data/mod/06_bootstrap/file/{sandstone_skin/small-image.png → sandstone_skin_image/image-small.png} +0 -0
  158. data/mod/06_bootstrap/file/{simplex_skin/icon-image.png → simplex_skin_image/image-icon.png} +0 -0
  159. data/mod/06_bootstrap/file/{simplex_skin/large-image.png → simplex_skin_image/image-large.png} +0 -0
  160. data/mod/06_bootstrap/file/{simplex_skin/medium-image.png → simplex_skin_image/image-medium.png} +0 -0
  161. data/mod/06_bootstrap/file/{simplex_skin/original-image.png → simplex_skin_image/image-original.png} +0 -0
  162. data/mod/06_bootstrap/file/{simplex_skin/small-image.png → simplex_skin_image/image-small.png} +0 -0
  163. data/mod/06_bootstrap/file/{slate_skin/icon-image.png → slate_skin_image/image-icon.png} +0 -0
  164. data/mod/06_bootstrap/file/{slate_skin/large-image.png → slate_skin_image/image-large.png} +0 -0
  165. data/mod/06_bootstrap/file/{slate_skin/medium-image.png → slate_skin_image/image-medium.png} +0 -0
  166. data/mod/06_bootstrap/file/{slate_skin/original-image.png → slate_skin_image/image-original.png} +0 -0
  167. data/mod/06_bootstrap/file/{slate_skin/small-image.png → slate_skin_image/image-small.png} +0 -0
  168. data/mod/06_bootstrap/file/{spacelab_skin/icon-image.png → spacelab_skin_image/image-icon.png} +0 -0
  169. data/mod/06_bootstrap/file/{spacelab_skin/large-image.png → spacelab_skin_image/image-large.png} +0 -0
  170. data/mod/06_bootstrap/file/{spacelab_skin/medium-image.png → spacelab_skin_image/image-medium.png} +0 -0
  171. data/mod/06_bootstrap/file/{spacelab_skin/original-image.png → spacelab_skin_image/image-original.png} +0 -0
  172. data/mod/06_bootstrap/file/{spacelab_skin/small-image.png → spacelab_skin_image/image-small.png} +0 -0
  173. data/mod/06_bootstrap/file/{superhero_skin/icon-image.png → superhero_skin_image/image-icon.png} +0 -0
  174. data/mod/06_bootstrap/file/{superhero_skin/large-image.png → superhero_skin_image/image-large.png} +0 -0
  175. data/mod/06_bootstrap/file/{superhero_skin/medium-image.png → superhero_skin_image/image-medium.png} +0 -0
  176. data/mod/06_bootstrap/file/{superhero_skin/original-image.png → superhero_skin_image/image-original.png} +0 -0
  177. data/mod/06_bootstrap/file/{superhero_skin/small-image.png → superhero_skin_image/image-small.png} +0 -0
  178. data/mod/06_bootstrap/file/{united_skin/icon-image.png → united_skin_image/image-icon.png} +0 -0
  179. data/mod/06_bootstrap/file/{united_skin/large-image.png → united_skin_image/image-large.png} +0 -0
  180. data/mod/06_bootstrap/file/{united_skin/medium-image.png → united_skin_image/image-medium.png} +0 -0
  181. data/mod/06_bootstrap/file/{united_skin/original-image.png → united_skin_image/image-original.png} +0 -0
  182. data/mod/06_bootstrap/file/{united_skin/small-image.png → united_skin_image/image-small.png} +0 -0
  183. data/mod/06_bootstrap/file/{yeti_skin/icon-image.png → yeti_skin_image/image-icon.png} +0 -0
  184. data/mod/06_bootstrap/file/{yeti_skin/large-image.png → yeti_skin_image/image-large.png} +0 -0
  185. data/mod/06_bootstrap/file/{yeti_skin/medium-image.png → yeti_skin_image/image-medium.png} +0 -0
  186. data/mod/06_bootstrap/file/{yeti_skin/original-image.png → yeti_skin_image/image-original.png} +0 -0
  187. data/mod/06_bootstrap/file/{yeti_skin/small-image.png → yeti_skin_image/image-small.png} +0 -0
  188. data/mod/06_bootstrap/lib/stylesheets/bootstrap_cards.scss +5 -3
  189. data/spec/lib/card/reference_spec.rb +8 -1
  190. data/tmpsets/README.md +2 -0
  191. data/tmpsets/set/mod001-01_core/all/active_card.rb +40 -0
  192. data/tmpsets/set/mod001-01_core/all/collection.rb +348 -0
  193. data/tmpsets/set/mod001-01_core/all/content.rb +68 -0
  194. data/tmpsets/set/mod001-01_core/all/erb.rb +17 -0
  195. data/tmpsets/set/mod001-01_core/all/fetch.rb +242 -0
  196. data/tmpsets/set/mod001-01_core/all/haml.rb +13 -0
  197. data/tmpsets/set/mod001-01_core/all/initialize.rb +56 -0
  198. data/tmpsets/set/mod001-01_core/all/name.rb +279 -0
  199. data/tmpsets/set/mod001-01_core/all/pattern.rb +62 -0
  200. data/tmpsets/set/mod001-01_core/all/permissions.rb +289 -0
  201. data/tmpsets/set/mod001-01_core/all/phases.rb +187 -0
  202. data/tmpsets/set/mod001-01_core/all/references.rb +130 -0
  203. data/tmpsets/set/mod001-01_core/all/rules.rb +324 -0
  204. data/tmpsets/set/mod001-01_core/all/states.rb +28 -0
  205. data/tmpsets/set/mod001-01_core/all/templating.rb +132 -0
  206. data/tmpsets/set/mod001-01_core/all/tracked_attributes.rb +136 -0
  207. data/tmpsets/set/mod001-01_core/all/trash.rb +56 -0
  208. data/tmpsets/set/mod001-01_core/all/type.rb +91 -0
  209. data/tmpsets/set/mod001-01_core/all/utils.rb +162 -0
  210. data/tmpsets/set/mod001-01_core/all/view_cache.rb +14 -0
  211. data/tmpsets/set/mod002-01_history/all/actions.rb +54 -0
  212. data/tmpsets/set/mod002-01_history/all/content_history.rb +140 -0
  213. data/tmpsets/set/mod002-01_history/all/history.rb +341 -0
  214. data/tmpsets/set/mod003-02_basic_types/all/all_css.rb +48 -0
  215. data/tmpsets/set/mod003-02_basic_types/all/all_csv.rb +58 -0
  216. data/tmpsets/set/mod003-02_basic_types/all/all_js.rb +13 -0
  217. data/tmpsets/set/mod003-02_basic_types/all/base.rb +128 -0
  218. data/tmpsets/set/mod003-02_basic_types/all/file.rb +42 -0
  219. data/tmpsets/set/mod003-02_basic_types/all/json.rb +72 -0
  220. data/tmpsets/set/mod003-02_basic_types/all/rss.rb +78 -0
  221. data/tmpsets/set/mod003-02_basic_types/all/text.rb +14 -0
  222. data/tmpsets/set/mod003-02_basic_types/type/html.rb +33 -0
  223. data/tmpsets/set/mod003-02_basic_types/type/plain_text.rb +16 -0
  224. data/tmpsets/set/mod003-02_basic_types/type/pointer.rb +358 -0
  225. data/tmpsets/set/mod004-03_machines/right/machine_input.rb +8 -0
  226. data/tmpsets/set/mod004-03_machines/right/machine_output.rb +30 -0
  227. data/tmpsets/set/mod004-03_machines/self/script_ace.rb +18 -0
  228. data/tmpsets/set/mod004-03_machines/self/script_card_menu.rb +17 -0
  229. data/tmpsets/set/mod004-03_machines/self/script_html5shiv_printshiv.rb +8 -0
  230. data/tmpsets/set/mod004-03_machines/self/script_jquery.rb +8 -0
  231. data/tmpsets/set/mod004-03_machines/self/script_jquery_helper.rb +18 -0
  232. data/tmpsets/set/mod004-03_machines/self/script_slot.rb +13 -0
  233. data/tmpsets/set/mod004-03_machines/self/script_tinymce.rb +8 -0
  234. data/tmpsets/set/mod004-03_machines/self/style_bootstrap_compatible.rb +11 -0
  235. data/tmpsets/set/mod004-03_machines/self/style_cards.rb +12 -0
  236. data/tmpsets/set/mod004-03_machines/self/style_jquery_ui_smoothness.rb +9 -0
  237. data/tmpsets/set/mod004-03_machines/type/coffee_script.rb +67 -0
  238. data/tmpsets/set/mod004-03_machines/type/css.rb +55 -0
  239. data/tmpsets/set/mod004-03_machines/type/java_script.rb +43 -0
  240. data/tmpsets/set/mod004-03_machines/type/scss.rb +28 -0
  241. data/tmpsets/set/mod004-03_machines/type/skin.rb +18 -0
  242. data/tmpsets/set/mod005-04_settings/abstract/permission.rb +101 -0
  243. data/tmpsets/set/mod005-04_settings/right/add_help.rb +17 -0
  244. data/tmpsets/set/mod005-04_settings/right/comment.rb +9 -0
  245. data/tmpsets/set/mod005-04_settings/right/create.rb +9 -0
  246. data/tmpsets/set/mod005-04_settings/right/default.rb +9 -0
  247. data/tmpsets/set/mod005-04_settings/right/delete.rb +9 -0
  248. data/tmpsets/set/mod005-04_settings/right/help.rb +9 -0
  249. data/tmpsets/set/mod005-04_settings/right/read.rb +9 -0
  250. data/tmpsets/set/mod005-04_settings/right/script.rb +16 -0
  251. data/tmpsets/set/mod005-04_settings/right/structure.rb +16 -0
  252. data/tmpsets/set/mod005-04_settings/right/style.rb +16 -0
  253. data/tmpsets/set/mod005-04_settings/right/update.rb +9 -0
  254. data/tmpsets/set/mod005-04_settings/self/accountable.rb +9 -0
  255. data/tmpsets/set/mod005-04_settings/self/add_help.rb +8 -0
  256. data/tmpsets/set/mod005-04_settings/self/autoname.rb +8 -0
  257. data/tmpsets/set/mod005-04_settings/self/captcha.rb +8 -0
  258. data/tmpsets/set/mod005-04_settings/self/create.rb +8 -0
  259. data/tmpsets/set/mod005-04_settings/self/default.rb +8 -0
  260. data/tmpsets/set/mod005-04_settings/self/delete.rb +8 -0
  261. data/tmpsets/set/mod005-04_settings/self/help.rb +8 -0
  262. data/tmpsets/set/mod005-04_settings/self/input.rb +7 -0
  263. data/tmpsets/set/mod005-04_settings/self/layout.rb +8 -0
  264. data/tmpsets/set/mod005-04_settings/self/on_create.rb +8 -0
  265. data/tmpsets/set/mod005-04_settings/self/on_delete.rb +8 -0
  266. data/tmpsets/set/mod005-04_settings/self/on_update.rb +8 -0
  267. data/tmpsets/set/mod005-04_settings/self/options.rb +8 -0
  268. data/tmpsets/set/mod005-04_settings/self/options_label.rb +8 -0
  269. data/tmpsets/set/mod005-04_settings/self/read.rb +8 -0
  270. data/tmpsets/set/mod005-04_settings/self/recent_settings.rb +8 -0
  271. data/tmpsets/set/mod005-04_settings/self/script.rb +8 -0
  272. data/tmpsets/set/mod005-04_settings/self/structure.rb +8 -0
  273. data/tmpsets/set/mod005-04_settings/self/style.rb +8 -0
  274. data/tmpsets/set/mod005-04_settings/self/table_of_contents.rb +8 -0
  275. data/tmpsets/set/mod005-04_settings/self/thanks.rb +8 -0
  276. data/tmpsets/set/mod005-04_settings/self/update.rb +8 -0
  277. data/tmpsets/set/mod005-04_settings/type/setting.rb +96 -0
  278. data/tmpsets/set/mod006-05_email/all/email_html.rb +11 -0
  279. data/tmpsets/set/mod006-05_email/all/email_text.rb +11 -0
  280. data/tmpsets/set/mod006-05_email/all/follow.rb +260 -0
  281. data/tmpsets/set/mod006-05_email/all/notify.rb +244 -0
  282. data/tmpsets/set/mod006-05_email/all/observer.rb +33 -0
  283. data/tmpsets/set/mod006-05_email/right/bcc.rb +51 -0
  284. data/tmpsets/set/mod006-05_email/right/cc.rb +9 -0
  285. data/tmpsets/set/mod006-05_email/right/follow.rb +90 -0
  286. data/tmpsets/set/mod006-05_email/right/follow_fields.rb +8 -0
  287. data/tmpsets/set/mod006-05_email/right/followers.rb +35 -0
  288. data/tmpsets/set/mod006-05_email/right/following.rb +58 -0
  289. data/tmpsets/set/mod006-05_email/right/from.rb +9 -0
  290. data/tmpsets/set/mod006-05_email/right/html_message.rb +9 -0
  291. data/tmpsets/set/mod006-05_email/right/to.rb +9 -0
  292. data/tmpsets/set/mod006-05_email/self/always.rb +20 -0
  293. data/tmpsets/set/mod006-05_email/self/created.rb +27 -0
  294. data/tmpsets/set/mod006-05_email/self/edited.rb +30 -0
  295. data/tmpsets/set/mod006-05_email/self/follow.rb +8 -0
  296. data/tmpsets/set/mod006-05_email/self/follow_defaults.rb +71 -0
  297. data/tmpsets/set/mod006-05_email/self/never.rb +21 -0
  298. data/tmpsets/set/mod006-05_email/type/email_template.rb +119 -0
  299. data/tmpsets/set/mod006-05_email/type_plus_right/user/follow.rb +182 -0
  300. data/tmpsets/set/mod007-05_standard/abstract/attachment.rb +91 -0
  301. data/tmpsets/set/mod007-05_standard/all/account.rb +73 -0
  302. data/tmpsets/set/mod007-05_standard/all/comment.rb +45 -0
  303. data/tmpsets/set/mod007-05_standard/all/error.rb +198 -0
  304. data/tmpsets/set/mod007-05_standard/all/event_viz.rb +75 -0
  305. data/tmpsets/set/mod007-05_standard/all/links.rb +153 -0
  306. data/tmpsets/set/mod007-05_standard/all/rich_html/content.rb +248 -0
  307. data/tmpsets/set/mod007-05_standard/all/rich_html/editing.rb +216 -0
  308. data/tmpsets/set/mod007-05_standard/all/rich_html/form.rb +238 -0
  309. data/tmpsets/set/mod007-05_standard/all/rich_html/header.rb +80 -0
  310. data/tmpsets/set/mod007-05_standard/all/rich_html/menu.rb +135 -0
  311. data/tmpsets/set/mod007-05_standard/all/rich_html/modal.rb +98 -0
  312. data/tmpsets/set/mod007-05_standard/all/rich_html/toolbar.rb +271 -0
  313. data/tmpsets/set/mod007-05_standard/all/rich_html/wrapper.rb +158 -0
  314. data/tmpsets/set/mod007-05_standard/right/account.rb +187 -0
  315. data/tmpsets/set/mod007-05_standard/right/discussion.rb +9 -0
  316. data/tmpsets/set/mod007-05_standard/right/email.rb +57 -0
  317. data/tmpsets/set/mod007-05_standard/right/password.rb +44 -0
  318. data/tmpsets/set/mod007-05_standard/right/salt.rb +11 -0
  319. data/tmpsets/set/mod007-05_standard/right/stats.rb +41 -0
  320. data/tmpsets/set/mod007-05_standard/right/status.rb +15 -0
  321. data/tmpsets/set/mod007-05_standard/right/token.rb +11 -0
  322. data/tmpsets/set/mod007-05_standard/right/when_created.rb +11 -0
  323. data/tmpsets/set/mod007-05_standard/right/when_last_edited.rb +11 -0
  324. data/tmpsets/set/mod007-05_standard/rstar/rules.rb +411 -0
  325. data/tmpsets/set/mod007-05_standard/self/account_links.rb +55 -0
  326. data/tmpsets/set/mod007-05_standard/self/alerts.rb +11 -0
  327. data/tmpsets/set/mod007-05_standard/self/all.rb +28 -0
  328. data/tmpsets/set/mod007-05_standard/self/foot.rb +14 -0
  329. data/tmpsets/set/mod007-05_standard/self/head.rb +126 -0
  330. data/tmpsets/set/mod007-05_standard/self/navbox.rb +39 -0
  331. data/tmpsets/set/mod007-05_standard/self/now.rb +12 -0
  332. data/tmpsets/set/mod007-05_standard/self/performance_log.rb +98 -0
  333. data/tmpsets/set/mod007-05_standard/self/recent.rb +54 -0
  334. data/tmpsets/set/mod007-05_standard/self/search.rb +49 -0
  335. data/tmpsets/set/mod007-05_standard/self/signin.rb +130 -0
  336. data/tmpsets/set/mod007-05_standard/self/stats.rb +109 -0
  337. data/tmpsets/set/mod007-05_standard/self/version.rb +15 -0
  338. data/tmpsets/set/mod007-05_standard/type/basic.rb +52 -0
  339. data/tmpsets/set/mod007-05_standard/type/cardtype.rb +78 -0
  340. data/tmpsets/set/mod007-05_standard/type/date.rb +14 -0
  341. data/tmpsets/set/mod007-05_standard/type/file.rb +103 -0
  342. data/tmpsets/set/mod007-05_standard/type/image.rb +89 -0
  343. data/tmpsets/set/mod007-05_standard/type/layout_type.rb +21 -0
  344. data/tmpsets/set/mod007-05_standard/type/number.rb +25 -0
  345. data/tmpsets/set/mod007-05_standard/type/phrase.rb +9 -0
  346. data/tmpsets/set/mod007-05_standard/type/search_type.rb +291 -0
  347. data/tmpsets/set/mod007-05_standard/type/session.rb +42 -0
  348. data/tmpsets/set/mod007-05_standard/type/set.rb +354 -0
  349. data/tmpsets/set/mod007-05_standard/type/signup.rb +150 -0
  350. data/tmpsets/set/mod007-05_standard/type/toggle.rb +18 -0
  351. data/tmpsets/set/mod007-05_standard/type/uri.rb +17 -0
  352. data/tmpsets/set/mod007-05_standard/type/user.rb +78 -0
  353. data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/form.rb +41 -0
  354. data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/helper.rb +150 -0
  355. data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/wrapper.rb +18 -0
  356. data/tmpsets/set/mod008-06_bootstrap/all/rich_bootstrap.rb +14 -0
  357. data/tmpsets/set/mod008-06_bootstrap/self/bootstrap_cards.rb +15 -0
  358. data/tmpsets/set/mod008-06_bootstrap/self/bootstrap_js.rb +13 -0
  359. data/tmpsets/set/mod008-06_bootstrap/self/bootswatch_shared.rb +38 -0
  360. data/tmpsets/set/mod008-06_bootstrap/self/smartmenu_css.rb +13 -0
  361. data/tmpsets/set/mod008-06_bootstrap/self/smartmenu_js.rb +12 -0
  362. data/tmpsets/set_pattern/100-all.rb +24 -0
  363. data/tmpsets/set_pattern/101-all_plus.rb +26 -0
  364. data/tmpsets/set_pattern/102-type.rb +36 -0
  365. data/tmpsets/set_pattern/103-star.rb +28 -0
  366. data/tmpsets/set_pattern/104-rstar.rb +30 -0
  367. data/tmpsets/set_pattern/105-right.rb +33 -0
  368. data/tmpsets/set_pattern/106-type_plus_right.rb +36 -0
  369. data/tmpsets/set_pattern/107-self.rb +32 -0
  370. metadata +306 -107
  371. data/mod/05_standard/set/all/attach.rb +0 -164
  372. data/mod/05_standard/spec/set/all/attach_spec.rb +0 -9
data/db/version.txt CHANGED
@@ -1 +1 @@
1
- 20141216053032
1
+ 20150724210803
@@ -1 +1 @@
1
- 20150702130543
1
+ 20150724123438
data/lib/card.rb CHANGED
@@ -1,7 +1,15 @@
1
1
  # -*- encoding : utf-8 -*-
2
+ require 'carrierwave'
2
3
 
3
4
  Object.send :remove_const, :Card if Object.send(:const_defined?, :Card)
4
5
 
6
+ # This documentation is intended for developers who want to understand:
7
+ #
8
+ # a. how ruby Card objects work, and
9
+ # b. how to extend them.
10
+ #
11
+ # It assumes that you've already read the introductory text in {file:README_Developers.rdoc}.
12
+ #
5
13
  class Card < ActiveRecord::Base
6
14
 
7
15
  # attributes that ActiveJob can handle
@@ -11,6 +19,7 @@ class Card < ActiveRecord::Base
11
19
  end
12
20
 
13
21
 
22
+
14
23
  require_dependency 'card/active_record_ext'
15
24
  require_dependency 'card/codename'
16
25
  require_dependency 'card/query'
@@ -31,7 +40,7 @@ class Card < ActiveRecord::Base
31
40
  has_many :actions, -> { where( :draft=>[nil,false]).order :id }
32
41
  has_many :drafts, -> { where( :draft=>true ).order :id }, :class_name=> :Action
33
42
 
34
- cattr_accessor :set_patterns, :error_codes, :serializable_attributes
43
+ cattr_accessor :set_patterns, :error_codes, :serializable_attributes, :set_specific_attributes
35
44
  @@set_patterns, @@error_codes = [], {}
36
45
 
37
46
  serializable_attr_accessor :action, :supercard, :current_act, :current_action,
@@ -43,16 +52,17 @@ class Card < ActiveRecord::Base
43
52
 
44
53
  attr_accessor :follower_stash
45
54
 
55
+
46
56
  define_callbacks :approve, :store, :stored, :extend, :subsequent
47
57
 
48
58
  before_validation :approve
49
59
  around_save :store
50
60
  after_save :extend
51
61
 
52
-
53
62
  TRACKED_FIELDS = %w(name type_id db_content trash)
54
-
63
+ extend CarrierWave::Mount
55
64
  ActiveSupport.run_load_hooks(:card, self)
65
+
56
66
  end
57
67
 
58
68
 
data/lib/card/chunk.rb CHANGED
@@ -6,30 +6,36 @@ require 'uri/common'
6
6
  # and interrogated by a format. Each Chunk class has a
7
7
  # +pattern+ that states what sort of text it matches.
8
8
  # Chunks are initalized by passing in the result of a
9
- # match by its pattern.
9
+
10
10
 
11
11
  class Card
12
+
13
+ # A chunk is a pattern of text that can be protected
14
+ # and interrogated by a format. Each Chunk class has a
15
+ # +pattern+ that states what sort of text it matches.
16
+ # Chunks are initalized by passing in the result of a
17
+ # match by its pattern.
12
18
  module Chunk
13
19
  mattr_accessor :raw_list, :prefix_regexp_by_list, :prefix_map
14
20
  @@raw_list, @@prefix_regexp_by_list, @@prefix_map = {}, {}, {}
15
-
21
+
16
22
  class << self
17
23
  def register_class klass, hash
18
24
  klass.config = hash.merge :class => klass
19
- prefix_index = hash[:idx_char] || :default # this is gross and needs to be moved out.
25
+ prefix_index = hash[:idx_char] || :default # this is gross and needs to be moved out.
20
26
  prefix_map[prefix_index] = klass.config
21
27
  end
22
-
28
+
23
29
  def register_list key, list
24
30
  raw_list[key] = list
25
31
  end
26
-
32
+
27
33
  def find_class_by_prefix prefix
28
34
  config = prefix_map[ prefix[0,1] ] || prefix_map[ prefix[-1,1] ] || prefix_map[:default]
29
35
  #prefix identified by first character, last character, or default. a little ugly...
30
36
  config[:class]
31
37
  end
32
-
38
+
33
39
  def get_prefix_regexp chunk_list_key
34
40
  prefix_regexp_by_list[chunk_list_key] ||= begin
35
41
  chunk_types = raw_list[chunk_list_key].map { |chunkname| const_get chunkname }
@@ -41,17 +47,18 @@ class Card
41
47
  end
42
48
 
43
49
  end
44
-
45
-
50
+
51
+
46
52
  #not sure whether this is best place. Could really happen almost anywhere (even before chunk classes are loaded).
47
53
  register_list :default, [ :URI, :HostURI, :EmailURI, :EscapedLiteral, :Include, :Link ]
48
54
  register_list :references, [ :EscapedLiteral, :Include, :Link ]
49
- register_list :inclusion_only, [ :Include ]
50
-
55
+ register_list :inclusion_only, [ :Include ]
56
+ register_list :query, [ :QueryReference ]
57
+
51
58
  class Abstract
52
59
  class_attribute :config
53
60
  attr_reader :text, :process_chunk
54
-
61
+
55
62
  class << self
56
63
  def full_match content, prefix=nil
57
64
  # warn "attempting full match on #{content}. class = #{self}"
@@ -61,7 +68,7 @@ class Card
61
68
  def full_re prefix
62
69
  config[:full_re]
63
70
  end
64
-
71
+
65
72
  def context_ok? content, chunk_start
66
73
  true
67
74
  end
@@ -74,15 +81,15 @@ class Card
74
81
  interpret match, content
75
82
  self
76
83
  end
77
-
84
+
78
85
  def interpret match_string, content, params
79
86
  Rails.logger.info "no #interpret method found for chunk class: #{self.class}"
80
87
  end
81
-
88
+
82
89
  def format
83
90
  @content.format
84
91
  end
85
-
92
+
86
93
  def card
87
94
  @content.card
88
95
  end
data/lib/card/content.rb CHANGED
@@ -8,15 +8,16 @@ class Card
8
8
  attr_reader :revision, :format, :chunks, :opts
9
9
 
10
10
  def initialize content, format_or_card, opts={}
11
- @format = if Card===format_or_card
12
- Format.new format_or_card, :format=>nil
13
- else
14
- format_or_card
15
- end
11
+ @format =
12
+ if Card===format_or_card
13
+ Format.new format_or_card, :format=>nil
14
+ else
15
+ format_or_card
16
+ end
16
17
  @opts = opts || {}
17
-
18
+
18
19
  unless Array === content
19
- content = parse_content content
20
+ content = parse_content content
20
21
  end
21
22
  super content
22
23
  end
@@ -24,7 +25,7 @@ class Card
24
25
  def card
25
26
  format.card
26
27
  end
27
-
28
+
28
29
  def chunk_list
29
30
  @opts[:chunk_list] || @format.chunk_list
30
31
  end
data/lib/card/diff.rb CHANGED
@@ -1,23 +1,23 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
3
  module Card::Diff
4
-
4
+
5
5
  def self.complete a, b, opts={}
6
6
  DiffBuilder.new(a, b, opts).complete
7
7
  end
8
-
8
+
9
9
  def self.summary a, b, opts={}
10
10
  DiffBuilder.new(a, b, opts).summary
11
11
  end
12
-
12
+
13
13
  def self.render_added_chunk text
14
14
  "<ins class='diffins diff-green'>#{text}</ins>"
15
15
  end
16
-
16
+
17
17
  def self.render_deleted_chunk text, count=true
18
18
  "<del class='diffdel diff-red'>#{text}</del>"
19
19
  end
20
-
20
+
21
21
  def self.render_chunk action, text
22
22
  case action
23
23
  when '+' then render_added_chunk text
@@ -30,16 +30,16 @@ module Card::Diff
30
30
 
31
31
  class DiffBuilder
32
32
  attr_reader :summary, :complete
33
-
34
- # diff options
35
- # :format => :html|:text|:pointer|:raw
33
+
34
+ # diff options
35
+ # :format => :html|:text|:pointer|:raw
36
36
  # :html = maintain html structure, but compare only content
37
37
  # :text = remove all html tags; compare plain text
38
38
  # :pointer = remove all double square brackets
39
39
  # :raw = escape html tags and compare everything
40
40
  #
41
41
  # :summary => {:length=><number> , :joint=><string> }
42
-
42
+
43
43
  def initialize(old_version, new_version, opts={})
44
44
  @new_version = new_version
45
45
  @old_version = old_version
@@ -47,7 +47,7 @@ module Card::Diff
47
47
  @lcs_opts[:summary] = opts[:summary]
48
48
  @dels_cnt = 0
49
49
  @adds_cnt = 0
50
-
50
+
51
51
  if not @new_version
52
52
  @complete = ''
53
53
  @summary = ''
@@ -57,13 +57,13 @@ module Card::Diff
57
57
  end
58
58
 
59
59
  def red?
60
- @dels_cnt > 0
60
+ @dels_cnt > 0
61
61
  end
62
-
62
+
63
63
  def green?
64
- @adds_cnt > 0
64
+ @adds_cnt > 0
65
65
  end
66
-
66
+
67
67
  def lcs_opts_for_format format
68
68
  opts = {}
69
69
  case format
@@ -85,7 +85,7 @@ module Card::Diff
85
85
  end
86
86
  opts
87
87
  end
88
-
88
+
89
89
  def lcs_diff
90
90
  @lcs = LCS.new(@old_version, @new_version, @lcs_opts)
91
91
  @summary = @lcs.summary
@@ -94,7 +94,7 @@ module Card::Diff
94
94
  @adds_cnt = @lcs.adds_cnt
95
95
  end
96
96
 
97
-
97
+
98
98
  class LCS
99
99
  attr_reader :adds_cnt, :dels_cnt
100
100
  def initialize old_text, new_text, opts, summary=nil
@@ -102,12 +102,12 @@ module Card::Diff
102
102
  @exclude_pattern = opts[:exclude] # regex; put back to the result after diff
103
103
  @preprocess = opts[:preprocess] # block; called with every word
104
104
  @postprocess = opts[:postprocess] # block; called with complete diff
105
-
105
+
106
106
  @adds_cnt = 0
107
107
  @dels_cnt = 0
108
-
108
+
109
109
  @splitters = %w( <[^>]+> \[\[[^\]]+\]\] \{\{[^}]+\}\} \s+ )
110
- @disjunction_pattern = /^\s/
110
+ @disjunction_pattern = /^\s/
111
111
  @summary ||= Summary.new opts[:summary]
112
112
  if not old_text
113
113
  list = split_and_preprocess(new_text)
@@ -122,24 +122,24 @@ module Card::Diff
122
122
  run_diff
123
123
  end
124
124
  end
125
-
126
- def summary
125
+
126
+ def summary
127
127
  @summary.result
128
128
  end
129
-
129
+
130
130
  def complete
131
131
  @result
132
132
  end
133
-
134
- private
135
-
133
+
134
+ private
135
+
136
136
  def init_diff old_text, new_text
137
137
  @adds = []
138
138
  @dels = []
139
139
  @result = ''
140
140
  old_words, old_ex = separate_comparables_from_excludees old_text
141
141
  new_words, new_ex = separate_comparables_from_excludees new_text
142
-
142
+
143
143
  @words = {
144
144
  :old => old_words,
145
145
  :new => new_words
@@ -149,22 +149,22 @@ module Card::Diff
149
149
  :new => ExcludeeIterator.new(new_ex)
150
150
  }
151
151
  end
152
-
153
- def run_diff
154
- prev_action = nil
152
+
153
+ def run_diff
154
+ prev_action = nil
155
155
  ::Diff::LCS.traverse_balanced(@words[:old], @words[:new]) do |word|
156
156
 
157
- if prev_action
157
+ if prev_action
158
158
  if prev_action != word.action and
159
- !(prev_action == '-' and word.action == '!') and
159
+ !(prev_action == '-' and word.action == '!') and
160
160
  !(prev_action == '!' and word.action == '+')
161
161
 
162
162
  # delete and/or add section stops here; write changes to result
163
163
  write_dels
164
164
  write_adds
165
-
165
+
166
166
  write_excludees # new neutral section starts, we can just write excludees to result
167
-
167
+
168
168
  else # current word belongs to edit of previous word
169
169
  case word.action
170
170
  when '-'
@@ -176,39 +176,39 @@ module Card::Diff
176
176
  add_new_excludees
177
177
  else
178
178
  write_excludees
179
- end
179
+ end
180
180
  end
181
181
  else
182
182
  write_excludees
183
183
  end
184
-
184
+
185
185
  process_word word
186
- prev_action = word.action
186
+ prev_action = word.action
187
187
  end
188
188
  write_dels
189
189
  write_adds
190
190
  write_excludees
191
-
191
+
192
192
  @result = postprocess @result
193
193
  end
194
194
 
195
-
195
+
196
196
  def added_chunk text, count=true
197
197
  @adds_cnt += 1 if count
198
198
  Card::Diff.render_added_chunk text
199
199
  end
200
-
200
+
201
201
  def deleted_chunk text, count=true
202
202
  @dels_cnt += 1 if count
203
203
  Card::Diff.render_deleted_chunk text
204
204
  end
205
205
 
206
-
206
+
207
207
  def write_unchanged text
208
208
  @result << text
209
209
  @summary.omit
210
210
  end
211
-
211
+
212
212
  def write_dels
213
213
  if !@dels.empty?
214
214
  @result << deleted_chunk(@dels.join)
@@ -216,7 +216,7 @@ module Card::Diff
216
216
  @dels = []
217
217
  end
218
218
  end
219
-
219
+
220
220
  def write_adds
221
221
  if !@adds.empty?
222
222
  @result << added_chunk(@adds.join)
@@ -224,13 +224,13 @@ module Card::Diff
224
224
  @adds = []
225
225
  end
226
226
  end
227
-
227
+
228
228
  def write_excludees
229
229
  while ex = @excludees[:new].next
230
230
  @result << ex[:element]
231
231
  end
232
232
  end
233
-
233
+
234
234
  def del_old_excludees
235
235
  while ex = @excludees[:old].next
236
236
  if ex[:type] == :disjunction
@@ -241,7 +241,7 @@ module Card::Diff
241
241
  end
242
242
  end
243
243
  end
244
-
244
+
245
245
  def add_new_excludees
246
246
  while ex = @excludees[:new].next
247
247
  if ex[:type] == :disjunction
@@ -252,11 +252,11 @@ module Card::Diff
252
252
  end
253
253
  end
254
254
  end
255
-
255
+
256
256
  def process_word word
257
257
  process_element word.old_element, word.new_element, word.action
258
258
  end
259
-
259
+
260
260
  def process_element old_element, new_element, action
261
261
  case action
262
262
  when '-'
@@ -275,13 +275,13 @@ module Card::Diff
275
275
  @excludees[:new].word_step
276
276
  end
277
277
  end
278
-
278
+
279
279
  def separate_comparables_from_excludees text
280
280
  # return two arrays, one with all words, one with pairs (index in word list, html_tag)
281
281
  list = split_and_preprocess text
282
282
  if @exclude_pattern
283
283
  list.each_with_index.inject([[],[]]) do |res, pair|
284
- element, index = pair
284
+ element, index = pair
285
285
  if element.match @disjunction_pattern
286
286
  res[1] << {:chunk_index=>index, :element=>element, :type=>:disjunction}
287
287
  elsif element.match @exclude_pattern
@@ -295,19 +295,19 @@ module Card::Diff
295
295
  [list, []]
296
296
  end
297
297
  end
298
-
298
+
299
299
  def split_and_preprocess text
300
300
  splitted = split_to_list_of_words(text).select do |s|
301
301
  s.size > 0 and (!@reject_pattern or !s.match @reject_pattern)
302
302
  end
303
303
  @preprocess ? splitted.map {|s| @preprocess.call(s) } : splitted
304
304
  end
305
-
305
+
306
306
  def split_to_list_of_words text
307
307
  split_regex = /(#{@splitters.join '|'})/
308
308
  text.split(split_regex)
309
309
  end
310
-
310
+
311
311
  def preprocess text
312
312
  if @preprocess
313
313
  @preprocess.call(text)
@@ -315,7 +315,7 @@ module Card::Diff
315
315
  text
316
316
  end
317
317
  end
318
-
318
+
319
319
  def postprocess text
320
320
  if @postprocess
321
321
  @postprocess.call(text)
@@ -323,64 +323,64 @@ module Card::Diff
323
323
  text
324
324
  end
325
325
  end
326
-
327
-
328
- class Summary
326
+
327
+
328
+ class Summary
329
329
  def initialize opts
330
330
  opts ||= {}
331
- @remaining_chars = opts[:length] || 50
331
+ @remaining_chars = opts[:length] || 50
332
332
  @joint = opts[:joint] || '...'
333
-
333
+
334
334
  @summary = nil
335
335
  @chunks = []
336
336
  end
337
-
337
+
338
338
  def result
339
339
  @summary ||= render_chunks
340
340
  end
341
-
341
+
342
342
  def add text
343
343
  add_chunk text, :added
344
344
  end
345
-
345
+
346
346
  def delete text
347
347
  add_chunk text, :deleted
348
348
  end
349
-
350
- def omit
349
+
350
+ def omit
351
351
  if @chunks.empty? or @chunks.last[:action] != :ellipsis
352
352
  add_chunk @joint, :ellipsis
353
353
  end
354
- end
355
-
354
+ end
355
+
356
356
  private
357
-
357
+
358
358
  def add_chunk text, action
359
359
  if @remaining_chars > 0
360
360
  @chunks << {:action => action, :text=>text}
361
361
  @remaining_chars -= text.size
362
362
  end
363
363
  end
364
-
364
+
365
365
  def render_chunks
366
366
  truncate_overlap
367
367
  @chunks.map do |chunk|
368
368
  Card::Diff.render_chunk chunk[:action], chunk[:text]
369
- end.join
369
+ end.join
370
370
  end
371
-
371
+
372
372
  def truncate_overlap
373
373
  if @remaining_chars < 0
374
374
  if @chunks.last[:action] == :ellipsis
375
375
  @chunks.pop
376
376
  @remaining_chars += @joint.size
377
377
  end
378
-
378
+
379
379
  index = @chunks.size - 1
380
380
  while @remaining_chars < @joint.size and index >= 0
381
381
  if @remaining_chars + @chunks[index][:text].size == @joint.size # d
382
382
  @chunks.pop
383
- if index-1 >= 0
383
+ if index-1 >= 0
384
384
  if @chunks[index-1][:action] == :added
385
385
  @chunks << {:action => :ellipsis, :text=>@joint}
386
386
  elsif @chunks[index-1][:action] == :deleted
@@ -389,7 +389,7 @@ module Card::Diff
389
389
  end
390
390
  break
391
391
  elsif @remaining_chars + @chunks[index][:text].size > @joint.size
392
- @chunks[index][:text] = @chunks[index][:text][0..(@remaining_chars-@joint.size-1)]
392
+ @chunks[index][:text] = @chunks[index][:text][0..(@remaining_chars-@joint.size-1)]
393
393
  @chunks[index][:text] += @joint
394
394
  break
395
395
  else
@@ -399,21 +399,21 @@ module Card::Diff
399
399
  index -= 1
400
400
  end
401
401
  end
402
- end
403
-
402
+ end
403
+
404
404
  end
405
-
406
- class ExcludeeIterator
405
+
406
+ class ExcludeeIterator
407
407
  def initialize list
408
408
  @list = list
409
409
  @index = 0
410
410
  @chunk_index = 0
411
411
  end
412
-
412
+
413
413
  def word_step
414
414
  @chunk_index += 1
415
415
  end
416
-
416
+
417
417
  def next
418
418
  if @index < @list.size and @list[@index][:chunk_index] == @chunk_index
419
419
  res = @list[@index]
@@ -423,7 +423,7 @@ module Card::Diff
423
423
  end
424
424
  end
425
425
  end
426
-
426
+
427
427
  end
428
428
  end
429
429
  end