card 1.107.0 → 1.108.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/config/environments/development.rb +1 -9
  4. data/config/environments/test.rb +2 -2
  5. data/config/initializers/01_core_extensions/integer.rb +13 -0
  6. data/config/initializers/01_core_extensions/{persistent_identifiers.rb → persistent_identifier.rb} +0 -5
  7. data/config/initializers/01_core_extensions/symbol.rb +11 -0
  8. data/config/initializers/core_extensions.rb +2 -2
  9. data/db/schema.rb +8 -4
  10. data/lib/card/auth/token.rb +1 -1
  11. data/lib/card/cache/all.rb +30 -7
  12. data/lib/card/cache/card_class.rb +12 -6
  13. data/lib/card/cache/class_methods.rb +122 -0
  14. data/lib/card/cache/populate.rb +64 -0
  15. data/lib/card/cache/{persistent.rb → shared.rb} +22 -16
  16. data/lib/card/cache/{persistent_class.rb → shared_class.rb} +2 -2
  17. data/lib/card/cache/temporary.rb +40 -8
  18. data/lib/card/cache.rb +65 -130
  19. data/lib/card/codename.rb +66 -54
  20. data/lib/card/director/class_methods.rb +13 -13
  21. data/lib/card/director/stages.rb +1 -1
  22. data/lib/card/error.rb +8 -0
  23. data/lib/card/fetch/card_class.rb +5 -24
  24. data/lib/card/fetch/retrieve.rb +1 -1
  25. data/lib/card/fetch/store.rb +4 -18
  26. data/lib/card/format/nesting.rb +1 -1
  27. data/lib/card/format/registration.rb +15 -7
  28. data/lib/card/format/render.rb +16 -15
  29. data/lib/card/format.rb +11 -4
  30. data/lib/card/lexicon.rb +37 -23
  31. data/lib/card/mark.rb +2 -34
  32. data/lib/card/name/all.rb +3 -7
  33. data/lib/card/name/card_class.rb +2 -2
  34. data/lib/card/name/name_variants.rb +7 -1
  35. data/lib/card/name.rb +60 -12
  36. data/lib/card/query/card_class.rb +1 -1
  37. data/lib/card/query/card_query/match_attributes.rb +14 -4
  38. data/lib/card/query/card_query/relational_attributes.rb +2 -0
  39. data/lib/card/query/card_query/run.rb +9 -3
  40. data/lib/card/query/sql_statement.rb +1 -1
  41. data/lib/card/reference/all.rb +8 -3
  42. data/lib/card/reference.rb +4 -9
  43. data/lib/card/rule/cache.rb +2 -0
  44. data/lib/card/rule/read_rule_cache.rb +2 -0
  45. data/lib/card/set/event.rb +1 -4
  46. data/lib/card/set/format/abstract_format/view_opts.rb +1 -1
  47. data/lib/card/set/format/abstract_format.rb +20 -3
  48. data/lib/card/set/inheritance.rb +2 -3
  49. data/lib/card/set/pattern/all.rb +12 -0
  50. data/lib/card/subcards/add.rb +1 -1
  51. data/lib/card/subcards/remove.rb +1 -1
  52. data/lib/card/view/cache/cache_action.rb +24 -7
  53. data/lib/card/view/cache.rb +34 -6
  54. data/lib/card/view/options/voo_api.rb +1 -1
  55. data/lib/card/view.rb +1 -0
  56. data/lib/cardio/cli.rb +1 -1
  57. data/lib/cardio/command/rake_command.rb +10 -2
  58. data/lib/cardio/command/rspec_command/parser.rb +9 -11
  59. data/lib/cardio/command/rspec_command.rb +7 -3
  60. data/lib/cardio/generators/deck_helper.rb +7 -7
  61. data/lib/cardio/migration/port.rb +37 -0
  62. data/lib/cardio/migration.rb +5 -36
  63. data/lib/cardio/mod/class_methods.rb +1 -0
  64. data/lib/cardio/mod.rb +1 -1
  65. data/lib/cardio/railtie.rb +5 -4
  66. data/lib/cardio/utils.rb +1 -1
  67. data/lib/generators/deck/deck_generator.rb +5 -11
  68. data/lib/generators/deck/templates/Gemfile.erb +2 -2
  69. data/lib/generators/deck/templates/config/puma.rb +0 -6
  70. data/lib/generators/mod/mod_generator.rb +7 -0
  71. data/lib/generators/set/set_generator.rb +2 -1
  72. data/mod/core/config/locales/en.yml +1 -0
  73. data/mod/core/data/schema/20200805200729_add_unique_pair_indices.rb +1 -1
  74. data/mod/core/data/schema/20240628212556_add_trash_index.rb +11 -0
  75. data/mod/core/data/schema/20241017160402_unique_codename.rb +13 -0
  76. data/mod/core/data/transform/20140317035504_account_requests_to_signups.rb +4 -6
  77. data/mod/core/data/transform/20150724123438_update_file_and_image_cards.rb +1 -1
  78. data/mod/core/data/transform/20190320091257_upgrade_recaptcha_to_v3.rb +3 -3
  79. data/mod/core/data/transform/20190502130029_add_shark_and_help_desk_role.rb +1 -1
  80. data/mod/core/data/transform/20190822093633_move_help_text_to_code.rb +2 -2
  81. data/mod/core/data/transform/20190829205148_remove_add_help.rb +1 -1
  82. data/mod/core/lib/tasks/card/migrate.rake +6 -5
  83. data/mod/core/lib/tasks/card/mod.rake +3 -0
  84. data/mod/core/lib/tasks/card.rake +6 -2
  85. data/mod/core/set/all/autoname.rb +1 -1
  86. data/mod/core/set/all/codename.rb +6 -8
  87. data/mod/core/set/all/name_events.rb +7 -5
  88. data/mod/core/set/all/result.rb +1 -1
  89. data/mod/core/set/all/trash.rb +2 -4
  90. data/mod/core/set/all/type.rb +1 -1
  91. data/mod/core/set/self/mod.rb +1 -1
  92. data/mod/core/set/self/trash.rb +1 -1
  93. data/mod/core/spec/set/all/trash_spec.rb +3 -3
  94. metadata +30 -24
  95. data/lib/card/cache/prepopulate.rb +0 -48
