lib/generators/deforest/deforest_generator.rb in deforest-1.1.0 vs lib/generators/deforest/deforest_generator.rb in deforest-1.1.1
- old
+ new
@@ -9,30 +9,29 @@
def copy_migration_file
migration_template "migration.rb", "db/migrate/create_deforest_logs.rb", migration_version: migration_version
end
def copy_initializer_file
- if rails5_and_up? && Rails.autoloaders.zeitwerk_enabled?
+ if DeforestGenerator.rails5_and_up? && Rails.autoloaders.zeitwerk_enabled?
copy_file "zeitwerk_enabled_initializer.rb", "config/initializers/deforest.rb"
else
copy_file "classic_enabled_initializer.rb", "config/initializers/deforest.rb"
end
end
- def rails5_and_up?
+ def self.rails5_and_up?
Rails::VERSION::MAJOR >= 5
end
def migration_version
- if rails5_and_up?
+ if DeforestGenerator.rails5_and_up?
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
end
end
def self.next_migration_number(dirname)
- if ActiveRecord::Base.timestamped_migrations
- current_time = Time.now.utc
- current_time.strftime("%Y%m%d%H%M%S")
+ if (rails5_and_up? && ActiveRecord.timestamped_migrations) || ActiveRecord::Base.timestamped_migrations
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
else
"%.3d" % (current_numeric_version(dirname) + 1)
end
end
end