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.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/config/environments/development.rb +1 -1
  4. data/config/environments/production.rb +5 -2
  5. data/config/initializers/01_core_extensions/array.rb +1 -0
  6. data/config/initializers/01_core_extensions/hash.rb +4 -0
  7. data/config/initializers/02_patches/active_record.rb +1 -1
  8. data/config/initializers/core_extensions.rb +0 -1
  9. data/config/initializers/deck_config.rb +3 -3
  10. data/config/initializers/patches.rb +6 -6
  11. data/config/locales/es.yml +2 -3
  12. data/db/seeds.rb +0 -1
  13. data/lib/card/auth/current.rb +8 -6
  14. data/lib/card/auth/permissions.rb +1 -1
  15. data/lib/card/auth/proxy.rb +2 -2
  16. data/lib/card/auth/setup.rb +2 -2
  17. data/lib/card/auth.rb +7 -6
  18. data/lib/card/cache/all.rb +1 -1
  19. data/lib/card/cache/class_methods.rb +2 -4
  20. data/lib/card/cache/shared.rb +1 -1
  21. data/lib/card/cache/temporary.rb +2 -2
  22. data/lib/card/codename.rb +1 -1
  23. data/lib/card/content/chunk/abstract.rb +1 -0
  24. data/lib/card/content/chunk.rb +0 -1
  25. data/lib/card/content/clean.rb +4 -2
  26. data/lib/card/content/diff/l_c_s.rb +1 -2
  27. data/lib/card/content/diff/result.rb +2 -1
  28. data/lib/card/content/diff.rb +2 -1
  29. data/lib/card/content/parser.rb +8 -7
  30. data/lib/card/content.rb +1 -1
  31. data/lib/card/director/subdirector_array.rb +1 -0
  32. data/lib/card/director.rb +1 -1
  33. data/lib/card/dirty/method_factory.rb +1 -0
  34. data/lib/card/env/location.rb +3 -3
  35. data/lib/card/env/location_history.rb +20 -20
  36. data/lib/card/env/success/target.rb +4 -4
  37. data/lib/card/env/support.rb +25 -2
  38. data/lib/card/error.rb +1 -0
  39. data/lib/card/fetch/store.rb +1 -1
  40. data/lib/card/format/error.rb +13 -2
  41. data/lib/card/format/method_delegation.rb +6 -4
  42. data/lib/card/format/registration.rb +5 -3
  43. data/lib/card/format/render.rb +51 -47
  44. data/lib/card/format/wrapper.rb +1 -0
  45. data/lib/card/lexicon.rb +5 -2
  46. data/lib/card/mailer.rb +1 -14
  47. data/lib/card/name/all/parts.rb +1 -1
  48. data/lib/card/name/all.rb +5 -0
  49. data/lib/card/name/name_variants.rb +1 -0
  50. data/lib/card/query/abstract_query/query_helper.rb +1 -2
  51. data/lib/card/query/abstract_query/tie.rb +1 -1
  52. data/lib/card/query/abstract_query.rb +3 -3
  53. data/lib/card/query/card_class.rb +1 -0
  54. data/lib/card/query/card_query/relational_attributes.rb +1 -1
  55. data/lib/card/query/card_query/run.rb +5 -1
  56. data/lib/card/query/clause.rb +1 -0
  57. data/lib/card/query/join.rb +3 -3
  58. data/lib/card/query/sql_statement.rb +7 -1
  59. data/lib/card/query.rb +1 -1
  60. data/lib/card/reference/all.rb +6 -7
  61. data/lib/card/rule/cache.rb +1 -0
  62. data/lib/card/rule/preference_cache.rb +2 -0
  63. data/lib/card/rule/read_rule_cache.rb +3 -0
  64. data/lib/card/set/event/all.rb +6 -4
  65. data/lib/card/set/event/callbacks.rb +1 -0
  66. data/lib/card/set/event/options.rb +3 -2
  67. data/lib/card/set/event/skip_and_trigger.rb +1 -1
  68. data/lib/card/set/event.rb +2 -2
  69. data/lib/card/set/format/abstract_format/view_definition.rb +1 -1
  70. data/lib/card/set/format/haml_paths.rb +1 -1
  71. data/lib/card/set/format.rb +4 -4
  72. data/lib/card/set/helpers.rb +4 -4
  73. data/lib/card/set/i18n_scanner.rb +23 -22
  74. data/lib/card/set/i18n_scope.rb +4 -3
  75. data/lib/card/set/pattern/all.rb +1 -1
  76. data/lib/card/set/pattern/base.rb +6 -3
  77. data/lib/card/set/pattern/class_methods.rb +1 -1
  78. data/lib/card/set/pattern.rb +1 -1
  79. data/lib/card/set/required_field.rb +3 -0
  80. data/lib/card/set/trait.rb +6 -1
  81. data/lib/card/subcards/all.rb +12 -4
  82. data/lib/card/view/cache/cache_action.rb +9 -3
  83. data/lib/card/view/cache.rb +17 -15
  84. data/lib/card/view/classy.rb +5 -5
  85. data/lib/card/view/options/key_lists.rb +1 -0
  86. data/lib/card/view/options/voo_api.rb +2 -2
  87. data/lib/card/view/options.rb +1 -0
  88. data/lib/card/view.rb +1 -1
  89. data/lib/cardio/command/application.rb +1 -1
  90. data/lib/cardio/command/custom.rb +7 -6
  91. data/lib/cardio/command/rake_command.rb +3 -2
  92. data/lib/cardio/command/rspec_command.rb +1 -0
  93. data/lib/cardio/generators/deck_generator_loader.rb +1 -1
  94. data/lib/cardio/generators.rb +4 -3
  95. data/lib/cardio/migration/port.rb +2 -0
  96. data/lib/cardio/migration/stamp.rb +1 -0
  97. data/lib/cardio/migration/transform.rb +1 -0
  98. data/lib/cardio/migration.rb +2 -0
  99. data/lib/cardio/mod/class_methods.rb +1 -2
  100. data/lib/cardio/mod/dirs.rb +2 -4
  101. data/lib/cardio/mod/eat/edibles.rb +8 -6
  102. data/lib/cardio/mod/eat.rb +7 -9
  103. data/lib/cardio/mod/load_strategy/set_binding_magic.rb +1 -1
  104. data/lib/cardio/mod/load_strategy/tmp_files.rb +3 -2
  105. data/lib/cardio/mod/load_strategy.rb +1 -0
  106. data/lib/cardio/mod/loader/set_pattern_loader.rb +4 -0
  107. data/lib/cardio/mod/loader/set_template.rb +14 -4
  108. data/lib/cardio/mod/loader.rb +2 -2
  109. data/lib/cardio/mod/sow/card_source.rb +1 -1
  110. data/lib/cardio/mod/sow/remote_source.rb +32 -0
  111. data/lib/cardio/mod/sow.rb +10 -10
  112. data/lib/cardio/railtie.rb +1 -0
  113. data/lib/cardio/script_loader.rb +1 -1
  114. data/lib/cardio/seed.rb +2 -2
  115. data/lib/cardio/utils.rb +1 -1
  116. data/lib/cardio/version.rb +2 -1
  117. data/lib/cardio.rb +3 -0
  118. data/lib/generators/deck/templates/config.ru.erb +1 -1
  119. data/mod/core/config/locales/de.yml +1 -1
  120. data/mod/core/config/locales/en.yml +2 -1
  121. data/mod/core/data/fixtures/real/cards.yml +1 -1
  122. data/mod/core/data/real.yml +1 -1
  123. data/mod/core/data/recode.yml +1 -0
  124. data/mod/core/data/schema/20141001105348_move_revisions_to_actions.rb +2 -2
  125. data/mod/core/data/schema/20241017160402_unique_codename.rb +8 -0
  126. data/mod/core/data/transform/20150724123438_update_file_and_image_cards.rb +1 -1
  127. data/mod/core/lib/tasks/card/export.rake +28 -0
  128. data/mod/core/lib/tasks/card/migrate.rake +3 -3
  129. data/mod/core/lib/tasks/card/mod.rake +1 -1
  130. data/mod/core/lib/tasks/card/seed.rake +2 -1
  131. data/mod/core/lib/tasks/card.rake +48 -16
  132. data/mod/core/set/all/admin.rb +1 -2
  133. data/mod/core/set/all/assign_attributes.rb +3 -2
  134. data/mod/core/set/all/codename.rb +7 -1
  135. data/mod/core/set/all/debug.rb +3 -3
  136. data/mod/core/set/all/initialize.rb +1 -0
  137. data/mod/core/set/all/states.rb +13 -16
  138. data/mod/core/set/all/type.rb +3 -1
  139. data/mod/core/set/all/utils.rb +0 -1
  140. data/mod/core/set/self/admin.rb +2 -1
  141. data/mod/core/set/self/autoname.rb +1 -1
  142. data/mod/core/set/self/mod.rb +4 -4
  143. data/mod/core/set/self/trash.rb +1 -1
  144. data/mod/core/set/type/mod.rb +18 -15
  145. data/mod/core/set_pattern/09_self.rb +4 -0
  146. data/mod/core/spec/set/all/admin_spec.rb +1 -1
  147. data/mod/core/spec/set/all/trash_spec.rb +9 -9
  148. metadata +42 -29
