class Gutentag::Generators::MigrationVersionsGenerator
Public Instance Methods
update_migration_versions()
click to toggle source
# File lib/gutentag/generators/migration_versions_generator.rb, line 10 def update_migration_versions superclass = "ActiveRecord::Migration[#{rails_version}]" if ::ActiveRecord::VERSION::MAJOR < 5 superclass = "ActiveRecord::Migration" end migration_files.each do |file| gsub_file file, /< ActiveRecord::Migration\[4\.2\]$/, "< #{superclass}" end end
Private Instance Methods
known_migration_names()
click to toggle source
# File lib/gutentag/generators/migration_versions_generator.rb, line 34 def known_migration_names @known_migration_names ||= begin Dir[File.join(__dir__, "../../../db/migrate/*.rb")].collect do |path| File.basename(path).gsub(/\A\d+_/, "").gsub(/\.rb\z/, "") end end end
migration_files()
click to toggle source
# File lib/gutentag/generators/migration_versions_generator.rb, line 26 def migration_files Dir[Rails.root.join("db/migrate/*.rb")].select do |path| known_migration_names.any? do |known| File.basename(path)[/\A\d+_#{known}\.gutentag.rb\z/] end end end
rails_version()
click to toggle source
# File lib/gutentag/generators/migration_versions_generator.rb, line 42 def rails_version @rails_version ||= [ ::ActiveRecord::VERSION::MAJOR, ::ActiveRecord::VERSION::MINOR ].join(".") end