1
0
mirror of https://github.com/fspc/BikeShed-1.git synced 2025-02-28 00:33:23 -05:00

BikeCsvImporter: colorize importer output to highlight individual row statuses

This commit is contained in:
Ilya Konanykhin 2017-03-20 21:44:27 +06:00
parent 072f303c65
commit ae79a34652
3 changed files with 5 additions and 2 deletions

View File

@ -35,6 +35,7 @@ group :development, :test do
gem 'factory_girl_rails', '~> 1.2'
gem 'pry', '~> 0.9.8'
gem 'faker', '~> 1.2.0'
gem 'colorize'
end
group :test do

View File

@ -69,6 +69,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.10.0)
colorize (0.8.1)
database_cleaner (1.2.0)
decent_exposure (1.0.2)
devise (2.0.6)
@ -255,6 +256,7 @@ DEPENDENCIES
cancan
capybara (~> 2.2.1)
coffee-rails (~> 3.2.1)
colorize
database_cleaner (~> 1.2.0)
decent_exposure (~> 1.0.1)
devise (~> 2.0.4)

View File

@ -30,10 +30,10 @@ class BikeCsvImporter
bike = new_bike bike_hash
check_method = dry_run ? :valid? : :save
if bike.try check_method
puts "Imported #{bike.shop_id}: #{bike}"
puts "Imported #{bike.shop_id}: #{bike}".green
imported_count += 1
else
puts "Skipped #{bike.try(:shop_id) || bike_hash.values.first}: #{bike.try(:errors).try(:full_messages).try :join, '; '}"
puts "Skipped #{bike.try(:shop_id) || bike_hash.values.first}: #{bike.try(:errors).try(:full_messages).try :join, '; '}".red
skipped_count += 1
end
end