card 1.19.1 → 1.19.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +3 -3
  3. data/VERSION +1 -1
  4. data/db/migrate_core_cards/20160908154210_add_trash_card.rb +7 -0
  5. data/lib/card.rb +2 -2
  6. data/lib/card/act_manager.rb +143 -0
  7. data/lib/card/act_manager/stage.rb +56 -0
  8. data/lib/card/act_manager/stage_director.rb +313 -0
  9. data/lib/card/act_manager/subdirector_array.rb +43 -0
  10. data/lib/card/set.rb +1 -0
  11. data/lib/card/set/i18n_scope.rb +52 -0
  12. data/lib/card/subcards.rb +2 -3
  13. data/lib/cardio.rb +4 -4
  14. data/mod/admin/set/self/admin.rb +1 -2
  15. data/mod/admin/set/self/trash.rb +29 -0
  16. data/mod/core/set/abstract/code_file.rb +5 -25
  17. data/mod/core/set/all/actify.rb +35 -0
  18. data/mod/core/set/all/fetch.rb +12 -15
  19. data/mod/core/set/all/i18n.rb +9 -0
  20. data/mod/core/set/all/phases.rb +1 -1
  21. data/mod/core/set/all/stages.rb +2 -2
  22. data/mod/developer/set/all/event_viz.rb +2 -1
  23. data/mod/email/set/all/notify.rb +1 -1
  24. data/mod/history/lib/card/act.rb +1 -1
  25. data/mod/history/lib/card/action.rb +1 -1
  26. data/mod/history/set/all/history.rb +1 -1
  27. data/mod/machines/set/abstract/machine.rb +1 -1
  28. data/mod/machines/spec/set/type/coffeescript_spec.rb +1 -1
  29. data/mod/machines/spec/set/type/css_spec.rb +1 -1
  30. data/mod/machines/spec/set/type/javascript_spec.rb +1 -1
  31. data/mod/machines/spec/set/type/scss_spec.rb +1 -1
  32. data/mod/machines/spec/set/type/skin_spec.rb +1 -1
  33. data/mod/machines/spec/{lib/shared_machine_examples.rb → shared_examples/machine.rb} +15 -24
  34. data/mod/machines/spec/{lib/shared_machine_input_examples.rb → shared_examples/machine_input.rb} +0 -0
  35. data/mod/settings/spec/set/right/script_spec.rb +1 -1
  36. data/mod/settings/spec/set/right/style_spec.rb +1 -4
  37. data/mod/solid_cache/set/abstract/solid_cache.rb +1 -1
  38. data/spec/lib/card/content_spec.rb +118 -132
  39. data/spec/lib/card/i18n_spec.rb +6 -7
  40. data/spec/lib/card/query_spec.rb +5 -4
  41. data/spec/lib/card/stage_director_spec.rb +1 -1
  42. data/spec/spec_helper.rb +3 -4
  43. data/tmpsets/set/{mod002-core → mod001-core}/abstract/code_file.rb +0 -0
  44. data/tmpsets/set/{mod002-core → mod001-core}/all/actify.rb +0 -0
  45. data/tmpsets/set/{mod002-core → mod001-core}/all/active_card.rb +0 -0
  46. data/tmpsets/set/{mod002-core → mod001-core}/all/collection.rb +0 -0
  47. data/tmpsets/set/{mod002-core → mod001-core}/all/content.rb +0 -0
  48. data/tmpsets/set/{mod002-core → mod001-core}/all/erb.rb +0 -0
  49. data/tmpsets/set/{mod002-core → mod001-core}/all/event.rb +0 -0
  50. data/tmpsets/set/{mod002-core → mod001-core}/all/export.rb +0 -0
  51. data/tmpsets/set/{mod002-core → mod001-core}/all/fetch.rb +12 -14
  52. data/tmpsets/set/{mod002-core → mod001-core}/all/haml.rb +0 -0
  53. data/tmpsets/set/{mod002-core → mod001-core}/all/initialize.rb +0 -0
  54. data/tmpsets/set/{mod002-core → mod001-core}/all/location_history.rb +0 -0
  55. data/tmpsets/set/{mod002-core → mod001-core}/all/name.rb +0 -0
  56. data/tmpsets/set/{mod002-core → mod001-core}/all/name_validations.rb +0 -0
  57. data/tmpsets/set/{mod002-core → mod001-core}/all/pattern.rb +0 -0
  58. data/tmpsets/set/{mod002-core → mod001-core}/all/permissions.rb +0 -0
  59. data/tmpsets/set/{mod002-core → mod001-core}/all/phases.rb +0 -0
  60. data/tmpsets/set/{mod002-core → mod001-core}/all/references.rb +0 -0
  61. data/tmpsets/set/{mod002-core → mod001-core}/all/rules.rb +0 -0
  62. data/tmpsets/set/{mod002-core → mod001-core}/all/stages.rb +0 -0
  63. data/tmpsets/set/{mod002-core → mod001-core}/all/states.rb +0 -0
  64. data/tmpsets/set/{mod002-core → mod001-core}/all/subcards.rb +0 -0
  65. data/tmpsets/set/{mod002-core → mod001-core}/all/templating.rb +0 -0
  66. data/tmpsets/set/{mod002-core → mod001-core}/all/tracked_attributes.rb +0 -0
  67. data/tmpsets/set/{mod002-core → mod001-core}/all/trash.rb +0 -50
  68. data/tmpsets/set/{mod002-core → mod001-core}/all/type.rb +0 -0
  69. data/tmpsets/set/{mod002-core → mod001-core}/all/utils.rb +33 -0
  70. data/tmpsets/set/{mod002-core → mod001-core}/all/view_cache.rb +0 -0
  71. data/tmpsets/set/{mod003-history → mod002-history}/all/actions.rb +0 -0
  72. data/tmpsets/set/{mod003-history → mod002-history}/all/content_history.rb +0 -0
  73. data/tmpsets/set/{mod003-history → mod002-history}/all/history.rb +0 -0
  74. data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/all/all_css.rb +0 -0
  75. data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/all/all_csv.rb +0 -0
  76. data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/all/all_js.rb +0 -0
  77. data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/all/base.rb +0 -0
  78. data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/all/file.rb +0 -0
  79. data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/all/json.rb +0 -0
  80. data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/all/rss.rb +0 -0
  81. data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/all/text.rb +0 -0
  82. data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/self/01_head/javascript.rb +0 -0
  83. data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/self/head.rb +1 -1
  84. data/tmpsets/set/{mod005-pointer → mod004-pointer}/abstract/01_pointer.rb +0 -0
  85. data/tmpsets/set/{mod005-pointer → mod004-pointer}/abstract/01_pointer/edit.rb +0 -0
  86. data/tmpsets/set/{mod005-pointer → mod004-pointer}/abstract/code_pointer.rb +0 -0
  87. data/tmpsets/set/{mod005-pointer → mod004-pointer}/self/script_editors.rb +0 -0
  88. data/tmpsets/set/{mod005-pointer → mod004-pointer}/self/script_mods.rb +0 -0
  89. data/tmpsets/set/{mod005-pointer → mod004-pointer}/self/script_pointer_config.rb +0 -0
  90. data/tmpsets/set/{mod005-pointer → mod004-pointer}/type/pointer.rb +0 -0
  91. data/tmpsets/set/{mod006-ace_editor → mod005-ace_editor}/abstract/ace_editor.rb +0 -0
  92. data/tmpsets/set/{mod006-ace_editor → mod005-ace_editor}/self/script_ace.rb +0 -0
  93. data/tmpsets/set/{mod006-ace_editor → mod005-ace_editor}/self/script_ace_config.rb +0 -0
  94. data/tmpsets/set/{mod007-prosemirror_editor → mod006-prosemirror_editor}/abstract/prosemirror_editor.rb +0 -0
  95. data/tmpsets/set/{mod007-prosemirror_editor → mod006-prosemirror_editor}/self/script_prosemirror.rb +0 -0
  96. data/tmpsets/set/{mod007-prosemirror_editor → mod006-prosemirror_editor}/self/script_prosemirror_config.rb +0 -0
  97. data/tmpsets/set/{mod009-solid_cache → mod008-solid_cache}/abstract/solid_cache.rb +1 -1
  98. data/tmpsets/set/{mod009-solid_cache → mod008-solid_cache}/all/solid_cache.rb +0 -0
  99. data/tmpsets/set/{mod009-solid_cache → mod008-solid_cache}/right/solid_cache.rb +0 -0
  100. data/tmpsets/set/{mod010-basic_types → mod009-basic_types}/type/html.rb +0 -0
  101. data/tmpsets/set/{mod010-basic_types → mod009-basic_types}/type/plain_text.rb +0 -0
  102. data/tmpsets/set/{mod011-machines → mod010-machines}/abstract/script.rb +0 -0
  103. data/tmpsets/set/{mod011-machines → mod010-machines}/all/reset_machines.rb +0 -0
  104. data/tmpsets/set/{mod011-machines → mod010-machines}/right/machine_cache.rb +0 -0
  105. data/tmpsets/set/{mod011-machines → mod010-machines}/right/machine_input.rb +0 -0
  106. data/tmpsets/set/{mod011-machines → mod010-machines}/right/machine_output.rb +1 -9
  107. data/tmpsets/set/{mod011-machines → mod010-machines}/self/script_card_menu.rb +0 -0
  108. data/tmpsets/set/{mod011-machines → mod010-machines}/self/script_html5shiv_printshiv.rb +0 -0
  109. data/tmpsets/set/{mod011-machines → mod010-machines}/self/script_jquery.rb +0 -0
  110. data/tmpsets/set/{mod011-machines → mod010-machines}/self/script_jquery_helper.rb +0 -0
  111. data/tmpsets/set/{mod011-machines → mod010-machines}/self/script_slot.rb +0 -0
  112. data/tmpsets/set/{mod011-machines → mod010-machines}/self/style_bootstrap_compatible.rb +0 -0
  113. data/tmpsets/set/{mod011-machines → mod010-machines}/self/style_cards.rb +0 -0
  114. data/tmpsets/set/{mod011-machines → mod010-machines}/self/style_jquery_ui_smoothness.rb +0 -0
  115. data/tmpsets/set/{mod011-machines → mod010-machines}/type/coffee_script.rb +6 -2
  116. data/tmpsets/set/{mod011-machines → mod010-machines}/type/css.rb +2 -2
  117. data/tmpsets/set/{mod011-machines → mod010-machines}/type/java_script.rb +2 -2
  118. data/tmpsets/set/{mod011-machines → mod010-machines}/type/scss.rb +0 -0
  119. data/tmpsets/set/{mod011-machines → mod010-machines}/type/skin.rb +2 -2
  120. data/tmpsets/set/{mod012-settings → mod011-settings}/abstract/permission.rb +0 -0
  121. data/tmpsets/set/{mod012-settings → mod011-settings}/right/add_help.rb +0 -0
  122. data/tmpsets/set/{mod012-settings → mod011-settings}/right/comment.rb +0 -0
  123. data/tmpsets/set/{mod012-settings → mod011-settings}/right/create.rb +0 -0
  124. data/tmpsets/set/{mod012-settings → mod011-settings}/right/default.rb +0 -0
  125. data/tmpsets/set/{mod012-settings → mod011-settings}/right/delete.rb +0 -0
  126. data/tmpsets/set/{mod012-settings → mod011-settings}/right/help.rb +0 -0
  127. data/tmpsets/set/{mod012-settings → mod011-settings}/right/read.rb +0 -0
  128. data/tmpsets/set/{mod012-settings → mod011-settings}/right/script.rb +1 -1
  129. data/tmpsets/set/{mod012-settings → mod011-settings}/right/structure.rb +0 -0
  130. data/tmpsets/set/{mod012-settings → mod011-settings}/right/style.rb +1 -1
  131. data/tmpsets/set/{mod012-settings → mod011-settings}/right/update.rb +0 -0
  132. data/tmpsets/set/{mod012-settings → mod011-settings}/self/accountable.rb +0 -0
  133. data/tmpsets/set/{mod012-settings → mod011-settings}/self/add_help.rb +0 -0
  134. data/tmpsets/set/{mod012-settings → mod011-settings}/self/autoname.rb +0 -0
  135. data/tmpsets/set/{mod012-settings → mod011-settings}/self/captcha.rb +0 -0
  136. data/tmpsets/set/{mod012-settings → mod011-settings}/self/create.rb +0 -0
  137. data/tmpsets/set/{mod012-settings → mod011-settings}/self/default.rb +0 -0
  138. data/tmpsets/set/{mod012-settings → mod011-settings}/self/default_html_view.rb +0 -0
  139. data/tmpsets/set/{mod012-settings → mod011-settings}/self/delete.rb +0 -0
  140. data/tmpsets/set/{mod012-settings → mod011-settings}/self/follow_fields.rb +0 -0
  141. data/tmpsets/set/{mod012-settings → mod011-settings}/self/help.rb +0 -0
  142. data/tmpsets/set/{mod012-settings → mod011-settings}/self/input.rb +0 -0
  143. data/tmpsets/set/{mod012-settings → mod011-settings}/self/layout.rb +0 -0
  144. data/tmpsets/set/{mod012-settings → mod011-settings}/self/on_create.rb +0 -0
  145. data/tmpsets/set/{mod012-settings → mod011-settings}/self/on_delete.rb +0 -0
  146. data/tmpsets/set/{mod012-settings → mod011-settings}/self/on_update.rb +0 -0
  147. data/tmpsets/set/{mod012-settings → mod011-settings}/self/options.rb +0 -0
  148. data/tmpsets/set/{mod012-settings → mod011-settings}/self/options_label.rb +0 -0
  149. data/tmpsets/set/{mod012-settings → mod011-settings}/self/read.rb +0 -0
  150. data/tmpsets/set/{mod012-settings → mod011-settings}/self/recent_settings.rb +0 -0
  151. data/tmpsets/set/{mod012-settings → mod011-settings}/self/script.rb +0 -0
  152. data/tmpsets/set/{mod012-settings → mod011-settings}/self/structure.rb +0 -0
  153. data/tmpsets/set/{mod012-settings → mod011-settings}/self/style.rb +0 -0
  154. data/tmpsets/set/{mod012-settings → mod011-settings}/self/table_of_contents.rb +0 -0
  155. data/tmpsets/set/{mod012-settings → mod011-settings}/self/thanks.rb +0 -0
  156. data/tmpsets/set/{mod012-settings → mod011-settings}/self/update.rb +0 -0
  157. data/tmpsets/set/{mod012-settings → mod011-settings}/type/setting.rb +0 -0
  158. data/tmpsets/set/{mod013-email → mod012-email}/all/email_html.rb +0 -0
  159. data/tmpsets/set/{mod013-email → mod012-email}/all/email_text.rb +0 -0
  160. data/tmpsets/set/{mod013-email → mod012-email}/all/follow.rb +0 -0
  161. data/tmpsets/set/{mod013-email → mod012-email}/all/notify.rb +0 -0
  162. data/tmpsets/set/{mod013-email → mod012-email}/all/observer.rb +0 -0
  163. data/tmpsets/set/{mod013-email → mod012-email}/right/bcc.rb +0 -0
  164. data/tmpsets/set/{mod013-email → mod012-email}/right/cc.rb +0 -0
  165. data/tmpsets/set/{mod013-email → mod012-email}/right/follow.rb +0 -0
  166. data/tmpsets/set/{mod013-email → mod012-email}/right/follow_fields.rb +0 -0
  167. data/tmpsets/set/{mod013-email → mod012-email}/right/followers.rb +0 -0
  168. data/tmpsets/set/{mod013-email → mod012-email}/right/following.rb +0 -0
  169. data/tmpsets/set/{mod013-email → mod012-email}/right/from.rb +0 -0
  170. data/tmpsets/set/{mod013-email → mod012-email}/right/html_message.rb +0 -0
  171. data/tmpsets/set/{mod013-email → mod012-email}/right/to.rb +0 -0
  172. data/tmpsets/set/{mod013-email → mod012-email}/self/always.rb +0 -0
  173. data/tmpsets/set/{mod013-email → mod012-email}/self/created.rb +0 -0
  174. data/tmpsets/set/{mod013-email → mod012-email}/self/edited.rb +0 -0
  175. data/tmpsets/set/{mod013-email → mod012-email}/self/follow.rb +0 -0
  176. data/tmpsets/set/{mod013-email → mod012-email}/self/follow_defaults.rb +0 -0
  177. data/tmpsets/set/{mod013-email → mod012-email}/self/never.rb +0 -0
  178. data/tmpsets/set/{mod013-email → mod012-email}/type/email_template.rb +0 -0
  179. data/tmpsets/set/{mod013-email → mod012-email}/type_plus_right/user/follow.rb +8 -4
  180. data/tmpsets/set/mod016-standard/all/links.rb +2 -2
  181. data/tmpsets/set/mod018-bootstrap/all/bootstrap/table.rb +1 -1
  182. data/tmpsets/set/mod018-bootstrap/self/bootswatch_shared.rb +1 -1
  183. metadata +149 -163
  184. data/lib/card/director_register.rb +0 -101
  185. data/lib/card/stage.rb +0 -106
  186. data/lib/card/stage_director.rb +0 -310
  187. data/lib/card/subdirector_array.rb +0 -43
  188. data/tmpsets/set/mod001-admin/self/admin.rb +0 -130
  189. data/tmpsets/set/mod001-admin/self/admin_info.rb +0 -110
  190. data/tmpsets/set/mod001-admin/self/version.rb +0 -15
  191. data/tmpsets/set/mod002-core/all/debug.rb +0 -30
  192. data/tmpsets/set/mod002-core/all/update_read_rules.rb +0 -91
  193. data/tmpsets/set/mod011-machines/abstract/machine.rb +0 -277
  194. data/tmpsets/set/mod011-machines/abstract/machine_input.rb +0 -83
  195. data/tmpsets/set/mod014-developer/all/event_viz.rb +0 -59
  196. data/tmpsets/set/mod014-developer/all/view_viz.rb +0 -30
  197. data/tmpsets/set/mod014-developer/right/debug.rb +0 -96
  198. data/tmpsets/set/mod015-carrierwave/abstract/attachment.rb +0 -118
  199. data/tmpsets/set/mod015-carrierwave/abstract/attachment/paths.rb +0 -57
  200. data/tmpsets/set/mod015-carrierwave/abstract/attachment/storage_type.rb +0 -326
  201. data/tmpsets/set/mod015-carrierwave/abstract/attachment/upload_cache.rb +0 -84
  202. data/tmpsets/set/mod015-carrierwave/all/file_utils.rb +0 -35
  203. data/tmpsets/set/mod015-carrierwave/self/admin.rb +0 -30
  204. data/tmpsets/set/mod015-carrierwave/type/file.rb +0 -158
  205. data/tmpsets/set/mod015-carrierwave/type/image.rb +0 -97
