card 1.20.4 → 1.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/card.gemspec +9 -9
  4. data/db/migrate_core_cards/20170515101262_add_advanced_edit_cards.rb +20 -0
  5. data/db/migrate_core_cards/20170608083819_add_full_width_layout_card.rb +23 -0
  6. data/db/migrate_core_cards/20170608200649_add_input_options_codename.rb +8 -0
  7. data/db/seed/new/card_actions.yml +783 -791
  8. data/db/seed/new/card_acts.yml +65 -47
  9. data/db/seed/new/card_changes.yml +3198 -3177
  10. data/db/seed/new/card_references.yml +604 -534
  11. data/db/seed/new/cards.yml +2355 -2256
  12. data/db/seed/test/fixtures/card_actions.yml +1795 -1803
  13. data/db/seed/test/fixtures/card_acts.yml +264 -246
  14. data/db/seed/test/fixtures/card_changes.yml +6275 -6184
  15. data/db/seed/test/fixtures/card_references.yml +1305 -1263
  16. data/db/seed/test/fixtures/cards.yml +3393 -3298
  17. data/db/seed/test/seed.rb +2 -2
  18. data/db/version_core_cards.txt +1 -1
  19. data/lib/card.rb +4 -0
  20. data/lib/card/act_manager/subdirector_array.rb +1 -0
  21. data/lib/card/auth/current.rb +7 -3
  22. data/lib/card/env.rb +5 -0
  23. data/lib/card/env/success.rb +1 -1
  24. data/lib/card/format/names.rb +3 -13
  25. data/lib/card/model/save_helper.rb +4 -6
  26. data/lib/card/query.rb +2 -1
  27. data/lib/card/query/attributes.rb +34 -14
  28. data/lib/card/query/value.rb +3 -4
  29. data/lib/card/set/format.rb +29 -4
  30. data/lib/card/set/format/haml_views.rb +25 -13
  31. data/lib/card/set/trait.rb +1 -0
  32. data/lib/card/set_pattern.rb +17 -1
  33. data/lib/card/subcards.rb +3 -2
  34. data/lib/generators/card/format/format_generator.rb +2 -0
  35. data/lib/generators/card/set/set_generator.rb +2 -0
  36. data/lib/generators/card/template/USAGE +10 -0
  37. data/lib/generators/card/template/template_generator.rb +46 -0
  38. data/lib/generators/card/template/templates/haml_template.erb +1 -0
  39. data/mod/Modfile +1 -1
  40. data/mod/account/set/all/account.rb +9 -5
  41. data/mod/account/set/right/account.rb +17 -5
  42. data/mod/account/set/self/account_links.rb +1 -2
  43. data/mod/account/set/type/signup.rb +4 -5
  44. data/mod/account/set/type/user.rb +1 -1
  45. data/mod/account/spec/set/all/account_spec.rb +2 -2
  46. data/mod/account/spec/set/right/account_spec.rb +2 -2
  47. data/mod/account/spec/set/right/email_spec.rb +1 -1
  48. data/mod/account/spec/set/right/password_spec.rb +1 -1
  49. data/mod/account/spec/set/self/signin_spec.rb +2 -2
  50. data/mod/account/spec/set/type/signup_spec.rb +4 -0
  51. data/mod/ace_editor/set/abstract/ace_editor.rb +6 -3
  52. data/mod/ace_editor/set/self/script_ace.rb +1 -0
  53. data/mod/admin/set/self/admin.rb +1 -1
  54. data/mod/admin/set/self/version.rb +1 -0
  55. data/mod/basic_formats/format/css_format.rb +1 -0
  56. data/mod/basic_formats/format/csv_format.rb +1 -0
  57. data/mod/basic_formats/format/file_format.rb +1 -0
  58. data/mod/basic_formats/format/js_format.rb +1 -0
  59. data/mod/basic_formats/format/json_format.rb +1 -0
  60. data/mod/basic_formats/format/rss_format.rb +1 -0
  61. data/mod/basic_formats/format/xml_format.rb +1 -0
  62. data/mod/basic_formats/set/all/all_csv.rb +1 -1
  63. data/mod/basic_formats/set/all/base.rb +11 -3
  64. data/mod/basic_formats/set/all/json.rb +50 -8
  65. data/mod/basic_formats/set/all/rss.rb +21 -7
  66. data/mod/basic_formats/set/self/01_head/javascript.rb +1 -1
  67. data/mod/basic_formats/set/self/head.rb +1 -1
  68. data/mod/basic_formats/spec/set/all/base_spec.rb +13 -0
  69. data/mod/basic_types/set/type/html.rb +6 -2
  70. data/mod/basic_types/set/type/plain_text.rb +2 -3
  71. data/mod/bootstrap/lib/bootstrap.rb +2 -2
  72. data/mod/bootstrap/lib/bootstrap/basic_tags.rb +1 -1
  73. data/mod/bootstrap/lib/bootstrap/component.rb +2 -3
  74. data/mod/bootstrap/lib/bootstrap/component/form.rb +6 -5
  75. data/mod/bootstrap/lib/bootstrap/component/horizontal_form.rb +1 -1
  76. data/mod/bootstrap/lib/bootstrap/component/layout.rb +3 -3
  77. data/mod/bootstrap/lib/bootstrap/component_loader.rb +0 -2
  78. data/mod/bootstrap/lib/bootstrap/delegate.rb +2 -2
  79. data/mod/bootstrap/lib/bootstrapper.rb +1 -1
  80. data/mod/bootstrap/set/all/bootstrap/accordion.rb +1 -1
  81. data/mod/bootstrap/set/all/bootstrap/form.rb +2 -2
  82. data/mod/bootstrap/set/all/bootstrap/helper.rb +1 -0
  83. data/mod/bootstrap/set/all/bootstrap/wrapper.rb +1 -1
  84. data/mod/bootstrap/set/self/bootstrap_js.rb +1 -1
  85. data/mod/bootstrap/set/self/bootswatch_shared.rb +6 -6
  86. data/mod/bootstrap/set/self/script_mods.rb +1 -1
  87. data/mod/bootstrap/spec/set/all/bootstrap/bootstrap_builder_spec.rb +7 -6
  88. data/mod/bootstrap/spec/set/all/bootstrap/bootstrap_spec.rb +2 -1
  89. data/mod/bootstrap/spec/set/all/bootstrap/form_spec.rb +6 -3
  90. data/mod/bootstrap/spec/set/all/bootstrap/layout_spec.rb +3 -2
  91. data/mod/carrierwave/set/abstract/attachment.rb +1 -3
  92. data/mod/carrierwave/set/abstract/attachment/paths.rb +1 -1
  93. data/mod/carrierwave/set/abstract/attachment/storage_type.rb +11 -1
  94. data/mod/carrierwave/set/type/file.rb +3 -3
  95. data/mod/carrierwave/spec/lib/carrier_wave/file_card_uploader_spec.rb +3 -0
  96. data/mod/carrierwave/spec/set/type/file_spec.rb +24 -6
  97. data/mod/carrierwave/spec/set/type/image_spec.rb +3 -0
  98. data/mod/core/chunk/link.rb +1 -1
  99. data/mod/core/chunk/nest.rb +2 -1
  100. data/mod/core/chunk/query_reference.rb +1 -1
  101. data/mod/core/chunk/reference.rb +1 -0
  102. data/mod/core/chunk/uri.rb +4 -3
  103. data/mod/core/set/abstract/lock.rb +26 -0
  104. data/mod/core/set/all/assign_attributes.rb +8 -4
  105. data/mod/core/set/all/collection.rb +16 -7
  106. data/mod/core/set/all/content.rb +6 -0
  107. data/mod/core/set/all/event.rb +1 -1
  108. data/mod/core/set/all/fetch.rb +2 -2
  109. data/mod/core/set/all/haml.rb +5 -15
  110. data/mod/core/set/all/initialize.rb +2 -2
  111. data/mod/core/set/all/name.rb +1 -1
  112. data/mod/core/set/all/permissions.rb +28 -16
  113. data/mod/core/set/all/rules.rb +1 -2
  114. data/mod/core/set/all/subcards.rb +3 -3
  115. data/mod/core/set/all/templating.rb +5 -1
  116. data/mod/core/set/all/trash.rb +1 -1
  117. data/mod/core/set/all/utils.rb +1 -1
  118. data/mod/core/spec/set/all/actify_spec.rb +1 -1
  119. data/mod/core/spec/set/all/assign_attributes_spec.rb +2 -2
  120. data/mod/core/spec/set/all/collection_spec.rb +6 -3
  121. data/mod/core/spec/set/all/export_spec.rb +40 -112
  122. data/mod/core/spec/set/all/name_spec.rb +1 -1
  123. data/mod/core/spec/set/all/permissions_spec.rb +7 -7
  124. data/mod/core/spec/set/all/rules2_spec.rb +25 -25
  125. data/mod/core/spec/set/all/rules_spec.rb +2 -7
  126. data/mod/developer/set/all/event_viz.rb +1 -1
  127. data/mod/developer/set/right/debug.rb +1 -1
  128. data/mod/history/lib/card/act.rb +1 -0
  129. data/mod/history/lib/card/act/act_renderer.rb +23 -20
  130. data/mod/history/lib/card/act/act_renderer/absolute_act_renderer.rb +0 -1
  131. data/mod/history/lib/card/act/act_renderer/relative_act_renderer.rb +1 -0
  132. data/mod/history/lib/card/action.rb +1 -1
  133. data/mod/history/lib/card/action/action_renderer.rb +2 -2
  134. data/mod/history/lib/card/change.rb +2 -1
  135. data/mod/history/set/all/action_view.rb +1 -1
  136. data/mod/history/set/all/content_history.rb +7 -4
  137. data/mod/history/set/all/history.rb +6 -6
  138. data/mod/machines/file/all_script_machine_output/file.js +50 -34
  139. data/mod/machines/file/all_style_machine_output/file.css +1 -1
  140. data/mod/machines/lib/javascript/wagn.js.coffee +29 -18
  141. data/mod/machines/lib/javascript/wagn_layout.js.coffee +7 -3
  142. data/mod/machines/lib/stylesheets/style_cards.scss +10 -10
  143. data/mod/machines/set/abstract/machine.rb +5 -28
  144. data/mod/machines/set/abstract/script.rb +7 -4
  145. data/mod/machines/set/all/reset_machines.rb +1 -1
  146. data/mod/machines/set/self/script_jquery_helper.rb +2 -2
  147. data/mod/machines/set/self/script_slot.rb +1 -1
  148. data/mod/machines/set/type/coffee_script.rb +3 -2
  149. data/mod/machines/set/type/css.rb +7 -3
  150. data/mod/machines/set/type/scss.rb +7 -1
  151. data/mod/machines/spec/set/type/coffeescript_spec.rb +1 -1
  152. data/mod/machines/spec/set/type/javascript_spec.rb +1 -1
  153. data/mod/machines/spec/set/type/scss_spec.rb +3 -2
  154. data/mod/machines/spec/set/type/skin_spec.rb +1 -1
  155. data/mod/machines/spec/shared_examples/machine.rb +5 -3
  156. data/mod/machines/spec/shared_examples/machine_input.rb +1 -0
  157. data/mod/notifications/format/email_html_format.rb +1 -0
  158. data/mod/notifications/set/all/follow.rb +1 -1
  159. data/mod/notifications/set/all/observer.rb +1 -1
  160. data/mod/notifications/set/all/send_notifications.rb +2 -2
  161. data/mod/notifications/set/self/follow_defaults.rb +3 -8
  162. data/mod/notifications/set/type/email_template/email_config.rb +2 -2
  163. data/mod/notifications/set/type_plus_right/user/follow.rb +2 -2
  164. data/mod/notifications/spec/set/all/follow_spec.rb +7 -0
  165. data/mod/notifications/spec/set/all/notify_spec.rb +3 -0
  166. data/mod/notifications/spec/set/all/observer_spec.rb +1 -1
  167. data/mod/notifications/spec/set/right/followers_spec.rb +1 -0
  168. data/mod/pointer/set/abstract/00_paging_params.rb +11 -0
  169. data/mod/pointer/set/abstract/{00_paging.rb → 01_paging.rb} +10 -6
  170. data/mod/pointer/set/abstract/{00_paging → 01_paging}/paging_links.rb +0 -0
  171. data/mod/pointer/set/abstract/{01_pointer.rb → 02_pointer.rb} +26 -5
  172. data/mod/pointer/set/abstract/{01_pointer → 02_pointer}/edit.rb +3 -5
  173. data/mod/pointer/set/self/input_options.rb +12 -0
  174. data/mod/pointer/spec/set/self/input_options_spec.rb +8 -0
  175. data/mod/pointer/spec/set/type/pointer_spec.rb +3 -2
  176. data/mod/prosemirror_editor/set/abstract/prosemirror_editor.rb +1 -1
  177. data/mod/prosemirror_editor/set/self/script_prosemirror.rb +1 -0
  178. data/mod/settings/lib/card/setting.rb +1 -2
  179. data/mod/settings/set/abstract/permission.rb +1 -1
  180. data/mod/settings/set/self/add_help.rb +1 -1
  181. data/mod/settings/set/self/autoname.rb +1 -1
  182. data/mod/settings/set/self/csv_structure.rb +2 -0
  183. data/mod/settings/set/self/help.rb +1 -1
  184. data/mod/settings/set/self/input.rb +1 -2
  185. data/mod/settings/set/self/options.rb +2 -2
  186. data/mod/settings/set/self/options_label.rb +2 -2
  187. data/mod/settings/set/type/setting.rb +1 -1
  188. data/mod/settings/spec/set/right/script_spec.rb +1 -1
  189. data/mod/settings/spec/set/right/style_spec.rb +1 -1
  190. data/mod/solid_cache/set/abstract/solid_cache.rb +5 -3
  191. data/mod/solid_cache/spec/set/abstract/solid_cache_spec.rb +4 -3
  192. data/mod/standard/set/abstract/01_search_params.rb +4 -3
  193. data/mod/standard/set/abstract/search.rb +2 -1
  194. data/mod/standard/set/abstract/toolbar_split_button.rb +22 -0
  195. data/mod/standard/set/all/links.rb +3 -3
  196. data/mod/standard/set/all/rich_html/classy.rb +37 -0
  197. data/mod/standard/set/all/rich_html/editing.rb +6 -2
  198. data/mod/standard/set/all/rich_html/editor.rb +50 -0
  199. data/mod/standard/set/all/rich_html/form.rb +19 -12
  200. data/mod/standard/set/all/rich_html/form_elements.rb +2 -2
  201. data/mod/standard/set/all/rich_html/formgroup.rb +2 -1
  202. data/mod/standard/set/all/rich_html/header.rb +2 -27
  203. data/mod/standard/set/all/rich_html/menu.rb +1 -1
  204. data/mod/standard/set/all/rich_html/new.rb +5 -1
  205. data/mod/standard/set/all/rich_html/toolbar.rb +15 -60
  206. data/mod/standard/set/all/rich_html/wrapper.rb +6 -3
  207. data/mod/standard/set/right/when_created.rb +2 -2
  208. data/mod/standard/set/rstar/rules_editor.rb +10 -7
  209. data/mod/standard/set/self/activity_toolbar_button.rb +14 -0
  210. data/mod/standard/set/self/recent.rb +7 -2
  211. data/mod/standard/set/self/rules_toolbar_button.rb +42 -0
  212. data/mod/standard/set/self/search.rb +19 -6
  213. data/mod/standard/set/type/basic.rb +6 -6
  214. data/mod/standard/set/type/cardtype.rb +7 -3
  215. data/mod/standard/set/type/date.rb +2 -4
  216. data/mod/standard/set/type/layout_type.rb +1 -0
  217. data/mod/standard/set/type/list.rb +1 -1
  218. data/mod/standard/set/type/listed_by.rb +1 -2
  219. data/mod/standard/set/type/number.rb +4 -2
  220. data/mod/standard/set/type/phrase.rb +4 -2
  221. data/mod/standard/set/type/search_type.rb +11 -3
  222. data/mod/standard/set/type/set.rb +8 -8
  223. data/mod/standard/set/type/toggle.rb +1 -3
  224. data/mod/standard/set/type/uri.rb +6 -2
  225. data/mod/standard/spec/chunk/include_spec.rb +3 -2
  226. data/mod/standard/spec/chunk/query_reference_spec.rb +2 -2
  227. data/mod/standard/spec/set/all/history_spec.rb +1 -0
  228. data/mod/standard/spec/set/all/links_spec.rb +1 -0
  229. data/mod/standard/spec/set/all/rich_html/toolbar_spec.rb +2 -0
  230. data/mod/standard/spec/set/self/activity_toolbar_button_spec.rb +22 -0
  231. data/mod/standard/spec/set/type/email_template/email_config_spec.rb +10 -8
  232. data/mod/standard/spec/set/type/email_template_spec.rb +1 -0
  233. data/mod/standard/spec/set/type/list_spec.rb +2 -0
  234. data/mod/standard/spec/set/type/listed_by_spec.rb +5 -0
  235. data/mod/standard/spec/set/type/search_type_spec.rb +1 -1
  236. data/mod/standard/spec/set/type/toggle_spec.rb +1 -2
  237. data/mod/standard/spec/set/type/uri_spec.rb +0 -1
  238. data/mod/tinymce_editor/db/migrate_cards/20160804112560_add_tinymce_cards.rb +3 -1
  239. data/mod/tinymce_editor/set/abstract/tinymce_editor.rb +1 -1
  240. data/mod/tinymce_editor/set/self/script_tinymce.rb +1 -0
  241. data/mod/twitter/db/migrate_cards/20170305112346_add_twitter_cards.rb +1 -1
  242. data/mod/twitter/set/type/twitter_template.rb +1 -1
  243. data/spec/lib/card/format_spec.rb +26 -7
  244. data/spec/lib/card/loader_spec.rb +96 -35
  245. data/spec/lib/card/query_spec.rb +0 -1
  246. data/spec/support/card_spec_loader.rb +1 -0
  247. data/spec/support/helper/card_helper.rb +0 -36
  248. data/spec/support/helper/set_helper.rb +80 -0
  249. data/spec/support/matchers.rb +74 -0
  250. data/tmpsets/set/mod001-core/all/actify.rb +5 -6
  251. data/tmpsets/set/mod001-core/all/fetch.rb +14 -12
  252. data/tmpsets/set/mod001-core/all/name.rb +1 -1
  253. data/tmpsets/set/mod001-core/all/permissions.rb +12 -22
  254. data/tmpsets/set/mod001-core/all/tracked_attributes.rb +76 -0
  255. data/tmpsets/set/mod001-core/all/utils.rb +40 -3
  256. data/tmpsets/set/mod002-history/all/history.rb +1 -2
  257. data/tmpsets/set/mod008-solid_cache/abstract/solid_cache.rb +1 -1
  258. data/tmpsets/set/mod013-carrierwave/abstract/attachment.rb +282 -0
  259. data/tmpsets/set/mod013-carrierwave/type/file.rb +155 -0
  260. data/tmpsets/set/mod013-carrierwave/type/image.rb +96 -0
  261. data/tmpsets/set/mod014-admin/self/admin.rb +113 -0
  262. data/tmpsets/set/mod014-admin/self/admin_info.rb +110 -0
  263. data/tmpsets/set/mod014-admin/self/version.rb +15 -0
  264. data/tmpsets/set/mod015-developer/all/event_viz.rb +59 -0
  265. data/tmpsets/set/mod015-developer/all/view_viz.rb +30 -0
  266. data/tmpsets/set/mod015-developer/right/debug.rb +96 -0
  267. metadata +52 -22
