card 1.105.6 → 1.107.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/config/environments/development.rb +0 -3
- data/config/environments/production.rb +0 -3
- data/config/environments/test.rb +0 -2
- data/config/initializers/02_patches/active_record.rb +2 -2
- data/db/schema.rb +5 -13
- data/lib/card/auth/current.rb +1 -1
- data/lib/card/auth/permissions.rb +1 -9
- data/lib/card/codename.rb +8 -0
- data/lib/card/director/store.rb +1 -1
- data/lib/card/fetch/all.rb +1 -1
- data/lib/card/model/save_helper/save_helper_helper.rb +6 -2
- data/lib/card/query/abstract_query/tie.rb +16 -2
- data/lib/card/query/card_query/interpretation.rb +26 -3
- data/lib/card/query/reference_query.rb +4 -4
- data/lib/card/set.rb +27 -0
- data/lib/card/view/permission.rb +1 -1
- data/lib/cardio/command/rspec_command/parser.rb +1 -9
- data/lib/cardio/command.rb +1 -0
- data/lib/cardio/generators/base.rb +1 -1
- data/lib/cardio/migration/assumption.rb +29 -0
- data/lib/cardio/migration/schema.rb +12 -0
- data/lib/cardio/migration/stamp.rb +31 -0
- data/lib/cardio/migration/transform.rb +44 -0
- data/lib/cardio/migration.rb +64 -73
- data/lib/cardio/mod/dirs.rb +6 -5
- data/lib/cardio/mod/eat/edibles.rb +9 -3
- data/lib/cardio/mod/eat.rb +2 -1
- data/lib/cardio/mod/sow/card_source.rb +48 -0
- data/lib/cardio/mod/sow/yaml_dump.rb +25 -0
- data/lib/cardio/mod/sow.rb +22 -62
- data/lib/cardio/mod.rb +8 -4
- data/lib/cardio/railtie.rb +6 -6
- data/lib/cardio/seed.rb +3 -6
- data/lib/generators/deck/templates/cypress.json.erb +1 -1
- data/lib/generators/migration/USAGE +10 -11
- data/lib/generators/migration/migration_generator.rb +26 -24
- data/lib/generators/migration/templates/card_migration.erb +1 -3
- data/mod/core/config/admin.yml +10 -0
- data/mod/core/data/fixtures/real/transform_migrations.yml +351 -0
- data/mod/core/data/real.yml +0 -1
- data/mod/core/data/recode.yml +7 -0
- data/{db/migrate → mod/core/data/schema}/20110511221913_require_earlier_migrations.rb +3 -3
- data/{db/migrate → mod/core/data/schema}/20120105203350_require_1_8_migrations.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20121111025347_require_1_10_migrations.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20121118114000_split_link_type.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20121118115000_update_link_type.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20130106052640_table_cleanup.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20130109015336_trunk_left.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20140822073704_create_new_revision_tables.rb +1 -1
- data/mod/core/data/schema/20141001105348_move_revisions_to_actions.rb +87 -0
- data/{db/migrate → mod/core/data/schema}/20141216053032_better_index_names.rb +10 -4
- data/{db/migrate → mod/core/data/schema}/20150724210803_add_comment_to_actions.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20151105225559_more_space_for_db_content.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20160122153608_new_indices.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20170908114442_create_delayed_jobs.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20170908114452_increase_text_size_for_delayed_jobs.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20180514152037_add_card_virtuals_table.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20190116170824_add_left_key_to_card_virtuals.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20190131223248_add_codename_index.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20190929202325_rename_present_in_reference_table.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20200718051236_compound_names_do_not_store_name_and_key.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20200805200729_add_unique_pair_indices.rb +1 -3
- data/{db/migrate → mod/core/data/schema}/20211128040849_virtuals_updated_at.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20221031182227_remove_referee_key_requirement.rb +1 -1
- data/mod/core/data/test.yml +4 -4
- data/{db/migrate_core_cards → mod/core/data/transform}/20120611203506_rails_inflection_updates.rb +10 -6
- data/mod/core/data/transform/20130411191151_renaming_for_menu.rb +17 -0
- data/mod/core/data/transform/20130920214038_jsonize_tinymce.rb +28 -0
- data/{db/migrate_core_cards → mod/core/data/transform}/20130920291703_update_stylesheets.rb +1 -1
- data/mod/core/data/transform/20140307231621_user_data_to_cards.rb +40 -0
- data/{db/migrate_core_cards → mod/core/data/transform}/20140317035504_account_requests_to_signups.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20141204061304_watchers_to_following.rb +2 -2
- data/{db/migrate_core_cards → mod/core/data/transform}/20141208132416_partial_reference_type.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20150220134731_following_to_follow_rule.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20150429090551_search_card_context.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20150510031118_fix_skin_codenames.rb +2 -2
- data/{db/migrate_core_cards → mod/core/data/transform}/20150724123438_update_file_and_image_cards.rb +2 -2
- data/{db/migrate_core_cards → mod/core/data/transform}/20150807205221_create_references_for_search_cards.rb +1 -1
- data/mod/core/data/transform/20150824135418_update_file_history.rb +33 -0
- data/{db/migrate_core_cards → mod/core/data/transform}/20160811115836_rename_stats_to_admin.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20160914132636_fix_mod_files.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20161103154836_update_keys.rb +3 -3
- data/{db/migrate_core_cards → mod/core/data/transform}/20170830210517_correct_signup_success_message.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20180905061537_migrate_layouts.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20190125125150_add_script_rules_card.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20190320091257_upgrade_recaptcha_to_v3.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20190322095534_remove_toolbar_cards.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20190502130029_add_shark_and_help_desk_role.rb +2 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20190528131330_enabled_roles.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20190625153616_pointer_overhaul.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20190718140126_add_guides.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20190822093633_move_help_text_to_code.rb +3 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20190829205148_remove_add_help.rb +1 -1
- data/mod/core/data/transform/20190902193208_input_type.rb +10 -0
- data/{db/migrate_core_cards → mod/core/data/transform}/20190904174403_token_upgrade.rb +2 -2
- data/{db/migrate_core_cards → mod/core/data/transform}/20190909104250_add_cardtype_input_types.rb +2 -2
- data/{db/migrate_core_cards → mod/core/data/transform}/20191115160748_history_cleanup.rb +1 -1
- data/mod/core/data/transform/20230502094848_repair_all_references.rb +7 -0
- data/mod/core/lib/admin_item.rb +21 -0
- data/mod/core/lib/tasks/card/migrate.rake +79 -114
- data/mod/core/lib/tasks/card/seed.rake +1 -1
- data/mod/core/lib/tasks/card.rake +57 -28
- data/mod/core/set/abstract/task_table.rb +16 -0
- data/mod/core/set/all/admin.rb +108 -0
- data/mod/core/set/self/admin.rb +3 -12
- data/mod/core/set/self/mod.rb +39 -0
- data/mod/core/set/self/version.rb +1 -1
- data/mod/core/set/type/mod.rb +227 -0
- data/mod/core/spec/set/all/admin_spec.rb +34 -0
- data/mod/core/spec/set/type/mod_spec.rb +30 -0
- data/mod/core/spec/shared_examples/mod_admin_config.rb +10 -0
- metadata +78 -72
- data/db/migrate/20130411210957_update_codenames.rb +0 -15
- data/db/migrate/20141001105348_move_revisions_to_actions.rb +0 -70
- data/db/migrate/20141121172918_rename_card_migration_table.rb +0 -15
- data/db/migrate/20141208132159_remove_present_from_reference_table.rb +0 -9
- data/db/migrate_core_cards/20130411191151_renaming_for_menu.rb +0 -47
- data/db/migrate_core_cards/20130920214038_jsonize_tinymce.rb +0 -15
- data/db/migrate_core_cards/20140307231621_user_data_to_cards.rb +0 -28
- data/db/migrate_core_cards/20150824135418_update_file_history.rb +0 -24
- data/db/migrate_core_cards/20190902193208_input_type.rb +0 -15
- data/db/migrate_core_cards/20230502094848_repair_all_references.rb +0 -7
- data/lib/cardio/migration/core.rb +0 -11
- data/lib/cardio/migration/deck.rb +0 -0
- data/lib/cardio/migration/deck_structure.rb +0 -19
- data/lib/cardio/schema.rb +0 -96
- data/mod/core/data/fixtures/real/schema_migrations_core_cards.yml +0 -347
- data/mod/core/data/fixtures/real/schema_migrations_deck.yml +0 -1
- data/mod/core/data/fixtures/real/schema_migrations_deck_cards.yml +0 -5
data/lib/cardio/mod/dirs.rb
CHANGED
@@ -63,7 +63,7 @@ module Cardio
|
|
63
63
|
end
|
64
64
|
|
65
65
|
# Add a mod to mod load paths
|
66
|
-
def add_mod mod_name, path: nil, group: nil
|
66
|
+
def add_mod mod_name, path: nil, group: nil, spec: nil
|
67
67
|
if @mods_by_name.key? Mod.normalize_name(mod_name)
|
68
68
|
raise StandardError,
|
69
69
|
"name conflict: mod with name \"#{mod_name}\" already loaded"
|
@@ -72,7 +72,7 @@ module Cardio
|
|
72
72
|
path ||= File.join @current_path, mod_name
|
73
73
|
group ||= @current_group
|
74
74
|
|
75
|
-
mod = Mod.new mod_name, path, group, @mods.size
|
75
|
+
mod = Mod.new mod_name, path, group: group, index: @mods.size, spec: spec
|
76
76
|
@mods << mod
|
77
77
|
@mods_by_name[mod.name] = mod
|
78
78
|
end
|
@@ -139,15 +139,16 @@ module Cardio
|
|
139
139
|
|
140
140
|
def add_gem_mods
|
141
141
|
Cardio::Mod.gem_specs.each do |mod_name, spec|
|
142
|
-
add_gem_mod mod_name, spec
|
142
|
+
add_gem_mod mod_name, spec
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
|
-
def add_gem_mod mod_name,
|
146
|
+
def add_gem_mod mod_name, spec
|
147
147
|
return if @loaded_gem_mods.include?(mod_name)
|
148
148
|
|
149
149
|
@loaded_gem_mods << mod_name
|
150
|
-
|
150
|
+
group = spec.metadata["card-mod-group"] || "gem"
|
151
|
+
add_mod mod_name, path: spec.full_gem_path, group: group, spec: spec
|
151
152
|
end
|
152
153
|
|
153
154
|
def add_core_mods
|
@@ -14,7 +14,7 @@ module Cardio
|
|
14
14
|
def explicit_edibles
|
15
15
|
return yield unless @name
|
16
16
|
|
17
|
-
yield.
|
17
|
+
yield.select do |edible|
|
18
18
|
if @name.match?(/^\:/)
|
19
19
|
explicit_codename_match? edible[:codename]
|
20
20
|
else
|
@@ -71,14 +71,20 @@ module Cardio
|
|
71
71
|
end
|
72
72
|
|
73
73
|
# for processing that needs to happen on all cards, including fields
|
74
|
-
def each_card_hash items
|
74
|
+
def each_card_hash items, &block
|
75
75
|
items.each do |item|
|
76
|
+
raise Card::Error, "inedible pod data: #{item}" unless item.is_a? Hash
|
77
|
+
|
76
78
|
yield item
|
77
|
-
item
|
79
|
+
process_fields item, &block
|
78
80
|
end
|
79
81
|
items
|
80
82
|
end
|
81
83
|
|
84
|
+
def process_fields item
|
85
|
+
item[:fields]&.values&.each { |val| yield val if val.is_a? Hash }
|
86
|
+
end
|
87
|
+
|
82
88
|
def handle_attachments mod, hash
|
83
89
|
each_attachment hash do |key, filename|
|
84
90
|
hash[key] = mod_file mod, filename
|
data/lib/cardio/mod/eat.rb
CHANGED
@@ -25,7 +25,6 @@ module Cardio
|
|
25
25
|
track edible do
|
26
26
|
current_user edible.delete(:user)
|
27
27
|
time_machine edible.delete(:time) do
|
28
|
-
# binding.pry if edible[:type] == :link_list
|
29
28
|
Card.ensure edible
|
30
29
|
end
|
31
30
|
end
|
@@ -47,6 +46,8 @@ module Cardio
|
|
47
46
|
|
48
47
|
def track edible
|
49
48
|
rescuing edible do
|
49
|
+
# n = edible[:name]
|
50
|
+
# binding.pry if (n.is_a? Array) && n.first.to_s == "main_menu"
|
50
51
|
# puts "eating: #{edible}" if @verbose
|
51
52
|
card = yield
|
52
53
|
puts "eaten: #{card.name}".cyan if @verbose
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Cardio
|
2
|
+
class Mod
|
3
|
+
class Sow
|
4
|
+
# Fetch sow data form cards
|
5
|
+
module CardSource
|
6
|
+
def new_data_from_cards
|
7
|
+
cards.map { |c| c.pod_hash field_tags: field_tag_marks }
|
8
|
+
end
|
9
|
+
|
10
|
+
def field_tag_marks
|
11
|
+
@field_tag_marks ||= @field_tags.to_s.split(",").map do |mark|
|
12
|
+
mark.strip.cardname.codename_or_string
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def cards
|
17
|
+
if @name
|
18
|
+
cards_from_name
|
19
|
+
elsif @cql
|
20
|
+
Card.search JSON.parse(@cql).reverse_merge(limit: 0)
|
21
|
+
else
|
22
|
+
raise Card::Error::NotFound, "must specify either name (-n) or CQL (-c)"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def cards_from_name
|
27
|
+
case @items
|
28
|
+
when :only then item_cards
|
29
|
+
when true then main_cards + item_cards
|
30
|
+
else main_cards
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def item_cards
|
35
|
+
main_cards.map(&:item_cards).flatten
|
36
|
+
end
|
37
|
+
|
38
|
+
def main_cards
|
39
|
+
@main_cards ||= @name.split(",").map { |n| require_card n }
|
40
|
+
end
|
41
|
+
|
42
|
+
def require_card name
|
43
|
+
Card.fetch(name) || raise(Card::Error::NotFound, "card not found: #{name}")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Cardio
|
2
|
+
class Mod
|
3
|
+
class Sow
|
4
|
+
# Writing the card representations to yaml files in mod directories
|
5
|
+
module YamlDump
|
6
|
+
# write yaml to file
|
7
|
+
def dump hash
|
8
|
+
File.write filename, hash.to_yaml
|
9
|
+
puts "#{filename} now contains #{hash.size} items".green
|
10
|
+
end
|
11
|
+
|
12
|
+
# @return [String] -- MOD_DIR/data/ENVIRONMENT.yml
|
13
|
+
def filename
|
14
|
+
@filename ||= File.join mod_path, "#{@podtype}.yml"
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return Path
|
18
|
+
def mod_path
|
19
|
+
Mod.dirs.subpaths("data")[@mod] ||
|
20
|
+
raise(Card::Error::NotFound, "no data directory found for mod: #{@mod}")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/cardio/mod/sow.rb
CHANGED
@@ -5,10 +5,14 @@ module Cardio
|
|
5
5
|
#
|
6
6
|
# https://docs.google.com/document/d/13K_ynFwfpHwc3t5gnLeAkZJZHco1wK063nJNYwU8qfc/edit#
|
7
7
|
class Sow
|
8
|
+
include YamlDump
|
9
|
+
include CardSource
|
10
|
+
|
8
11
|
def initialize **args
|
9
12
|
@mod = args[:mod]
|
10
13
|
@name = args[:name]
|
11
14
|
@cql = args[:cql]
|
15
|
+
@url = args[:url]
|
12
16
|
@podtype = args[:podtype] || (Rails.env.test? ? :test : :real)
|
13
17
|
@items = args[:items]
|
14
18
|
@field_tags = args[:field_tags]
|
@@ -17,7 +21,7 @@ module Cardio
|
|
17
21
|
# if output mod given,
|
18
22
|
def out
|
19
23
|
Card::Cache.reset_all
|
20
|
-
@mod ? dump : puts(new_data.to_yaml.yellow)
|
24
|
+
@mod ? dump(output_hash) : puts(new_data.to_yaml.yellow)
|
21
25
|
:success
|
22
26
|
rescue Card::Error::NotFound => e
|
23
27
|
e.message
|
@@ -27,59 +31,6 @@ module Cardio
|
|
27
31
|
|
28
32
|
private
|
29
33
|
|
30
|
-
# @return [Array <Hash>]
|
31
|
-
def new_data
|
32
|
-
@new_data ||= cards.map { |c| c.pod_hash field_tags: field_tag_marks }
|
33
|
-
end
|
34
|
-
|
35
|
-
def field_tag_marks
|
36
|
-
@field_tag_marks ||= @field_tags.to_s.split(",").map do |mark|
|
37
|
-
mark.strip.cardname.codename_or_string
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
# @return [String] -- MOD_DIR/data/ENVIRONMENT.yml
|
42
|
-
def filename
|
43
|
-
@filename ||= File.join mod_path, "#{@podtype}.yml"
|
44
|
-
end
|
45
|
-
|
46
|
-
# write yaml to file
|
47
|
-
def dump
|
48
|
-
hash = output_hash
|
49
|
-
File.write filename, hash.to_yaml
|
50
|
-
puts "#{filename} now contains #{hash.size} items".green
|
51
|
-
end
|
52
|
-
|
53
|
-
def cards
|
54
|
-
if @name
|
55
|
-
cards_from_name
|
56
|
-
elsif @cql
|
57
|
-
Card.search JSON.parse(@cql).reverse_merge(limit: 0)
|
58
|
-
else
|
59
|
-
raise Card::Error::NotFound, "must specify either name (-n) or CQL (-c)"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def cards_from_name
|
64
|
-
case @items
|
65
|
-
when :only then item_cards
|
66
|
-
when true then main_cards + item_cards
|
67
|
-
else main_cards
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def item_cards
|
72
|
-
main_cards.map(&:item_cards).flatten
|
73
|
-
end
|
74
|
-
|
75
|
-
def main_cards
|
76
|
-
@main_cards ||= @name.split(",").map { |n| require_card n }
|
77
|
-
end
|
78
|
-
|
79
|
-
def require_card name
|
80
|
-
Card.fetch(name) || raise(Card::Error::NotFound, "card not found: #{name}")
|
81
|
-
end
|
82
|
-
|
83
34
|
def output_hash
|
84
35
|
if target.present?
|
85
36
|
merge_data
|
@@ -89,6 +40,12 @@ module Cardio
|
|
89
40
|
end
|
90
41
|
end
|
91
42
|
|
43
|
+
# @return [Array <Hash>]
|
44
|
+
def new_data
|
45
|
+
@new_data ||=
|
46
|
+
@url ? pod_hash_from_url : new_data_from_cards
|
47
|
+
end
|
48
|
+
|
92
49
|
def merge_data
|
93
50
|
new_data.each do |item|
|
94
51
|
if (index = target_index item)
|
@@ -99,6 +56,10 @@ module Cardio
|
|
99
56
|
end
|
100
57
|
end
|
101
58
|
|
59
|
+
def target
|
60
|
+
@target ||= (old_data || nil)
|
61
|
+
end
|
62
|
+
|
102
63
|
def target_index new_item
|
103
64
|
new_code = new_item[:codename]
|
104
65
|
new_name = new_item[:name].to_name
|
@@ -109,18 +70,17 @@ module Cardio
|
|
109
70
|
end
|
110
71
|
end
|
111
72
|
|
112
|
-
def
|
113
|
-
|
73
|
+
def old_data
|
74
|
+
return unless File.exist? filename
|
75
|
+
parse_pod_yaml File.read(filename)
|
114
76
|
end
|
115
77
|
|
116
|
-
def
|
117
|
-
|
78
|
+
def pod_hash_from_url
|
79
|
+
parse_pod_yaml URI.open(@url).read
|
118
80
|
end
|
119
81
|
|
120
|
-
|
121
|
-
|
122
|
-
Mod.dirs.subpaths("data")[@mod] ||
|
123
|
-
raise(Card::Error::NotFound, "no data directory found for mod: #{@mod}")
|
82
|
+
def parse_pod_yaml pod_yaml
|
83
|
+
YAML.safe_load pod_yaml, permitted_classes: [Symbol]
|
124
84
|
end
|
125
85
|
end
|
126
86
|
end
|
data/lib/cardio/mod.rb
CHANGED
@@ -42,13 +42,14 @@ module Cardio
|
|
42
42
|
class Mod
|
43
43
|
extend ClassMethods
|
44
44
|
|
45
|
-
attr_reader :name, :path, :group, :index
|
45
|
+
attr_reader :name, :path, :group, :index, :spec
|
46
46
|
|
47
|
-
def initialize name, path, group
|
47
|
+
def initialize name, path, group:, index:, spec: nil
|
48
48
|
@name = Mod.normalize_name name
|
49
49
|
@path = required_path path
|
50
50
|
@group = group || :custom
|
51
51
|
@index = index
|
52
|
+
@spec = spec
|
52
53
|
end
|
53
54
|
|
54
55
|
def mod_card_name
|
@@ -59,9 +60,12 @@ module Cardio
|
|
59
60
|
"mod_#{name}"
|
60
61
|
end
|
61
62
|
|
62
|
-
def subpath *parts
|
63
|
+
def subpath *parts, force: false
|
63
64
|
path = File.join [@path] + parts
|
64
|
-
path if File.exist? path
|
65
|
+
return path if File.exist? path
|
66
|
+
return unless force
|
67
|
+
|
68
|
+
FileUtils.mkdir_p path
|
65
69
|
end
|
66
70
|
|
67
71
|
def tmp_dir type
|
data/lib/cardio/railtie.rb
CHANGED
@@ -36,7 +36,6 @@ module Cardio
|
|
36
36
|
|
37
37
|
config.allow_irreversible_admin_tasks = false
|
38
38
|
config.raise_all_rendering_errors = false
|
39
|
-
config.rescue_all_in_controller = true
|
40
39
|
|
41
40
|
config.cache_set_module_list = false
|
42
41
|
|
@@ -65,14 +64,11 @@ module Cardio
|
|
65
64
|
|
66
65
|
p.add "lib/graph_q_l/types/query.rb"
|
67
66
|
p.add "mod-data"
|
67
|
+
p.add "data/schema"
|
68
|
+
p.add "data/transform"
|
68
69
|
|
69
70
|
p.add "db", with: "#{card_root}/db"
|
70
71
|
p.add "db/seeds.rb", with: "#{card_root}/db/seeds.rb"
|
71
|
-
p.add "db/migrate", with: "#{card_root}/db/migrate"
|
72
|
-
p.add "db/migrate_core_cards", with: "#{card_root}/db/migrate_core_cards"
|
73
|
-
|
74
|
-
p.add "db/migrate_deck", with: "db/migrate"
|
75
|
-
p.add "db/migrate_deck_cards", with: "db/migrate_cards"
|
76
72
|
|
77
73
|
Cardio::Mod.dirs.each do |mod_path|
|
78
74
|
c.autoload_paths += Dir["#{mod_path}/lib"]
|
@@ -83,7 +79,11 @@ module Cardio
|
|
83
79
|
p["config/initializers"] << "#{mod_path}/config/early"
|
84
80
|
p["late/initializers"] << "#{mod_path}/config/late"
|
85
81
|
p["lib/tasks"] << "#{mod_path}/lib/tasks"
|
82
|
+
|
86
83
|
p["mod-data"] << "#{mod_path}/data"
|
84
|
+
p["data/schema"] << "#{mod_path}/data/schema"
|
85
|
+
p["data/transform"] << "#{mod_path}/data/transform"
|
86
|
+
|
87
87
|
p["config/locales"] << "#{mod_path}/config/locales"
|
88
88
|
end
|
89
89
|
|
data/lib/cardio/seed.rb
CHANGED
@@ -2,8 +2,7 @@ module Cardio
|
|
2
2
|
# methods in support of seeding
|
3
3
|
module Seed
|
4
4
|
TABLES = %w[cards card_actions card_acts card_changes card_references
|
5
|
-
schema_migrations
|
6
|
-
schema_migrations_deck schema_migrations_deck_cards].freeze
|
5
|
+
schema_migrations transform_migrations].freeze
|
7
6
|
|
8
7
|
class << self
|
9
8
|
def default_path
|
@@ -23,10 +22,8 @@ module Cardio
|
|
23
22
|
|
24
23
|
return unless update_seed?
|
25
24
|
|
26
|
-
Cardio::Migration.assume_current
|
27
|
-
Cardio::Migration::
|
28
|
-
Cardio::Migration::DeckStructure.assume_current
|
29
|
-
# Cardio::Migration::Core.assume_current
|
25
|
+
Cardio::Migration::Schema.new.assume_current
|
26
|
+
Cardio::Migration::Transform.new.assume_current
|
30
27
|
end
|
31
28
|
|
32
29
|
def dump
|
@@ -4,5 +4,5 @@
|
|
4
4
|
"watchForFileChanges": false,
|
5
5
|
"projectId": "n4h7vq",
|
6
6
|
"integrationFolder": "<%= expanded_repo_path %>/decko/spec/cypress/integration",
|
7
|
-
"supportFile": "<%= expanded_repo_path %>/decko/spec/cypress/support/
|
7
|
+
"supportFile": "<%= expanded_repo_path %>/decko/spec/cypress/support/e2e.js"
|
8
8
|
}
|
@@ -1,24 +1,23 @@
|
|
1
1
|
|
2
2
|
Description:
|
3
|
-
Generates a migration of database content.
|
4
|
-
|
5
|
-
To import database content from a json file move your json file to db/migrate_cards/data
|
6
|
-
and choose as migration name import_<filename>.
|
3
|
+
Generates a migration of database schema or content.
|
7
4
|
|
8
5
|
Example:
|
9
|
-
<%= banner_command %> generate
|
6
|
+
<%= banner_command %> generate migration better_comments -m mymod
|
10
7
|
|
11
8
|
This will create:
|
12
9
|
|
13
|
-
|
14
|
-
|
15
|
-
...which is set up to use methods in lib/card/migration.rb
|
10
|
+
mod/mymod/data/transform/(migration_number)_better_comments.rb
|
16
11
|
|
17
12
|
|
18
|
-
<%= banner_command %> generate
|
13
|
+
<%= banner_command %> generate migration better_comments -m mymod --schema
|
19
14
|
|
20
15
|
This will create:
|
21
16
|
|
22
|
-
|
17
|
+
mod/mymod/data/schema/(migration_number)_better_comments.rb
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
23
|
|
24
|
-
...which is set up to import data from db/migrate_cards/data/better_search_cards.json
|
@@ -3,42 +3,44 @@
|
|
3
3
|
module Cardio
|
4
4
|
module Generators
|
5
5
|
# generate structure and card migrations
|
6
|
-
class MigrationGenerator < Base
|
6
|
+
class MigrationGenerator < ActiveRecord::Generators::Base
|
7
|
+
extend ClassMethods
|
7
8
|
source_root File.expand_path("templates", __dir__)
|
8
9
|
|
9
|
-
|
10
|
+
argument :name, required: true
|
10
11
|
|
11
|
-
class_option "
|
12
|
-
default: false, group: :runtime,
|
13
|
-
desc: "Create card migration for card core"
|
12
|
+
class_option "mod", aliases: "-m", group: :runtime, desc: "mod", required: true
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
raise "No migration directory for #{migration_type}" if mig_paths.blank?
|
14
|
+
class_option "schema",
|
15
|
+
type: :boolean, lazy_default: true, group: :runtime,
|
16
|
+
desc: "Create schema migration"
|
19
17
|
|
18
|
+
def create_migration_file
|
20
19
|
set_local_assigns!
|
21
|
-
migration_template
|
22
|
-
File.join(
|
20
|
+
migration_template "card_migration.erb",
|
21
|
+
File.join(migration_path, "#{file_name}.rb")
|
23
22
|
end
|
24
23
|
|
25
24
|
protected
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
def mod_object
|
27
|
+
@mod_object ||= Cardio::Mod.fetch(options[:mod]) || raise("unknown mod: #{mod}")
|
28
|
+
end
|
29
|
+
|
30
|
+
def migration_path
|
31
|
+
mod_object.subpath "data", migration_type.to_s, force: true
|
32
|
+
end
|
33
|
+
|
34
|
+
def migration_type
|
35
|
+
options["schema"] ? :schema : :transform
|
36
|
+
end
|
37
|
+
|
38
|
+
def migration_object
|
39
|
+
Migration.new_for migration_type
|
40
|
+
end
|
32
41
|
|
33
42
|
def set_local_assigns!
|
34
|
-
@
|
35
|
-
@migration_parent_class =
|
36
|
-
options["core"] ? "Cardio::Migration::Core" : "Cardio::Migration"
|
37
|
-
case file_name
|
38
|
-
when /^(import)_(.*)(?:\.json)?/
|
39
|
-
@migration_action = Regexp.last_match(1)
|
40
|
-
@json_filename = "#{Regexp.last_match(2)}.json"
|
41
|
-
end
|
43
|
+
@migration_parent_class = Cardio::Migration.migration_class migration_type
|
42
44
|
end
|
43
45
|
end
|
44
46
|
end
|