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
@@ -6,14 +6,13 @@ if use_i18_tasks
6
6
  require "i18n/tasks"
7
7
  end
8
8
 
9
- # Note: I18n::Tasks only knows how to function when run from root of Card GEM,
10
- # since it locates its configuration file and source to parse relative to this
11
-
12
- def card_gem_root
13
- Pathname(__FILE__).parent.parent.parent.parent.to_s
14
- end
15
-
16
9
  RSpec.describe "I18n" do
10
+ # Note: I18n::Tasks only knows how to function when run from root of Card GEM,
11
+ # since it locates its configuration file and source to parse relative to this
12
+ def card_gem_root
13
+ Pathname(__FILE__).parent.parent.parent.parent.to_s
14
+ end
15
+
17
16
  if use_i18_tasks
18
17
  let(:i18n) { Dir.chdir(card_gem_root) { I18n::Tasks::BaseTask.new } }
19
18
  let(:missing_keys) { Dir.chdir(card_gem_root) { i18n.missing_keys } }
@@ -1,10 +1,11 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- A_JOINEES = %w(B C D E F).freeze
4
- CARDS_MATCHING_TWO = ["Joe User", "One+Two", "One+Two+Three",
5
- "script: slot+*all+*script+*machine cache", "Two"].freeze
6
-
7
3
  describe Card::Query do
4
+ A_JOINEES = %w(B C D E F).freeze
5
+ CARDS_MATCHING_TWO = ["Joe User", "One+Two", "One+Two+Three",
6
+ "script: slot+*all+*script+*machine cache",
7
+ "Two"].freeze
8
+
8
9
  subject do
9
10
  Card::Query.run @query.reverse_merge return: :name, sort: :name
10
11
  end
@@ -1,4 +1,4 @@
1
- describe Card::StageDirector do
1
+ describe Card::ActManager::StageDirector do
2
2
  describe "abortion" do
3
3
  let(:create_card) { Card.create name: "a card" }
4
4
  let(:create_card_with_subcard) do
@@ -11,10 +11,9 @@ require File.expand_path("../../db/seed/test/seed.rb", __FILE__)
11
11
  require File.expand_path("../../config/simplecov_helper.rb", __FILE__)
12
12
  require "simplecov"
13
13
 
14
- require File.expand_path("../../mod/machines/spec/lib/"\
15
- "shared_machine_examples.rb", __FILE__)
16
- require File.expand_path("../../mod/machines/spec/lib/"\
17
- "shared_machine_input_examples.rb", __FILE__)
14
+ shared_example_dir =
15
+ File.expand_path("../../mod/machines/spec/shared_examples", __FILE__)
16
+ Dir["#{shared_example_dir}**/*.rb"].sort.each { |f| require f }
18
17
 
19
18
  Spork.prefork do
20
19
  if ENV["RAILS_ROOT"]
@@ -11,20 +11,18 @@ module ClassMethods
11
11
  # * database
12
12
  # * virtual cards
13
13
  #
14
- # @param mark [Integer, String, Card::Name, Symbol, Array]
15
- # one of three unique identifiers
16
- # 1. a numeric id (Integer)
17
- # 2. a name/key (String or Card::Name)
18
- # 3. a codename (Symbol)
19
- # or any combination of those. If you pass more then one mark they get
20
- # joined with a '+'
21
- # @param options [Hash]
22
- # Options:
23
- # :skip_virtual Real cards only
24
- # :skip_modules Don't load Set modules
25
- # :look_in_trash Return trashed card objects
26
- # :local_only Use only local cache for lookup and storing
27
- # new: { opts for Card#new } Return a new card when not found
14
+ # @param args [Integer, String, Card::Name, Symbol]
15
+ # one or more of the three unique identifiers
16
+ # 1. a numeric id (Integer)
17
+ # 2. a name/key (String or Card::Name)
18
+ # 3. a codename (Symbol)
19
+ # If you pass more then one mark they get joined with a '+'.
20
+ # The final argument can be a hash to set the following options
21
+ # :skip_virtual Real cards only
22
+ # :skip_modules Don't load Set modules
23
+ # :look_in_trash Return trashed card objects
24
+ # :local_only Use only local cache for lookup and storing
25
+ # new: { opts for Card#new } Return a new card when not found
28
26
  #