@@ -28,7 +28,7 @@ describe Card::Set::All::Name do
28
28
  end
29
29
 
30
30
  describe "codename" do
31
- before :each do
31
+ before do
32
32
  @card = Card["a"]
33
33
  end
34
34
 
@@ -171,7 +171,7 @@ describe Card::Set::All::Permissions do
171
171
  end
172
172
  c = Card.new(name: "Home+Heart")
173
173
  expect(c.who_can(:read)).to eq([Card::AnyoneSignedInID])
174
- expect(c.permission_rule_id_and_class(:read).first).to eq(@perm_card.id)
174
+ expect(c.permission_rule_id(:read)).to eq(@perm_card.id)
175
175
  c.save
176
176
  expect(c.read_rule_id).to eq(@perm_card.id)
177
177
  end
@@ -183,7 +183,7 @@ describe Card::Set::All::Permissions do
183
183
  end
184
184
  c = Card.new(name: "Home+Heart")
185
185
  expect(c.who_can(:read)).to eq([Card::AnyoneID])
186
- expect(c.permission_rule_id_and_class(:read).first).to(
186
+ expect(c.permission_rule_id(:read)).to(
187
187
  eq(Card.fetch("*all+*read").id)
188
188
  )
189
189
  c.save
@@ -226,7 +226,7 @@ describe Card::Set::All::Permissions do
226
226
  Card::Auth.as_bot do
227
227
  # Card::Auth.cache.reset
228
228
  @u1, @u2, @u3, @r1, @r2, @r3, @c1, @c2, @c3 =
229
- %w(u1 u2 u3 r1 r2 r3 c1 c2 c3).map { |x| Card[x] }
229
+ %w[u1 u2 u3 r1 r2 r3 c1 c2 c3].map { |x| Card[x] }
230
230
  end
231
231
  end
232
232
 
@@ -398,12 +398,12 @@ describe Card::Set::All::Permissions do
398
398
 
399
399
  Card::Auth.as(@u1) do
400
400
  expect(Card.search(content: "WeirdWord").map(&:name).sort).to(
401
- eq %w(c1 c2 c3)
401
+ eq %w[c1 c2 c3]
402
402
  )
403
403
  end
404
404
  Card::Auth.as(@u2) do
405
405
  expect(Card.search(content: "WeirdWord").map(&:name).sort).to(
406
- eq %w(c2 c3)
406
+ eq %w[c2 c3]
407
407
  )
408
408
  end
409
409
  end
@@ -422,14 +422,14 @@ describe Card::Set::All::Permissions do
422
422
 
423
423
  Card::Auth.as(@u1) do
424
424
  expect(Card.search(content: "WeirdWord").map(&:name).sort).to(
425
- eq(%w(c1 c2 c3))
425
+ eq(%w[c1 c2 c3])
426
426
  )
427
427
  end
428
428
  # for Card::Auth.as to be effective, you can't have a logged in user
429
429
  Card::Auth.current_id = nil
430
430
  Card::Auth.as(@u2) do
431
431
  expect(Card.search(content: "WeirdWord").map(&:name).sort).to(
432
- eq(%w(c2 c3))
432
+ eq(%w[c2 c3])
433
433
  )
434
434
  end
435
435
  end
@@ -8,11 +8,11 @@ describe Card do
8
8
  context "when there is a general toc rule of 2" do
9
9
  before do
10
10
  Card::Auth.as_bot do
11
- Card.create! name: "Basic+*type+*table of contents", content: "2"
11
+ described_class.create! name: "Basic+*type+*table of contents", content: "2"
12
12
  end
13
- expect(@c1 = Card["Onne Heading"]).to be
14
- expect(@c2 = Card["Twwo Heading"]).to be
15
- expect(@c3 = Card["Three Heading"]).to be
13
+ expect(@c1 = described_class["Onne Heading"]).to be
14
+ expect(@c2 = described_class["Twwo Heading"]).to be
15
+ expect(@c3 = described_class["Three Heading"]).to be
16
16
  expect(@c1.type_id).to eq(Card::BasicID)
17
17
  expect(@rule_card = @c1.rule_card(:table_of_contents)).to be
18
18
  end
@@ -44,11 +44,11 @@ describe Card do
44
44
 
45
45
  describe ".related_sets" do
46
46
  it "has 1 set (right) for a simple card" do
47
- sets = Card["A"].related_sets.map { |s| s[0] }
47
+ sets = described_class["A"].related_sets.map { |s| s[0] }
48
48
  expect(sets).to eq(["A+*right"])
49
49
  end
50
50
  it "has 2 sets (type, and right) for a cardtype card" do
51
- sets = Card["Cardtype A"].related_sets.map { |s| s[0] }
51
+ sets = described_class["Cardtype A"].related_sets.map { |s| s[0] }
52
52
  expect(sets).to eq(["Cardtype A+*type", "Cardtype A+*right"])
53
53
  end
54
54
  # it "shows type plus right sets when they exist" do
@@ -67,7 +67,7 @@ describe Card do
67
67
  # 'Cardtype A+*right', 'Basic+Cardtype A+*type plus right']
68
68
  # end
69
69
  it "is empty for a non-simple card" do
70
- sets = Card["A+B"].related_sets.map { |s| s[0] }
70
+ sets = described_class["A+B"].related_sets.map { |s| s[0] }
71
71
  expect(sets).to eq([])
72
72
  end
73
73
  end
@@ -81,8 +81,8 @@ describe Card do
81
81
 
82
82
  context "when I change the general toc setting to 1" do
83
83
  before do
84
- expect(@c1 = Card["Onne Heading"]).to be
85
- expect(@c2 = Card["Twwo Heading"]).to be
84
+ expect(@c1 = described_class["Onne Heading"]).to be
85
+ expect(@c2 = described_class["Twwo Heading"]).to be
86
86
  expect(@c1.type_id).to eq(Card::BasicID)
87
87
  expect(@rule_card = @c1.rule_card(:table_of_contents)).to be
88
88
  @rule_card.content = "1"
@@ -113,12 +113,12 @@ describe Card do
113
113
  context "when I use CardtypeE cards" do
114
114
  before do
115
115
  Card::Auth.as_bot do
116
- @c1 = Card.create name: "toc1", type: "CardtypeE",
117
- content: Card["Onne Heading"].content
118
- @c2 = Card.create name: "toc2", type: "CardtypeE",
119
- content: Card["Twwo Heading"].content
120
- @c3 = Card.create name: "toc3", type: "CardtypeE",
121
- content: Card["Three Heading"].content
116
+ @c1 = described_class.create name: "toc1", type: "CardtypeE",
117
+ content: described_class["Onne Heading"].content
118
+ @c2 = described_class.create name: "toc2", type: "CardtypeE",
119
+ content: described_class["Twwo Heading"].content
120
+ @c3 = described_class.create name: "toc3", type: "CardtypeE",
121
+ content: described_class["Three Heading"].content
122
122
  end
123
123
  expect(@c1.type_name).to eq("Cardtype E")
124
124
  @rule_card = @c1.rule_card(:table_of_contents)
@@ -170,11 +170,11 @@ describe Card do
170
170
  context "when I create a new rule" do
171
171
  before do
172
172
  Card::Auth.as_bot do
173
- Card.create! name: "Basic+*type+*table of contents", content: "2"
174
- @c1 = Card.create! name: "toc1", type: "CardtypeE",
175
- content: Card["Onne Heading"].content
176
- @c2 = Card.create! name: "toc2", content: Card["Twwo Heading"].content
177
- @c3 = Card.create! name: "toc3", content: Card["Three Heading"].content
173
+ described_class.create! name: "Basic+*type+*table of contents", content: "2"
174
+ @c1 = described_class.create! name: "toc1", type: "CardtypeE",
175
+ content: described_class["Onne Heading"].content
176
+ @c2 = described_class.create! name: "toc2", content: described_class["Twwo Heading"].content
177
+ @c3 = described_class.create! name: "toc3", content: described_class["Three Heading"].content
178
178
  expect(@c1.type_name).to eq("Cardtype E")
179
179
  @rule_card = @c1.rule_card(:table_of_contents)
180
180
 
@@ -182,16 +182,16 @@ describe Card do
182
182
  expect(@c2).to be
183
183
  expect(@c3).to be
184
184
  expect(@rule_card.name).to eq("*all+*table of contents")
185
- if (c = Card["CardtypeE+*type+*table of content"])
185
+ if (c = described_class["CardtypeE+*type+*table of content"])
186
186
  c.content = "2"
187
187
  c.save!
188
188
  else
189
- Card.create! name: "CardtypeE+*type+*table of content", content: "2"
189
+ described_class.create! name: "CardtypeE+*type+*table of content", content: "2"
190
190
  end
191
191
  end
192
192
  end
193
193
  it "takes on new setting value" do
194
- c = Card["toc1"]
194
+ c = described_class["toc1"]
195
195
  expect(c.rule_card(:table_of_contents).name)
196
196
  .to eq("CardtypeE+*type+*table of content")
197
197
  expect(c.rule(:table_of_contents)).to eq("2")
@@ -214,11 +214,11 @@ describe Card do
214
214
 
215
215
  context "when I change the general toc setting to 1" do
216
216
  before do
217
- expect(@c1 = Card["Onne Heading"]).to be
217
+ expect(@c1 = described_class["Onne Heading"]).to be
218
218
  # FIXME: CardtypeE should inherit from *default => Basic
219
219
  # @c2 = Card.create name: 'toc2', type: "CardtypeE",
220
220
  # content: Card['Twwo Heading'].content
221
- expect(@c2 = Card["Twwo Heading"]).to be
221
+ expect(@c2 = described_class["Twwo Heading"]).to be
222
222
  expect(@c1.type_id).to eq(Card::BasicID)
223
223
  expect(@rule_card = @c1.rule_card(:table_of_contents)).to be
224
224
  @rule_card.content = "1"
@@ -39,6 +39,7 @@ describe Card::Set::All::Rules do
39
39
  Card.create name: "*all+*help", content: "edit any kind of card"
40
40
  end
41
41
  subject { Card.new(type: "Book").rule(:add_help, fallback: :help) }
42
+
42
43
  it "retrieves default setting" do
43
44
  expect(subject).to eq("edit any kind of card")
44
45
  end
@@ -58,7 +59,7 @@ describe Card::Set::All::Rules do
58
59
 
59
60
  describe "#setting_codenames_by_group" do
60
61
  before do
61
- @pointer_settings = [:options, :options_label, :input]
62
+ @pointer_settings = %i[options options_label input]
62
63
  end
63
64
  it "doesn't fail on nonexistent trunks" do
64
65
  codenames = Card.new(name: "foob+*right").setting_codenames_by_group
@@ -73,12 +74,6 @@ describe Card::Set::All::Rules do
73
74
  expect(snbg.keys.first).to be_a Symbol
74
75
  expect(snbg.keys.member?(:pointer)).not_to be_truthy
75
76
  end
76
-
77
- it "returns pointer-specific setting names for pointer card" do
78
- c = Card.fetch "Fruit+*type+*create+*self", new: {}
79
- snbg = c.setting_codenames_by_group
80
- expect(snbg[:pointer]).to eq(@pointer_settings)
81
- end
82
77
  end
83
78
 
84
79
  describe "user specific rules" do
@@ -1,4 +1,4 @@
1
- require_dependency 'active_support/callbacks_ext'
1
+ require_dependency "active_support/callbacks_ext"
2
2
 
3
3
  # the events method is a developer's tool for visualizing the event order
4
4
  # for a given card.
@@ -49,7 +49,7 @@ format :html do
49
49
  db_card = Card.find_by_key(subject.key)
50
50
  return unless cache_card && db_card
51
51
  table(
52
- [:name, :updated_at, :updater_id, :content, :inspect].map do |field|
52
+ %i[name updated_at updater_id content inspect].map do |field|
53
53
  [field.to_s,
54
54
  h(cache_card.send(field)),
55
55
  h(db_card.send(field))]
@@ -1,4 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
+
2
3
  class Card
3
4
  # An "act" is a group of recorded {Card::Action actions} on {Card cards}.
4
5
  # Together, {Act acts}, {Action actions}, and {Change changes} comprise a
@@ -1,4 +1,4 @@
1
- #require_dependency File.expand_path("../../action/action_renderer", __FILE__)
1
+ # require_dependency File.expand_path("../../action/action_renderer", __FILE__)
2
2
 
3
3
  class Card
4
4
  class Act
@@ -6,6 +6,7 @@ class Card
6
6
  def initialize format, act, args
7
7
  @format = format
8
8
  @act = act
9
+ @act_card = act.card
9
10
  @args = args
10
11
  @card = @format.card
11
12
  @context = @args[:act_context]
@@ -13,7 +14,7 @@ class Card
13
14
 
14
15
  include ::Bootstrapper
15
16
 
16
- def method_missing(method_name, *args, &block)
17
+ def method_missing method_name, *args, &block
17
18
  if block_given?
18
19
  @format.send(method_name, *args, &block)
19
20
  else
@@ -26,29 +27,30 @@ class Card
26
27
  end
27
28
 
28
29
  def render
30
+ return "" unless @act_card
29
31
  act_accordion
30
32
  end
31
33
 
32
34
  def header
33
35
  #::Bootstrap.new(self).render do
34
36
  #::Boo.bs do
35
- bs_layout do
36
- row 10, 2 do
37
- column do
38
- html title
39
- tag(:span, "text-muted") { summary }
40
- end
41
- column act_links, class: "text-right"
42
- end
43
- row 12 do
44
- column subtitle
37
+ bs_layout do
38
+ row 10, 2 do
39
+ column do
40
+ html title
41
+ tag(:span, "text-muted") { summary }
45
42
  end
43
+ column act_links, class: "text-right"
44
+ end
45
+ row 12 do
46
+ column subtitle
46
47
  end
47
- #end
48
+ end
49
+ # end
48
50
  end
49
51
 
50
52
  def absolute_title
51
- accordion_expand_link(@act.card.name)
53
+ accordion_expand_link(@act_card.name)
52
54
  end
53
55
 
54
56
  def details
@@ -59,7 +61,7 @@ class Card
59
61
  end
60
62
 
61
63
  def summary
62
- [:create, :update, :delete, :draft].map do |type|
64
+ %i[create update delete draft].map do |type|
63
65
  next unless count_types[type] > 0
64
66
  "#{@format.action_icon type} #{count_types[type]}"
65
67
  end.compact.join " | "
@@ -68,17 +70,18 @@ class Card
68
70
  def act_links
69
71
  [
70
72
  link_to_history,
71
- (link_to_act_card unless @act.card.trash)
73
+ (link_to_act_card unless @act_card.trash)
72
74
  ].compact.join " "
73
75
  end
74
76
 
75
77
  def link_to_act_card
76
- link_to_card @act.card, glyphicon("new-window")
78
+ link_to_card @act_card, glyphicon("new-window")
77
79
  end
78
80
 
79
81
  def link_to_history
80
- link_to_card @act.card, glyphicon("time"), path: { view: :history,
81
- look_in_trash: true }
82
+ link_to_card @act_card, glyphicon("time"),
83
+ path: { view: :history, look_in_trash: true },
84
+ rel: "nofollow"
82
85
  end
83
86
 
84
87
  def approved_actions
@@ -175,7 +178,7 @@ class Card
175
178
 
176
179
  def previous_action
177
180
  # TODO: optimize
178
- actions.select { |action| action.card.last_action_id != action.id }
181
+ actions.reject { |action| action.card.last_action_id == action.id }
179
182
  end
180
183
 
181
184
  def show_or_hide_changes_link
@@ -29,6 +29,7 @@ class Card
29
29
  end
30
30
 
31
31
  def current_act?
32
+ return unless @format.card.last_act && @act
32
33
  @act.id == @format.card.last_act.id
33
34
  end
34
35
 
@@ -37,7 +37,7 @@ class Card
37
37
  }
38
38
 
39
39
  # these are the three possible values for action_type
40
- TYPE_OPTIONS = [:create, :update, :delete].freeze
40
+ TYPE_OPTIONS = %i[create update delete].freeze
41
41
 
42
42
  after_save :expire
43
43
 
@@ -11,7 +11,7 @@ class Card
11
11
  end
12
12
 
13
13
  include ::Bootstrapper
14
- def method_missing(method_name, *args, &block)
14
+ def method_missing method_name, *args, &block
15
15
  if block_given?
16
16
  @format.send(method_name, *args, &block)
17
17
  else
@@ -60,7 +60,7 @@ class Card
60
60
  path: { related: { view: "history", name: @action.card.name } },
61
61
  remote: true,
62
62
  class: "slotter",
63
- #"data-slot-selector" => ".card-slot.history-view"
63
+ # "data-slot-selector" => ".card-slot.history-view"
64
64
  )
