Sha256: e42302287457056da646e76fa0c4ae47eec2b06d7a87d3d1fba731078c9563d9
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
# -*- encoding : utf-8 -*- module Cardio module Generators # generate structure and card migrations class MigrationGenerator < Base source_root File.expand_path("templates", __dir__) # class_option "mod", aliases: "-m", group: :runtime, desc: "mod" class_option "core", type: :boolean, aliases: "-c", default: false, group: :runtime, desc: "Create card migration for card core" def create_migration_file migration_type = options["core"] ? :core_cards : :deck_cards mig_paths = Cardio.migration_paths(migration_type) raise "No migration directory for #{migration_type}" if mig_paths.blank? set_local_assigns! migration_template @migration_template, File.join(mig_paths.first, "#{file_name}.rb") end protected # sets the default migration template that is being used for the # generation of the migration # depending on the arguments which would be sent out in the command line, # the migration template # and the table name instance variables are setup. def set_local_assigns! @migration_template = "card_migration.erb" @migration_parent_class = options["core"] ? "Cardio::Migration::Core" : "Cardio::Migration" case file_name when /^(import)_(.*)(?:\.json)?/ @migration_action = Regexp.last_match(1) @json_filename = "#{Regexp.last_match(2)}.json" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
card-1.102.0 | lib/generators/migration/migration_generator.rb |