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
@@ -1,83 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- class Card; module Set; class Abstract; module MachineInput; extend Card::Set
3
- # ~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/machines/set/abstract/machine_input.rb ~~
4
- module MachineInputClassMethods
5
- attr_accessor :machines_wql
6
-
7
- def machine_input_for args
8
- @machines_wql = args
9
- end
10
-
11
- def machine_input &block
12
- define_method :machine_input, block
13
- end
14
- end
15
-
16
- def self.included host_class
17
- host_class.extend(MachineInputClassMethods)
18
- host_class.machines_wql = {}
19
- host_class.machine_input do
20
- format._render_raw
21
- end
22
- event_suffix = host_class.name.tr ":", "_"
23
- define_update_event event_suffix, host_class
24
- define_delete_events event_suffix, host_class
25
- end
26
-
27
- def self.define_delete_events event_suffix, host_class
28
- event_name = "before_machine_input_deleted_#{event_suffix}".to_sym
29
- host_class.event event_name, :store, on: :delete do
30
- # exclude self because it's on the way to the trash
31
- # otherwise it will be created again with the reset_machine_output
32
- # call in the event below
33
- @involved_machines =
34
- MachineInput.search_involved_machines(name, host_class)
35
- .reject { |card| card == self }
36
- end
37
- event_name = "after_machine_input_deleted_#{event_suffix}".to_sym
38
- host_class.event event_name, :finalize, on: :delete do
39
- expire_machine_cache
40
- @involved_machines.each do |item|
41
- item.reset_machine_output if item.is_a? Machine
42
- end
43
- end
44
- end
45
-
46
- def self.define_update_event event_suffix, host_class
47
- host_class.event(
48
- "after_machine_input_updated_#{event_suffix}".to_sym, :integrate,
49
- on: :save
50
- ) do
51
- expire_machine_cache
52
- MachineInput.search_involved_machines(name, host_class)
53
- .each do |item|
54
- item.reset_machine_output if item.is_a? Machine
55
- end
56
- end
57
- end
58
-
59
- def self.search_involved_machines name, host_class
60
- wql_statement =
61
- { right_plus: [
62
- { codename: "machine_input" },
63
- { link_to: name }
64
- ] }.merge(host_class.machines_wql)
65
- Card.search(wql_statement)
66
- end
67
-
68
- def expire_machine_cache
69
- Card.search(right_plus: [
70
- { codename: "machine_input" },
71
- { link_to: name }
72
- ],
73
- return: :name).each do |machine_name|
74
- next unless (cache = Card.fetch(name, machine_name, :machine_cache))
75
- Auth.as_bot do
76
- cache.update_attributes! trash: true
77
- end
78
- end
79
- end
80
-
81
-
82
- # ~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/machines/set/abstract/machine_input.rb ~~
83
- end;end;end;end;
@@ -1,59 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- class Card; module Set; class All; module EventViz; extend Card::Set
3
- # ~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/developer/set/all/event_viz.rb ~~
4
- require_dependency 'active_support/callbacks_ext'
5
-
6
- # the events method is a developer's tool for visualizing the event order
7
- # for a given card.
8
- # For example, from a console you might run
9
- #
10
- # puts mycard.events :update
11
- #
12
- # to see the order of events that will be executed on mycard.
13
- # The indention and arrows (^v) indicate event dependencies.
14
- #
15
- # Note: as of yet, the functionality is a bit rough. It does not display events
16
- # that are called directly from within other events,
17
- # and certain event requirements (like the presence of a 'current_act') may
18
- # prevent events from showing up in the tree.
19
- def events action
20
- @action = action
21
- events = Card::Stage::STAGES.map { |stage| events_tree("#{stage}_stage") }
22
- @action = nil
23
- puts_events events
24
- end
25
-
26
- # private
27
-
28
- def puts_events events, prefix="", depth=0
29
- r = ""
30
- depth += 1
31
- events.each do |e|
32
- space = " " * (depth * 2)
33
-
34
- # FIXME: this is not right. before and around callbacks are processed in
35
- # declaration order regardless of kind. not all befores then all arounds
36
- e[:before] && r += puts_events(e[:before], space + "v ", depth)
37
- e[:around] && r += puts_events(e[:around], space + "vv ", depth)
38
- r += "#{prefix}#{e[:name]}\n"
39
- e[:after] && r += puts_events(e[:after].reverse, space + "^ ", depth)
40
- end
41
- r
42
- end
43
-
44
- def events_tree filt
45
- hash = { name: filt }
46
- if respond_to? "_#{filt}_callbacks"
47
- send("_#{filt}_callbacks").each do |callback|
48
- next unless callback.applies? self
49
- hash[callback.kind] ||= []
50
- hash[callback.kind] << events_tree(callback.filter)
51
- end
52
- end
53
-
54
- hash
55
- end
56
-
57
-
58
- # ~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/developer/set/all/event_viz.rb ~~
59
- end;end;end;end;
@@ -1,30 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- class Card; module Set; class All; module ViewViz; extend Card::Set
3
- # ~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/developer/set/all/view_viz.rb ~~
4
- format :html do
5
- view :views_by_format do
6
- format_views =
7
- self.class.ancestors.each_with_object({}) do |format_class, hash|
8
- views =
9
- format_class.instance_methods.map do |method|
10
- next unless method.to_s =~ /^_view_(.+)$/
11
- Regexp.last_match(1)
12
- end.compact
13
- next unless views.present?
14
- format_class.name =~ /^Card(::Set)?::(.+?)$/ #::(\w+Format)
15
- hash[Regexp.last_match(2)] = views
16
- end
17
- accordion_group format_views
18
- end
19
-
20
- view :views_by_name do
21
- views = methods.map do |method|
22
- Regexp.last_match(1) if method.to_s =~ /^_view_(.+)$/
23
- end.compact.sort
24
- list_group views
25
- end
26
- end
27
-
28
-
29
- # ~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/developer/set/all/view_viz.rb ~~
30
- end;end;end;end;
@@ -1,96 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- class Card; module Set; class Right; module Debug; extend Card::Set
3
- # ~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/developer/set/right/debug.rb ~~
4
- def virtual?
5
- true
6
- end
7
-
8
- format :html do
9
- view :core do |_args|
10
- subject = card.left
11
-
12
- output [
13
- ["Sets",
14
- static_tabs("set modules" => set_modules_accordion(subject),
15
- "all modules" => singleton_modules_list(subject),
16
- "patterns" => set_patterns_breadcrumb(subject))],
17
- ["Views",
18
- static_tabs("by format" => subformat(subject)._render_views_by_format,
19
- "by name" => subformat(subject)._render_views_by_name)],
20
- ["Events",
21
- static_tabs(create: "<pre>#{subject.events(:create)}</pre>",
22
- update: "<pre>#{subject.events(:update)}</pre>",
23
- delete: "<pre>#{subject.events(:delete)}</pre>")],
24
- ["Cache/DB Comparison", cache_comparison_table(subject)]
25
- ].map { |item| section(*item) }
26
- end
27
-
28
- # rubocop:disable AccessorMethodName
29
- def set_modules_accordion subject
30
- sets = subject.set_modules.each_with_object({}) do |sm, hash|
31
- ans = sm.ancestors
32
- ans.shift
33
- hash[sm.to_s] = ans
34
- end
35
- accordion_group sets
36
- end
37
-
38
- def set_patterns_breadcrumb subject
39
- links = subject.patterns.reverse.map { |pattern| card_link pattern.to_s }
40
- breadcrumb(links)
41
- end
42
- # rubocop:enable AccessorMethodName
43
-
44
- def singleton_modules_list subject
45
- all_mods = subject.singleton_class.ancestors.map(&:to_s)
46
- all_mods.shift
47
- list_group all_mods
48
- end
49
-
50
- def cache_comparison_table subject
51
- cache_card = Card.fetch(subject.key)
52
- db_card = Card.find_by_key(subject.key)
53
- return unless cache_card && db_card
54
- table(
55
- [:name, :updated_at, :updater_id, :content, :inspect].map do |field|
56
- [field.to_s,
57
- h(cache_card.send(field)),
58
- h(db_card.send(field))]
59
- end,
60
- header: ["Field", "Cache Val", "Database Val"]
61
- )
62
- end
63
-
64
- def section title, content
65
- %(
66
- <h2>#{title}</h2>
67
- #{content}
68
- )
69
- end
70
-
71
- def class_locations klass
72
- methods = defined_methods(klass)
73
- file_groups = methods.group_by { |sl| sl[0] }
74
- file_counts = file_groups.map do |file, sls|
75
- lines = sls.map { |sl| sl[1] }
76
- count = lines.size
77
- line = lines.min
78
- { file: file, count: count, line: line }
79
- end
80
- file_counts.sort_by! { |fc| fc[:count] }
81
- file_counts.map { |fc| [fc[:file], fc[:line]] }
82
- end
83
-
84
- def defined_methods klass
85
- methods =
86
- klass.methods(false).map { |m| klass.method(m) } +
87
- klass.instance_methods(false).map { |m| klass.instance_method(m) }
88
- methods.map!(&:source_location)
89
- methods.compact!
90
- methods
91
- end
92
- end
93
-
94
-
95
- # ~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/developer/set/right/debug.rb ~~
96
- end;end;end;end;
@@ -1,118 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- class Card; module Set; class Abstract; module Attachment; extend Card::Set
3
- # ~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/carrierwave/set/abstract/attachment.rb ~~
4
- require "carrier_wave/cardmount"
5
-
6
- attr_writer :empty_ok
7
-
8
- def self.included host_class
9
- host_class.extend CarrierWave::CardMount
10
- end
11
-
12
- event :select_file_revision, after: :select_action do
13
- attachment.retrieve_from_store!(attachment.identifier)
14
- end
15
-
16
- # we need a card id for the path so we have to update db_content when we have
17
- # an id
18
- event :correct_identifier, :finalize,
19
- on: :create, when: proc { |c| !c.web? } do
20
- update_column(:db_content, attachment.db_content)
21
- expire
22
- end
23
-
24
- event :save_original_filename, :prepare_to_store,
25
- when: proc { |c| c.file_ready_to_save? } do
26
- return unless @current_action
27
- @current_action.update_attributes! comment: original_filename
28
- end
29
-
30
- event :validate_file_exist, :validate, on: :save do
31
- return if empty_ok?
32
- if will_be_stored_as == :web
33
- errors.add "url is missing" if content.blank?
34
- elsif !attachment.file.present?
35
- errors.add attachment_name, "is missing"
36
- end
37
- end
38
-
39
- event :write_identifier, after: :save_original_filename,
40
- when: proc { |c| !c.web? } do
41
- self.content = attachment.db_content
42
- end
43
-
44
- def file_ready_to_save?
45
- attachment.file.present? &&
46
- !preliminary_upload? &&
47
- !save_preliminary_upload? &&
48
- attachment_changed?
49
- end
50
-
51
- def item_names _args={} # needed for flexmail attachments. hacky.
52
- [cardname]
53
- end
54
-
55
- def original_filename
56
- return content.split("/").last if web?
57
- attachment.original_filename
58
- end
59
-
60
- def unfilled?
61
- !attachment.present? && !save_preliminary_upload? && !subcards.present? &&
62
- !content.present?
63
- end
64
-
65
- def attachment_changed?
66
- send "#{attachment_name}_changed?"
67
- end
68
-
69
- def create_versions?
70
- true
71
- end
72
-
73
- def empty_ok?
74
- @empty_ok
75
- end
76
-
77
- def assign_set_specific_attributes
78
- # reset content if we really have something to upload
79
- if @set_specific.present? && @set_specific[attachment_name.to_s].present?
80
- self.content = nil
81
- end
82
- super
83
- end
84
-
85
- def delete_files_for_action action
86
- with_selected_action_id(action.id) do
87
- attachment.file.delete
88
- attachment.versions.each_value do |version|
89
- version.file.delete
90
- end
91
- end
92
- end
93
-
94
- # create filesystem links to files from prior action
95
- def rollback_to action
96
- update_attributes! revision(action).merge(empty_ok: true)
97
- end
98
-
99
- def attachment_format ext
100
- if ext.present? && attachment && (original_ext = attachment.extension)
101
- if ["file", original_ext].member? ext
102
- original_ext
103
- elsif (exts = MIME::Types[attachment.content_type])
104
- if exts.find { |mt| mt.extensions.member? ext }
105
- ext
106
- else
107
- exts[0].extensions[0]
108
- end
109
- end
110
- end
111
- rescue => e
112
- Rails.logger.info "attachment_format issue: #{e.message}"
113
- nil
114
- end
115
-
116
-
117
- # ~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/carrierwave/set/abstract/attachment.rb ~~
118
- end;end;end;end;
@@ -1,57 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- class Card; module Set; class Abstract; module Attachment; module Paths; extend Card::Set
3
- # ~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/carrierwave/set/abstract/attachment/paths.rb ~~
4
- MOD_FILE_DIR = "file".freeze
5
-
6
- def store_dir
7
- will_become_coded? ? coded_dir(@new_mod) : upload_dir
8
- end
9
-
10
- def retrieve_dir
11
- coded? ? coded_dir : upload_dir
12
- end
13
-
14
- # place for files of regular file cards
15
- def upload_dir
16
- id ? "#{files_base_dir}/#{id}" : tmp_upload_dir
17
- end
18
-
19
- # place for files of mod file cards
20
- def coded_dir new_mod=nil
21
- dir = File.join mod_dir(new_mod), MOD_FILE_DIR, codename
22
- FileUtils.mkdir_p dir
23
- dir
24
- end
25
-
26
- def mod_dir new_mod=nil
27
- find_mod = new_mod || mod
28
- Card::Mod::Loader.mod_dirs.path(find_mod) ||
29
- raise(Error, "can't find mod \"#{find_mod}\"")
30
- end
31
-
32
- def files_base_dir
33
- bucket ? bucket_config[:subdirectory] : Card.paths["files"].existent.first
34
- end
35
-
36
- # used in the indentifier
37
- def file_dir
38
- if coded?
39
- ":#{codename}"
40
- elsif cloud?
41
- "(#{bucket})/#{file_id}"
42
- else
43
- "~#{file_id}"
44
- end
45
- end
46
-
47
- def public?
48
- who_can(:read).include? Card[:anyone].id
49
- end
50
-
51
- def file_id
52
- id? ? id : upload_cache_card.id
53
- end
54
-
55
-
56
- # ~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/carrierwave/set/abstract/attachment/paths.rb ~~
57
- end;end;end;end;end;