@@ -55,7 +55,7 @@ class Card
55
55
  card.supercard = @context_card
56
56
  card.update_superleft card.name
57
57
  @keys << card.key
58
- Card.write_to_soft_cache card
58
+ Card.write_to_temp_cache card
59
59
  card.director = @context_card.director.subdirectors.add card
60
60
  card
61
61
  end
@@ -26,7 +26,7 @@ class Card
26
26
  Director.deep_delete subcard.director
27
27
  subcard.current_action&.delete
28
28
  end
29
- Card.cache.soft.delete key
29
+ Card.cache.temp.delete key
30
30
  subcard
31
31
  end
32
32
 
@@ -3,6 +3,13 @@ class Card
3
3
  module Cache
4
4
  # determine action to be used in #fetch
5
5
  module CacheAction
6
+ ACTIVE_CACHE_LEVEL =
7
+ { always: :cache_yield,
8
+ deep: :cache_yield,
9
+ default: :yield,
10
+ yes: :yield,
11
+ never: :stub }.freeze
12
+
6
13
  private
7
14
 
8
15
  # course of action based on config/status/options
@@ -58,7 +65,7 @@ class Card
58
65
 
59
66
  # @return [True/False]
60
67
  def free_cache_ok?
61
- cache_setting != :never && clean_enough_to_cache?
68
+ !cache_setting.in?(%i[default never]) && clean_enough_to_cache?
62
69
  end
63
70
 
64
71
  # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -72,23 +79,36 @@ class Card
72
79
 
73
80
  # @return [True/False]
