Commit df43ced1cdf8d87240b2d2d9335f0cd694cd161d
1 parent
aec9f919
Exists in
master
and in
22 other branches
ActionItem261: flushing after '.'
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2015 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
1 changed file
with
9 additions
and
4 deletions
Show diff stats
script/fbes_populate_helper.rb
| 1 | require File.dirname(__FILE__) + '/../config/environment' | 1 | require File.dirname(__FILE__) + '/../config/environment' |
| 2 | 2 | ||
| 3 | - STATES = { | 3 | +STATES = { |
| 4 | 12 => Region.find_by_name('Acre'), | 4 | 12 => Region.find_by_name('Acre'), |
| 5 | 27 => Region.find_by_name('Alagoas'), | 5 | 27 => Region.find_by_name('Alagoas'), |
| 6 | 13 => Region.find_by_name('Amazonas'), | 6 | 13 => Region.find_by_name('Amazonas'), |
| @@ -30,17 +30,22 @@ require File.dirname(__FILE__) + '/../config/environment' | @@ -30,17 +30,22 @@ require File.dirname(__FILE__) + '/../config/environment' | ||
| 30 | 17 => Region.find_by_name('Tocantins'), | 30 | 17 => Region.find_by_name('Tocantins'), |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | +def step | ||
| 34 | + print '.' | ||
| 35 | + $stdout.flush | ||
| 36 | +end | ||
| 37 | + | ||
| 33 | def new_cat(name, parent = nil) | 38 | def new_cat(name, parent = nil) |
| 34 | path = (parent ? parent.path + '/' : '') + name.to_slug | 39 | path = (parent ? parent.path + '/' : '') + name.to_slug |
| 35 | pc = ProductCategory.find_by_path(path) || ProductCategory.create!(:name => name, :parent => parent, :environment => Environment.default) | 40 | pc = ProductCategory.find_by_path(path) || ProductCategory.create!(:name => name, :parent => parent, :environment => Environment.default) |
| 36 | - print '.' | 41 | + step |
| 37 | pc | 42 | pc |
| 38 | end | 43 | end |
| 39 | 44 | ||
| 40 | def new_region(name, parent, lat, lng) | 45 | def new_region(name, parent, lat, lng) |
| 41 | path = (parent ? parent.path + '/' : '') + name.to_slug | 46 | path = (parent ? parent.path + '/' : '') + name.to_slug |
| 42 | region = Region.find_by_path(path) || Region.create!(:name => name, :parent => parent, :lat => lat, :lng => lng, :environment => Environment.default) | 47 | region = Region.find_by_path(path) || Region.create!(:name => name, :parent => parent, :lat => lat, :lng => lng, :environment => Environment.default) |
| 43 | - print '.' | 48 | + step |
| 44 | region | 49 | region |
| 45 | end | 50 | end |
| 46 | 51 | ||
| @@ -59,5 +64,5 @@ require File.dirname(__FILE__) + '/../config/environment' | @@ -59,5 +64,5 @@ require File.dirname(__FILE__) + '/../config/environment' | ||
| 59 | consumptions.each do |c| | 64 | consumptions.each do |c| |
| 60 | ent.consumptions.create!(c) unless ent.consumptions.find(:first, :conditions => c) | 65 | ent.consumptions.create!(c) unless ent.consumptions.find(:first, :conditions => c) |
| 61 | end | 66 | end |
| 62 | - print '.' | 67 | + step |
| 63 | end | 68 | end |