card 1.109.0 → 1.110.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/config/locales/es.yml +2 -3
- data/db/seeds.rb +0 -1
- data/lib/card/auth/current.rb +2 -2
- data/lib/card/auth/permissions.rb +1 -1
- data/lib/card/auth/proxy.rb +3 -3
- data/lib/card/auth/setup.rb +2 -2
- data/lib/card/cache/all.rb +1 -1
- data/lib/card/cache/class_methods.rb +1 -1
- data/lib/card/cache/shared.rb +3 -2
- data/lib/card/codename.rb +1 -0
- data/lib/card/content/chunk.rb +2 -2
- data/lib/card/content/parser.rb +4 -4
- data/lib/card/content.rb +7 -9
- data/lib/card/director/all.rb +4 -4
- data/lib/card/director/card_class.rb +3 -3
- data/lib/card/director/event_delay.rb +2 -2
- data/lib/card/director/phases.rb +2 -2
- data/lib/card/director/store.rb +2 -2
- data/lib/card/env/location_history.rb +15 -16
- data/lib/card/env/support.rb +6 -5
- data/lib/card/error.rb +2 -2
- data/lib/card/fetch/card_class.rb +2 -2
- data/lib/card/format/card_action_view.rb +1 -1
- data/lib/card/format/content.rb +4 -4
- data/lib/card/format/error.rb +12 -2
- data/lib/card/format/method_delegation.rb +4 -4
- data/lib/card/format/nesting/mode.rb +2 -2
- data/lib/card/format/render.rb +59 -54
- data/lib/card/format/wrapper.rb +2 -2
- data/lib/card/lexicon.rb +5 -2
- data/lib/card/model/save_helper/save_helper_helper.rb +2 -2
- data/lib/card/model/save_helper.rb +2 -2
- data/lib/card/name/all/parts.rb +10 -10
- data/lib/card/name/all.rb +4 -2
- data/lib/card/name.rb +3 -3
- data/lib/card/query/card_class.rb +2 -2
- data/lib/card/query/card_query/interpretation.rb +1 -1
- data/lib/card/query/card_query/normalization.rb +1 -1
- data/lib/card/query/card_query/relational_attributes.rb +1 -1
- data/lib/card/query/card_query/run.rb +5 -1
- data/lib/card/query/card_query.rb +2 -1
- data/lib/card/query/sql_statement/where.rb +1 -1
- data/lib/card/query/sql_statement.rb +7 -1
- data/lib/card/query.rb +1 -1
- data/lib/card/reference/all.rb +2 -2
- data/lib/card/set/advanced_api.rb +4 -3
- data/lib/card/set/event/all.rb +1 -1
- data/lib/card/set/event.rb +6 -8
- data/lib/card/set/format/abstract_format/haml_views.rb +2 -2
- data/lib/card/set/format/abstract_format/view_definition.rb +6 -6
- data/lib/card/set/format/abstract_format/wrapper.rb +5 -5
- data/lib/card/set/format/abstract_format.rb +7 -5
- data/lib/card/set/format/haml_paths.rb +2 -2
- data/lib/card/set/format.rb +2 -2
- data/lib/card/set/inheritance.rb +1 -1
- data/lib/card/set/pattern/base.rb +1 -0
- data/lib/card/set/required_field.rb +1 -1
- data/lib/card/subcards.rb +4 -4
- data/lib/card/view/cache/cache_action.rb +19 -7
- data/lib/card/view/cache.rb +26 -23
- data/lib/card/view/options/voo_api.rb +1 -1
- data/lib/card/view/options.rb +1 -0
- data/lib/card/view.rb +1 -1
- data/lib/cardio/command/rspec_command/parser.rb +1 -1
- data/lib/cardio/generators/deck_helper.rb +1 -1
- data/lib/cardio/job.rb +0 -1
- data/lib/cardio/mod/dirs.rb +2 -2
- data/lib/cardio/mod/eat.rb +5 -8
- data/lib/cardio/mod/load_strategy/set_binding_magic.rb +2 -2
- data/lib/cardio/mod/loader/set_loader.rb +1 -1
- data/lib/cardio/mod/loader.rb +2 -2
- data/lib/cardio/mod/sow.rb +1 -1
- data/lib/cardio/seed.rb +2 -2
- data/lib/generators/deck/deck_generator.rb +1 -1
- data/lib/generators/migration/migration_generator.rb +1 -0
- data/mod/core/config/locales/de.yml +1 -1
- data/mod/core/config/locales/en.yml +1 -1
- data/mod/core/data/fixtures/real/cards.yml +1 -1
- data/mod/core/data/real.yml +1 -1
- data/mod/core/data/recode.yml +1 -0
- data/mod/core/lib/tasks/card/mod.rake +1 -1
- data/mod/core/lib/tasks/card/trash.rake +8 -0
- data/mod/core/lib/tasks/card.rake +19 -18
- data/mod/core/set/all/assign_attributes.rb +3 -3
- data/mod/core/set/all/codename.rb +0 -1
- data/mod/core/set/all/initialize.rb +2 -2
- data/mod/core/set/all/states.rb +6 -10
- data/mod/core/set/all/type.rb +1 -1
- data/mod/core/set/self/mod.rb +2 -2
- data/mod/core/spec/set/all/admin_spec.rb +1 -1
- data/mod/core/spec/set/all/trash_spec.rb +2 -2
- metadata +5 -4
data/lib/card/format/render.rb
CHANGED
|
@@ -41,6 +41,58 @@ class Card
|
|
|
41
41
|
add_debug_info view, method, rendered
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
+
def pretty_path source_location
|
|
45
|
+
"#{source_location.first.gsub(%r{^.+mod\d+-([^/]+)},
|
|
46
|
+
'\1: ')}:#{source_location.second}"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# see {Abstract::Format}
|
|
50
|
+
# (:default), :yes, :deep, :force, :always, :never
|
|
51
|
+
def view_cache_setting view
|
|
52
|
+
voo&.cache || view_setting(:cache, view) || :default
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def view_setting setting_name, view
|
|
56
|
+
try Card::Set::Format.view_setting_method_name(view, setting_name)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def stub_render cached_content
|
|
60
|
+
return cached_content if Cardio.config.view_cache == :debug
|
|
61
|
+
|
|
62
|
+
# stub_debugging do
|
|
63
|
+
# Rails.logger.info cached_content
|
|
64
|
+
expand_stubs cached_content
|
|
65
|
+
# end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def view_method view
|
|
69
|
+
unless supports_view? view
|
|
70
|
+
raise Card::Error::UserError, unsupported_view_error_message(view)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
method Card::Set::Format.view_method_name(view)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def supports_view? view
|
|
77
|
+
respond_to? Card::Set::Format.view_method_name(view)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def current_view view
|
|
81
|
+
old_view = @current_view
|
|
82
|
+
@current_view = view
|
|
83
|
+
yield
|
|
84
|
+
ensure
|
|
85
|
+
@current_view = old_view
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def stub_nest stub_hash
|
|
89
|
+
prepare_stub_nest(stub_hash) do |stub_card, view_opts|
|
|
90
|
+
nest stub_card, view_opts, stub_hash[:format_opts]
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
private
|
|
95
|
+
|
|
44
96
|
def wrap_and_render view
|
|
45
97
|
current_view(view) { with_wrapper { final_render view } }
|
|
46
98
|
rescue StandardError => e
|
|
@@ -64,36 +116,15 @@ class Card
|
|
|
64
116
|
Env.params[:debug] == "view"
|
|
65
117
|
end
|
|
66
118
|
|
|
67
|
-
def
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
def view_cache_setting view
|
|
75
|
-
voo&.cache || view_setting(:cache, view) || :default
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def view_setting setting_name, view
|
|
79
|
-
try Card::Set::Format.view_setting_method_name(view, setting_name)
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def stub_render cached_content
|
|
83
|
-
# stub_debugging do
|
|
84
|
-
expand_stubs cached_content
|
|
85
|
-
# end
|
|
119
|
+
def stub_debugging
|
|
120
|
+
result = yield
|
|
121
|
+
if Rails.env.development? && result.is_a?(String) && result =~ /StUb/
|
|
122
|
+
Rails.logger.debug "STUB IN RENDERED VIEW: #{card.name}: " \
|
|
123
|
+
"#{voo.ok_view}\n#{result}"
|
|
124
|
+
end
|
|
125
|
+
result
|
|
86
126
|
end
|
|
87
127
|
|
|
88
|
-
# def stub_debugging
|
|
89
|
-
# result = yield
|
|
90
|
-
# if Rails.env.development? && result.is_a?(String) && result =~ /StUb/
|
|
91
|
-
# Rails.logger.debug "STUB IN RENDERED VIEW: #{card.name}: " \
|
|
92
|
-
# "#{voo.ok_view}\n#{result}"
|
|
93
|
-
# end
|
|
94
|
-
# result
|
|
95
|
-
# end
|
|
96
|
-
|
|
97
128
|
def prepare_stub_nest stub_hash
|
|
98
129
|
stub_card = Card.fetch_from_cast stub_hash[:cast]
|
|
99
130
|
view_opts = stub_hash[:view_opts]
|
|
@@ -118,32 +149,6 @@ class Card
|
|
|
118
149
|
conto.to_s
|
|
119
150
|
end
|
|
120
151
|
end
|
|
121
|
-
|
|
122
|
-
def view_method view
|
|
123
|
-
unless supports_view? view
|
|
124
|
-
raise Card::Error::UserError, unsupported_view_error_message(view)
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
method Card::Set::Format.view_method_name(view)
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
def supports_view? view
|
|
131
|
-
respond_to? Card::Set::Format.view_method_name(view)
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
def current_view view
|
|
135
|
-
old_view = @current_view
|
|
136
|
-
@current_view = view
|
|
137
|
-
yield
|
|
138
|
-
ensure
|
|
139
|
-
@current_view = old_view
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
def stub_nest stub_hash
|
|
143
|
-
prepare_stub_nest(stub_hash) do |stub_card, view_opts|
|
|
144
|
-
nest stub_card, view_opts, stub_hash[:format_opts]
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
152
|
end
|
|
148
153
|
end
|
|
149
154
|
end
|
data/lib/card/format/wrapper.rb
CHANGED
|
@@ -41,9 +41,9 @@ class Card
|
|
|
41
41
|
def raise_wrap_error wrapper
|
|
42
42
|
if wrapper.is_a? String
|
|
43
43
|
raise Card::Error::UserError, "unknown layout card: #{wrapper}"
|
|
44
|
-
else
|
|
45
|
-
raise ArgumentError, "unknown wrapper: #{wrapper}"
|
|
46
44
|
end
|
|
45
|
+
|
|
46
|
+
raise ArgumentError, "unknown wrapper: #{wrapper}"
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
def send_wrapper_method method_name, opts
|
data/lib/card/lexicon.rb
CHANGED
|
@@ -18,9 +18,12 @@ class Card
|
|
|
18
18
|
# param name [String]
|
|
19
19
|
# @return [Integer]
|
|
20
20
|
def id name
|
|
21
|
-
return
|
|
21
|
+
return if name.blank?
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
name = name.to_name
|
|
24
|
+
return if name.relative_fragment?
|
|
25
|
+
|
|
26
|
+
(lex = name_to_lex name) && lex_to_id(lex)
|
|
24
27
|
end
|
|
25
28
|
|
|
26
29
|
def cache
|
|
@@ -17,11 +17,11 @@ class Card
|
|
|
17
17
|
Card.exist? name
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
def method_missing
|
|
20
|
+
def method_missing(method, *)
|
|
21
21
|
method_name, cardtype_card = extract_cardtype_from_method_name method
|
|
22
22
|
return super unless method_name
|
|
23
23
|
|
|
24
|
-
sargs = standardize_args(*
|
|
24
|
+
sargs = standardize_args(*).merge(type_id: cardtype_card.id)
|
|
25
25
|
if method_name == "ensure"
|
|
26
26
|
Card.ensure sargs
|
|
27
27
|
else
|
|
@@ -12,8 +12,8 @@ class Card
|
|
|
12
12
|
include SaveHelperHelper
|
|
13
13
|
include SaveArguments
|
|
14
14
|
|
|
15
|
-
def with_user
|
|
16
|
-
Card::Auth.with(current_id: user_name.card_id, &
|
|
15
|
+
def with_user(user_name, &)
|
|
16
|
+
Card::Auth.with(current_id: user_name.card_id, &)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def create_card name_or_args, content_or_args=nil
|
data/lib/card/name/all/parts.rb
CHANGED
|
@@ -3,14 +3,14 @@ class Card
|
|
|
3
3
|
module All
|
|
4
4
|
# Card methods for handling name parts, eg A and B are both parts of A+B
|
|
5
5
|
module Parts
|
|
6
|
-
def left
|
|
6
|
+
def left(*)
|
|
7
7
|
case
|
|
8
8
|
when simple? then nil
|
|
9
9
|
when superleft then superleft
|
|
10
10
|
when name_is_changing? && name.to_name.trunk_name == name_before_act.to_name
|
|
11
11
|
nil # prevent recursion when, eg, renaming A+B to A+B+C
|
|
12
12
|
else
|
|
13
|
-
Card.fetch
|
|
13
|
+
Card.fetch(name.left, *)
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
|
|
@@ -18,16 +18,16 @@ class Card
|
|
|
18
18
|
left(args) || Card.new(args.merge(name: name.left))
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
def right
|
|
22
|
-
Card.fetch(name.right, *
|
|
21
|
+
def right(*)
|
|
22
|
+
Card.fetch(name.right, *) unless simple?
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
def trunk
|
|
26
|
-
simple? ? self : left(*
|
|
25
|
+
def trunk(*)
|
|
26
|
+
simple? ? self : left(*)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
def tag
|
|
30
|
-
simple? ? self : Card.fetch(name.right, *
|
|
29
|
+
def tag(*)
|
|
30
|
+
simple? ? self : Card.fetch(name.right, *)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def right_id= cardish
|
|
@@ -44,11 +44,11 @@ class Card
|
|
|
44
44
|
when_id_exists(cardish) { |id| write_attribute attribute, id }
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
def when_id_exists
|
|
47
|
+
def when_id_exists(cardish, &)
|
|
48
48
|
if (card_id = Card.id cardish)
|
|
49
49
|
yield card_id
|
|
50
50
|
elsif cardish.is_a? Card
|
|
51
|
-
with_id_after_store
|
|
51
|
+
with_id_after_store(cardish, &)
|
|
52
52
|
else
|
|
53
53
|
yield cardish # eg nil
|
|
54
54
|
end
|
data/lib/card/name/all.rb
CHANGED
|
@@ -24,7 +24,6 @@ class Card
|
|
|
24
24
|
update_subcard_names @name
|
|
25
25
|
write_attribute :name, (@name.simple? ? @name.s : nil)
|
|
26
26
|
assign_side_ids
|
|
27
|
-
@name
|
|
28
27
|
end
|
|
29
28
|
|
|
30
29
|
def [] *args
|
|
@@ -58,6 +57,10 @@ class Card
|
|
|
58
57
|
end
|
|
59
58
|
end
|
|
60
59
|
|
|
60
|
+
def id_string
|
|
61
|
+
"~#{id}"
|
|
62
|
+
end
|
|
63
|
+
|
|
61
64
|
def key= newkey
|
|
62
65
|
return if newkey == key
|
|
63
66
|
|
|
@@ -66,7 +69,6 @@ class Card
|
|
|
66
69
|
@key = newkey
|
|
67
70
|
end
|
|
68
71
|
clean_patterns
|
|
69
|
-
@key
|
|
70
72
|
end
|
|
71
73
|
|
|
72
74
|
private
|
data/lib/card/name.rb
CHANGED
|
@@ -40,7 +40,7 @@ class Card
|
|
|
40
40
|
elsif (id = id_from_string str) # handles ~[id] and :[codename]
|
|
41
41
|
from_id_from_string id, str
|
|
42
42
|
else
|
|
43
|
-
super
|
|
43
|
+
super(str)
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
|
|
@@ -89,8 +89,8 @@ class Card
|
|
|
89
89
|
new_from_parts(parts) { |part| new part }
|
|
90
90
|
end
|
|
91
91
|
|
|
92
|
-
def new_from_parts
|
|
93
|
-
name_parts = parts.flatten.map(&
|
|
92
|
+
def new_from_parts(parts, &)
|
|
93
|
+
name_parts = parts.flatten.map(&)
|
|
94
94
|
new name_parts.join(joint), true
|
|
95
95
|
end
|
|
96
96
|
|
|
@@ -2,9 +2,9 @@ class Card
|
|
|
2
2
|
module Query
|
|
3
3
|
# query-related methods with which to extend Card class
|
|
4
4
|
module CardClass
|
|
5
|
-
def search
|
|
5
|
+
def search(spec, comment=nil, &)
|
|
6
6
|
results = ::Card::Query.run(spec, comment)
|
|
7
|
-
results.each(&
|
|
7
|
+
results.each(&) if block_given? && results.is_a?(Array)
|
|
8
8
|
results
|
|
9
9
|
end
|
|
10
10
|
|
|
@@ -28,7 +28,7 @@ class Card
|
|
|
28
28
|
case clause
|
|
29
29
|
when Hash then clause
|
|
30
30
|
when Integer then { id: clause }
|
|
31
|
-
when String then { id:
|
|
31
|
+
when String then { id: Card::Lexicon.id(clause) || -2 }
|
|
32
32
|
when Symbol then { id: Card::Codename.id(clause) }
|
|
33
33
|
else raise Error::BadQuery, "Invalid clause: #{clause.inspect}"
|
|
34
34
|
end
|
|
@@ -4,7 +4,7 @@ class Card
|
|
|
4
4
|
# interpret CQL attributes that relate multiple cards
|
|
5
5
|
# each method below corresponds to a relational CQL term
|
|
6
6
|
#
|
|
7
|
-
# NOTE: methods using "restrict" can
|
|
7
|
+
# NOTE: methods using "restrict" can be executed without
|
|
8
8
|
# tying in an additional query if the val in question can be
|
|
9
9
|
# reduced to an id.
|
|
10
10
|
module RelationalAttributes
|
|
@@ -38,7 +38,7 @@ class Card
|
|
|
38
38
|
case
|
|
39
39
|
when respond_to?(:"#{retrn}_result") then :"#{retrn}_result"
|
|
40
40
|
when retrn.match?(/id$/) then :id_result
|
|
41
|
-
when retrn.match?(
|
|
41
|
+
when retrn.match?(/^_\w+/) then :name_result
|
|
42
42
|
when retrn == "key" then :key_result
|
|
43
43
|
else :default_result
|
|
44
44
|
end
|
|
@@ -52,6 +52,10 @@ class Card
|
|
|
52
52
|
record[field]
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
+
def content_result record, _pattern
|
|
56
|
+
record["db_content"]
|
|
57
|
+
end
|
|
58
|
+
|
|
55
59
|
def id_result record, field
|
|
56
60
|
record[field].to_i
|
|
57
61
|
end
|
|
@@ -13,6 +13,7 @@ class Card
|
|
|
13
13
|
include Sorting
|
|
14
14
|
include Conjunctions
|
|
15
15
|
include Custom
|
|
16
|
+
|
|
16
17
|
# Query Execution
|
|
17
18
|
|
|
18
19
|
# By default a query returns card objects. This is accomplished by returning
|
|
@@ -32,7 +33,7 @@ class Card
|
|
|
32
33
|
end
|
|
33
34
|
|
|
34
35
|
def initialize statement, comment=nil
|
|
35
|
-
super
|
|
36
|
+
super(statement)
|
|
36
37
|
@comment = comment || default_comment
|
|
37
38
|
interpret @statement
|
|
38
39
|
end
|
|
@@ -3,7 +3,7 @@ class Card
|
|
|
3
3
|
class SqlStatement
|
|
4
4
|
# handle where clause in SqlStatement
|
|
5
5
|
module Where
|
|
6
|
-
def where explicit
|
|
6
|
+
def where explicit: true
|
|
7
7
|
conditions = [explicit_conditions(@query), implicit_conditions(@query)]
|
|
8
8
|
conditions = conditions.reject(&:blank?).join " AND "
|
|
9
9
|
"#{'WHERE ' if explicit}#{conditions}" unless conditions.blank?
|
|
@@ -24,6 +24,7 @@ class Card
|
|
|
24
24
|
@fields = fields
|
|
25
25
|
@tables = tables
|
|
26
26
|
@joins = joins
|
|
27
|
+
@indexes = indexes
|
|
27
28
|
@where = where
|
|
28
29
|
@group = group
|
|
29
30
|
@order = order
|
|
@@ -33,7 +34,8 @@ class Card
|
|
|
33
34
|
|
|
34
35
|
def to_s
|
|
35
36
|
[
|
|
36
|
-
comment, select, from,
|
|
37
|
+
comment, select, from,
|
|
38
|
+
@joins, @indexes, @where, @group, @order, @limit_and_offset
|
|
37
39
|
].compact.join " "
|
|
38
40
|
end
|
|
39
41
|
|
|
@@ -103,6 +105,10 @@ class Card
|
|
|
103
105
|
end
|
|
104
106
|
end
|
|
105
107
|
|
|
108
|
+
def indexes
|
|
109
|
+
"USE INDEX (#{Array.wrap(@mods[:index]).join ', '})" if @mods[:index]
|
|
110
|
+
end
|
|
111
|
+
|
|
106
112
|
def full_syntax
|
|
107
113
|
@query.full? ? yield : return
|
|
108
114
|
end
|
data/lib/card/query.rb
CHANGED
|
@@ -83,7 +83,7 @@ class Card
|
|
|
83
83
|
# "dir" is DEPRECATED in favor of sort_dir
|
|
84
84
|
# "sort" is DEPRECATED in favor of sort_by, except in cases where sort's value
|
|
85
85
|
# is a hash
|
|
86
|
-
MODIFIERS = %i[conj return sort_by sort_as sort_dir sort dir group limit offset]
|
|
86
|
+
MODIFIERS = %i[conj return index sort_by sort_as sort_dir sort dir group limit offset]
|
|
87
87
|
.each_with_object({}) { |v, h| h[v] = nil }
|
|
88
88
|
|
|
89
89
|
OPERATORS =
|
data/lib/card/reference/all.rb
CHANGED
|
@@ -113,10 +113,10 @@ class Card
|
|
|
113
113
|
end
|
|
114
114
|
end
|
|
115
115
|
|
|
116
|
-
def each_reference_type
|
|
116
|
+
def each_reference_type(ref_types, &)
|
|
117
117
|
ref_types.delete PARTIAL_REF_CODE if ref_types.size > 1
|
|
118
118
|
# partial references are not necessary if there are explicit references
|
|
119
|
-
ref_types.each(&
|
|
119
|
+
ref_types.each(&)
|
|
120
120
|
end
|
|
121
121
|
|
|
122
122
|
# invokes the given block for each reference in content with
|
|
@@ -9,16 +9,17 @@ class Card
|
|
|
9
9
|
|
|
10
10
|
def setting_opts opts
|
|
11
11
|
extend Card::Setting
|
|
12
|
+
|
|
12
13
|
register_setting opts
|
|
13
14
|
end
|
|
14
15
|
|
|
15
|
-
def ensure_set
|
|
16
|
+
def ensure_set(&)
|
|
16
17
|
set_module = yield
|
|
17
18
|
set_module = card_set_module_const_get(set_module) unless set_module.is_a?(Module)
|
|
18
19
|
rescue NameError => e
|
|
19
20
|
define_set_from_error e
|
|
20
21
|
# try again - there might be another submodule that doesn't exist
|
|
21
|
-
ensure_set(&
|
|
22
|
+
ensure_set(&)
|
|
22
23
|
else
|
|
23
24
|
set_module.extend Card::Set
|
|
24
25
|
end
|
|
@@ -32,7 +33,7 @@ class Card
|
|
|
32
33
|
|
|
33
34
|
def attachment name, args
|
|
34
35
|
include_set Abstract::Attachment
|
|
35
|
-
add_attributes name, "remote_#{name}_url"
|
|
36
|
+
add_attributes name, :"remote_#{name}_url",
|
|
36
37
|
:action_id_of_cached_upload, :empty_ok,
|
|
37
38
|
:storage_type, :bucket, :mod
|
|
38
39
|
mount_uploader name, (args[:uploader] || ::CarrierWave::FileCardUploader)
|
data/lib/card/set/event/all.rb
CHANGED
|
@@ -31,7 +31,7 @@ class Card
|
|
|
31
31
|
|
|
32
32
|
def on_condition_applies? _event, actions
|
|
33
33
|
actions = Array(actions).compact
|
|
34
|
-
actions.empty?
|
|
34
|
+
actions.empty? || actions.include?(action)
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
# if changing name/type, the old card has no-longer-applicable set modules,
|
data/lib/card/set/event.rb
CHANGED
|
@@ -69,8 +69,8 @@ class Card
|
|
|
69
69
|
# event to fire.
|
|
70
70
|
# @option opts [Symbol] :stage alternate representation for specifying stage
|
|
71
71
|
# @option opts [True/False] :after_subcards run event after running subcard events
|
|
72
|
-
def event
|
|
73
|
-
Event.new(event, self).register
|
|
72
|
+
def event(event, stage_or_opts={}, opts={}, &)
|
|
73
|
+
Event.new(event, self).register(stage_or_opts, opts, &)
|
|
74
74
|
end
|
|
75
75
|
end
|
|
76
76
|
|
|
@@ -160,15 +160,13 @@ class Card
|
|
|
160
160
|
end
|
|
161
161
|
end
|
|
162
162
|
|
|
163
|
-
def rescuing_if_integration
|
|
164
|
-
is_integration ? rescuing_integration(&
|
|
163
|
+
def rescuing_if_integration(is_integration, &)
|
|
164
|
+
is_integration ? rescuing_integration(&) : yield
|
|
165
165
|
end
|
|
166
166
|
|
|
167
167
|
# one failed integration event should not harm others.
|
|
168
|
-
def rescuing_integration
|
|
169
|
-
Error.rescue_card(self, &
|
|
170
|
-
ensure
|
|
171
|
-
true
|
|
168
|
+
def rescuing_integration(&)
|
|
169
|
+
Error.rescue_card(self, &)
|
|
172
170
|
end
|
|
173
171
|
|
|
174
172
|
def log_event_call event
|
|
@@ -24,9 +24,9 @@ class Card
|
|
|
24
24
|
|
|
25
25
|
private
|
|
26
26
|
|
|
27
|
-
def haml_view_block
|
|
27
|
+
def haml_view_block(view, &)
|
|
28
28
|
path = haml_template_path view
|
|
29
|
-
haml_template_proc
|
|
29
|
+
haml_template_proc(::File.read(path), path, &)
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def haml_template_proc template, path, &block
|
|
@@ -9,8 +9,8 @@ class Card
|
|
|
9
9
|
|
|
10
10
|
private
|
|
11
11
|
|
|
12
|
-
def define_view_method
|
|
13
|
-
view_block = view_block
|
|
12
|
+
def define_view_method(view, def_opts, &)
|
|
13
|
+
view_block = view_block(view, def_opts, &)
|
|
14
14
|
view_type = def_opts[:async] ? :async : :standard
|
|
15
15
|
send "define_#{view_type}_view_method", view, &view_block
|
|
16
16
|
end
|
|
@@ -20,7 +20,7 @@ class Card
|
|
|
20
20
|
define_method Card::Set::Format.view_method_name(view), &block
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
def define_async_view_method
|
|
23
|
+
def define_async_view_method(view, &)
|
|
24
24
|
# This case makes only sense for HtmlFormat
|
|
25
25
|
# but I don't see an easy way to override class methods for a specific
|
|
26
26
|
# format. All formats are extended with this general module. So
|
|
@@ -28,7 +28,7 @@ class Card
|
|
|
28
28
|
# We need something like AbstractHtmlFormat for that.
|
|
29
29
|
|
|
30
30
|
view_content = "#{view}_async_content"
|
|
31
|
-
define_standard_view_method
|
|
31
|
+
define_standard_view_method(view_content, &)
|
|
32
32
|
define_standard_view_method view do
|
|
33
33
|
%(<card-view-placeholder data-url="#{path view: view_content}" />)
|
|
34
34
|
end
|
|
@@ -44,8 +44,8 @@ class Card
|
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
def template_view_block
|
|
48
|
-
return haml_view_block(view, &
|
|
47
|
+
def template_view_block(view, template, &)
|
|
48
|
+
return haml_view_block(view, &) if template == :haml
|
|
49
49
|
|
|
50
50
|
raise Card::Error::ServerError, "unknown view template: #{template}"
|
|
51
51
|
end
|
|
@@ -37,20 +37,20 @@ class Card
|
|
|
37
37
|
# wrapper :burger, :div, class: "medium"
|
|
38
38
|
#
|
|
39
39
|
# wrap_with_burger "meat" # => "<div class='medium'>meat</div>"
|
|
40
|
-
def wrapper
|
|
40
|
+
def wrapper(wrapper_name, *, &)
|
|
41
41
|
method_name = Card::Set::Format.wrapper_method_name(wrapper_name)
|
|
42
42
|
if block_given?
|
|
43
|
-
define_method
|
|
43
|
+
define_method(method_name, &)
|
|
44
44
|
else
|
|
45
|
-
define_tag_wrapper
|
|
45
|
+
define_tag_wrapper(method_name, *)
|
|
46
46
|
end
|
|
47
47
|
define_wrap_with_method wrapper_name, method_name
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
def layout
|
|
50
|
+
def layout(layout, opts={}, &)
|
|
51
51
|
Card::Layout.register_built_in_layout layout, opts
|
|
52
52
|
method_name = Card::Set::Format.layout_method_name(layout)
|
|
53
|
-
define_method
|
|
53
|
+
define_method(method_name, &)
|
|
54
54
|
wrapper layout do
|
|
55
55
|
send method_name
|
|
56
56
|
end
|
|
@@ -51,10 +51,12 @@ class Card
|
|
|
51
51
|
# nested cards in your cache. (Instead, stub them and process them
|
|
52
52
|
# separately)
|
|
53
53
|
# * *:always* - cache even when rendered within another cached view
|
|
54
|
-
# * *:deep* cache this view and include nested cards
|
|
54
|
+
# * *:deep* cache this view and include nested cards (but stub nested views
|
|
55
|
+
# that are set to "never")
|
|
55
56
|
# * *:never* - don't ever cache this view, even if it's rendered by another
|
|
56
57
|
# view of the same card. Frequently used to prevent caching problems, when
|
|
57
58
|
# dynamic context (eg params) can alter the view.
|
|
59
|
+
# * *:force* - deep cache everything, even views marked "never"
|
|
58
60
|
#
|
|
59
61
|
# You should certainly {Card::View::Cache learn more about caching} if you want
|
|
60
62
|
# to develop mods that are safe in a caching environment.
|
|
@@ -92,9 +94,9 @@ class Card
|
|
|
92
94
|
# * __:wrap__ wrap view dynamically. Value is Symbol for wrapper or Hash with
|
|
93
95
|
# wrappers and wrapper options. See {Wrapper}
|
|
94
96
|
#
|
|
95
|
-
def view
|
|
97
|
+
def view(viewname, *args, &)
|
|
96
98
|
def_opts = process_view_opts viewname, args
|
|
97
|
-
define_view_method
|
|
99
|
+
define_view_method(viewname, def_opts, &)
|
|
98
100
|
end
|
|
99
101
|
|
|
100
102
|
# simple placeholder for views designed to be overridden elsewhere
|
|
@@ -106,8 +108,8 @@ class Card
|
|
|
106
108
|
end
|
|
107
109
|
|
|
108
110
|
# define code to be executed before a view is rendered
|
|
109
|
-
def before
|
|
110
|
-
define_method
|
|
111
|
+
def before(view, &)
|
|
112
|
+
define_method("_before_#{view}", &)
|
|
111
113
|
end
|
|
112
114
|
|
|
113
115
|
# Defines a setting method that can be used in all formats. Example:
|
|
@@ -63,8 +63,8 @@ class Card
|
|
|
63
63
|
path if ::File.exist? path
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
-
def haml_block_locals
|
|
67
|
-
instance_exec(&
|
|
66
|
+
def haml_block_locals(&)
|
|
67
|
+
instance_exec(&) if block_given?
|
|
68
68
|
instance_variables.each_with_object({}) do |var, h|
|
|
69
69
|
h[var.to_s.tr("@", "").to_sym] = instance_variable_get var
|
|
70
70
|
end
|
data/lib/card/set/format.rb
CHANGED
|
@@ -115,7 +115,7 @@ class Card
|
|
|
115
115
|
|
|
116
116
|
private
|
|
117
117
|
|
|
118
|
-
def define_on_format
|
|
118
|
+
def define_on_format(format_name=:base, &)
|
|
119
119
|
# format class name, eg. HtmlFormat
|
|
120
120
|
klass = Card::Format.format_class_name format_name
|
|
121
121
|
|
|
@@ -127,7 +127,7 @@ class Card
|
|
|
127
127
|
m.extend Card::Set::Format::AbstractFormat
|
|
128
128
|
m
|
|
129
129
|
end
|
|
130
|
-
mod.class_eval(&
|
|
130
|
+
mod.class_eval(&)
|
|
131
131
|
end
|
|
132
132
|
|
|
133
133
|
def register_set_format format_class, mod
|
data/lib/card/set/inheritance.rb
CHANGED