65
65
  end
66
66
  end
@@ -1,4 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
+
2
3
  class Card
3
4
  # A _change_ is an alteration to a card's name, type, content, or trash state.
4
5
  # Together, {Act acts}, {Action actions}, and {Change changes} comprise a
@@ -19,7 +20,7 @@ class Card
19
20
  inverse_of: :card_changes
20
21
 
21
22
  # lists the database fields for which changes are recorded
22
- TRACKED_FIELDS = %w(name type_id db_content trash).freeze
23
+ TRACKED_FIELDS = %w[name type_id db_content trash].freeze
23
24
 
24
25
  class << self
25
26
  # delete all {Change changes} not associated with an {Action action}
@@ -32,7 +32,7 @@ format :html do
32
32
 
33
33
  def content_diff action, view_type
34
34
  diff = action.new_content? &&
35
- _render_content_changes(action: action, diff_type: view_type) #, hide_diff: @hide_diff
35
+ _render_content_changes(action: action, diff_type: view_type) # , hide_diff: @hide_diff
36
36
  return "<i>empty</i>" unless diff.present?
37
37
  diff
38
38
  end
@@ -116,12 +116,15 @@ def last_act
116
116
  @last_act ||=
117
117
  if (action = last_action)
118
118
  last_act_on_self = acts.last
