From 95bdcc986e43e4ba7c3cc74972cffe4cdb1bb64a Mon Sep 17 00:00:00 2001 From: Martin Date: Mon, 16 Oct 2023 17:25:06 +0200 Subject: [PATCH] =?UTF-8?q?refactor(renomme):=20deplace=20le=20phone=5Ffix?= =?UTF-8?q?er.rb=20dans=20un=20repertoire=20dedi=C3=A9=20aux=20fix=20de=20?= =?UTF-8?q?data=20en=20prod?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{phone_fixer.rb => data_fixer/champs_phone_invalid.rb} | 2 +- lib/tasks/data_fixer.rake | 6 +++--- .../champs_phone_invalid_spec.rb} | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) rename app/lib/{phone_fixer.rb => data_fixer/champs_phone_invalid.rb} (90%) rename spec/lib/{phone_fixer_spec.rb => data_fixer/champs_phone_invalid_spec.rb} (97%) diff --git a/app/lib/phone_fixer.rb b/app/lib/data_fixer/champs_phone_invalid.rb similarity index 90% rename from app/lib/phone_fixer.rb rename to app/lib/data_fixer/champs_phone_invalid.rb index 0e0fce15e..6c6574a11 100644 --- a/app/lib/phone_fixer.rb +++ b/app/lib/data_fixer/champs_phone_invalid.rb @@ -1,4 +1,4 @@ -class PhoneFixer +class DataFixer::ChampsPhoneInvalid def self.fix(phones_string) phone_candidates = phones_string .split(/-/) diff --git a/lib/tasks/data_fixer.rake b/lib/tasks/data_fixer.rake index 19d70d9b8..4cf0da630 100644 --- a/lib/tasks/data_fixer.rake +++ b/lib/tasks/data_fixer.rake @@ -2,7 +2,7 @@ require Rails.root.join("lib", "tasks", "task_helper") namespace :data_fixer do desc <<~EOD - Given a procedure_id in argument, run the PhoneFixer. + Given a procedure_id in argument, run the DataFixer::ChampsPhoneInvalid. ex: rails data_fixer:fix_phones\[1\] EOD task :fix_phones, [:procedure_id] => :environment do |_t, args| @@ -14,11 +14,11 @@ namespace :data_fixer do invalid_phone_champs = phone_champs.reject(&:valid?) - fixable_phone_champs = invalid_phone_champs.filter { |phone| PhoneFixer.fixable?(phone.value) } + fixable_phone_champs = invalid_phone_champs.filter { |phone| DataFixer::ChampsPhoneInvalid.fixable?(phone.value) } fixable_phone_champs.each do |phone| fixable_phone_value = phone.value - fixed_phone_value = PhoneFixer.fix(fixable_phone_value) + fixed_phone_value = DataFixer::ChampsPhoneInvalid.fix(fixable_phone_value) if phone.update(value: fixed_phone_value) rake_puts "Invalid phone #{fixable_phone_value} is fixed as #{fixed_phone_value}" else diff --git a/spec/lib/phone_fixer_spec.rb b/spec/lib/data_fixer/champs_phone_invalid_spec.rb similarity index 97% rename from spec/lib/phone_fixer_spec.rb rename to spec/lib/data_fixer/champs_phone_invalid_spec.rb index 5f9225343..72ba48c9e 100644 --- a/spec/lib/phone_fixer_spec.rb +++ b/spec/lib/data_fixer/champs_phone_invalid_spec.rb @@ -1,4 +1,4 @@ -describe PhoneFixer do +describe DataFixer::ChampsPhoneInvalid do describe '#fix' do subject { described_class.fix(phone_str) }