@@ -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(pattern_code)
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 Lint/Eval
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 Lint/Eval
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 pattern_code
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
- 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
- text.scan(/[^\w._-]tr[( ]\s*["':](\w+)/).map do |_match|
14
- occurrence = occurrence_from_position(
15
- path, text, Regexp.last_match.offset(0).first
16
- )
17
- [absolute_key(".#{_match[0]}", path), occurrence]
18
- end
19
- end
20
- end
21
- ::I18n::Tasks.add_scanner "Card::Set::I18nScanner"
22
- end
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
@@ -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..-1].join "."
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)..-1]
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)..-1]
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
@@ -25,7 +25,7 @@ class Card
25
25
 
26
26
  # new cards do not
27
27
  def patterns
28
- @patterns ||= (new_card? ? concrete_patterns[1..-1] : concrete_patterns)
28
+ @patterns ||= (new_card? ? concrete_patterns[1..] : concrete_patterns)
29
29
  end
30
30
 
31
31
  def reset_patterns
@@ -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?, :anchor_parts_count,
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)..-1]
57
+ [@anchor_name[0..-anchor_parts_count]] + parts[(-anchor_parts_count + 1)..]
55
58
  end
56
59
  end
57
60
 
@@ -38,7 +38,7 @@ class Card
38
38
  compound_only? ? card.name.compound? : true