74
81
  def active_cache_ok?
75
- return false unless parent && clean_enough_to_cache?
82
+ return false unless cacheable_card? && clean_enough_to_cache?
76
83
  return true if normalized_options[:skip_perms]
77
84
 
78
85
  active_cache_permissible?
79
86
  end
80
87
 
88
+ def cacheable_card?
89
+ return true if caching == :deep || parent.present?
90
+ # a parent voo means we're still in the same card
91
+
92
+ return unless (superformat_card = format.parent&.card)
93
+
94
+ superformat_card.name == card.name.left_name
95
+ end
96
+
81
97
  # apply any permission checks required by view.
82
98
  # (do not cache views with nuanced permissions)
83
99
  def active_cache_permissible?
84
100
  case view_perms
85
101
  when :none then true
86
- when parent.view_perms then true
102
+ when view_perm_context then true
87
103
  when *Permission::CRUD then format.anyone_can?(view_perms)
88
104
  else false
89
105
  end
90
106
  end
91
107
 
108
+ def view_perm_context
109
+ parent&.view_perms || format.parent&.voo&.view_perms
110
+ end
111
+
92
112
  # determine the cache action from the cache setting
93
113
  # (assuming cache status is "active")
94
114
  # @return [Symbol] cache action
@@ -97,15 +117,12 @@ class Card
97
117
  level || raise("unknown cache setting: #{cache_setting}")
98
118
  end
99
119
 
100
- ACTIVE_CACHE_LEVEL =
101
- { always: :cache_yield, standard: :yield, never: :stub }.freeze
102
-
103
120
  # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
104
121
  # SHARED METHODS
105
122
 
106
123
  # @return [Symbol] :standard, :always, or :never
107
124
  def cache_setting
108
- format.view_cache_setting requested_view
125
+ @cache_setting ||= format.view_cache_setting requested_view
109
126
  end
110
127
 
111
128
  # altered view requests and altered cards are not cacheable
@@ -166,6 +166,8 @@ class Card
166
166
  # cached and retrieved even when it's rendered inside another cached view.
167
167
  #
168
168
  module Cache
169
+ EXPIRE_VALUES = %i[minute hour day week month].freeze
170
+
169
171
  require "card/view/cache/cache_action"
170
172
  require "card/view/cache/stub"
171
173
 
@@ -221,7 +223,7 @@ class Card
221
223
 
222
224
  # keep track of nested cache fetching
223
225
  def caching &block
224
- self.class.caching(self, &block)
226
+ self.class.caching(cache_setting, &block)
225
227
  end
226
228
 
227
229
  # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -229,8 +231,24 @@ class Card
229
231
 
230
232
  def cache_key
231
233
  @cache_key ||= [
232
- card_cache_key, format.class, format.nest_mode, options_for_cache_key
233
- ].map(&:to_s).join "-"
234
+ format.symbol, nest_mode, timestamp, card_cache_key, options_for_cache_key
235
+ ].compact.map(&:to_s).join "-"
236
+ end
237
+
238
+ def nest_mode
239
+ mode = format.nest_mode
240
+ mode == :normal ? nil : mode
241
+ end
242
+
243
+ def timestamp
244
+ return unless (expire = format.view_setting :expire, requested_view)
245
+ raise "invalid expire setting: #{expire}" unless EXPIRE_VALUES.include? expire
246
+
247
+ Time.now.send("end_of_#{expire}").to_i
248
+ end
249
+
250
+ def cache_setting
251
+ @cache_setting ||= format.view_cache_setting requested_view
234
252
  end
235
253
 
236
254
  def card_cache_key
@@ -243,7 +261,7 @@ class Card
243
261
  end
244
262
 
245
263
  def options_for_cache_key
246
- hash_for_cache_key(live_options) + hash_for_cache_key(viz_hash)
264
+ hash_for_cache_key(live_options) + ";" + hash_for_cache_key(viz_hash)
247
265
  end
248
266
 
249
267
  def hash_for_cache_key hash