29
27
  # @return [Card]
30
28
  def fetch *args
@@ -1,56 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  class Card; module Set; class All; module Trash; extend Card::Set
3
3
  # ~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/core/set/all/trash.rb ~~
4
- Self::Admin.add_to_basket(
5
- :tasks,
6
- name: :empty_trash,
7
- execute_policy: -> { Card.empty_trash },
8
- stats: {
9
- title: "trashed cards",
10
- count: -> { Card.where(trash: true) },
11
- link_text: "delete all",
12
- task: "empty_trash"
13
- }
14
- )
15
-
16
- module ClassMethods
17
- def empty_trash
18
- Card.delete_trashed_files
19
- Card.where(trash: true).delete_all
20
- Card::Action.delete_cardless
21
- Card::Reference.unmap_if_referee_missing
22
- Card::Reference.delete_if_referer_missing
23
- end
24
-
25
- # deletes any file not associated with a real card.
26
- def delete_trashed_files
27
- dir = Cardio.paths["files"].existent.first
28
- # TODO: handle cloud files
29
- return unless dir
30
-
31
- trashed_card_ids = all_trashed_card_ids
32
- file_ids = all_file_ids
33
- file_ids.each do |file_id|
34
- next unless trashed_card_ids.member?(file_id)
35
- if Card.exists?(file_id) # double check!
36
- raise Card::Error, "Narrowly averted deleting current file"
37
- end
38
- FileUtils.rm_rf "#{dir}/#{file_id}", secure: true
39
- end
40
- end
41
-
42
- def all_file_ids
43
- dir = Card.paths["files"].existent.first
44
- Dir.entries(dir)[2..-1].map(&:to_i)
45
- end
46
-
47
- def all_trashed_card_ids
48
- trashed_card_sql = %( select id from cards where trash is true )
49
- sql_results = Card.connection.select_all(trashed_card_sql)
50
- sql_results.map(&:values).flatten.map(&:to_i)
51
- end
52
- end
53
-
54
4
  def delete
55
5
  update_attributes trash: true unless new_card?
56
6
  end
@@ -2,6 +2,28 @@
2
2
  class Card; module Set; class All; module Utils; extend Card::Set
3
3
  # ~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/core/set/all/utils.rb ~~
4
4
  module ClassMethods
5
+ def empty_trash
6
+ Card.delete_trashed_files
7
+ Card.where(trash: true).delete_all
8
+ Card::Action.delete_cardless
9
+ Card::Reference.unmap_if_referee_missing
10
+ Card::Reference.delete_if_referer_missing
11
+ end
12
+
13
+ # deletes any file not associated with a real card.
14
+ def delete_trashed_files
15
+ trashed_card_ids = all_trashed_card_ids
16
+ file_ids = all_file_ids
17
+ dir = Cardio.paths["files"].existent.first
18
+ file_ids.each do |file_id|
19
+ next unless trashed_card_ids.member?(file_id)
20
+ if Card.exists?(file_id) # double check!
21
+ raise Card::Error, "Narrowly averted deleting current file"
22
+ end
23
+ FileUtils.rm_rf "#{dir}/#{file_id}", secure: true
24
+ end
25
+ end
26
+
5
27
  def delete_tmp_files id=nil
6
28
  dir = Cardio.paths["files"].existent.first + "/tmp"
7
29
  dir += "/#{id}" if id
@@ -10,6 +32,17 @@ module ClassMethods
10
32
  Rails.logger.info "failed to remove tmp files"
11
33
  end
12
34
 