39
39
  end
40
40
 
41
- def anchor_parts_count
41
+ def anchor_parts_count _anchor_name=nil
42
42
  @anchor_parts_count ||= (anchorless? ? 0 : 1)
43
43
  end
44
44
 
@@ -39,7 +39,7 @@ class Card
39
39
  # list of codenames of pattern cards
40
40
  # @return [Array <Symbol>]
41
41
  def codes
42
- @codes ||= concrete.map(&:pattern_code).to_set
42
+ @codes ||= concrete.to_set(&:pattern_code)
43
43
  end
44
44
 
45
45
  # list of lists of codenames in pattern load order
@@ -1,5 +1,8 @@
1
1
  class Card
2
2
  module Set
3
+ # supports requiring field cards
4
+ # for example, if A requires a B field, then you cannot create A without also
5
+ # creating A+B
3
6
  class RequiredField
4
7
  attr_reader :parent_set, :field, :options
5
8
 
@@ -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
@@ -30,7 +30,7 @@ class Card
30
30
  end
31
31
 
32
32
  def field field_name, args={}
33
- if (sf = subcards.field field_name)
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
- subcards.field(field_name)&.content
42
+ subfield(field_name)&.content
43
43
  end
44
44
 
45
- def field? tag
46
- fetch(tag) || subcards.field(tag).present?
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
- active_cache_ok? ? active_cache_action_from_setting : :stub
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] :standard, :always, or :never
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
@@ -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
- caching do
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
- def caching &block
226
- self.class.caching(cache_setting, &block)
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) + ";" + hash_for_cache_key(viz_hash)
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
- !@caching.nil?
310
+ !caching.nil?
302
311
  end
303
312
 
304
- def caching setting, &block
305
- return @caching unless block_given?
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
@@ -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
- case space
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
@@ -1,6 +1,7 @@
1
1
  class Card
2
2
  class View
3
3
  module Options
4
+ # lists of view option keys
4
5
  module KeyLists
5
6
  # all standard option keys
6
7
  # @return [Array]
@@ -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.reject { |k, _v| Options.all_keys.include? k }
200
+ foreign_opts = opts.except(*Options.all_keys)
201
201
  foreign_opts.empty? ? nil : foreign_opts
202
202
  end
203
203
  end
@@ -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 live_options[:view]
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("../../../generators/deck/deck_generator", __FILE__)
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 !["-h", "--help"].intersection(args).empty?
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 " + "#{group}s".yellow + ":"
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
- " " + command.to_s.ljust(12).light_cyan + alt.ljust(10) + conf[:desc]
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
- return [task_cmd] if !@envs || @envs.empty?
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}"
@@ -8,6 +8,7 @@ module Cardio
8
8
  def initialize args
9
9
  require "rspec/core"
10
10
 
11
+ super()
11
12
  cardio_args, @rspec_args = split_args args
12
13
  @opts = {}
13
14
  Parser.new(@opts).parse!(cardio_args)
@@ -1,2 +1,2 @@
1
1
  require "cardio/generators"
2
- require File.expand_path("../../../generators/deck/deck_generator", __FILE__)
2
+ require File.expand_path("../../generators/deck/deck_generator", __dir__)
@@ -11,9 +11,9 @@ module Cardio
11
11
  module ClassMethods
12
12
  def source_root path=nil
13
13
  if path
14
- @_card_source_root = path
14
+ @source_root = path
15
15
  else
16
- @_card_source_root ||= File.expand_path(
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
- @namespace ||= super.sub(/cardio:/, "")
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
@@ -5,6 +5,7 @@ module Cardio
5
5
  def stamp
6
6
  mode do
7
7
  return unless (version = stampable_version) && (file = stamp_file)
8
+
8
9
  puts ">> writing version: #{version} to #{file.path}"
9
10
  file.puts version
10
11
  end
@@ -32,6 +32,7 @@ module Cardio
32
32
 
33
33
  def contentedly
34
34
  return yield if ENV["NO_CARD_LOAD"]
35
+
35
36
  Card::Cache.reset_all
36
37
  Card::Auth.as_bot do
37
38
  yield
@@ -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
@@ -129,10 +129,8 @@ module Cardio
129
129
  end
130
130
  end
131
131
 
132
- def each_subpath *subdirs
133
- subpaths(*subdirs).each do |mod_name, subpath|
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..-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 @pod_type == :all
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