@@ -283,11 +301,21 @@ class Card
283
301
  !@caching.nil?
284
302
  end
285
303
 
286
- def caching voo
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
287
313
  old_caching = @caching
288
- @caching = voo
314
+ # puts "OPEN CACHING from #{old_caching} to #{setting}" unless @caching == :deep
315
+ @caching = setting unless @caching == :deep
289
316
  yield
290
317
  ensure
318
+ # puts "CLOSE CACHING from #{@caching} to #{old_caching}"
291
319
  @caching = old_caching
292
320
  end
293
321
  end
@@ -103,7 +103,7 @@ class Card
103
103
  # symbols as keys, managing standard view inheritance, and special
104
104
  # handling for main_views.
105
105
  def normalize_options
106
- @normalized_options = opts = options_to_hash @raw_options.clone
106
+ @normalized_options = opts = options_to_hash(@raw_options.clone)
107
107
  normalize_special_options! opts
108
108
  @optional = opts.delete(:optional) || false
109
109
  add_implicit_options!
data/lib/card/view.rb CHANGED
@@ -68,6 +68,7 @@ class Card
68
68
  def process
69
69
  return if process_live_options == :hide
70
70
 
71
+ # Rails.logger.debug "processing #{card.name} / #{ok_view}"
71
72
  fetch { yield ok_view }
72
73
  end
73
74
 
data/lib/cardio/cli.rb CHANGED
@@ -8,7 +8,7 @@ Cardio::ScriptLoader.script_name = "card"
8
8
  # the rest of this script is not run.
9
9
  Cardio::ScriptLoader.exec!
10
10
 
11
- require "rails/ruby_version_check"
11
+ # require "rails/ruby_version_check"
12
12
  Signal.trap("INT") { exit(1) }
13
13
 
14
14
  require "cardio/command/application"
@@ -1,10 +1,11 @@
1
1
  require File.expand_path("command_base", __dir__)
2
+ require "shellwords"
2
3
 
3
4
  module Cardio
4
5
  class Command
5
6
  # enhance standard rake command with some decko/card -specific options
6
7
  class RakeCommand < CommandBase
7
- def initialize gem, command, args={}
8
+ def initialize gem, command, args=[]
8
9
  @command = command
9
10
  @task = "#{gem}:#{command}"
10
11
  @args = [args].flatten
@@ -31,13 +32,20 @@ module Cardio
31
32
 
32
33
  def commands
33
34
  task_cmd = "bundle exec rake #{@task}"
34
- task_cmd += " -- #{@args.join ' '}" unless @args.empty?
35
+ task_cmd += " -- #{escape_args(@args).join ' '}" unless @args.empty?
36
+ puts task_cmd
35
37
  return [task_cmd] if !@envs || @envs.empty?
36
38
 
37
39
  # @envs.map do |env|
38
40
  # "env RAILS_ENV=#{env} #{task_cmd}"
39
41
  # end
40
42
  end
43
+
44
+ def escape_args args
45
+ args.map do |arg|
46
+ arg.start_with?("-") ? arg : arg.shellescape
47
+ end
48
+ end
41
49
  end
42
50
  end
43
51
  end
@@ -1,6 +1,8 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
3
  require "optparse"
4
+ require "cardio/mod"
5
+ require "pry"
4
6
 
5
7
  module Cardio
6
8
  class Command
@@ -11,11 +13,6 @@ module Cardio
11
13
 
12
14
  #{Command.bin_name.upcase} ARGS
13
15
 
14
- You don't have to give a full path for FILENAME; the basename is enough.
15
- If FILENAME does not include '_spec', then rspec searches for the
16
- corresponding spec file. The line number always refers to the example in the
17
- spec file.
18
-
19
16
  MESSAGE
20
17
 
21
18
  RSPEC_BANNER = <<~BANNER.freeze
@@ -24,7 +21,8 @@ module Cardio
24
21
 
25
22
  RSPEC ARGS