119
- if last_act_on_self && action.act &&
120
- (action.act == last_act_on_self ||
121
- last_act_on_self.acted_at > action.act.acted_at)
119
+ act_of_last_action = action.act
120
+ return act_of_last_action unless last_act_on_self
121
+ return last_act_on_self unless act_of_last_action
122
+
123
+ return last_act_on_self if act_of_last_action == last_act_on_self
124
+ if last_act_on_self.acted_at > act_of_last_action.acted_at
122
125
  last_act_on_self
123
126
  else
124
- action.act
127
+ act_of_last_action
125
128
  end
126
129
  end
127
130
  end
@@ -163,7 +163,7 @@ format :html do
163
163
  intrusive_acts = card.intrusive_acts
164
164
  .page(page_from_params).per(ACTS_PER_PAGE)
165
165
  wrap_with :span, class: "slotter" do
166
- paginate intrusive_acts, remote: true, theme: 'twitter-bootstrap-3'
166
+ paginate intrusive_acts, remote: true, theme: "twitter-bootstrap-3"
167
167
  end
168
168
  end
169
169
 
@@ -172,17 +172,17 @@ format :html do
172
172
  end
173
173
 
174
174
  def action_legend with_drafts=true
175
- types = [:create, :update, :delete]
175
+ types = %i[create update delete]
176
176
  legend = types.map do |action_type|
177
- "#{action_icon(action_type)} #{action_type}d"
178
- end
177
+ "#{action_icon(action_type)} #{action_type}d"
178
+ end
179
179
  legend << "#{action_icon(:draft)} unsaved draft" if with_drafts
180
180
  "<small>Actions: #{legend.join ' | '}</small>"
181
181
  end
182
182
 
183
183
  def content_legend
184
- legend = [Card::Content::Diff.render_added_chunk('Additions'),
185
- Card::Content::Diff.render_deleted_chunk('Subtractions')]
184
+ legend = [Card::Content::Diff.render_added_chunk("Additions"),
185
+ Card::Content::Diff.render_deleted_chunk("Subtractions")]
186
186
  "<small>Content changes: #{legend.join ' | '}</small>"
187
187
  end
188
188