card 1.16.9 → 1.16.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/db/migrate_core_cards/20120611203506_rails_inflection_updates.rb +3 -1
- data/db/seed/new/card_actions.yml +389 -557
- data/db/seed/new/card_acts.yml +595 -1
- data/db/seed/new/card_changes.yml +22595 -7526
- data/db/seed/new/card_references.yml +379 -407
- data/db/seed/new/cards.yml +1694 -2072
- data/db/seed/test/fixtures/card_actions.yml +966 -1102
- data/db/seed/test/fixtures/card_acts.yml +1017 -399
- data/db/seed/test/fixtures/card_changes.yml +24750 -9681
- data/db/seed/test/fixtures/card_references.yml +603 -631
- data/db/seed/test/fixtures/cards.yml +2293 -2671
- data/lib/card/set.rb +1 -1
- data/mod/01_core/set/all/content.rb +14 -12
- data/mod/03_machines/lib/javascript/wagn_mod.js.coffee +1 -1
- data/mod/05_standard/set/abstract/attachment.rb +9 -9
- data/mod/05_standard/set/all/rich_html/content.rb +115 -103
- data/mod/05_standard/set/type/file.rb +1 -1
- data/tmpsets/set/mod001-01_core/all/active_card.rb +2 -1
- data/tmpsets/set/mod001-01_core/all/collection.rb +3 -3
- data/tmpsets/set/mod001-01_core/all/content.rb +2 -1
- data/tmpsets/set/mod001-01_core/all/erb.rb +2 -1
- data/tmpsets/set/mod001-01_core/all/fetch.rb +169 -93
- data/tmpsets/set/mod001-01_core/all/haml.rb +2 -1
- data/tmpsets/set/mod001-01_core/all/initialize.rb +11 -23
- data/tmpsets/set/mod001-01_core/all/name.rb +130 -80
- data/tmpsets/set/mod001-01_core/all/pattern.rb +2 -1
- data/tmpsets/set/mod001-01_core/all/permissions.rb +2 -1
- data/tmpsets/set/mod001-01_core/all/phases.rb +95 -96
- data/tmpsets/set/mod001-01_core/all/references.rb +2 -1
- data/tmpsets/set/mod001-01_core/all/rules.rb +2 -1
- data/tmpsets/set/mod001-01_core/all/states.rb +2 -1
- data/tmpsets/set/mod001-01_core/all/templating.rb +2 -1
- data/tmpsets/set/mod001-01_core/all/tracked_attributes.rb +85 -60
- data/tmpsets/set/mod001-01_core/all/trash.rb +16 -13
- data/tmpsets/set/mod001-01_core/all/type.rb +5 -25
- data/tmpsets/set/mod001-01_core/all/utils.rb +2 -1
- data/tmpsets/set/mod001-01_core/all/view_cache.rb +2 -1
- data/tmpsets/set/mod002-01_history/all/actions.rb +2 -1
- data/tmpsets/set/mod002-01_history/all/content_history.rb +7 -4
- data/tmpsets/set/mod002-01_history/all/history.rb +119 -83
- data/tmpsets/set/mod003-02_basic_types/all/all_css.rb +2 -1
- data/tmpsets/set/mod003-02_basic_types/all/all_csv.rb +2 -1
- data/tmpsets/set/mod003-02_basic_types/all/all_js.rb +2 -1
- data/tmpsets/set/mod003-02_basic_types/all/base.rb +52 -50
- data/tmpsets/set/mod003-02_basic_types/all/file.rb +2 -1
- data/tmpsets/set/mod003-02_basic_types/all/json.rb +2 -1
- data/tmpsets/set/mod003-02_basic_types/all/rss.rb +2 -1
- data/tmpsets/set/mod003-02_basic_types/all/text.rb +2 -1
- data/tmpsets/set/mod003-02_basic_types/type/html.rb +2 -1
- data/tmpsets/set/mod003-02_basic_types/type/plain_text.rb +2 -1
- data/tmpsets/set/mod003-02_basic_types/type/pointer.rb +10 -1
- data/tmpsets/set/mod004-03_machines/right/machine_input.rb +2 -1
- data/tmpsets/set/mod004-03_machines/right/machine_output.rb +2 -1
- data/tmpsets/set/mod004-03_machines/self/script_ace.rb +2 -1
- data/tmpsets/set/mod004-03_machines/self/script_card_menu.rb +2 -1
- data/tmpsets/set/mod004-03_machines/self/script_html5shiv_printshiv.rb +2 -1
- data/tmpsets/set/mod004-03_machines/self/script_jquery.rb +2 -1
- data/tmpsets/set/mod004-03_machines/self/script_jquery_helper.rb +2 -1
- data/tmpsets/set/mod004-03_machines/self/script_slot.rb +2 -1
- data/tmpsets/set/mod004-03_machines/self/script_tinymce.rb +2 -1
- data/tmpsets/set/mod004-03_machines/self/style_bootstrap_compatible.rb +2 -1
- data/tmpsets/set/mod004-03_machines/self/style_cards.rb +2 -1
- data/tmpsets/set/mod004-03_machines/self/style_jquery_ui_smoothness.rb +2 -1
- data/tmpsets/set/mod004-03_machines/type/coffee_script.rb +2 -1
- data/tmpsets/set/mod004-03_machines/type/css.rb +2 -1
- data/tmpsets/set/mod004-03_machines/type/java_script.rb +2 -1
- data/tmpsets/set/mod004-03_machines/type/scss.rb +2 -1
- data/tmpsets/set/mod004-03_machines/type/skin.rb +2 -1
- data/tmpsets/set/mod005-04_settings/abstract/permission.rb +2 -1
- data/tmpsets/set/mod005-04_settings/right/add_help.rb +2 -1
- data/tmpsets/set/mod005-04_settings/right/comment.rb +2 -1
- data/tmpsets/set/mod005-04_settings/right/create.rb +2 -1
- data/tmpsets/set/mod005-04_settings/right/default.rb +2 -1
- data/tmpsets/set/mod005-04_settings/right/delete.rb +2 -1
- data/tmpsets/set/mod005-04_settings/right/help.rb +2 -1
- data/tmpsets/set/mod005-04_settings/right/read.rb +2 -1
- data/tmpsets/set/mod005-04_settings/right/script.rb +2 -1
- data/tmpsets/set/mod005-04_settings/right/structure.rb +2 -1
- data/tmpsets/set/mod005-04_settings/right/style.rb +2 -1
- data/tmpsets/set/mod005-04_settings/right/update.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/accountable.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/add_help.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/autoname.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/captcha.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/create.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/default.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/delete.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/help.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/input.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/layout.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/on_create.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/on_delete.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/on_update.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/options.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/options_label.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/read.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/recent_settings.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/script.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/structure.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/style.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/table_of_contents.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/thanks.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/update.rb +2 -1
- data/tmpsets/set/mod005-04_settings/type/setting.rb +2 -1
- data/tmpsets/set/mod006-05_email/all/email_html.rb +2 -1
- data/tmpsets/set/mod006-05_email/all/email_text.rb +2 -1
- data/tmpsets/set/mod006-05_email/all/follow.rb +2 -1
- data/tmpsets/set/mod006-05_email/all/notify.rb +2 -1
- data/tmpsets/set/mod006-05_email/all/observer.rb +2 -1
- data/tmpsets/set/mod006-05_email/right/bcc.rb +2 -1
- data/tmpsets/set/mod006-05_email/right/cc.rb +2 -1
- data/tmpsets/set/mod006-05_email/right/follow.rb +2 -1
- data/tmpsets/set/mod006-05_email/right/follow_fields.rb +2 -1
- data/tmpsets/set/mod006-05_email/right/followers.rb +7 -6
- data/tmpsets/set/mod006-05_email/right/following.rb +3 -2
- data/tmpsets/set/mod006-05_email/right/from.rb +2 -1
- data/tmpsets/set/mod006-05_email/right/html_message.rb +2 -1
- data/tmpsets/set/mod006-05_email/right/to.rb +2 -1
- data/tmpsets/set/mod006-05_email/self/always.rb +2 -1
- data/tmpsets/set/mod006-05_email/self/created.rb +2 -1
- data/tmpsets/set/mod006-05_email/self/edited.rb +2 -1
- data/tmpsets/set/mod006-05_email/self/follow.rb +2 -1
- data/tmpsets/set/mod006-05_email/self/follow_defaults.rb +2 -1
- data/tmpsets/set/mod006-05_email/self/never.rb +2 -1
- data/tmpsets/set/mod006-05_email/type/email_template.rb +2 -1
- data/tmpsets/set/mod006-05_email/type_plus_right/user/follow.rb +3 -2
- data/tmpsets/set/mod007-05_standard/abstract/attachment.rb +22 -9
- data/tmpsets/set/mod007-05_standard/all/account.rb +2 -1
- data/tmpsets/set/mod007-05_standard/all/comment.rb +2 -1
- data/tmpsets/set/mod007-05_standard/all/error.rb +2 -1
- data/tmpsets/set/mod007-05_standard/all/event_viz.rb +2 -1
- data/tmpsets/set/mod007-05_standard/all/links.rb +2 -1
- data/tmpsets/set/mod007-05_standard/all/rich_html/content.rb +3 -2
- data/tmpsets/set/mod007-05_standard/all/rich_html/editing.rb +2 -1
- data/tmpsets/set/mod007-05_standard/all/rich_html/form.rb +23 -12
- data/tmpsets/set/mod007-05_standard/all/rich_html/header.rb +2 -1
- data/tmpsets/set/mod007-05_standard/all/rich_html/menu.rb +3 -2
- data/tmpsets/set/mod007-05_standard/all/rich_html/modal.rb +2 -1
- data/tmpsets/set/mod007-05_standard/all/rich_html/toolbar.rb +2 -1
- data/tmpsets/set/mod007-05_standard/all/rich_html/wrapper.rb +2 -1
- data/tmpsets/set/mod007-05_standard/right/account.rb +7 -6
- data/tmpsets/set/mod007-05_standard/right/discussion.rb +2 -1
- data/tmpsets/set/mod007-05_standard/right/email.rb +2 -1
- data/tmpsets/set/mod007-05_standard/right/password.rb +2 -1
- data/tmpsets/set/mod007-05_standard/right/salt.rb +2 -1
- data/tmpsets/set/mod007-05_standard/right/stats.rb +2 -1
- data/tmpsets/set/mod007-05_standard/right/status.rb +2 -1
- data/tmpsets/set/mod007-05_standard/right/token.rb +2 -1
- data/tmpsets/set/mod007-05_standard/right/when_created.rb +2 -1
- data/tmpsets/set/mod007-05_standard/right/when_last_edited.rb +2 -1
- data/tmpsets/set/mod007-05_standard/rstar/rules.rb +2 -1
- data/tmpsets/set/mod007-05_standard/self/account_links.rb +2 -1
- data/tmpsets/set/mod007-05_standard/self/alerts.rb +2 -1
- data/tmpsets/set/mod007-05_standard/self/all.rb +2 -1
- data/tmpsets/set/mod007-05_standard/self/foot.rb +2 -1
- data/tmpsets/set/mod007-05_standard/self/head.rb +2 -2
- data/tmpsets/set/mod007-05_standard/self/navbox.rb +2 -1
- data/tmpsets/set/mod007-05_standard/self/now.rb +2 -1
- data/tmpsets/set/mod007-05_standard/self/recent.rb +2 -1
- data/tmpsets/set/mod007-05_standard/self/search.rb +2 -1
- data/tmpsets/set/mod007-05_standard/self/signin.rb +45 -36
- data/tmpsets/set/mod007-05_standard/self/stats.rb +2 -1
- data/tmpsets/set/mod007-05_standard/self/version.rb +2 -1
- data/tmpsets/set/mod007-05_standard/type/basic.rb +2 -1
- data/tmpsets/set/mod007-05_standard/type/cardtype.rb +2 -1
- data/tmpsets/set/mod007-05_standard/type/date.rb +2 -1
- data/tmpsets/set/mod007-05_standard/type/file.rb +11 -3
- data/tmpsets/set/mod007-05_standard/type/image.rb +2 -1
- data/tmpsets/set/mod007-05_standard/type/layout_type.rb +2 -1
- data/tmpsets/set/mod007-05_standard/type/number.rb +2 -1
- data/tmpsets/set/mod007-05_standard/type/phrase.rb +2 -1
- data/tmpsets/set/mod007-05_standard/type/search_type.rb +70 -64
- data/tmpsets/set/mod007-05_standard/type/session.rb +2 -1
- data/tmpsets/set/mod007-05_standard/type/set.rb +2 -1
- data/tmpsets/set/mod007-05_standard/type/signup.rb +96 -64
- data/tmpsets/set/mod007-05_standard/type/toggle.rb +2 -1
- data/tmpsets/set/mod007-05_standard/type/uri.rb +2 -1
- data/tmpsets/set/mod007-05_standard/type/user.rb +50 -40
- data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/form.rb +2 -1
- data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/helper.rb +2 -1
- data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/wrapper.rb +2 -1
- data/tmpsets/set/mod008-06_bootstrap/all/rich_bootstrap.rb +2 -1
- data/tmpsets/set/mod008-06_bootstrap/self/bootstrap_cards.rb +2 -1
- data/tmpsets/set/mod008-06_bootstrap/self/bootstrap_js.rb +2 -1
- data/tmpsets/set/mod008-06_bootstrap/self/bootswatch_shared.rb +2 -1
- data/tmpsets/set/mod008-06_bootstrap/self/smartmenu_css.rb +2 -1
- data/tmpsets/set/mod008-06_bootstrap/self/smartmenu_js.rb +2 -1
- metadata +2 -2
@@ -88,7 +88,7 @@ format :html do
|
|
88
88
|
|
89
89
|
view :preview_editor, tags: :unknown_ok do |args|
|
90
90
|
cached_upload_card_name = Card::Env.params[:attachment_upload]
|
91
|
-
cached_upload_card_name.gsub!(/\[\w+\]$/, "[
|
91
|
+
cached_upload_card_name.gsub!(/\[\w+\]$/, "[action_id_of_cached_upload]")
|
92
92
|
<<-HTML
|
93
93
|
<div class="chosen-file">
|
94
94
|
<input type="hidden" name="#{cached_upload_card_name}" value="#{card.selected_action_id}">
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
class Card; module Set; module All; module ActiveCard; extend Card::Set
|
2
|
+
class Card; module Set; module All; module ActiveCard; extend Card::Set
|
3
|
+
# ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/active_card.rb ~~~~~~~~~~~
|
3
4
|
=begin
|
4
5
|
|
5
6
|
# following may be useful, but is neither tested nor in use
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
class Card; module Set; module All; module Collection; extend Card::Set
|
2
|
+
class Card; module Set; module All; module Collection; extend Card::Set
|
3
|
+
# ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/collection.rb ~~~~~~~~~~~
|
3
4
|
|
4
5
|
module ClassMethods
|
5
6
|
def search spec
|
@@ -195,7 +196,6 @@ format do
|
|
195
196
|
end
|
196
197
|
end
|
197
198
|
|
198
|
-
|
199
199
|
def nested_fields args={}
|
200
200
|
result = []
|
201
201
|
each_nested_field(args) do |chunk|
|
@@ -216,7 +216,7 @@ format do
|
|
216
216
|
|
217
217
|
each_nested_chunk(args) do |chunk|
|
218
218
|
# TODO handle structures that are non-virtual
|
219
|
-
if chunk.referee_name.to_name.
|
219
|
+
if chunk.referee_name.to_name.field_of? card.name
|
220
220
|
if chunk.referee_card && chunk.referee_card.virtual? && !processed_chunk_keys.include?(chunk.referee_name.key)
|
221
221
|
processed_chunk_keys << chunk.referee_name.key
|
222
222
|
subformat(chunk.referee_card).each_nested_field(args) do |sub_chunk|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
class Card; module Set; module All; module Content; extend Card::Set
|
2
|
+
class Card; module Set; module All; module Content; extend Card::Set
|
3
|
+
# ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/content.rb ~~~~~~~~~~~
|
3
4
|
::Card.error_codes[:conflict] = [:conflict, 409]
|
4
5
|
|
5
6
|
def content
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
class Card; module Set; module All; module Erb; extend Card::Set
|
2
|
+
class Card; module Set; module All; module Erb; extend Card::Set
|
3
|
+
# ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/erb.rb ~~~~~~~~~~~
|
3
4
|
format do
|
4
5
|
def render_erb locals={}, template=nil, a_binding=nil, &block
|
5
6
|
template ||= block.call
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
class Card; module Set; module All; module Fetch; extend Card::Set
|
2
|
+
class Card; module Set; module All; module Fetch; extend Card::Set
|
3
|
+
# ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/fetch.rb ~~~~~~~~~~~
|
3
4
|
# = Card#fetch
|
4
5
|
#
|
5
6
|
# A multipurpose retrieval operator that incorporates caching, "virtual" card retrieval
|
@@ -22,64 +23,77 @@ module ClassMethods
|
|
22
23
|
# :skip_virtual Real cards only
|
23
24
|
# :skip_modules Don't load Set modules
|
24
25
|
# :look_in_trash Return trashed card objects
|
26
|
+
# :local_only Use only local cache for lookup and storing
|
25
27
|
# new: { card opts } Return a new card when not found
|
26
28
|
#
|
27
|
-
def fetch mark, opts={}
|
28
|
-
|
29
|
-
|
30
|
-
when /^\~(\d+)$/ # get by id
|
31
|
-
mark = $1.to_i
|
32
|
-
when /^\:(\w+)$/ # get by codename
|
33
|
-
mark = $1.to_sym
|
34
|
-
end
|
35
|
-
end
|
36
|
-
mark = Card::Codename[mark] if Symbol === mark # id from codename
|
29
|
+
def fetch mark, opts = {}
|
30
|
+
validate_fetch_opts! opts
|
31
|
+
mark = normalize_mark mark
|
37
32
|
|
38
33
|
if mark.present?
|
39
|
-
card, mark, needs_caching = fetch_from_cache_or_db mark, opts
|
34
|
+
card, mark, needs_caching = fetch_from_cache_or_db mark, opts
|
40
35
|
else
|
41
36
|
return unless opts[:new]
|
42
37
|
end
|
43
38
|
|
44
|
-
if Integer
|
45
|
-
return if card.nil?
|
46
|
-
|
47
|
-
return card.renew(opts)
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
39
|
+
if mark.is_a?(Integer)
|
40
|
+
return if card.nil?
|
41
|
+
elsif card && card.new_card? && opts[:new].present?
|
42
|
+
return card.renew(opts)
|
43
|
+
elsif !card || (card.type_unknown? && !skip_type_lookup?(opts))
|
44
|
+
needs_caching = true
|
45
|
+
card = new_for_cache mark, opts # new (or improved) card for cache
|
52
46
|
end
|
53
47
|
|
54
|
-
write_to_cache card if
|
48
|
+
write_to_cache card, opts if needs_caching
|
55
49
|
|
56
50
|
if card.new_card?
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
else
|
62
|
-
card.include_set_modules unless opts[:skip_modules] # need to load modules here to call the right virtual? method
|
63
|
-
return unless card.virtual?
|
51
|
+
case
|
52
|
+
when opts[:new].present? then return card.renew(opts)
|
53
|
+
when opts[:new] # noop for empty hash
|
54
|
+
when opts[:skip_virtual] then return nil
|
64
55
|
end
|
65
|
-
card.
|
56
|
+
card.rename_from_mark mark unless opts[:local_only]
|
66
57
|
end
|
67
|
-
|
58
|
+
# need to load modules here to call the right virtual? method
|
68
59
|
card.include_set_modules unless opts[:skip_modules]
|
69
|
-
card
|
60
|
+
card if opts[:new] || card.known?
|
61
|
+
end
|
62
|
+
|
63
|
+
def fetch_local mark, opts = {}
|
64
|
+
fetch mark, opts.merge(:local_only=>true)
|
65
|
+
end
|
66
|
+
|
67
|
+
def fetch_id mark
|
68
|
+
if mark.is_a?(Integer)
|
69
|
+
mark
|
70
|
+
elsif mark.is_a?(Symbol) && Card::Codename[mark]
|
71
|
+
Card::Codename[mark]
|
72
|
+
else
|
73
|
+
card = quick_fetch mark.to_s
|
74
|
+
card && card.id
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def quick_fetch mark
|
79
|
+
fetch mark, skip_virtual: true, skip_modules: true
|
70
80
|
end
|
71
81
|
|
72
|
-
def
|
73
|
-
|
74
|
-
|
82
|
+
def assign_or_initialize_by name, attributes, fetch_opts = {}
|
83
|
+
if (known_card = Card.fetch(name, fetch_opts))
|
84
|
+
known_card.refresh.assign_attributes attributes
|
85
|
+
known_card
|
86
|
+
else
|
87
|
+
Card.new attributes.merge(name: name)
|
88
|
+
end
|
75
89
|
end
|
76
90
|
|
77
|
-
def []
|
91
|
+
def [] mark
|
78
92
|
fetch mark, skip_virtual: true
|
79
93
|
end
|
80
94
|
|
81
95
|
def exists? mark
|
82
|
-
card =
|
96
|
+
card = quick_fetch mark
|
83
97
|
card.present?
|
84
98
|
end
|
85
99
|
|
@@ -88,14 +102,19 @@ module ClassMethods
|
|
88
102
|
card.present?
|
89
103
|
end
|
90
104
|
|
91
|
-
def expire name
|
92
|
-
#note: calling instance method breaks on dirty names
|
105
|
+
def expire name, subcards = false
|
106
|
+
# note: calling instance method breaks on dirty names
|
93
107
|
key = name.to_name.key
|
94
|
-
if card = Card.cache.read(
|
108
|
+
if card = Card.cache.read(key)
|
109
|
+
if subcards
|
110
|
+
card.expire_subcards
|
111
|
+
else
|
112
|
+
card.preserve_subcards
|
113
|
+
end
|
95
114
|
Card.cache.delete key
|
96
115
|
Card.cache.delete "~#{card.id}" if card.id
|
97
116
|
end
|
98
|
-
#Rails.logger.warn "expiring #{name}, #{card.inspect}"
|
117
|
+
# Rails.logger.warn "expiring #{name}, #{card.inspect}"
|
99
118
|
end
|
100
119
|
|
101
120
|
# set_names reverse map (cached)
|
@@ -118,90 +137,135 @@ module ClassMethods
|
|
118
137
|
end
|
119
138
|
end
|
120
139
|
|
121
|
-
def
|
122
|
-
|
140
|
+
def validate_fetch_opts! opts
|
141
|
+
if opts[:new] && opts[:skip_virtual]
|
142
|
+
fail Card::Error, 'fetch called with new args and skip_virtual'
|
143
|
+
end
|
123
144
|
end
|
124
145
|
|
125
|
-
def
|
126
|
-
Card
|
146
|
+
def cache
|
147
|
+
Card::Cache[Card]
|
127
148
|
end
|
128
149
|
|
129
|
-
def
|
130
|
-
if
|
131
|
-
|
132
|
-
|
133
|
-
|
150
|
+
def fetch_from_cache cache_key, local_only=false
|
151
|
+
if Card.cache
|
152
|
+
if local_only
|
153
|
+
Card.cache.read_local cache_key
|
154
|
+
else
|
155
|
+
Card.cache.read cache_key
|
156
|
+
end
|
134
157
|
end
|
135
158
|
end
|
136
159
|
|
137
160
|
def fetch_from_cache_or_db mark, opts
|
138
161
|
needs_caching = false
|
139
|
-
mark_type = Integer
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
162
|
+
mark_type = mark.is_a?(Integer) ? :id : :key
|
163
|
+
expanded_mark = expand_mark mark, opts
|
164
|
+
card = send("fetch_from_cache_by_#{mark_type}",
|
165
|
+
expanded_mark, opts[:local_only])
|
166
|
+
|
167
|
+
if card.nil? || (opts[:look_in_trash] && card.new_card? && !card.trash)
|
168
|
+
query = { mark_type => expanded_mark }
|
169
|
+
query[:trash] = false unless opts[:look_in_trash]
|
170
|
+
card = fetch_from_db query
|
171
|
+
needs_caching = card && !card.trash
|
172
|
+
card.restore_subcards if card
|
146
173
|
end
|
147
174
|
|
148
|
-
card
|
175
|
+
[card, mark, needs_caching]
|
176
|
+
end
|
149
177
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
needs_caching = card && !card.trash
|
154
|
-
end
|
155
|
-
elsif card.nil?
|
156
|
-
needs_caching = true
|
157
|
-
card = Card.where( mark_type => val, trash: false).take
|
178
|
+
def fetch_from_cache_by_id id, local_only = false
|
179
|
+
if name = fetch_from_cache("~#{id}", local_only)
|
180
|
+
fetch_from_cache name, local_only
|
158
181
|
end
|
182
|
+
end
|
159
183
|
|
160
|
-
|
184
|
+
def fetch_from_cache_by_key key, local_only = false
|
185
|
+
fetch_from_cache key, local_only
|
161
186
|
end
|
162
187
|
|
188
|
+
def fetch_from_db query
|
189
|
+
Card.where(query).take
|
190
|
+
end
|
163
191
|
|
164
|
-
def
|
165
|
-
|
166
|
-
|
167
|
-
|
192
|
+
def new_for_cache name, opts
|
193
|
+
new name: name,
|
194
|
+
skip_modules: true,
|
195
|
+
skip_type_lookup: skip_type_lookup?(opts)
|
168
196
|
end
|
169
197
|
|
170
|
-
def
|
171
|
-
|
198
|
+
def skip_type_lookup? opts
|
199
|
+
# if opts[:new] is not empty then we are initializing a variant that is
|
200
|
+
# different from the cached variant
|
201
|
+
# and can postpone type lookup for the cached variant
|
202
|
+
# if skipping virtual no need to look for actual type
|
203
|
+
opts[:skip_virtual] || opts[:new].present?
|
172
204
|
end
|
173
205
|
|
174
|
-
def
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
206
|
+
def write_to_cache card, opts
|
207
|
+
if opts[:local_only]
|
208
|
+
write_to_local_cache card
|
209
|
+
elsif Card.cache
|
210
|
+
Card.cache.write card.key, card
|
211
|
+
Card.cache.write "~#{card.id}", card.key if card.id && card.id != 0
|
212
|
+
end
|
180
213
|
end
|
181
214
|
|
182
|
-
def
|
183
|
-
|
215
|
+
def write_to_local_cache card
|
216
|
+
if Card.cache
|
217
|
+
Card.cache.write_local card.key, card
|
218
|
+
Card.cache.write_local "~#{card.id}", card.key if card.id && card.id != 0
|
219
|
+
end
|
184
220
|
end
|
185
221
|
|
186
|
-
def
|
187
|
-
|
188
|
-
|
222
|
+
def expand_mark mark, opts
|
223
|
+
if mark.is_a?(Integer)
|
224
|
+
mark
|
225
|
+
else
|
226
|
+
fullname_from_name(mark, opts[:new]).key
|
227
|
+
end
|
189
228
|
end
|
190
229
|
|
230
|
+
def normalize_mark mark
|
231
|
+
case mark
|
232
|
+
when String
|
233
|
+
case mark
|
234
|
+
when /^\~(\d+)$/ # get by id
|
235
|
+
$1.to_i
|
236
|
+
when /^\:(\w+)$/ # get by codename
|
237
|
+
Card::Codename[$1.to_sym]
|
238
|
+
else
|
239
|
+
mark
|
240
|
+
end
|
241
|
+
when Symbol
|
242
|
+
Card::Codename[mark] # id from codename
|
243
|
+
else
|
244
|
+
mark
|
245
|
+
end
|
246
|
+
end
|
191
247
|
|
248
|
+
def fullname_from_name name, new_opts = {}
|
249
|
+
if new_opts && supercard = new_opts[:supercard]
|
250
|
+
name.to_name.to_absolute_name supercard.name
|
251
|
+
else
|
252
|
+
name.to_name
|
253
|
+
end
|
254
|
+
end
|
192
255
|
end
|
193
256
|
|
194
257
|
# ~~~~~~~~~~ Instance ~~~~~~~~~~~~~
|
195
258
|
|
196
|
-
def fetch opts={}
|
259
|
+
def fetch opts = {}
|
197
260
|
if traits = opts.delete(:trait)
|
198
|
-
traits =
|
199
|
-
traits.inject(self)
|
261
|
+
traits = Array.wrap traits
|
262
|
+
traits.inject(self) do |card, trait|
|
263
|
+
Card.fetch card.cardname.trait(trait), opts
|
264
|
+
end
|
200
265
|
end
|
201
266
|
end
|
202
267
|
|
203
|
-
|
204
|
-
def renew args={}
|
268
|
+
def renew args = {}
|
205
269
|
opts = args[:new].clone
|
206
270
|
opts[:name] ||= cardname
|
207
271
|
opts[:skip_modules] = args[:skip_modules]
|
@@ -210,18 +274,22 @@ end
|
|
210
274
|
|
211
275
|
def expire_pieces
|
212
276
|
cardname.piece_names.each do |piece|
|
213
|
-
Card.expire piece
|
277
|
+
Card.expire piece, !cardname.field_of?(piece)
|
214
278
|
end
|
215
279
|
end
|
216
280
|
|
217
|
-
|
218
|
-
|
219
|
-
|
281
|
+
def expire subcards = false
|
282
|
+
# Rails.logger.warn "expiring i:#{id}, #{inspect}"
|
283
|
+
if subcards
|
284
|
+
expire_subcards
|
285
|
+
else
|
286
|
+
preserve_subcards
|
287
|
+
end
|
220
288
|
Card.cache.delete key
|
221
289
|
Card.cache.delete "~#{id}" if id
|
222
290
|
end
|
223
291
|
|
224
|
-
def refresh force=false
|
292
|
+
def refresh force = false
|
225
293
|
if force || self.frozen? || self.readonly?
|
226
294
|
fresh_card = self.class.find id
|
227
295
|
fresh_card.include_set_modules
|
@@ -235,6 +303,14 @@ def eager_renew? opts
|
|
235
303
|
opts[:skip_virtual] && new_card? && opts[:new].present?
|
236
304
|
end
|
237
305
|
|
306
|
+
def type_unknown?
|
307
|
+
type_id.nil?
|
308
|
+
end
|
309
|
+
|
310
|
+
def rename_from_mark mark
|
311
|
+
return unless mark && mark.to_s != name
|
312
|
+
self.name = mark.to_s
|
313
|
+
end
|
238
314
|
|
239
315
|
|
240
316
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
class Card; module Set; module All; module Haml; extend Card::Set
|
2
|
+
class Card; module Set; module All; module Haml; extend Card::Set
|
3
|
+
# ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/haml.rb ~~~~~~~~~~~
|
3
4
|
format do
|
4
5
|
def render_haml locals={}, template=nil, a_binding=nil, &block
|
5
6
|
template ||= block.call
|
@@ -1,9 +1,10 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
class Card; module Set; module All; module Initialize; extend Card::Set
|
2
|
+
class Card; module Set; module All; module Initialize; extend Card::Set
|
3
|
+
# ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/initialize.rb ~~~~~~~~~~~
|
3
4
|
JUNK_INIT_ARGS = %w{ missing skip_virtual id }
|
4
5
|
|
5
6
|
module ClassMethods
|
6
|
-
def new args={},
|
7
|
+
def new args = {}, _options = {}
|
7
8
|
args = (args || {}).stringify_keys
|
8
9
|
JUNK_INIT_ARGS.each { |a| args.delete(a) }
|
9
10
|
%w{ type type_code }.each { |k| args.delete(k) if args[k].blank? }
|
@@ -12,30 +13,17 @@ module ClassMethods
|
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
15
|
-
def initialize args={}
|
16
|
-
args['name']
|
17
|
-
args['type_id'] = args['type_id'].to_i
|
18
|
-
|
19
|
-
args.delete('type_id') if args['type_id'] == 0 # can come in as 0, '', or nil
|
20
|
-
@type_args = {
|
21
|
-
type: args.delete('type' ),
|
22
|
-
type_code: args.delete('type_code'),
|
23
|
-
type_id: args[ 'type_id' ]
|
24
|
-
}
|
25
|
-
|
16
|
+
def initialize args = {}
|
17
|
+
args['name'] = args['name'].to_s
|
26
18
|
args['db_content'] = args.delete('content') if args['content']
|
27
|
-
|
28
|
-
#FIXME -- too much of the above is duplicated by assign_attributes (tracked_attributes.rb)
|
29
|
-
|
30
19
|
@supercard = args.delete 'supercard' # must come before name =
|
31
20
|
skip_modules = args.delete 'skip_modules'
|
21
|
+
skip_type_lookup = args['skip_type_lookup']
|
32
22
|
|
33
23
|
super args # ActiveRecord #initialize
|
34
|
-
|
35
|
-
|
36
|
-
self.type_id = tid
|
24
|
+
if !type_id && !skip_type_lookup
|
25
|
+
self.type_id = get_type_id_from_structure
|
37
26
|
end
|
38
|
-
|
39
27
|
include_set_modules unless skip_modules
|
40
28
|
self
|
41
29
|
end
|
@@ -46,15 +34,15 @@ def include_set_modules
|
|
46
34
|
singleton_class.send :include, m
|
47
35
|
end
|
48
36
|
assign_set_specific_attributes
|
49
|
-
@set_mods_loaded=true
|
37
|
+
@set_mods_loaded = true
|
50
38
|
end
|
51
39
|
self
|
52
40
|
end
|
53
41
|
|
54
|
-
|
55
42
|
event :initialize_success_object, before: :handle do
|
56
43
|
Env[:success] = Success.new(cardname, Env.params[:success])
|
57
|
-
end
|
44
|
+
end
|
45
|
+
|
58
46
|
|
59
47
|
# ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/initialize.rb ~~~~~~~~~~~
|
60
48
|
end;end;end;end;
|