mirror of
https://github.com/fspc/BikeShed-1.git
synced 2025-02-28 08:43:23 -05:00
BikeCsvImporter: colorize importer output to highlight individual row statuses
This commit is contained in:
parent
072f303c65
commit
ae79a34652
1
Gemfile
1
Gemfile
@ -35,6 +35,7 @@ group :development, :test do
|
|||||||
gem 'factory_girl_rails', '~> 1.2'
|
gem 'factory_girl_rails', '~> 1.2'
|
||||||
gem 'pry', '~> 0.9.8'
|
gem 'pry', '~> 0.9.8'
|
||||||
gem 'faker', '~> 1.2.0'
|
gem 'faker', '~> 1.2.0'
|
||||||
|
gem 'colorize'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
|
@ -69,6 +69,7 @@ GEM
|
|||||||
coffee-script-source
|
coffee-script-source
|
||||||
execjs
|
execjs
|
||||||
coffee-script-source (1.10.0)
|
coffee-script-source (1.10.0)
|
||||||
|
colorize (0.8.1)
|
||||||
database_cleaner (1.2.0)
|
database_cleaner (1.2.0)
|
||||||
decent_exposure (1.0.2)
|
decent_exposure (1.0.2)
|
||||||
devise (2.0.6)
|
devise (2.0.6)
|
||||||
@ -255,6 +256,7 @@ DEPENDENCIES
|
|||||||
cancan
|
cancan
|
||||||
capybara (~> 2.2.1)
|
capybara (~> 2.2.1)
|
||||||
coffee-rails (~> 3.2.1)
|
coffee-rails (~> 3.2.1)
|
||||||
|
colorize
|
||||||
database_cleaner (~> 1.2.0)
|
database_cleaner (~> 1.2.0)
|
||||||
decent_exposure (~> 1.0.1)
|
decent_exposure (~> 1.0.1)
|
||||||
devise (~> 2.0.4)
|
devise (~> 2.0.4)
|
||||||
|
@ -30,10 +30,10 @@ class BikeCsvImporter
|
|||||||
bike = new_bike bike_hash
|
bike = new_bike bike_hash
|
||||||
check_method = dry_run ? :valid? : :save
|
check_method = dry_run ? :valid? : :save
|
||||||
if bike.try check_method
|
if bike.try check_method
|
||||||
puts "Imported #{bike.shop_id}: #{bike}"
|
puts "Imported #{bike.shop_id}: #{bike}".green
|
||||||
imported_count += 1
|
imported_count += 1
|
||||||
else
|
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
|
skipped_count += 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user