35
+ def all_file_ids
36
+ dir = Card.paths["files"].existent.first
37
+ Dir.entries(dir)[2..-1].map(&:to_i)
38
+ end
39
+
40
+ def all_trashed_card_ids
41
+ trashed_card_sql = %( select id from cards where trash is true )
42
+ sql_results = Card.connection.select_all(trashed_card_sql)
43
+ sql_results.map(&:values).flatten.map(&:to_i)
44
+ end
45
+
13
46
  def merge_list attribs, opts={}
14
47
  unmerged = []
15
48
  attribs.each do |row|
@@ -54,7 +54,7 @@ format :html do
54
54
  if params[:debug] == "style"
55
55
  page_path(style_card.cardname, item: :import, format: :css)
56
56
  elsif style_card
57
- style_card.machine_output_url
57
+ card_path style_card.machine_output_url
58
58
  end
59
59
  return unless @css_path
60
60
  %(<link href="#{@css_path}" media="all" rel="stylesheet" type="text/css" />)
@@ -31,7 +31,7 @@ module ClassMethods
31
31
  # cards whose solid caches are expired because of the update.
32
32
  # @param set_of_changed_card [set constant] a set of cards that triggers
33
33
  # a cache update
34
- # @params args [Hash]
34
+ # @param args [Hash]
35
35
  # @option args [Symbol, Array of symbols] :on the action(s)
36
36
  # (:create, :update, or :delete) on which the cache update
37
37
  # should be triggered. Default is all actions.
@@ -9,14 +9,6 @@ def history?
9
9
  false
10
10
  end
11
11
 
12
- event :remove_codename, :prepare_to_validate,
13
- on: :delete,
14
- when: proc { |c| c.codename.present? } do
15
- # load file before deleting codename otherwise it will fail later
16
- attachment
17
- self.codename = nil
18
- end
19
-
20
12
  format do
21
13
  view :not_found do |args|
22
14
  if update_machine_output_live?
@@ -31,7 +23,7 @@ format do
31
23
 
32
24
  def update_machine_output_live?
33
25
  case
34
- when !card.left.is_a?(Abstract::Machine) then false # must be a machine
26
+ when !card.left.is_a?(Machine) then false # must be a machine
35
27
  when card.left.locked? then false # machine must not be running
36
28
  when card.new_card? then true # always update if new
37
29
  else
@@ -5,8 +5,12 @@ class Card; module Set; class Type; module CoffeeScript; extend Card::Set
5
5
  require "coffee-script"
6
6
 
7
7
  include_set Abstract::Script
8
- include_set Abstract::Machine
9
- include_set Abstract::MachineInput
8
+
9
+ require_dependency "card/machine"
10
+ require_dependency "card/machine_input"
11
+
12
+ include Machine
13
+ include MachineInput
10
14
 
11
15
  store_machine_output filetype: "js"
12
16
 
@@ -3,8 +3,8 @@ class Card; module Set; class Type; module Css; extend Card::Set
3
3
  # ~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/machines/set/type/css.rb ~~
4
4
  # -*- encoding : utf-8 -*-
5
5
  require "sass"
6
- include_set Abstract::Machine
7
- include_set Abstract::MachineInput
6
+ include Machine
7
+ include MachineInput
8
8
  include_set Abstract::AceEditor
9
9
 
10
10
  store_machine_output filetype: "css"
@@ -5,8 +5,8 @@ class Card; module Set; class Type; module JavaScript; extend Card::Set
5
5
 
6
6
  include_set Abstract::Script
7
7
 
8
- include_set Abstract::Machine
9
- include_set Abstract::MachineInput
8
+ include Machine
9
+ include MachineInput
10
10
 
11
11
  store_machine_output filetype: "js"
12
12
 
@@ -1,8 +1,8 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  class Card; module Set; class Type; module Skin; extend Card::Set
3
3
  # ~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/machines/set/type/skin.rb ~~
4
- include_set Abstract::Machine
5
- include_set Abstract::MachineInput
4
+ include Machine
5
+ include MachineInput
6
6
 
7
7
  store_machine_output filetype: "css"
8
8