@@ -52,7 +52,7 @@ describe Card::Set::Type::Scss do
52
52
  end
53
53
  end
54
54
 
55
- it_should_behave_like "content machine", that_produces_css do
55
+ it_should_behave_like "content machine", that_produces: :css do
56
56
  let(:machine_card) { Card.gimme! "test scss", type: :scss, content: scss }
57
57
  let(:card_content) do
58
58
  { in: scss, out: compressed_css,
@@ -8,7 +8,7 @@ describe Card::Set::Type::Skin do
8
8
  let(:new_css) { "#box{display: none }\n" }
9
9
  let(:compressed_new_css) { "#box{display:none}\n" }
10
10
 
11
- it_should_behave_like "pointer machine", that_produces_css do
11
+ it_should_behave_like "pointer machine", that_produces: :css do
12
12
  let(:machine_card) do
13
13
  Card.gimme! "test skin machine", type: :skin, content: ""
14
14
  end
@@ -1,19 +1,7 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- def that_produces type
4
- type
5
- end
6
-
7
- def method_missing m, *args, &block
8
- case m
9
- when /that_produces_(.+)/
10
- return Regexp.last_match(1)
11
- else
12
- super
13
- end
14
- end
15
-
16
- shared_examples_for "machine" do |filetype|
3
+ shared_examples_for "machine" do |args|
4
+ let(:filetype) { args[:that_produces] }
17
5
  context "machine is run" do
18
6
  before do
19
7
  machine.update_machine_output
@@ -25,14 +13,16 @@ shared_examples_for "machine" do |filetype|
25
13
  it "has +machine_output card" do
26
14
  expect(machine.machine_output_card.real?).to be_truthy
27
15
  end
28
- it "generates #{filetype} file" do
16
+ it "generates #{args[:that_produces]} file" do
29
17
  expect(machine.machine_output_path).to match(/\.#{filetype}$/)
30
18
  end
31
19
  end
32
20
  end
33
21
 
34
- shared_examples_for "content machine" do |filetype|
35
- it_should_behave_like "machine", that_produces(filetype) do
22
+ shared_examples_for "content machine" do |args|
23
+ let(:filetype) { args[:that_produces] }
24
+
25
+ it_should_behave_like "machine", args do
36
26
  let(:machine) { machine_card }
37
27
  end
38
28
 
@@ -50,7 +40,7 @@ shared_examples_for "content machine" do |filetype|
50
40
  path = machine_card.machine_output_path
51
41
  expect(File.read(path)).to eq(card_content[:out])
52
42
  end
53
- it "updates #{filetype} file when content is changed" do
43
+ it "updates #{args[:that_produces]} file when content is changed" do
54
44
  changed_factory = machine_card
55
45
  changed_factory.putty content: card_content[:changed_in]
56
46
  changed_path = changed_factory.machine_output_path
@@ -59,7 +49,8 @@ shared_examples_for "content machine" do |filetype|
59
49
  end
60
50
  end
61
51
 
62
- shared_examples_for "pointer machine" do |filetype|
52
+ shared_examples_for "pointer machine" do |args|
53
+ let(:filetype) { args[:that_produces] }
63
54
  subject do
64
55
  # We build the following structure:
65
56
  #
@@ -115,7 +106,7 @@ shared_examples_for "pointer machine" do |filetype|
115
106
  change_machine
116
107
  end
117
108
 
118
- it_should_behave_like "machine", that_produces(filetype) do
109
+ it_should_behave_like "machine", args do
119
110
  let(:machine) { machine_card }
120
111
  end
121
112
 
@@ -138,18 +129,18 @@ shared_examples_for "pointer machine" do |filetype|
138
129
  end
139
130
 
140
131
  describe "+machine_output card" do
141
- it 'creates #{filetype} file with supplied content' do
132
+ it 'creates #{args[:that_produces]} file with supplied content' do
142
133
  path = subject.machine_output_path
143
134
  expect(File.read(path)).to eq(card_content[:out])
144
135
  end
145
136
 
146
- it 'updates #{filetype} file if item is changed' do
137
+ it 'updates #{args[:that_produces]} file if item is changed' do
147
138
  machine_input_card.putty content: card_content[:changed_in]
148
139
  changed_path = subject.machine_output_path
149
140
  expect(File.read(changed_path)).to eq(card_content[:changed_out])
150
141
  end
151
142
 
152
- it 'updates #{filetype} file if item is added' do
143
+ it 'updates #{args[:that_produces]} file if item is added' do
153
144
  Card::Auth.as_bot do
154
145
  ca = Card.gimme! "pointer item", type: Card::SkinID, content: ""
155
146
  subject.items = [ca]
@@ -161,7 +152,7 @@ shared_examples_for "pointer machine" do |filetype|
161
152
  end
162
153
 
163
154
  context "a non-existent card was added as item and now created" do
164
- it 'updates #{filetype} file' do
155
+ it 'updates #{args[:that_produces]} file' do
165
156
  Card::Auth.as_bot do
166
157
  subject.content = "[[non-existent input]]"
167
158
  subject.save!
@@ -8,7 +8,7 @@ describe Card::Set::Right::Script do
8
8
  let(:new_js) { 'alert( "Hey" );' }
9
9
  let(:compressed_new_js) { 'alert("Hey");' }
10
10
 
11
- it_should_behave_like "pointer machine", that_produces_js do
11
+ it_should_behave_like "pointer machine", that_produces: :js do
12
12
  let(:input_name) { "test js" }
13
13
  let(:machine_card) do
14
14
  Card.gimme! "test my style+*script", type: :pointer, content: ""
@@ -1,8 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- require File.expand_path("../../../../../machines/spec/lib/"\
4
- "shared_machine_examples.rb", __FILE__)
5
-
6
3
  describe Card::Set::Right::Style do
7
4
  # describe "#delet"
8
5
  # it "should delete tempfile"
@@ -13,7 +10,7 @@ describe Card::Set::Right::Style do
13
10
  let(:new_css) { "#box{ display: none}\n" }
14
11
  let(:compressed_new_css) { "#box{display:none}\n" }
15
12
 
16
- it_should_behave_like "pointer machine", that_produces_css do
13
+ it_should_behave_like "pointer machine", that_produces: :css do
17
14
  let(:machine_card) do
18
15
  Card.gimme! "test my style+*style", type: :pointer, content: ""
19
16
  end
@@ -28,7 +28,7 @@ module ClassMethods
28
28
  # cards whose solid caches are expired because of the update.
29
29
  # @param set_of_changed_card [set constant] a set of cards that triggers
30
30
  # a cache update
31
- # @params args [Hash]
31
+ # @param args [Hash]
32
32
  # @option args [Symbol, Array of symbols] :on the action(s)
33
33
  # (:create, :update, or :delete) on which the cache update
34
34
  # should be triggered. Default is all actions.
@@ -1,156 +1,144 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  require "card/content"
3
3
 
4
- EXAMPLES = {
5
- nests: {
6
- content: "Some Literals: \\[{I'm not| a link]}, and " \
4
+ describe Card::Content do
5
+ EXAMPLES = {
6
+ nests: {
7
+ content: "Some Literals: \\[{I'm not| a link]}, and " \
7
8
  '\\{{This Card|Is not Included}}' \
8
9
  ", but " \
9
10
  "{{this is}}" \
10
11
  ", and some tail",
11
- rendered: ["Some Literals: \\[{I'm not| a link]}, and ",
12
- "<span>{</span>{This Card|Is not Included}}",
13
- ", but ",
14
- { options: { inc_name: "this is",
15
- inc_syntax: "this is"
16
- }
17
- },
18
- ", and some tail"
19
- ],
20
- classes: [String, :EscapedLiteral, String, :Include, String]
21
- },
22
-
23
- links_and_nests: {
24
- content: "Some Links and includes: [[the card|the text]], " \
12
+ rendered: ["Some Literals: \\[{I'm not| a link]}, and ",
13
+ "<span>{</span>{This Card|Is not Included}}",
14
+ ", but ",
15
+ { options: { inc_name: "this is",
16
+ inc_syntax: "this is" } },
17
+ ", and some tail"],
18
+ classes: [String, :EscapedLiteral, String, :Include, String]
19
+ },
20
+
21
+ links_and_nests: {
22
+ content: "Some Links and includes: [[the card|the text]], " \
25
23
  "and {{This Card|Is Included}}{{this too}} " \
26
24
  "and [[http://external.wagn.org/path|link text]]" \
27
25
  "{{Included|open}}",
28
- rendered: ["Some Links and includes: ",
29
- '<a class="wanted-card" ' \
26
+ rendered: ["Some Links and includes: ",
27
+ '<a class="wanted-card" ' \
30
28
  'href="/the_card?card%5Bname%5D=the+card">' \
31
29
  "the text</a>",
32
- ", and ",
33
- { options: { view: "Is Included",
34
- inc_name: "This Card",
35
- inc_syntax: "This Card|Is Included"
36
- }
37
- },
38
- { options: { inc_name: "this too",
39
- inc_syntax: "this too"
40
- }
41
- },
42
- " and ",
43
- '<a target="_blank" class="external-link" ' \
30
+ ", and ",
31
+ { options: { view: "Is Included",
32
+ inc_name: "This Card",
33
+ inc_syntax: "This Card|Is Included" } },
34
+ { options: { inc_name: "this too",
35
+ inc_syntax: "this too" } },
36
+ " and ",
37
+ '<a target="_blank" class="external-link" ' \
44
38
  'href="http://external.wagn.org/path">link text</a>',
45
- { options: { view: "open",
46
- inc_name: "Included",
47
- inc_syntax: "Included|open"
48
- }
49
- }
50
- ],
51
- classes: [
52
- String, :Link, String, :Include, :Include, String, :Link, :Include
53
- ]
54
- },
55
-
56
- uris_and_links: {
57
- content: "Some URIs and Links: http://a.url.com/ " \
39
+ { options: { view: "open",
40
+ inc_name: "Included",
41
+ inc_syntax: "Included|open" } }],
42
+ classes: [
43
+ String, :Link, String, :Include, :Include, String, :Link, :Include
44
+ ]
45
+ },
46
+
47
+ uris_and_links: {
48
+ content: "Some URIs and Links: http://a.url.com/ " \
58
49
  "More urls: wagn.com/a/path/to.html " \
59
50
  "http://localhost:2020/path?cgi=foo&bar=baz " \
60
51
  "[[http://brain.org/Home|extra]] " \
61
52
  "[ http://gerry.wagn.com/a/path ] " \
62
53
  "{ https://brain.org/more?args } ",
63
- rendered: ["Some URIs and Links: ",
64
- '<a target="_blank" class="external-link" ' \
54
+ rendered: ["Some URIs and Links: ",
55
+ '<a target="_blank" class="external-link" ' \
65
56
  'href="http://a.url.com/">http://a.url.com/</a>',
66
- " More urls: ",
67
- '<a target="_blank" class="external-link" ' \
57
+ " More urls: ",
58
+ '<a target="_blank" class="external-link" ' \
68
59
  'href="http://wagn.com/a/path/to.html">' \
69
60
  "wagn.com/a/path/to.html</a>",
70
- " ",
71
- '<a target="_blank" class="external-link" ' \
61
+ " ",
62
+ '<a target="_blank" class="external-link" ' \
72
63
  'href="http://localhost:2020/path?cgi=foo&amp;bar=baz">' \
73
64
  "http://localhost:2020/path?cgi=foo&bar=baz</a>",
74
- " ",
75
- '<a target="_blank" class="external-link" ' \
65
+ " ",
66
+ '<a target="_blank" class="external-link" ' \
76
67
  'href="http://brain.org/Home">extra</a>',
77
- " [ ",
78
- '<a target="_blank" class="external-link" ' \
68
+ " [ ",
69
+ '<a target="_blank" class="external-link" ' \
79
70
  'href="http://gerry.wagn.com/a/path">' \
80
71
  "http://gerry.wagn.com/a/path</a>",
81
- " ] { ",
82
- '<a target="_blank" class="external-link" ' \
72
+ " ] { ",
73
+ '<a target="_blank" class="external-link" ' \
83
74
  'href="https://brain.org/more?args">' \
84
75
  "https://brain.org/more?args</a>",
85
- " } "
86
- ],
87
- text_rendered: ["Some URIs and Links: ", "http://a.url.com/",
88
- " More urls: ",
89
- "wagn.com/a/path/to.html[http://wagn.com/a/path/to.html]",
90
- " ",
91
- "http://localhost:2020/path?cgi=foo&bar=baz",
92
- " ",
93
- "extra[http://brain.org/Home]",
94
- " [ ",
95
- "http://gerry.wagn.com/a/path",
96
- " ] { ",
97
- "https://brain.org/more?args",
98
- " } "
99
- ],
100
- classes: [
101
- String, :URI, String, :HostURI, String, :URI, String, :Link,
102
- String, :URI, String, :URI, String
103
- ]
104
- },
105
-
106
- uris_and_links_2: {
107
- content: "Some URIs and Links: http://a.url.com " \
76
+ " } "],
77
+ text_rendered: ["Some URIs and Links: ", "http://a.url.com/",
78
+ " More urls: ",
79
+ "wagn.com/a/path/to.html[http://wagn.com/a/path/to.html]",
80
+ " ",
81
+ "http://localhost:2020/path?cgi=foo&bar=baz",
82
+ " ",
83
+ "extra[http://brain.org/Home]",
84
+ " [ ",
85
+ "http://gerry.wagn.com/a/path",
86
+ " ] { ",
87
+ "https://brain.org/more?args",
88
+ " } "],
89
+ classes: [
90
+ String, :URI, String, :HostURI, String, :URI, String, :Link,
91
+ String, :URI, String, :URI, String
92
+ ]
93
+ },
94
+
95
+ uris_and_links_2: {
96
+ content: "Some URIs and Links: http://a.url.com " \
108
97
  "More urls: wagn.com/a/path/to.html " \
109
98
  "[ http://gerry.wagn.com/a/path ] " \
110
99
  "{ https://brain.org/more?args } " \
111
100
  "http://localhost:2020/path?cgi=foo&bar=baz " \
112
101
  "[[http://brain.org/Home|extra]]",
113
- rendered: ["Some URIs and Links: ",
114
- '<a target="_blank" class="external-link" ' \
102
+ rendered: ["Some URIs and Links: ",
103
+ '<a target="_blank" class="external-link" ' \
115
104
  'href="http://a.url.com">http://a.url.com</a>',
116
- " More urls: ",
117
- '<a target="_blank" class="external-link" ' \
105
+ " More urls: ",
106
+ '<a target="_blank" class="external-link" ' \
118
107
  'href="http://wagn.com/a/path/to.html">' \
119
108
  "wagn.com/a/path/to.html</a>",
120
- " [ ",
121
- '<a target="_blank" class="external-link" ' \
109
+ " [ ",
110
+ '<a target="_blank" class="external-link" ' \
122
111
  'href="http://gerry.wagn.com/a/path">' \
123
112
  "http://gerry.wagn.com/a/path</a>",
124
- " ] { ",
125
- '<a target="_blank" class="external-link" ' \
113
+ " ] { ",
114
+ '<a target="_blank" class="external-link" ' \
126
115
  'href="https://brain.org/more?args">' \
127
116
  "https://brain.org/more?args</a>",
128
- " } ",
129
- '<a target="_blank" class="external-link" ' \
117
+ " } ",
118
+ '<a target="_blank" class="external-link" ' \
130
119
  'href="http://localhost:2020/path?cgi=foo&amp;bar=baz">' \
131
120
  "http://localhost:2020/path?cgi=foo&bar=baz</a>",
132
- " ",
133
- '<a target="_blank" class="external-link" ' \
134
- 'href="http://brain.org/Home">extra</a>'
135
- ],
136
- classes: [
137
- String, :URI, String, :HostURI, String, :URI, String, :URI, String, :URI,
138
- String, :Link
139
- ]
140
- },
141
-
142
- no_chunks: {
143
- content: "No chunks",
144
- rendered: "No chunks"
145
- },
146
-
147
- single_nest: {
148
- content: "{{one nest|size;large}}",
149
- classes: [:Include]
150
- },
151
-
152
- css: {
153
- content: %(
121
+ " ",
122
+ '<a target="_blank" class="external-link" ' \
123
+ 'href="http://brain.org/Home">extra</a>'],
124
+ classes: [
125
+ String, :URI, String, :HostURI, String, :URI, String, :URI,
126
+ String, :URI, String, :Link
127
+ ]
128
+ },
129
+
130
+ no_chunks: {
131
+ content: "No chunks",
132
+ rendered: "No chunks"
133
+ },
134
+
135
+ single_nest: {
136
+ content: "{{one nest|size;large}}",
137
+ classes: [:Include]
138
+ },
139
+
140
+ css: {
141
+ content: %(
154
142
  /* body text */
155
143
  body {
156
144
  color: #444444;
@@ -178,21 +166,20 @@ EXAMPLES = {
178
166
  color: #222299;
179
167
  }
180
168
  )
181
- }
182
- }.freeze
169
+ }
170
+ }.freeze
183
171
 
184
- EXAMPLES.each_value do |val|
185
- next unless val[:classes]
186
- val[:classes] = val[:classes].map do |klass|
187
- klass.is_a?(Class) ? klass : Card::Content::Chunk.const_get(klass)
172
+ EXAMPLES.each_value do |val|
173
+ next unless val[:classes]
174
+ val[:classes] = val[:classes].map do |klass|
175
+ klass.is_a?(Class) ? klass : Card::Content::Chunk.const_get(klass)
176
+ end
188
177
  end
189
- end
190
178
 
191
- describe Card::Content do
192
179
  context "instance" do
193
180
  before do
194
181
  @check_proc = proc do |m, v|
195
- if Array === m
182
+ if m.is_a? Array
196
183
  wrong_class = m[0] != v.class
197
184
  expect(wrong_class).to be_falsey
198
185
  is_last = m.size == 1
@@ -278,18 +265,18 @@ describe Card::Content do
278
265
  describe "render" do
279
266
  it "renders all nests" do
280
267
  @example = :nests
281
- expect(cobj.as_json.to_s).to match /not rendered/
282
- cobj.process_each_chunk &@render_block
268
+ expect(cobj.as_json.to_s).to match(/not rendered/)
269
+ cobj.process_each_chunk(&@render_block)
283
270
  rdr = cobj.as_json.to_json
284
- expect(rdr).not_to match /not rendered/
271
+ expect(rdr).not_to match(/not rendered/)
285
272
  expect(rdr).to eq(rendered.to_json)
286
273
  end
287
274
 
288
275
  it "renders links and nests" do
289
276
  @example = :links_and_nests
290
- cobj.process_each_chunk &@render_block
277
+ cobj.process_each_chunk(&@render_block)
291
278
  rdr = cobj.as_json.to_json
292
- expect(rdr).not_to match /not rendered/
279
+ expect(rdr).not_to match(/not rendered/)
293
280
  expect(rdr).to eq(rendered.to_json)
294
281
  end
295
282
 
@@ -298,24 +285,24 @@ describe Card::Content do
298
285
  card2 = Card[@card.id]
299
286
  format = card2.format format: :text
300
287
  cobj = Card::Content.new content, format
301
- cobj.process_each_chunk &@render_block
288
+ cobj.process_each_chunk(&@render_block)
302
289
  expect(cobj.as_json.to_json).to eq(text_rendered.to_json)
303
290
  end
304
291
 
305
292
  it "does not need rendering if no nests" do
306
293
  @example = :uris_and_links
307
- cobj.process_each_chunk &@render_block
294
+ cobj.process_each_chunk(&@render_block)
308
295
  expect(cobj.as_json.to_json).to eq(rendered.to_json)
309
296
  end
310
297
 
311
298
  it "does not need rendering if no nests (b)" do
312
299
  @example = :uris_and_links_2
313
300
  rdr1 = cobj.as_json.to_json
314
- expect(rdr1).to match /not rendered/
301
+ expect(rdr1).to match(/not rendered/)
315
302
  # links are rendered too, but not with a block
316
- cobj.process_each_chunk &@render_block
303
+ cobj.process_each_chunk(&@render_block)
317
304
  rdr2 = cobj.as_json.to_json
318
- expect(rdr2).not_to match /not rendered/
305
+ expect(rdr2).not_to match(/not rendered/)
319
306
  expect(rdr2).to eq(rendered.to_json)
320
307
  end
321
308
  end
@@ -325,8 +312,7 @@ describe Card::Content do
325
312
  " {{this is a test}}, {{this|view|is:too}} and",
326
313
  " so is http://foo.bar.come//",
327
314
  ' and foo="my attr, not int a tag" <not a=tag ',
328
- ' p class"foobar"> and more'
329
- ].freeze
315
+ ' p class"foobar"> and more'].freeze
330
316
 
331
317
  context "class" do
332
318
  describe "#clean!" do