Use casecmp() instead of casecmp?() for now (#4832)

* Use casecmp() instead of casecmp?() for now

casecmp?() is only available in ruby 2.4.0.  Users running earlier ruby versions
would see errors, e.g., running
RAILS_ENV=production rails mastodon:maintenance:remove_deprecated_preview_cards.

* Correctly check whether casecmp() returns 0
This commit is contained in:
Joseph Mingrone 2017-09-06 22:55:06 -03:00 committed by Eugen Rochko
parent be75b13d68
commit 5264496240
1 changed files with 3 additions and 3 deletions

View File

@ -47,7 +47,7 @@ namespace :mastodon do
confirm = STDIN.gets.chomp confirm = STDIN.gets.chomp
puts puts
if confirm.casecmp?('y') if confirm.casecmp('y').zero?
password = SecureRandom.hex password = SecureRandom.hex
user = User.new(email: email, password: password, account_attributes: { username: username }) user = User.new(email: email, password: password, account_attributes: { username: username })
if user.save if user.save
@ -289,13 +289,13 @@ namespace :mastodon do
puts 'Delete records and associated files from deprecated preview cards? [y/N]: ' puts 'Delete records and associated files from deprecated preview cards? [y/N]: '
confirm = STDIN.gets.chomp confirm = STDIN.gets.chomp
if confirm.casecmp?('y') if confirm.casecmp('y').zero?
DeprecatedPreviewCard.in_batches.destroy_all DeprecatedPreviewCard.in_batches.destroy_all
puts 'Drop deprecated preview cards table? [y/N]: ' puts 'Drop deprecated preview cards table? [y/N]: '
confirm = STDIN.gets.chomp confirm = STDIN.gets.chomp
if confirm.casecmp?('y') if confirm.casecmp('y').zero?
ActiveRecord::Migration.drop_table :deprecated_preview_cards ActiveRecord::Migration.drop_table :deprecated_preview_cards
end end
end end