26
23
 
27
- See https://rspec.info/features/3-12/rspec-core/command-line/ or run card rspec -- -hbe
24
+ See https://rspec.info/features/3-12/rspec-core/command-line/ or
25
+ run card rspec -- -hb
28
26
  BANNER
29
27
 
30
28
  DESC = {
@@ -36,7 +34,7 @@ module Cardio
36
34
  parser.banner = RSPEC_BANNER
37
35
  parser.separator RSPEC_PATH_MESSAGE
38
36
 
39
- file_options parser, opts
37
+ # file_options parser, opts
40
38
  other_options parser, opts
41
39
  parser.separator "\n"
42
40
  end
@@ -51,13 +49,13 @@ module Cardio
51
49
  end
52
50
 
53
51
  def other_options parser, opts
54
- parser.on("-s", "--[no-]simplecov", "Run with simplecov") do |s|
52
+ parser.on("-s", "--simplecov", "Run with simplecov") do |s|
55
53
  opts[:simplecov] = s
56
54
  end
57
- parser.on("--rescue", "Run with pry-rescue") do
55
+ parser.on("--pry-rescue", "Run with pry-rescue") do
58
56
  process_rescue_opts opts
59
57
  end
60
- parser.on("--[no-]spring", "Run with spring") do |spring|
58
+ parser.on("--spring", "Run with spring") do |spring|
61
59
  process_spring_opts spring, opts
62
60
  end
63
61
  end
@@ -90,7 +88,7 @@ module Cardio
90
88
  elsif (files = find_spec_file(filename, "mod"))&.present?
91
89
  files
92
90
  else
93
- find_spec_file(file, "#{base_dir}/mod")
91
+ find_spec_file(filename, "#{base_dir}/mod")
94
92
  end
95
93
  end
96
94
 
@@ -1,4 +1,5 @@
1
1
  require File.expand_path("command_base", __dir__)
2
+ require "cardio"
2
3
 
3
4
  module Cardio
4
5
  class Command
@@ -25,9 +26,12 @@ module Cardio
25
26
  end
26
27
 
27
28
  def coverage
28
- "CARD_LOAD_STRATEGY=tmp_files" if @opts[:simplecov]
29
- # # no coverage if rspec was started with file argument
30
- # "CARD_SIMPLECOV=false" if @opts[:files] || @opts[:"no-simplecov"]
29
+ if @opts[:simplecov]
30
+ "CARD_LOAD_STRATEGY=tmp_files"
31
+ elsif @opts[:files]
32
+ # explicitly no coverage if rs pec was started with file argument
33
+ "CARD_SIMPLECOV=false"
34
+ end
31
35
  end
32
36
  end
33
37
  end
@@ -59,13 +59,13 @@ module Cardio
59
59
  platypus? ? File.expand_path("#{repo_path}/decko/features/") : "mod/"
60
60
  end
61
61
 
62
- def database_gem_and_version
63
- entry = database_gemfile_entry
64
- text = %("#{entry.name}")
65
- text << %(, '#{entry.version}') if entry.version
66
- # single quotes to prevent, eg: `gem "pg", ">= 0.18', '< 2.0"`
67
- text
68
- end
62
+ # def database_gem_and_version
63
+ # entry = database_gemfile_entry
64
+ # text = %("#{entry.name}")
65
+ # text << %(, '#{[entry.version].flatten.join "', '"}') if entry.version
66
+ # # single quotes to prevent, eg: `gem "pg", ">= 0.18', '< 2.0"`
67
+ # text
68
+ # end
69
69
 
70
70
  def jasmine_yml prefix
71
71
  inside("javascripts/support") do
@@ -0,0 +1,37 @@
1
+ module Cardio
2
+ class Migration
3
+ # methods for porting migrations from old table to new table
4
+ module Port
5
+ def port_all
6
+ %i[schema transform].each do |type|
7
+ migration_class(type).port
8
+ end
9
+ end
10
+
11
+ def port
12
+ return unless lease_connection.table_exists? old_deck_table
13
+ rename_old_tables
14
+ lease_connection.execute "INSERT INTO #{table} (#{select_nonduplicate_versions})"
15
+ lease_connection.drop_table old_deck_table
16
+ end
17
+
18
+ private
19
+
20
+ def select_nonduplicate_versions
21
+ "SELECT * FROM #{old_deck_table} o WHERE NOT EXISTS " \
22
+ "(SELECT * FROM #{table} n WHERE o.version = n.version)"
23
+ end
24
+
25
+ def rename_old_tables
26
+ old_tables.each do |old_table_name|
27
+ next unless lease_connection.table_exists? old_table_name
28
+ lease_connection.rename_table old_table_name, table
29
+ end
30
+ end
31
+
32
+ def lease_connection
33
+ ActiveRecord::Base.lease_connection
34
+ end
35
+ end
36
+ end
37
+ end
@@ -4,6 +4,7 @@ module Cardio
4
4
  class Migration < ActiveRecord::Migration[6.1]
5
5
  include Assumption
6
6
  include Stamp
7
+ extend Port
7
8
 
8
9
  class << self
9
10
  attr_reader :migration_type, :old_tables, :old_deck_table
@@ -16,40 +17,11 @@ module Cardio
16
17
  migration_class(type).new
17
18
  end
18
19
 
19
- def port_all
20
- %i[schema transform].each do |type|
21
- migration_class(type).port
22
- end
23
- end
24
-
25
- def port
26
- return unless connection.table_exists? old_deck_table
27
- rename_old_tables
28
- connection.execute "INSERT INTO #{table} (#{select_nonduplicate_versions})"
29
- connection.drop_table old_deck_table
30
- end
31
-
32
20
  private
33
21
 
34
- def select_nonduplicate_versions
35
- "SELECT * FROM #{old_deck_table} o WHERE NOT EXISTS " \
36
- "(SELECT * FROM #{table} n WHERE o.version = n.version)"
37
- end
38
-
39
- def rename_old_tables
40
- old_tables.each do |old_table_name|
41
- next unless connection.table_exists? old_table_name
42
- connection.rename_table old_table_name, table
43
- end
44
- end
45
-
46
22
  def table
47
23
  "#{migration_type}_migrations"
48
24
  end
49
-
50
- def connection
51
- ActiveRecord::Base.connection
52
- end
53
25
  end
54
26
 
55
27
  def migration_type
@@ -74,7 +46,8 @@ module Cardio
74
46
 
75
47
  def context
76
48
  mode do |paths|
77
- yield ActiveRecord::MigrationContext.new(paths, ActiveRecord::SchemaMigration)
49
+ migrations = ActiveRecord::SchemaMigration.new ActiveRecord::Base.connection_pool
50
+ yield ActiveRecord::MigrationContext.new(paths, migrations)
78
51
  end
79
52
  end
80
53
 
@@ -88,18 +61,14 @@ module Cardio
88
61
 
89
62
  private
90
63
 
91
- def connection
92
- Cardio::Migration.connection
93
- end
94
-
95
64
  def with_migration_table
96
65
  yield
97
66
  end
98
67
 
99
68
  def table_name= table_name
100
69
  ActiveRecord::Base.schema_migrations_table_name = table_name
101
- ActiveRecord::SchemaMigration.table_name = table_name
102
- ActiveRecord::SchemaMigration.reset_column_information
70
+ # ActiveRecord::SchemaMigration.table_name = table_name
71
+ # ActiveRecord::SchemaMigration.reset_column_information
103
72
  end
104
73
  end
105
74
  end
@@ -78,6 +78,7 @@ module Cardio
78
78
  yield hash
79
79
  # puts "updating asset lists"
80
80
  Card[:all, :script].update! content: hash[:script].compact
81
+ Card::Auth.as_bot # FIXME: should not be necessary
81
82
  Card[:style_mods].update! content: hash[:style].compact
82
83
  # puts "refreshing assets"
83
84
  Card::Assets.refresh force: true
data/lib/cardio/mod.rb CHANGED
@@ -74,7 +74,7 @@ module Cardio
74
74
  end
75
75
 
76
76
  def ensure_card
77
- if Card::Codename.exists? codename
77
+ if Card::Codename.exist? codename
78
78
  card = Card.fetch codename.to_sym
79
79
  card.update type: :mod unless card.type_code == :mod
80
80
  card
@@ -21,16 +21,16 @@ module Cardio
21
21
 
22
22
  config.view_cache = false
23
23
 
24
- config.request_logger = false
25
- config.performance_logger = false
24
+ config.cache_log_level = nil
25
+
26
26
  config.sql_comments = false
27
27
 
28
28
  config.deck_origin = nil
29
29
 
30
30
  config.rich_text_editor = :tinymce
31
31
 
32
- config.persistent_cache = true
33
- config.prepopulate_cache = false
32
+ config.shared_cache = true
33
+ config.seed_cache_from_stash = false
34
34
  config.asset_refresh = :cautious
35
35
  config.compress_assets = true
36
36
 
@@ -76,6 +76,7 @@ module Cardio
76
76
 
77
77
  p["lib/graph_q_l/types/query.rb"] <<
78
78
  "#{mod_path}/lib/graph_q_l/types/query.rb"
79
+ p["config/environments"] << "#{mod_path}/config/environments"
79
80
  p["config/initializers"] << "#{mod_path}/config/early"
80
81
  p["late/initializers"] << "#{mod_path}/config/late"
81
82
  p["lib/tasks"] << "#{mod_path}/lib/tasks"
data/lib/cardio/utils.rb CHANGED
@@ -42,7 +42,7 @@ module Cardio
42
42
  end
43
43
 
44
44
  def delete_files_with_id dir, file_id
45
- raise Card::Error, t(:core_exception_almost_deleted) if Card.exists?(file_id)
45
+ raise Card::Error, t(:core_exception_almost_deleted) if Card.exist?(file_id)
46
46
 
47
47
  ::FileUtils.rm_rf "#{dir}/#{file_id}", secure: true
48
48
  end
@@ -16,6 +16,10 @@ module Cardio
16
16
 
17
17
  source_root File.expand_path("templates", __dir__)
18
18
 
19
+ def self.databases
20
+ Rails::Generators::Database::DATABASES.join "/"
21
+ end
22
+
19
23
  # All but the first aliases should be considered deprecated
20
24
  class_option "monkey",
21
25
  type: :boolean, aliases: %w[-M --mod-dev],
@@ -36,7 +40,7 @@ module Cardio
36
40
  class_option :database,
37
41
  type: :string, aliases: %w[-D -d], default: "mysql",
38
42
  desc: "Preconfigure for selected database " \
39
- "(options: #{DATABASES.join('/')})"
43
+ "(options: #{databases})"
40
44
 
41
45
  class_option "interactive",
42
46
  type: :boolean, aliases: %w[-I -i], default: false, group: :runtime,
@@ -128,16 +132,6 @@ module Cardio
128
132
  3. Run `#{prefix}decko server` to start your server"
129
133
  end
130
134
  end
131
-
132
- protected
133
-
134
- def database_gemfile_entry
135
- return [] if options[:skip_active_record]
136
-
137
- gem_name, gem_version = gem_for_database
138
- msg = "Use #{options[:database]} as the database for Active Record"
139
- GemfileEntry.version gem_name, gem_version, msg
140
- end
141
135
  end
142
136
  end
143
137
  end
@@ -6,7 +6,7 @@ gem "decko"<%= repo_path_constraint %>
6
6
  # DATABASE
7
7
  # Decko currently supports MySQL (best tested), PostgreSQL (well tested), and SQLite
8
8
  # (not well tested).
9
- gem <%= database_gem_and_version %>
9
+ <%= database_gemfile_entry %>
10
10
 
11
11
 
12
12
  # WEBSERVER
@@ -43,7 +43,7 @@ gem "card-mod-defaults"<%= repo_path_constraint :mod %>
43
43
  <%= "# " if shark? %>gem "decko-cucumber", group: :cucumber<%= repo_path_constraint :support %>
44
44
  <%= "# " if shark? %>gem "decko-cypress", group: :cypress<%= repo_path_constraint :support %>
45
45
  <%= "# " if shark? %>gem "decko-profile", group: :profile<%= repo_path_constraint :support %>
46
- <%= "# " if shark? || !spring_install? %>gem "decko-spring"<%= repo_path_constraint :support %>
46
+ <%# "# " if shark? || !spring_install? >gem "decko-spring"<%= repo_path_constraint :support %>
47
47
 
48
48
  <% if platypus? %>
49
49
  # PLATYPUSES
@@ -8,9 +8,3 @@ preload_app!
8
8
  # rackup DefaultRackup
9
9
  port ENV["PORT"] || 3000
10
10
  environment ENV["RACK_ENV"] || "development"
11
-
12
- on_worker_boot do
13
- # Worker specific setup for Rails 4.1+
14
- # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
15
- ActiveRecord::Base.establish_connection
16
- end
@@ -6,6 +6,7 @@ module Cardio
6
6
  class ModGenerator < ModBase
7
7
  def create_mod
8
8
  inside mod_path do
9
+ data_dir
9
10
  assets_dir
10
11
  config_dir
11
12
  set_dir
@@ -27,6 +28,12 @@ module Cardio
27
28
  end
28
29
  end
29
30
 
31
+ def data_dir
32
+ inside "data" do
33
+ create_file "real.yml"
34
+ end
35
+ end
36
+
30
37
  def set_dir
31
38
  inside "set" do
32
39
  %w[abstract all type type_plus_right right self].each do |pattern|
@@ -6,8 +6,9 @@ module Cardio
6
6
  class SetGenerator < ModBase
7
7
  source_root File.expand_path("templates", __dir__)
8
8
 
9
+ argument :name, type: :string, banner: "MOD"
9
10
  argument :set_pattern, required: true
10
- argument :anchors, required: true, type: :array
11
+ argument :anchors, required: true, type: :array, banner: "[ANCHOR1] [ANCHOR2]"
11
12
 
12
13
  class_option "spec-only", type: :boolean,
13
14
  default: false, group: :runtime,
@@ -21,6 +21,7 @@ en:
21
21
  core_exception_almost_deleted: Narrowly averted deleting current file
22
22
  core_is_incomplete: is incomplete
23
23
  core_only_admins_codename: only admins can set codename
24
+ core_error_codename_special_characters: codenames cannot have special characters; only a-z and _.
24
25
  core_renaming: "Renaming"
25
26
  core_rename: "Rename"
26
27
  core_rename_confirm: "Are you sure you want to rename?"
@@ -36,6 +36,6 @@ class AddUniquePairIndices < Cardio::Migration::Schema
36
36
  end
37
37
 
38
38
  def connection
39
- ActiveRecord::Base.connection
39
+ ActiveRecord::Base.lease_connection
40
40
  end
41
41
  end
@@ -0,0 +1,11 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ class AddTrashIndex < Cardio::Migration::Schema
4
+ def up
5
+ add_index :cards, :trash, name: "cards_trash_index"
6
+ end
7
+
8
+ def down
9
+ remove_index :cards, name: "cards_trash_index"
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ class UniqueCodename < Cardio::Migration::Schema
4
+ def up
5
+ remove_index :cards, name: "cards_codename_index"
6
+ add_index :cards, :codename, name: "cards_codename_index", unique: true
7
+ end
8
+
9
+ def down
10
+ remove_index :cards, name: "cards_codename_index"
11
+ add_index :cards, :codename, name: "cards_codename_index"
12
+ end
13
+ end