card 1.109.1 → 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/lib/card/auth/current.rb +1 -1
- data/lib/card/auth/proxy.rb +2 -2
- data/lib/card/cache/class_methods.rb +1 -1
- data/lib/card/cache/shared.rb +3 -2
- 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 +7 -7
- 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/method_delegation.rb +4 -4
- data/lib/card/format/nesting/mode.rb +2 -2
- data/lib/card/format/render.rb +10 -9
- data/lib/card/format/wrapper.rb +2 -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 +0 -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.rb +2 -1
- data/lib/card/query/sql_statement/where.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 +13 -7
- data/lib/card/view/cache.rb +13 -12
- 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 +4 -4
- 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 +1 -1
- data/lib/generators/deck/deck_generator.rb +1 -1
- data/lib/generators/migration/migration_generator.rb +1 -0
- data/mod/core/lib/tasks/card/trash.rake +8 -0
- data/mod/core/lib/tasks/card.rake +17 -17
- data/mod/core/set/all/assign_attributes.rb +3 -3
- data/mod/core/set/all/initialize.rb +2 -2
- data/mod/core/set/self/mod.rb +2 -2
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: abe5aee55e82a21646046cd81ce981f95e68ec7a5c013d065e4a49202a268e22
|
|
4
|
+
data.tar.gz: 35909d80d33bd11bc6084c52adab226d655f1052df391b6e4da86c3a2275a525
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7e270754fe2e275c495bb908e9d2e6a4d0f955babc02b9368c28d6ab4a07198f63453d431b7b0cd6a5900c9e1a885447c78f74c3428848efd80c73097eb8fc76
|
|
7
|
+
data.tar.gz: de120f96396a0b25f6f49f4154c936b497a94e806b02b6634af4db31fb478348ddd4a8dee610085fc38d0dba2baef428df6b6998b7f71a25d4f7b16f05b92824
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.20.0
|
data/lib/card/auth/current.rb
CHANGED
data/lib/card/auth/proxy.rb
CHANGED
|
@@ -12,7 +12,7 @@ class Card
|
|
|
12
12
|
def [] klass
|
|
13
13
|
raise "nil klass" if klass.nil?
|
|
14
14
|
|
|
15
|
-
cache_by_class[klass] ||= new class: klass, store:
|
|
15
|
+
cache_by_class[klass] ||= new class: klass, store: shared_cache || nil
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
# clear the temporary caches and ensure we're using the latest stamp
|
data/lib/card/cache/shared.rb
CHANGED
|
@@ -16,6 +16,7 @@ class Card
|
|
|
16
16
|
#
|
|
17
17
|
class Shared
|
|
18
18
|
extend SharedClass
|
|
19
|
+
|
|
19
20
|
# @param opts [Hash]
|
|
20
21
|
# @option opts [Rails::Cache] :store
|
|
21
22
|
# @option opts [ruby Class] :class, typically ActiveRecord descendant
|
|
@@ -116,8 +117,8 @@ class Card
|
|
|
116
117
|
@store.write full_key(key), value
|
|
117
118
|
end
|
|
118
119
|
|
|
119
|
-
def fetch
|
|
120
|
-
@store.fetch
|
|
120
|
+
def fetch(key, &)
|
|
121
|
+
@store.fetch(full_key(key), &)
|
|
121
122
|
end
|
|
122
123
|
|
|
123
124
|
def delete key
|
data/lib/card/content/chunk.rb
CHANGED
data/lib/card/content/parser.rb
CHANGED
|
@@ -60,7 +60,8 @@ class Card
|
|
|
60
60
|
|
|
61
61
|
def match_prefix prefix_regexp
|
|
62
62
|
prefix_match = @content[@position..].match(prefix_regexp)
|
|
63
|
-
|
|
63
|
+
return unless prefix_match
|
|
64
|
+
|
|
64
65
|
@prefix = prefix_match[0]
|
|
65
66
|
# prefix of matched chunk
|
|
66
67
|
@chunk_start = prefix_match.begin(0) + @position
|
|
@@ -73,7 +74,6 @@ class Card
|
|
|
73
74
|
@position = @chunk_start
|
|
74
75
|
# move scanning position up to beginning of chunk
|
|
75
76
|
true
|
|
76
|
-
end
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
def record_chunk
|
|
@@ -98,10 +98,10 @@ class Card
|
|
|
98
98
|
end
|
|
99
99
|
|
|
100
100
|
def handle_remainder
|
|
101
|
-
|
|
101
|
+
return unless @chunks.any? && @last_position < @content.size
|
|
102
|
+
|
|
102
103
|
# handle any leftover nonchunk string at the end of content
|
|
103
104
|
@chunks << @content[@last_position..]
|
|
104
|
-
end
|
|
105
105
|
end
|
|
106
106
|
end
|
|
107
107
|
end
|
data/lib/card/content.rb
CHANGED
|
@@ -7,9 +7,7 @@ class Card
|
|
|
7
7
|
# Each chunk has an object whose class inherits from {Card::Content::Chunk::Abstract}
|
|
8
8
|
#
|
|
9
9
|
class Content < SimpleDelegator
|
|
10
|
-
extend Clean
|
|
11
|
-
|
|
12
|
-
Chunk # trigger autoload
|
|
10
|
+
extend Clean # trigger autoload
|
|
13
11
|
|
|
14
12
|
attr_reader :revision, :format, :chunks, :opts
|
|
15
13
|
|
|
@@ -47,8 +45,8 @@ class Card
|
|
|
47
45
|
end
|
|
48
46
|
|
|
49
47
|
# sends &block to #process_chunk on each Chunk object
|
|
50
|
-
def process_chunks
|
|
51
|
-
return custom_process_chunks(&
|
|
48
|
+
def process_chunks(&)
|
|
49
|
+
return custom_process_chunks(&) if block_given?
|
|
52
50
|
|
|
53
51
|
each_chunk(&:process_chunk)
|
|
54
52
|
end
|
|
@@ -98,12 +96,12 @@ class Card
|
|
|
98
96
|
"<#{__getobj__.class}:#{card}:#{self}>"
|
|
99
97
|
end
|
|
100
98
|
|
|
101
|
-
def without_nests
|
|
102
|
-
without_chunks
|
|
99
|
+
def without_nests(&)
|
|
100
|
+
without_chunks(Chunk::Nest, &)
|
|
103
101
|
end
|
|
104
102
|
|
|
105
|
-
def without_references
|
|
106
|
-
without_chunks
|
|
103
|
+
def without_references(&)
|
|
104
|
+
without_chunks(Chunk::Nest, Chunk::Link, Chunk::EscapedLiteral, &)
|
|
107
105
|
end
|
|
108
106
|
|
|
109
107
|
def without_chunks *chunk_classes
|
data/lib/card/director/all.rb
CHANGED
|
@@ -27,11 +27,11 @@ class Card
|
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
def act
|
|
30
|
+
def act(options={}, &)
|
|
31
31
|
if act_card
|
|
32
|
-
add_to_act
|
|
32
|
+
add_to_act(options, &)
|
|
33
33
|
else
|
|
34
|
-
start_new_act(&
|
|
34
|
+
start_new_act(&)
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
|
|
@@ -45,7 +45,7 @@ class Card
|
|
|
45
45
|
|
|
46
46
|
def save! **args
|
|
47
47
|
as_subcard = args.delete :as_subcard
|
|
48
|
-
act(as_subcard: as_subcard) { super
|
|
48
|
+
act(as_subcard: as_subcard) { super(**args) }
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
def save *_args
|
|
@@ -107,11 +107,11 @@ class Card
|
|
|
107
107
|
end
|
|
108
108
|
end
|
|
109
109
|
|
|
110
|
-
def ensuring_purity
|
|
110
|
+
def ensuring_purity(card, other, opts, &)
|
|
111
111
|
if opts[:codename] && other
|
|
112
|
-
ensure_purity_advanced
|
|
112
|
+
ensure_purity_advanced(card, other, opts, &)
|
|
113
113
|
else
|
|
114
|
-
ensure_purity_simple
|
|
114
|
+
ensure_purity_simple(card, &)
|
|
115
115
|
end
|
|
116
116
|
end
|
|
117
117
|
|
|
@@ -20,10 +20,10 @@ class Card
|
|
|
20
20
|
Cardio.config.delaying == true
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
def with_delay_act
|
|
23
|
+
def with_delay_act(act_id, card, &)
|
|
24
24
|
return yield unless act_id && (self.act = Act.find act_id)
|
|
25
25
|
|
|
26
|
-
run_job_with_act
|
|
26
|
+
run_job_with_act(act, card, &)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def run_job_with_act act, card, &block
|
data/lib/card/director/phases.rb
CHANGED
|
@@ -31,10 +31,10 @@ class Card
|
|
|
31
31
|
|
|
32
32
|
# Unlike other phases, the storage phase takes a block,
|
|
33
33
|
# because it is called by an "around" callback
|
|
34
|
-
def storage_phase
|
|
34
|
+
def storage_phase(&)
|
|
35
35
|
catch_up_to_stage :prepare_to_store # unless @abort
|
|
36
36
|
# puts "before store #{@card.name}: abort:#{@abort}"
|
|
37
|
-
run_stage
|
|
37
|
+
run_stage(:store, &) # unless @abort
|
|
38
38
|
run_stage :finalize # unless @abort
|
|
39
39
|
raise ActiveRecord::RecordInvalid, @card if @card.errors.any?
|
|
40
40
|
ensure
|
data/lib/card/director/store.rb
CHANGED
|
@@ -21,14 +21,14 @@ class Card
|
|
|
21
21
|
# the subcards as we do in the other phases.
|
|
22
22
|
# Instead we have to call `save` on the subcards and use the ActiveRecord
|
|
23
23
|
# :around_save callback.
|
|
24
|
-
def store
|
|
24
|
+
def store(&)
|
|
25
25
|
raise Card::Error, "need block to store main card" if main? && !block_given?
|
|
26
26
|
|
|
27
27
|
# the block is the ActiveRecord block from the around save callback that
|
|
28
28
|
# saves the card
|
|
29
29
|
if block_given?
|
|
30
30
|
run_stage_callbacks :store
|
|
31
|
-
store_with_subcards(&
|
|
31
|
+
store_with_subcards(&)
|
|
32
32
|
else
|
|
33
33
|
trigger_storage_phase_callback
|
|
34
34
|
end
|
|
@@ -26,13 +26,13 @@ class Card
|
|
|
26
26
|
end.compact
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
def save_interrupted_action uri
|
|
30
|
-
|
|
31
|
-
end
|
|
29
|
+
# def save_interrupted_action uri
|
|
30
|
+
# session[:interrupted_action] = uri
|
|
31
|
+
# end
|
|
32
32
|
|
|
33
|
-
def interrupted_action
|
|
34
|
-
|
|
35
|
-
end
|
|
33
|
+
# def interrupted_action
|
|
34
|
+
# session.delete :interrupted_action
|
|
35
|
+
# end
|
|
36
36
|
|
|
37
37
|
private
|
|
38
38
|
|
|
@@ -41,7 +41,7 @@ class Card
|
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
def location_cardname location
|
|
44
|
-
URI.parse(location).path.sub(
|
|
44
|
+
URI.parse(location).path.sub(%r{^/}, "").sub(%r{/.*$}, "")&.cardname
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
def save_location? card
|
data/lib/card/error.rb
CHANGED
|
@@ -27,7 +27,7 @@ class Card
|
|
|
27
27
|
self.card = message
|
|
28
28
|
message = message_from_card
|
|
29
29
|
end
|
|
30
|
-
super
|
|
30
|
+
super
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def message_from_card
|
|
@@ -119,7 +119,7 @@ class Card
|
|
|
119
119
|
|
|
120
120
|
def initialize status, msg=""
|
|
121
121
|
@status = status
|
|
122
|
-
super
|
|
122
|
+
super(msg)
|
|
123
123
|
end
|
|
124
124
|
end
|
|
125
125
|
|
|
@@ -28,8 +28,8 @@ class Card
|
|
|
28
28
|
# new: { opts for Card#new } Return a new card when not found
|
|
29
29
|
#
|
|
30
30
|
# @return [Card]
|
|
31
|
-
def fetch
|
|
32
|
-
f = Fetch.new(*
|
|
31
|
+
def fetch(*)
|
|
32
|
+
f = Fetch.new(*)
|
|
33
33
|
f.retrieve_or_new
|
|
34
34
|
rescue ActiveModel::RangeError => _e
|
|
35
35
|
Card.new name: "card id out of range: #{f.mark}"
|
data/lib/card/format/content.rb
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
class Card
|
|
2
2
|
class Format
|
|
3
3
|
module Content
|
|
4
|
-
def process_content
|
|
4
|
+
def process_content(override_content=nil, content_opts=nil, &)
|
|
5
5
|
content_obj = content_object override_content, content_opts
|
|
6
|
-
content_obj.process_chunks(&
|
|
6
|
+
content_obj.process_chunks(&)
|
|
7
7
|
content_obj.to_s
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
# 1. Break out references (nests / links) into separate chunks
|
|
11
11
|
# 2. yields the other (non-ref) content
|
|
12
12
|
# 3. processes references
|
|
13
|
-
def safe_process_content
|
|
13
|
+
def safe_process_content(override_content=nil, content_opts=nil, &)
|
|
14
14
|
content_obj = content_object override_content, chunk_list: :references
|
|
15
|
-
process_content content_obj.without_references(&
|
|
15
|
+
process_content content_obj.without_references(&), content_opts
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
# nested by another card's content
|
|
@@ -38,11 +38,11 @@ class Card
|
|
|
38
38
|
# TODO: make it so we fall back to super if action_view can't handle method.
|
|
39
39
|
# It's not as easy as `elsif api_render? method`, because respond_to gives
|
|
40
40
|
# false for many methods action view can actually handle, like `h`
|
|
41
|
-
def method_missing
|
|
41
|
+
def method_missing(method, *opts, &)
|
|
42
42
|
if (match = api_render? method)
|
|
43
43
|
api_render match, opts
|
|
44
44
|
else
|
|
45
|
-
delegate_to_action_view
|
|
45
|
+
delegate_to_action_view(method, opts, &)
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
|
|
@@ -54,8 +54,8 @@ class Card
|
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
def interpret_render_opts
|
|
58
|
-
(opts[0] ? opts.shift.clone : {}).tap(&
|
|
57
|
+
def interpret_render_opts(opts, &)
|
|
58
|
+
(opts[0] ? opts.shift.clone : {}).tap(&)
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
def optional_render_opt opts, args
|
|
@@ -21,11 +21,11 @@ class Card
|
|
|
21
21
|
# run block with new_mode as nest_mode, then return to prior mode
|
|
22
22
|
# @param new_mode [Symbol] :normal, :compact, :edit, or :template
|
|
23
23
|
# @return block result
|
|
24
|
-
def with_nest_mode
|
|
24
|
+
def with_nest_mode(new_mode, &)
|
|
25
25
|
if new_mode == @nest_mode
|
|
26
26
|
yield
|
|
27
27
|
else
|
|
28
|
-
with_altered_nest_mode
|
|
28
|
+
with_altered_nest_mode(new_mode, &)
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
|
data/lib/card/format/render.rb
CHANGED
|
@@ -47,7 +47,7 @@ class Card
|
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
# see {Abstract::Format}
|
|
50
|
-
# (:default), :yes, :deep, :always, :never
|
|
50
|
+
# (:default), :yes, :deep, :force, :always, :never
|
|
51
51
|
def view_cache_setting view
|
|
52
52
|
voo&.cache || view_setting(:cache, view) || :default
|
|
53
53
|
end
|
|
@@ -60,6 +60,7 @@ class Card
|
|
|
60
60
|
return cached_content if Cardio.config.view_cache == :debug
|
|
61
61
|
|
|
62
62
|
# stub_debugging do
|
|
63
|
+
# Rails.logger.info cached_content
|
|
63
64
|
expand_stubs cached_content
|
|
64
65
|
# end
|
|
65
66
|
end
|
|
@@ -115,14 +116,14 @@ class Card
|
|
|
115
116
|
Env.params[:debug] == "view"
|
|
116
117
|
end
|
|
117
118
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
|
126
|
+
end
|
|
126
127
|
|
|
127
128
|
def prepare_stub_nest stub_hash
|
|
128
129
|
stub_card = Card.fetch_from_cast stub_hash[:cast]
|
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
|
|
@@ -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
|
|
@@ -70,7 +69,6 @@ class Card
|
|
|
70
69
|
@key = newkey
|
|
71
70
|
end
|
|
72
71
|
clean_patterns
|
|
73
|
-
@key
|
|
74
72
|
end
|
|
75
73
|
|
|
76
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
|
|
@@ -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?
|
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)
|