diff --git a/app/models/card.rb b/app/models/card.rb index 56698860..8aa1211a 100644 --- a/app/models/card.rb +++ b/app/models/card.rb @@ -4,15 +4,14 @@ class Card < ApplicationRecord belongs_to :side belongs_to :faction belongs_to :card_type - has_and_belongs_to_many :subtype_relations, class_name: 'Subtype' + has_many :card_subtypes + has_many :subtypes, :through => :card_subtypes has_many :printings - has_many :legality - validates :code, uniqueness: true validates :name, uniqueness: true def versions - printings.includes(nr_set: :nr_cycle).order(date_release: :desc) + printings.includes(card_set: :cycle).order(date_release: :desc) end def strength_selector diff --git a/app/models/card_cycle.rb b/app/models/card_cycle.rb new file mode 100644 index 00000000..b5488fc4 --- /dev/null +++ b/app/models/card_cycle.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +class CardCycle < ApplicationRecord + has_many :card_sets + # TODO(plural): Add association path for cycles -> printings +end diff --git a/app/models/card_set.rb b/app/models/card_set.rb new file mode 100644 index 00000000..16c74e3d --- /dev/null +++ b/app/models/card_set.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +class CardSet < ApplicationRecord + belongs_to :card_cycle + belongs_to :card_set_type +end diff --git a/app/models/card_set_type.rb b/app/models/card_set_type.rb new file mode 100644 index 00000000..68b4c801 --- /dev/null +++ b/app/models/card_set_type.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +class CardSetType < ApplicationRecord + has_many :card_sets +end diff --git a/app/models/card_subtype.rb b/app/models/card_subtype.rb new file mode 100644 index 00000000..0c15ff5a --- /dev/null +++ b/app/models/card_subtype.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class CardSubtype < ApplicationRecord + self.table_name = "cards_subtypes" + + belongs_to :card, + :primary_key => :id, + :foreign_key => :card_id + belongs_to :subtype, + :primary_key => :id, + :foreign_key => :subtype_id +end diff --git a/app/models/card_subtypes.rb b/app/models/card_subtypes.rb deleted file mode 100644 index 02374988..00000000 --- a/app/models/card_subtypes.rb +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true - -class CardSubtypes < ApplicationRecord - belongs_to :cards - belongs_to :subtypes -end diff --git a/app/models/faction.rb b/app/models/faction.rb index 68aa2cb0..7a2d75c8 100644 --- a/app/models/faction.rb +++ b/app/models/faction.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +# TODO(plural): add a side code to faction. class Faction < ApplicationRecord has_many :cards end diff --git a/app/models/legality.rb b/app/models/legality.rb deleted file mode 100644 index 29d4389b..00000000 --- a/app/models/legality.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class Legality < ApplicationRecord - belongs_to :legality_type - belongs_to :deck_format - belongs_to :card -end diff --git a/app/models/legality_type.rb b/app/models/legality_type.rb deleted file mode 100644 index f9d7e774..00000000 --- a/app/models/legality_type.rb +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true - -class LegalityType < ApplicationRecord - has_many :legalities -end diff --git a/app/models/nr_cycle.rb b/app/models/nr_cycle.rb deleted file mode 100644 index c8907cd8..00000000 --- a/app/models/nr_cycle.rb +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true - -class NrCycle < ApplicationRecord - has_many :nr_sets -end diff --git a/app/models/nr_set.rb b/app/models/nr_set.rb deleted file mode 100644 index 3657dd04..00000000 --- a/app/models/nr_set.rb +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true - -class NrSet < ApplicationRecord - belongs_to :nr_cycle, optional: true - belongs_to :nr_set_type -end diff --git a/app/models/nr_set_type.rb b/app/models/nr_set_type.rb deleted file mode 100644 index 44d78fd5..00000000 --- a/app/models/nr_set_type.rb +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true - -class NrSetType < ApplicationRecord - has_many :nr_sets -end diff --git a/app/models/printing.rb b/app/models/printing.rb index 3e54e6eb..92e8c427 100644 --- a/app/models/printing.rb +++ b/app/models/printing.rb @@ -2,7 +2,8 @@ class Printing < ApplicationRecord belongs_to :card - belongs_to :nr_set + belongs_to :card_set + # TODO(plural): Add an association to cycle. def format_flavor t = flavor || '' diff --git a/app/models/side.rb b/app/models/side.rb index e160c981..e0e667be 100644 --- a/app/models/side.rb +++ b/app/models/side.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true class Side < ApplicationRecord + # TODO(plural): Add an association for factions. has_many :cards end diff --git a/app/models/subtype.rb b/app/models/subtype.rb index bf65e88f..1db5c159 100644 --- a/app/models/subtype.rb +++ b/app/models/subtype.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true class Subtype < ApplicationRecord - has_and_belongs_to_many :cards + has_many :card_subtypes + has_many :cards, :through => :card_subtypes end diff --git a/db/migrate/.keep b/db/migrate/.keep new file mode 100644 index 00000000..e69de29b diff --git a/db/schema.rb b/db/schema.rb index f65d54e2..d5b07fb2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,158 +10,114 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20220114191001) do +ActiveRecord::Schema.define(version: 2022_02_13_014409) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" - create_table "card_types", force: :cascade do |t| - t.text "code", null: false + create_table "card_set_types", id: :string, force: :cascade do |t| + t.text "name", null: false + t.text "description" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + + create_table "card_sets", id: :string, force: :cascade do |t| + t.text "name", null: false + t.date "date_release" + t.integer "size" + t.text "card_cycle_id" + t.text "card_set_type_id" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + + create_table "card_types", id: :string, force: :cascade do |t| t.text "name", null: false t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false - t.index ["code"], name: "index_card_types_on_code", unique: true end - create_table "cards", force: :cascade do |t| + create_table "cards", id: :string, force: :cascade do |t| + t.text "name", null: false + t.text "card_type_id", null: false + t.text "side_id", null: false + t.text "faction_id", null: false t.integer "advancement_requirement" t.integer "agenda_points" t.integer "base_link" - t.text "code", null: false t.integer "cost" t.integer "deck_limit" - t.integer "faction_id" t.integer "influence_cost" t.integer "influence_limit" t.integer "memory_cost" t.integer "minimum_deck_size" - t.text "name", null: false - t.integer "side_id" t.integer "strength" - t.text "subtypes" t.text "text" t.integer "trash_cost" - t.integer "card_type_id" t.boolean "uniqueness" + t.text "keywords" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false t.index ["card_type_id"], name: "index_cards_on_card_type_id" - t.index ["code"], name: "index_cards_on_code", unique: true t.index ["faction_id"], name: "index_cards_on_faction_id" t.index ["side_id"], name: "index_cards_on_side_id" + t.index ["name"], name: "index_cards_unique_name", unique: true end create_table "cards_subtypes", id: false, force: :cascade do |t| - t.integer "card_id", null: false - t.integer "subtype_id", null: false - t.index ["subtype_id"], name: "index_cards_subtypes_on_subtype_id" - end - - create_table "factions", force: :cascade do |t| - t.text "code", null: false - t.boolean "is_mini", null: false - t.text "name", null: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["code"], name: "index_factions_on_code", unique: true - end - - create_table "legality_types", force: :cascade do |t| - t.text "name", null: false - t.text "code", null: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["code"], name: "index_legality_types_on_code", unique: true - end - - create_table "nr_cycles", force: :cascade do |t| - t.text "code", null: false - t.text "name", null: false - t.text "description" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["code"], name: "index_nr_cycles_on_code", unique: true + t.text "card_id", null: false + t.text "subtype_id", null: false + t.index ["card_id", "subtype_id"], name: "index_cards_subtypes_on_card_id_and_subtype_id" end - create_table "nr_set_types", force: :cascade do |t| - t.text "code", null: false + create_table "card_cycles", id: :string, force: :cascade do |t| t.text "name", null: false t.text "description" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false - t.index ["code"], name: "index_nr_set_types_on_code", unique: true end - create_table "nr_sets", force: :cascade do |t| - t.text "code", null: false + create_table "factions", id: :string, force: :cascade do |t| + t.boolean "is_mini", null: false t.text "name", null: false - t.date "date_release" - t.integer "size" - t.integer "nr_cycle_id" - t.integer "nr_set_type_id" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false - t.index ["code"], name: "index_nr_sets_on_code", unique: true - t.index ["nr_cycle_id"], name: "index_nr_sets_on_nr_cycle_id" - t.index ["nr_set_type_id"], name: "index_nr_sets_on_nr_set_type_id" end - create_table "printings", force: :cascade do |t| + create_table "printings", id: :string, force: :cascade do |t| + t.text "card_id" + t.text "card_set_id" t.text "printed_text" t.boolean "printed_uniqueness" - t.text "code" t.text "flavor" t.text "illustrator" t.integer "position" t.integer "quantity" t.date "date_release" - t.integer "card_id" - t.integer "nr_set_id" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false - t.index ["card_id"], name: "index_printings_on_card_id" - t.index ["code"], name: "index_printings_on_code", unique: true - t.index ["nr_set_id"], name: "index_printings_on_nr_set_id" end - create_table "sides", force: :cascade do |t| - t.text "code", null: false + create_table "sides", id: :string, force: :cascade do |t| t.text "name", null: false t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false - t.index ["code"], name: "index_sides_on_code", unique: true end - create_table "subtypes", force: :cascade do |t| - t.text "code", null: false + create_table "subtypes", id: :string, force: :cascade do |t| t.text "name", null: false t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false - t.index ["code"], name: "index_subtypes_on_code", unique: true end -# create_table "users", force: :cascade do |t| -# t.string "email", default: "", null: false -# t.string "encrypted_password", default: "", null: false -# t.string "reset_password_token" -# t.datetime "reset_password_sent_at", precision: 6 -# t.datetime "remember_created_at", precision: 6 -# t.datetime "created_at", precision: 6, null: false -# t.datetime "updated_at", precision: 6, null: false -# t.string "name", null: false -# t.string "confirmation_token" -# t.datetime "confirmed_at", precision: 6 -# t.datetime "confirmation_sent_at", precision: 6 -# t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true -# t.index ["email"], name: "index_users_on_email", unique: true -# t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true -# end - - add_foreign_key "cards", "card_types" - add_foreign_key "cards", "factions" - add_foreign_key "cards", "sides" - add_foreign_key "nr_sets", "nr_cycles" - add_foreign_key "nr_sets", "nr_set_types" - add_foreign_key "printings", "cards" - add_foreign_key "printings", "nr_sets" + add_foreign_key "card_sets", "card_cycles", column: "card_cycle_id", primary_key: "id" + add_foreign_key "card_sets", "card_set_types", column: "card_set_type_id", primary_key: "id" + add_foreign_key "cards_subtypes", "cards", column: "card_id", primary_key: "id" + add_foreign_key "cards_subtypes", "subtypes", column: "subtype_id", primary_key: "id" + add_foreign_key "cards", "card_types", column: "card_type_id", primary_key: "id" + add_foreign_key "cards", "factions", column: "faction_id", primary_key: "id" + add_foreign_key "cards", "sides", column: "side_id", primary_key: "id" + add_foreign_key "printings", "cards", column: "card_id", primary_key: "id" + add_foreign_key "printings", "card_sets", column: "card_set_id", primary_key: "id" end diff --git a/lib/tasks/cards.rake b/lib/tasks/cards.rake index d728b0c6..6c8eae7f 100644 --- a/lib/tasks/cards.rake +++ b/lib/tasks/cards.rake @@ -26,7 +26,7 @@ namespace :cards do keywords.each { |k| subtypes[subtype_name_to_code(k)] = k } - return subtypes + return subtypes end # Normalize set names by stripping apostrophes and replacing spaces with -. @@ -41,7 +41,7 @@ namespace :cards do .gsub(/[!:",\(\)\*]/, '') # Single quotes before or after a space and before a - are removed. # This normalized a word like Earth's to earths which reads better - # than earth-s + # than earth-s .gsub(/' /, ' ') .gsub(/ '/, ' ') .gsub(/'-/, '-') @@ -49,24 +49,30 @@ namespace :cards do .gsub('. ', ' ') # Trailing periods are removed. .gsub(/\.$/, '') - .gsub(/[\. '\/\.&;]/, '-') + .gsub(/[\. '\/\.&;]/, '-') end def import_sides(sides_path) sides = JSON.parse(File.read(sides_path)) - Side.import sides, on_duplicate_key_update: { conflict_target: [ :code ], columns: :all } + sides.map! do |s| + { + id: s['code'], + name: s['name'], + } + end + Side.import sides, on_duplicate_key_update: { conflict_target: [ :id ], columns: :all } end def import_factions(path) factions = JSON.parse(File.read(path)) factions.map! do |f| { - code: f['code'], + id: f['code'], name: f['name'], is_mini: f['is_mini'] } end - Faction.import factions, on_duplicate_key_update: { conflict_target: [ :code ], columns: :all } + Faction.import factions, on_duplicate_key_update: { conflict_target: [ :id ], columns: :all } end def import_types(path) @@ -74,11 +80,11 @@ namespace :cards do types = types.select {|t| t['is_subtype'] == false} types.map! do |t| { - code: t['code'], + id: t['code'], name: t['name'], } end - CardType.import types, on_duplicate_key_update: { conflict_target: [ :code ], columns: :all } + CardType.import types, on_duplicate_key_update: { conflict_target: [ :id ], columns: :all } end def import_subtypes(packs_json) @@ -92,19 +98,14 @@ namespace :cards do } subtypes = subtypes.to_a.map do |k, v| { - code: k, + id: k, name: v } - end - Subtype.import subtypes, on_duplicate_key_update: { conflict_target: [ :code ], columns: :all } + end + Subtype.import subtypes, on_duplicate_key_update: { conflict_target: [ :id ], columns: :all } end def import_cards(cards) - factions = Faction.all.index_by(&:code) - sides = Side.all.index_by(&:code) - types = CardType.all.index_by(&:code) - subtypes = Subtype.all.index_by(&:code) - new_cards = [] seen_cards = {} cards.each do |card| @@ -114,11 +115,15 @@ namespace :cards do next end seen_cards[card["title"]] = true + new_card = Card.new( + id: stripped_title_to_card_code(card["stripped_title"]), + card_type_id: card["type_code"], + side_id: card["side_code"], + faction_id: card["faction_code"], advancement_requirement: card["advancement_cost"], - agenda_points: card["agendaUpoints"], + agenda_points: card["agenda_points"], base_link: card["base_link"], - code: stripped_title_to_card_code(card["stripped_title"]), cost: card["cost"], deck_limit: card["deck_limit"], influence_cost: card["faction_cost"], @@ -127,14 +132,11 @@ namespace :cards do minimum_deck_size: card["minimum_deck_size"], name: card["title"], strength: card["strength"], - subtypes: card["keywords"], text: card["text"], trash_cost: card["trash_cost"], - uniqueness: card["uniqueness"] + uniqueness: card["uniqueness"], + keywords: card["keywords"], ) - new_card.faction = factions[card["faction_code"]] if card["faction_code"] - new_card.side = sides[card["side_code"]] if card["side_code"] - new_card.card_type = types[card["type_code"]] if card["type_code"] new_cards << new_card end @@ -143,22 +145,22 @@ namespace :cards do new_cards.each_slice(250) { |s| num_cards += s.length puts ' %d cards' % num_cards - Card.import s, on_duplicate_key_update: { conflict_target: [ :code ], columns: :all } + Card.import s, on_duplicate_key_update: { conflict_target: [ :id ], columns: :all } } end # We don't reload JSON files in here because we have already saved all the cards # with their subtypes fields and can parse from there. def import_card_subtypes - subtypes = Subtype.all.index_by(&:code) + # TODO(plural): Deal with caïssa type. + subtypes = Subtype.all.index_by(&:id) cards = Card.all card_id_to_subtype_id = [] cards.each { |c| - keywords_to_subtype_codes(c.subtypes).each { |k,v| + keywords_to_subtype_codes(c.keywords).each { |k,v| card_id_to_subtype_id << [c.id, subtypes[k].id] } } - puts "Have to insert %d card -> subtype mappings." % card_id_to_subtype_id.length # Use a transaction since we are deleting the mapping table. ActiveRecord::Base.transaction do puts 'Clear out existing card -> subtype mappings' @@ -171,10 +173,11 @@ namespace :cards do card_id_to_subtype_id.each_slice(250) { |m| num_assoc += m.length puts ' %d card -> subtype associations' % num_assoc - sql = "INSERT INTO cards_subtypes (card_id, subtype_id) VALUES " + sql = "INSERT INTO cards_subtypes (card_id, subtype_id) VALUES " vals = [] m.each { |m| - vals << "(%d, %d)" % [m[0], m[1]] + # TODO(plural): use the associations object for this or ensure this is safe + vals << "('%s', '%s')" % [m[0], m[1]] } sql << vals.join(", ") unless ActiveRecord::Base.connection.execute(sql) @@ -189,90 +192,90 @@ namespace :cards do cycles = JSON.parse(File.read(path)) cycles.map! do |c| { - code: c['code'], + id: c['code'], name: c['name'], } end - NrCycle.import cycles, on_duplicate_key_update: { conflict_target: [ :code ], columns: :all } + CardCycle.import cycles, on_duplicate_key_update: { conflict_target: [ :id ], columns: :all } end def import_set_types # TODO(plural): Make json files for set types. - subtypes = Subtype.all.index_by(&:code) + subtypes = Subtype.all set_types = [ - { code: 'campaign', name: 'Campaign' }, - { code: 'core', name: 'Core' }, - { code: 'data_pack', name: 'Data Pack' }, - { code: 'deluxe', name: 'Deluxe' }, - { code: 'draft', name: 'Draft' }, - { code: 'expansion', name: 'Expansion' }, - { code: 'promo', name: 'Promo' } + { id: 'campaign', name: 'Campaign' }, + { id: 'core', name: 'Core' }, + { id: 'data_pack', name: 'Data Pack' }, + { id: 'deluxe', name: 'Deluxe' }, + { id: 'draft', name: 'Draft' }, + { id: 'expansion', name: 'Expansion' }, + { id: 'promo', name: 'Promo' } ] - NrSetType.import set_types, on_duplicate_key_update: { conflict_target: [ :code ], columns: :all } + CardSetType.import set_types, on_duplicate_key_update: { conflict_target: [ :id ], columns: :all } end def import_sets(path) # TODO(plural): Get mappings into the JSON files. set_type_mapping = { - "terminal-directive-campaign" => 1, # campaign - "revised-core-set" => 2, # core - "system-gateway" => 2, # core - "system-core-2019" => 2, # core - "core-set" => 2, # core - "system-update-2021" => 2, # core - "reign-and-reverie" => 4, # deluxe - "data-and-destiny" => 4, # deluxe - "order-and-chaos" => 4, # deluxe - "creation-and-control" => 4, # deluxe - "honor-and-profit" => 4, # deluxe - "draft" => 5, # draft - "magnum-opus" => 6, # expansion - "magnum-opus-reprint" => 6, # expansion - "uprising-booster-pack" => 6, # expansion - "napd-multiplayer" => 7, # promo + "terminal-directive-campaign" => 'campaign', + "revised-core-set" => 'core', + "system-gateway" => 'core', + "system-core-2019" => 'core', + "core-set" => 'core', + "system-update-2021" => 'core', + "reign-and-reverie" => 'deluxe', + "data-and-destiny" => 'deluxe', + "order-and-chaos" => 'deluxe', + "creation-and-control" => 'deluxe', + "honor-and-profit" => 'deluxe', + "draft" => 'draft', + "magnum-opus" => 'expansion', + "magnum-opus-reprint" => 'expansion', + "uprising-booster-pack" => 'expansion', + "napd-multiplayer" => 'promo', } - cycles = NrCycle.all.index_by(&:code) + cycles = CardCycle.all sets = JSON.parse(File.read(path)) # TODO(plural): Get the updated code values in the JSON files, probably with a new name. sets.map! do |s| { - "code": set_name_to_code(s["name"]), + "id": set_name_to_code(s["name"]), "name": s["name"], # TODO(plural): Make this a proper date type, not a string. "date_release": s["date_release"], - "size": s["size"], - "nr_cycle_id": cycles[s["cycle_code"]].id, - "nr_set_type_id": set_type_mapping.fetch(set_name_to_code(s["name"]), 3) + "size": s["size"], + "card_cycle_id": s["cycle_code"], #cycles[s["cycle_code"]].id, + "card_set_type_id": set_type_mapping.fetch(set_name_to_code(s["name"]), "data_pack") } end - NrSet.import sets, on_duplicate_key_update: { conflict_target: [ :code ], columns: :all } + CardSet.import sets, on_duplicate_key_update: { conflict_target: [ :id ], columns: :all } end def import_printings(pack_cards_json, packs_path) raw_packs = JSON.parse(File.read(packs_path)) - old_pack_code_to_set_code = {} + old_pack_id_to_set_id = {} raw_packs.each{ |r| - old_pack_code_to_set_code[r["code"]] = set_name_to_code(r["name"]) + old_pack_id_to_set_id[r["code"]] = set_name_to_code(r["name"]) } - raw_cards = Card.all.index_by(&:code) - nr_sets = NrSet.all.index_by(&:code) + raw_cards = Card.all.index_by(&:id) + sets = CardSet.all.index_by(&:id) new_printings = [] pack_cards_json.each { |set_card| card = raw_cards[stripped_title_to_card_code(set_card["stripped_title"])] - nr_set = nr_sets[old_pack_code_to_set_code[set_card["pack_code"]]] + set = sets[old_pack_id_to_set_id[set_card["pack_code"]]] new_printings << Printing.new( printed_text: card.text, printed_uniqueness: card.uniqueness, - code: set_card["code"], + id: set_card["code"], flavor: set_card["flavor"], illustrator: set_card["illustrator"], position: set_card["position"], quantity: set_card["quantity"], - date_release: nr_set["date_release"], + date_release: set["date_release"], card: card, - nr_set: nr_set + card_set: set ) } @@ -280,7 +283,7 @@ namespace :cards do new_printings.each_slice(250) { |s| num_printings += s.length puts ' %d printings' % num_printings - Printing.import s, on_duplicate_key_update: { conflict_target: [ :code ], columns: :all } + Printing.import s, on_duplicate_key_update: { conflict_target: [ :id ], columns: :all } } end @@ -288,37 +291,37 @@ namespace :cards do args.with_defaults(:json_dir => '/netrunner-cards-json/') puts 'Import card data...' + # The JSON from the files in packs/ are used by multiple methods. + pack_cards_json = load_pack_card_files(args[:json_dir] + '/pack/*.json') + puts 'Importing Sides...' import_sides(args[:json_dir] + '/sides.json') puts 'Import factions...' import_factions(args[:json_dir] + '/factions.json') + puts 'Importing Cycles...' + import_cycles(args[:json_dir] + '/cycles.json') + puts 'Importing Types...' import_types(args[:json_dir] + '/types.json') - # The JSON from the files in packs/ are used by multiple methods. - pack_cards_json = load_pack_card_files(args[:json_dir] + '/pack/*.json') - puts 'Importing Subtypes...,' import_subtypes(pack_cards_json) puts 'Importing Cards...' import_cards(pack_cards_json) - puts 'Importing Cycles...' - import_cycles(args[:json_dir] + '/cycles.json') + puts 'Importing Subtypes for Cards...' + import_card_subtypes() - puts 'Importing Set Types...' + puts 'Importing Card Set Types...' import_set_types() puts 'Importing Sets...' import_sets(args[:json_dir] + '/packs.json') - puts 'Importing Subtypes for Cards...' - import_card_subtypes() - - puts('Importing Printings...') + puts 'Importing Printings...' import_printings(pack_cards_json, args[:json_dir] + '/packs.json') puts 'Done!'