card 1.108.1 → 1.109.1
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/environments/development.rb +1 -1
- data/config/environments/production.rb +5 -2
- data/config/initializers/01_core_extensions/array.rb +1 -0
- data/config/initializers/01_core_extensions/hash.rb +4 -0
- data/config/initializers/02_patches/active_record.rb +1 -1
- data/config/initializers/core_extensions.rb +0 -1
- data/config/initializers/deck_config.rb +3 -3
- data/config/initializers/patches.rb +6 -6
- data/config/locales/es.yml +2 -3
- data/db/seeds.rb +0 -1
- data/lib/card/auth/current.rb +8 -6
- data/lib/card/auth/permissions.rb +1 -1
- data/lib/card/auth/proxy.rb +2 -2
- data/lib/card/auth/setup.rb +2 -2
- data/lib/card/auth.rb +7 -6
- data/lib/card/cache/all.rb +1 -1
- data/lib/card/cache/class_methods.rb +2 -4
- data/lib/card/cache/shared.rb +1 -1
- data/lib/card/cache/temporary.rb +2 -2
- data/lib/card/codename.rb +1 -1
- data/lib/card/content/chunk/abstract.rb +1 -0
- data/lib/card/content/chunk.rb +0 -1
- data/lib/card/content/clean.rb +4 -2
- data/lib/card/content/diff/l_c_s.rb +1 -2
- data/lib/card/content/diff/result.rb +2 -1
- data/lib/card/content/diff.rb +2 -1
- data/lib/card/content/parser.rb +8 -7
- data/lib/card/content.rb +1 -1
- data/lib/card/director/subdirector_array.rb +1 -0
- data/lib/card/director.rb +1 -1
- data/lib/card/dirty/method_factory.rb +1 -0
- data/lib/card/env/location.rb +3 -3
- data/lib/card/env/location_history.rb +20 -20
- data/lib/card/env/success/target.rb +4 -4
- data/lib/card/env/support.rb +25 -2
- data/lib/card/error.rb +1 -0
- data/lib/card/fetch/store.rb +1 -1
- data/lib/card/format/error.rb +13 -2
- data/lib/card/format/method_delegation.rb +6 -4
- data/lib/card/format/registration.rb +5 -3
- data/lib/card/format/render.rb +51 -47
- data/lib/card/format/wrapper.rb +1 -0
- data/lib/card/lexicon.rb +5 -2
- data/lib/card/mailer.rb +1 -14
- data/lib/card/name/all/parts.rb +1 -1
- data/lib/card/name/all.rb +5 -0
- data/lib/card/name/name_variants.rb +1 -0
- data/lib/card/query/abstract_query/query_helper.rb +1 -2
- data/lib/card/query/abstract_query/tie.rb +1 -1
- data/lib/card/query/abstract_query.rb +3 -3
- data/lib/card/query/card_class.rb +1 -0
- 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/clause.rb +1 -0
- data/lib/card/query/join.rb +3 -3
- data/lib/card/query/sql_statement.rb +7 -1
- data/lib/card/query.rb +1 -1
- data/lib/card/reference/all.rb +6 -7
- data/lib/card/rule/cache.rb +1 -0
- data/lib/card/rule/preference_cache.rb +2 -0
- data/lib/card/rule/read_rule_cache.rb +3 -0
- data/lib/card/set/event/all.rb +6 -4
- data/lib/card/set/event/callbacks.rb +1 -0
- data/lib/card/set/event/options.rb +3 -2
- data/lib/card/set/event/skip_and_trigger.rb +1 -1
- data/lib/card/set/event.rb +2 -2
- data/lib/card/set/format/abstract_format/view_definition.rb +1 -1
- data/lib/card/set/format/haml_paths.rb +1 -1
- data/lib/card/set/format.rb +4 -4
- data/lib/card/set/helpers.rb +4 -4
- data/lib/card/set/i18n_scanner.rb +23 -22
- data/lib/card/set/i18n_scope.rb +4 -3
- data/lib/card/set/pattern/all.rb +1 -1
- data/lib/card/set/pattern/base.rb +6 -3
- data/lib/card/set/pattern/class_methods.rb +1 -1
- data/lib/card/set/pattern.rb +1 -1
- data/lib/card/set/required_field.rb +3 -0
- data/lib/card/set/trait.rb +6 -1
- data/lib/card/subcards/all.rb +12 -4
- data/lib/card/view/cache/cache_action.rb +9 -3
- data/lib/card/view/cache.rb +17 -15
- data/lib/card/view/classy.rb +5 -5
- data/lib/card/view/options/key_lists.rb +1 -0
- data/lib/card/view/options/voo_api.rb +2 -2
- data/lib/card/view/options.rb +1 -0
- data/lib/card/view.rb +1 -1
- data/lib/cardio/command/application.rb +1 -1
- data/lib/cardio/command/custom.rb +7 -6
- data/lib/cardio/command/rake_command.rb +3 -2
- data/lib/cardio/command/rspec_command.rb +1 -0
- data/lib/cardio/generators/deck_generator_loader.rb +1 -1
- data/lib/cardio/generators.rb +4 -3
- data/lib/cardio/migration/port.rb +2 -0
- data/lib/cardio/migration/stamp.rb +1 -0
- data/lib/cardio/migration/transform.rb +1 -0
- data/lib/cardio/migration.rb +2 -0
- data/lib/cardio/mod/class_methods.rb +1 -2
- data/lib/cardio/mod/dirs.rb +2 -4
- data/lib/cardio/mod/eat/edibles.rb +8 -6
- data/lib/cardio/mod/eat.rb +7 -9
- data/lib/cardio/mod/load_strategy/set_binding_magic.rb +1 -1
- data/lib/cardio/mod/load_strategy/tmp_files.rb +3 -2
- data/lib/cardio/mod/load_strategy.rb +1 -0
- data/lib/cardio/mod/loader/set_pattern_loader.rb +4 -0
- data/lib/cardio/mod/loader/set_template.rb +14 -4
- data/lib/cardio/mod/loader.rb +2 -2
- data/lib/cardio/mod/sow/card_source.rb +1 -1
- data/lib/cardio/mod/sow/remote_source.rb +32 -0
- data/lib/cardio/mod/sow.rb +10 -10
- data/lib/cardio/railtie.rb +1 -0
- data/lib/cardio/script_loader.rb +1 -1
- data/lib/cardio/seed.rb +2 -2
- data/lib/cardio/utils.rb +1 -1
- data/lib/cardio/version.rb +2 -1
- data/lib/cardio.rb +3 -0
- data/lib/generators/deck/templates/config.ru.erb +1 -1
- data/mod/core/config/locales/de.yml +1 -1
- data/mod/core/config/locales/en.yml +2 -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/data/schema/20141001105348_move_revisions_to_actions.rb +2 -2
- data/mod/core/data/schema/20241017160402_unique_codename.rb +8 -0
- data/mod/core/data/transform/20150724123438_update_file_and_image_cards.rb +1 -1
- data/mod/core/lib/tasks/card/export.rake +28 -0
- data/mod/core/lib/tasks/card/migrate.rake +3 -3
- data/mod/core/lib/tasks/card/mod.rake +1 -1
- data/mod/core/lib/tasks/card/seed.rake +2 -1
- data/mod/core/lib/tasks/card.rake +48 -16
- data/mod/core/set/all/admin.rb +1 -2
- data/mod/core/set/all/assign_attributes.rb +3 -2
- data/mod/core/set/all/codename.rb +7 -1
- data/mod/core/set/all/debug.rb +3 -3
- data/mod/core/set/all/initialize.rb +1 -0
- data/mod/core/set/all/states.rb +13 -16
- data/mod/core/set/all/type.rb +3 -1
- data/mod/core/set/all/utils.rb +0 -1
- data/mod/core/set/self/admin.rb +2 -1
- data/mod/core/set/self/autoname.rb +1 -1
- data/mod/core/set/self/mod.rb +4 -4
- data/mod/core/set/self/trash.rb +1 -1
- data/mod/core/set/type/mod.rb +18 -15
- data/mod/core/set_pattern/09_self.rb +4 -0
- data/mod/core/spec/set/all/admin_spec.rb +1 -1
- data/mod/core/spec/set/all/trash_spec.rb +9 -9
- metadata +42 -29
data/lib/card/set/helpers.rb
CHANGED
@@ -10,7 +10,7 @@ class Card
|
|
10
10
|
# Card::Set::Type::User
|
11
11
|
def shortname
|
12
12
|
first = 2 # shortname eliminates Card::Set
|
13
|
-
last = first + num_set_parts
|
13
|
+
last = pattern_code == :self ? -1 : (first + num_set_parts)
|
14
14
|
set_name_parts[first..last].join "::"
|
15
15
|
end
|
16
16
|
|
@@ -88,7 +88,7 @@ class Card
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def test_set
|
91
|
-
# rubocop:disable
|
91
|
+
# rubocop:disable Security/Eval
|
92
92
|
::Card::Set::Self.const_remove_if_defined :TestSet
|
93
93
|
eval <<-RUBY, binding, __FILE__, __LINE__ + 1
|
94
94
|
class ::Card::Set::Self
|
@@ -99,7 +99,7 @@ class Card
|
|
99
99
|
end
|
100
100
|
RUBY
|
101
101
|
::Card::Set::Self::TestSet
|
102
|
-
# rubocop:enable
|
102
|
+
# rubocop:enable Security/Eval
|
103
103
|
end
|
104
104
|
|
105
105
|
def base_format_modules?
|
@@ -115,7 +115,7 @@ class Card
|
|
115
115
|
Card::Set.modules[set_format_type_key][format_class][shortname] || []
|
116
116
|
end
|
117
117
|
|
118
|
-
def num_set_parts
|
118
|
+
def num_set_parts
|
119
119
|
return 1 if pattern_code == :abstract
|
120
120
|
|
121
121
|
Pattern.find(pattern_code).anchor_parts_count
|
@@ -1,23 +1,24 @@
|
|
1
1
|
# lib/my_custom_scanner.rb
|
2
|
-
require "i18n/tasks/scanners/file_scanner"
|
3
|
-
class Card
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
2
|
+
# require "i18n/tasks/scanners/file_scanner"
|
3
|
+
# class Card
|
4
|
+
# module Set
|
5
|
+
# class I18nScanner < ::I18n::Tasks::Scanners::FileScanner
|
6
|
+
# include ::I18n::Tasks::Scanners::RelativeKeys
|
7
|
+
# include ::I18n::Tasks::Scanners::OccurrenceFromPosition
|
8
|
+
#
|
9
|
+
# # @return [Array<[absolute key, Results::Occurrence]>]
|
10
|
+
# def scan_file path
|
11
|
+
# text = read_file(path)
|
12
|
+
#
|
13
|
+
# # tr()
|
14
|
+
# text.scan(/[^\w._-]tr[( ]\s*["':](\w+)/).map do |_match|
|
15
|
+
# occurrence = occurrence_from_position(
|
16
|
+
# path, text, Regexp.last_match.offset(0).first
|
17
|
+
# )
|
18
|
+
# [absolute_key(".#{_match[0]}", path), occurrence]
|
19
|
+
# end
|
20
|
+
# end
|
21
|
+
# end
|
22
|
+
# ::I18n::Tasks.add_scanner "Card::Set::I18nScanner"
|
23
|
+
# end
|
24
|
+
# end
|
data/lib/card/set/i18n_scope.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
class Card
|
2
2
|
module Set
|
3
|
+
# Adapt Internationalization(i18n) scope handling to infer mod prefixes.
|
3
4
|
module I18nScope
|
4
5
|
delegate :tmp_files?, to: Cardio::Mod::LoadStrategy
|
5
6
|
|
@@ -22,7 +23,7 @@ class Card
|
|
22
23
|
|
23
24
|
def set_from_parts parts, index
|
24
25
|
start_index = index + (tmp_files? ? 2 : 1)
|
25
|
-
parts[start_index
|
26
|
+
parts[start_index..].join "."
|
26
27
|
end
|
27
28
|
|
28
29
|
def mod_from_parts parts, set_index
|
@@ -55,7 +56,7 @@ class Card
|
|
55
56
|
# this method returns ["core", "all", "event"]
|
56
57
|
# def set_path_parts backtrace
|
57
58
|
# parts = path_parts backtrace
|
58
|
-
# res = parts[path_mod_index(parts)
|
59
|
+
# res = parts[path_mod_index(parts)..]
|
59
60
|
# res.delete_at 1
|
60
61
|
# end
|
61
62
|
|
@@ -65,7 +66,7 @@ class Card
|
|
65
66
|
# this method returns ["core", "all", "event"]
|
66
67
|
# def tmp_set_path_parts backtrace
|
67
68
|
# path_parts = find_tmp_set_path(backtrace).split(File::SEPARATOR)
|
68
|
-
# res = path_parts[tmp_path_mod_index(path_parts)
|
69
|
+
# res = path_parts[tmp_path_mod_index(path_parts)..]
|
69
70
|
# res[0] = mod_name_from_tmp_dir res.first
|
70
71
|
# res[-1] = res.last.split(".").first
|
71
72
|
# res
|
data/lib/card/set/pattern/all.rb
CHANGED
@@ -4,8 +4,7 @@ class Card
|
|
4
4
|
# class from which set patterns inherit
|
5
5
|
class Base
|
6
6
|
extend ClassMethods
|
7
|
-
delegate :pattern_code, :pattern, :anchorless?, :
|
8
|
-
:assigns_type, to: :class
|
7
|
+
delegate :pattern_code, :pattern, :anchorless?, :assigns_type, to: :class
|
9
8
|
|
10
9
|
def initialize card
|
11
10
|
return if anchorless?
|
@@ -43,6 +42,10 @@ class Card
|
|
43
42
|
end
|
44
43
|
end
|
45
44
|
|
45
|
+
def anchor_parts_count
|
46
|
+
@anchor_parts_count ||= self.class.anchor_parts_count @anchor_name
|
47
|
+
end
|
48
|
+
|
46
49
|
def anchor_parts
|
47
50
|
return [@anchor_name] unless anchor_parts_count > 1
|
48
51
|
|
@@ -51,7 +54,7 @@ class Card
|
|
51
54
|
parts
|
52
55
|
else
|
53
56
|
# handles cases where anchor is a compound card, eg A+B+*self
|
54
|
-
[@anchor_name[0..-anchor_parts_count]] + parts[(-anchor_parts_count + 1)
|
57
|
+
[@anchor_name[0..-anchor_parts_count]] + parts[(-anchor_parts_count + 1)..]
|
55
58
|
end
|
56
59
|
end
|
57
60
|
|
data/lib/card/set/pattern.rb
CHANGED
data/lib/card/set/trait.rb
CHANGED
@@ -53,6 +53,7 @@ class Card
|
|
53
53
|
|
54
54
|
def assign_trait_type trait, type
|
55
55
|
return unless type && (parts = trait_module_key_parts trait)
|
56
|
+
|
56
57
|
assign_type type, normalize_const(parts)
|
57
58
|
end
|
58
59
|
|
@@ -71,7 +72,11 @@ class Card
|
|
71
72
|
end
|
72
73
|
|
73
74
|
def define_trait_card trait, opts
|
74
|
-
define_method "#{trait}_card" do
|
75
|
+
define_method "#{trait}_card" do |sub=false|
|
76
|
+
if sub && (card = subfield trait)
|
77
|
+
return card
|
78
|
+
end
|
79
|
+
|
75
80
|
# opts = opts.clone.merge supercard: card
|
76
81
|
fetch trait.to_sym, new: opts.clone, eager_cache: true
|
77
82
|
end
|
data/lib/card/subcards/all.rb
CHANGED
@@ -30,7 +30,7 @@ class Card
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def field field_name, args={}
|
33
|
-
if (sf =
|
33
|
+
if (sf = subfield field_name)
|
34
34
|
sf.assign_attributes args
|
35
35
|
sf
|
36
36
|
else
|
@@ -39,11 +39,19 @@ class Card
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def field_content field_name
|
42
|
-
|
42
|
+
subfield(field_name)&.content
|
43
43
|
end
|
44
44
|
|
45
|
-
def
|
46
|
-
|
45
|
+
def subfield field_name
|
46
|
+
subcards.field field_name
|
47
|
+
end
|
48
|
+
|
49
|
+
def subfield? field_name
|
50
|
+
subfield(field_name).present?
|
51
|
+
end
|
52
|
+
|
53
|
+
def field? field_name
|
54
|
+
fetch(field_name) || subfield?(field_name)
|
47
55
|
end
|
48
56
|
|
49
57
|
def drop_subcard name_or_card
|
@@ -74,7 +74,13 @@ class Card
|
|
74
74
|
|
75
75
|
# @return [Symbol]
|
76
76
|
def active_cache_action
|
77
|
-
|
77
|
+
if caching == :deep && cache_setting != :never
|
78
|
+
:yield
|
79
|
+
elsif active_cache_ok?
|
80
|
+
active_cache_action_from_setting
|
81
|
+
else
|
82
|
+
:stub
|
83
|
+
end
|
78
84
|
end
|
79
85
|
|
80
86
|
# @return [True/False]
|
@@ -89,7 +95,7 @@ class Card
|
|
89
95
|
return true if caching == :deep || parent.present?
|
90
96
|
# a parent voo means we're still in the same card
|
91
97
|
|
92
|
-
return unless (superformat_card = format.parent&.card)
|
98
|
+
return false unless (superformat_card = format.parent&.card)
|
93
99
|
|
94
100
|
superformat_card.name == card.name.left_name
|
95
101
|
end
|
@@ -120,7 +126,7 @@ class Card
|
|
120
126
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
121
127
|
# SHARED METHODS
|
122
128
|
|
123
|
-
# @return [Symbol] :
|
129
|
+
# @return [Symbol] :always, :deep, or :never
|
124
130
|
def cache_setting
|
125
131
|
@cache_setting ||= format.view_cache_setting requested_view
|
126
132
|
end
|
data/lib/card/view/cache.rb
CHANGED
@@ -215,15 +215,20 @@ class Card
|
|
215
215
|
# If view is cached, retrieve it. Otherwise render and store it.
|
216
216
|
# Uses the primary cache API.
|
217
217
|
def cache_fetch &block
|
218
|
-
|
218
|
+
with_caching do
|
219
219
|
ensure_cache_key
|
220
|
+
# Rails.logger.debug "Fetching::: #{cache_key}"
|
220
221
|
self.class.cache.fetch cache_key, &block
|
221
222
|
end
|
222
223
|
end
|
223
224
|
|
224
225
|
# keep track of nested cache fetching
|
225
|
-
|
226
|
-
self.class.
|
226
|
+
def with_caching &block
|
227
|
+
self.class.with_caching(cache_setting, &block)
|
228
|
+
end
|
229
|
+
|
230
|
+
def caching
|
231
|
+
self.class.caching
|
227
232
|
end
|
228
233
|
|
229
234
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
@@ -261,7 +266,7 @@ class Card
|
|
261
266
|
end
|
262
267
|
|
263
268
|
def options_for_cache_key
|
264
|
-
hash_for_cache_key(live_options)
|
269
|
+
"#{hash_for_cache_key(live_options)};#{hash_for_cache_key(viz_hash)}"
|
265
270
|
end
|
266
271
|
|
267
272
|
def hash_for_cache_key hash
|
@@ -293,24 +298,20 @@ class Card
|
|
293
298
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
294
299
|
# cache-related Card::View class methods
|
295
300
|
module ClassMethods
|
301
|
+
def caching
|
302
|
+
@caching
|
303
|
+
end
|
304
|
+
|
296
305
|
def cache
|
297
306
|
Card::Cache[Card::View]
|
298
307
|
end
|
299
308
|
|
300
309
|
def caching?
|
301
|
-
|
310
|
+
!caching.nil?
|
302
311
|
end
|
303
312
|
|
304
|
-
def
|
305
|
-
|
306
|
-
|
307
|
-
caching_mode setting, &block
|
308
|
-
end
|
309
|
-
|
310
|
-
private
|
311
|
-
|
312
|
-
def caching_mode setting
|
313
|
-
old_caching = @caching
|
313
|
+
def with_caching setting
|
314
|
+
old_caching = caching
|
314
315
|
# puts "OPEN CACHING from #{old_caching} to #{setting}" unless @caching == :deep
|
315
316
|
@caching = setting unless @caching == :deep
|
316
317
|
yield
|
@@ -318,6 +319,7 @@ class Card
|
|
318
319
|
# puts "CLOSE CACHING from #{@caching} to #{old_caching}"
|
319
320
|
@caching = old_caching
|
320
321
|
end
|
322
|
+
|
321
323
|
end
|
322
324
|
end
|
323
325
|
end
|
data/lib/card/view/classy.rb
CHANGED
@@ -120,18 +120,18 @@ class Card
|
|
120
120
|
[classes, class_list(:single_use).delete(klass)]
|
121
121
|
end
|
122
122
|
|
123
|
+
OK_TYPES = { ancestor_format: [:public],
|
124
|
+
self_format: %i[public format_private],
|
125
|
+
self: %i[public format_private private] }.freeze
|
123
126
|
def ok_types space
|
124
|
-
|
125
|
-
when :ancestor_format then [:public]
|
126
|
-
when :self_format then %i[public format_private]
|
127
|
-
when :self then %i[public format_private private]
|
128
|
-
end
|
127
|
+
OK_TYPES[space]
|
129
128
|
end
|
130
129
|
|
131
130
|
def class_list type=:private
|
132
131
|
unless type.in? %i[private format_private public single_use]
|
133
132
|
raise ArgumentError, "#{type} not a valid class list"
|
134
133
|
end
|
134
|
+
|
135
135
|
@class_list ||= {}
|
136
136
|
@class_list[type] ||= {}
|
137
137
|
end
|
@@ -165,7 +165,7 @@ class Card
|
|
165
165
|
|
166
166
|
# adds the wrappers assigned to ok_view in view definition
|
167
167
|
def process_view_wrappers
|
168
|
-
view_wrappers = format.view_setting(:wrap, ok_view)
|
168
|
+
view_wrappers = format.view_setting(:wrap, ok_view) if requested_view
|
169
169
|
return unless view_wrappers.present?
|
170
170
|
|
171
171
|
@live_options[:wrap] = Array.wrap(@live_options[:wrap])
|
@@ -197,7 +197,7 @@ class Card
|
|
197
197
|
# @param opts [Hash] options hash
|
198
198
|
# @return [Hash] options Hash
|
199
199
|
def foreign_options_in opts
|
200
|
-
foreign_opts = opts.
|
200
|
+
foreign_opts = opts.except(*Options.all_keys)
|
201
201
|
foreign_opts.empty? ? nil : foreign_opts
|
202
202
|
end
|
203
203
|
end
|
data/lib/card/view/options.rb
CHANGED
@@ -52,6 +52,7 @@ class Card
|
|
52
52
|
:structure, # overrides the content of the card
|
53
53
|
:title, # overrides the name of the card
|
54
54
|
:variant, # override the standard name with a different variant
|
55
|
+
:joint, # what joins the parts of a compound name ("+" by default)
|
55
56
|
:input_type, # inline_nests makes a form within standard content (Symbol)
|
56
57
|
:type, # set the default type of new cards
|
57
58
|
:size, # set an image size
|
data/lib/card/view.rb
CHANGED
@@ -76,7 +76,7 @@ class Card
|
|
76
76
|
# be overridden, eg for the main view (top view of the main card on a page)
|
77
77
|
# @return [Symbol] view name
|
78
78
|
def requested_view
|
79
|
-
@requested_view ||= View.normalize
|
79
|
+
@requested_view ||= View.normalize(live_options[:view] || @raw_view)
|
80
80
|
end
|
81
81
|
|
82
82
|
# the final view. can be different from @requested_view when there are
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require "rails/generators"
|
2
|
-
require File.expand_path("
|
2
|
+
require File.expand_path("../../generators/deck/deck_generator", __dir__)
|
3
3
|
require "cardio/command"
|
4
4
|
|
5
5
|
Cardio::Command.run_non_deck_command ARGV.first, "cardio/commands"
|
@@ -8,14 +8,14 @@ module Cardio
|
|
8
8
|
private
|
9
9
|
|
10
10
|
def run_new
|
11
|
-
if
|
12
|
-
ARGV.unshift "new"
|
13
|
-
require "cardio/command/application"
|
14
|
-
else
|
11
|
+
if ["-h", "--help"].intersection(args).empty?
|
15
12
|
puts "Can't initialize a new deck within the directory of another, " \
|
16
13
|
"please change to a non-deck directory first.\n"
|
17
14
|
puts "Type '#{gem}' for help."
|
18
15
|
exit 1
|
16
|
+
else
|
17
|
+
ARGV.unshift "new"
|
18
|
+
require "cardio/command/application"
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -46,9 +46,10 @@ module Cardio
|
|
46
46
|
|
47
47
|
def run_help_for_group group
|
48
48
|
puts
|
49
|
-
puts "For "
|
49
|
+
puts "For #{"#{group}s".yellow}:"
|
50
50
|
map.each do |command, conf|
|
51
51
|
next unless conf[:group] == group
|
52
|
+
|
52
53
|
puts command_help(command, conf)
|
53
54
|
end
|
54
55
|
puts
|
@@ -57,7 +58,7 @@ module Cardio
|
|
57
58
|
# formats command string for help text
|
58
59
|
def command_help command, conf
|
59
60
|
alt = conf[:alias] ? "(or #{conf[:alias]})" : ""
|
60
|
-
"
|
61
|
+
" #{command.to_s.ljust(12).light_cyan}#{alt.ljust(10)}#{conf[:desc]}"
|
61
62
|
end
|
62
63
|
end
|
63
64
|
end
|
@@ -6,6 +6,7 @@ module Cardio
|
|
6
6
|
# enhance standard rake command with some decko/card -specific options
|
7
7
|
class RakeCommand < CommandBase
|
8
8
|
def initialize gem, command, args=[]
|
9
|
+
super()
|
9
10
|
@command = command
|
10
11
|
@task = "#{gem}:#{command}"
|
11
12
|
@args = [args].flatten
|
@@ -33,8 +34,8 @@ module Cardio
|
|
33
34
|
def commands
|
34
35
|
task_cmd = "bundle exec rake #{@task}"
|
35
36
|
task_cmd += " -- #{escape_args(@args).join ' '}" unless @args.empty?
|
36
|
-
puts task_cmd
|
37
|
-
|
37
|
+
puts task_cmd.yellow
|
38
|
+
[task_cmd] if !@envs || @envs.empty?
|
38
39
|
|
39
40
|
# @envs.map do |env|
|
40
41
|
# "env RAILS_ENV=#{env} #{task_cmd}"
|
@@ -1,2 +1,2 @@
|
|
1
1
|
require "cardio/generators"
|
2
|
-
require File.expand_path("
|
2
|
+
require File.expand_path("../../generators/deck/deck_generator", __dir__)
|
data/lib/cardio/generators.rb
CHANGED
@@ -11,9 +11,9 @@ module Cardio
|
|
11
11
|
module ClassMethods
|
12
12
|
def source_root path=nil
|
13
13
|
if path
|
14
|
-
@
|
14
|
+
@source_root = path
|
15
15
|
else
|
16
|
-
@
|
16
|
+
@source_root ||= File.expand_path(
|
17
17
|
"../../generators/#{generator_name}/templates", __FILE__
|
18
18
|
)
|
19
19
|
end
|
@@ -33,7 +33,8 @@ module Cardio
|
|
33
33
|
# Override Rails namespace handling so we can put generators in `module Cardio`
|
34
34
|
def namespace name=nil
|
35
35
|
return super if name
|
36
|
-
|
36
|
+
|
37
|
+
@namespace ||= super.sub("cardio:", "")
|
37
38
|
end
|
38
39
|
end
|
39
40
|
delegate :banner_command, to: :class
|
@@ -10,6 +10,7 @@ module Cardio
|
|
10
10
|
|
11
11
|
def port
|
12
12
|
return unless lease_connection.table_exists? old_deck_table
|
13
|
+
|
13
14
|
rename_old_tables
|
14
15
|
lease_connection.execute "INSERT INTO #{table} (#{select_nonduplicate_versions})"
|
15
16
|
lease_connection.drop_table old_deck_table
|
@@ -25,6 +26,7 @@ module Cardio
|
|
25
26
|
def rename_old_tables
|
26
27
|
old_tables.each do |old_table_name|
|
27
28
|
next unless lease_connection.table_exists? old_table_name
|
29
|
+
|
28
30
|
lease_connection.rename_table old_table_name, table
|
29
31
|
end
|
30
32
|
end
|
data/lib/cardio/migration.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
3
|
module Cardio
|
4
|
+
# Base class for both schema and transform card migrations,
|
5
|
+
# which are found in <mod>/data/schema and <mod>/data/transform respectively
|
4
6
|
class Migration < ActiveRecord::Migration[6.1]
|
5
7
|
include Assumption
|
6
8
|
include Stamp
|
@@ -42,7 +42,6 @@ module Cardio
|
|
42
42
|
def ensure_installed
|
43
43
|
Card::Auth.as_bot do
|
44
44
|
Card::Cache.reset_all
|
45
|
-
puts "installing card mods".green
|
46
45
|
ensure_asset_lists do |hash|
|
47
46
|
puts "ensuring mod and asset cards"
|
48
47
|
Cardio.mods.each { |mod| ensure_asset_cards mod.ensure_card, hash }
|
@@ -108,7 +107,7 @@ module Cardio
|
|
108
107
|
|
109
108
|
# @return [True/False]
|
110
109
|
def gem_spec? spec
|
111
|
-
return unless spec
|
110
|
+
return false unless spec
|
112
111
|
|
113
112
|
spec.name.match?(/^card-mod-/) || spec.metadata["card-mod"].present?
|
114
113
|
end
|
data/lib/cardio/mod/dirs.rb
CHANGED
@@ -129,10 +129,8 @@ module Cardio
|
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
132
|
-
def each_subpath *subdirs
|
133
|
-
subpaths(*subdirs).each
|
134
|
-
yield mod_name, subpath
|
135
|
-
end
|
132
|
+
def each_subpath *subdirs, &block
|
133
|
+
subpaths(*subdirs).each(&block)
|
136
134
|
end
|
137
135
|
|
138
136
|
private
|
@@ -15,7 +15,7 @@ module Cardio
|
|
15
15
|
return yield unless @name
|
16
16
|
|
17
17
|
yield.select do |edible|
|
18
|
-
if @name.match?(
|
18
|
+
if @name.match?(/^:/)
|
19
19
|
explicit_codename_match? edible[:codename]
|
20
20
|
else
|
21
21
|
explicit_name_match? edible[:name]
|
@@ -24,7 +24,7 @@ module Cardio
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def explicit_codename_match? codename
|
27
|
-
codename && (codename == @name[1
|
27
|
+
codename && (codename == @name[1..])
|
28
28
|
end
|
29
29
|
|
30
30
|
def explicit_name_match? name
|
@@ -98,7 +98,7 @@ module Cardio
|
|
98
98
|
|
99
99
|
def mod_file mod, filename
|
100
100
|
unless (mod_file_path = mod.subpath "data/files", filename)
|
101
|
-
raise StandardError, "#{filename} not found. "\
|
101
|
+
raise StandardError, "#{filename} not found. " \
|
102
102
|
"Should be in data/files in #{mod.name} mod."
|
103
103
|
end
|
104
104
|
File.open mod_file_path
|
@@ -109,16 +109,18 @@ module Cardio
|
|
109
109
|
end
|
110
110
|
|
111
111
|
def pod_types
|
112
|
-
if
|
112
|
+
if all_pod_types?
|
113
113
|
%i[real test]
|
114
114
|
elsif @pod_type
|
115
115
|
[@pod_type]
|
116
|
-
elsif Rails.env.test?
|
117
|
-
%i[real test]
|
118
116
|
else
|
119
117
|
[:real]
|
120
118
|
end
|
121
119
|
end
|
120
|
+
|
121
|
+
def all_pod_types?
|
122
|
+
@pod_type == :all || (Rails.env.test? && !@pod_type)
|
123
|
+
end
|
122
124
|
end
|
123
125
|
end
|
124
126
|
end
|