module SeedReport

Constants

VERSION

Public Class Methods

cyan(a_string) click to toggle source
# File lib/seed_report.rb, line 39
def cyan(a_string)
  "\e[36m#{a_string}\e[0m"
end
for_model(model, &block) click to toggle source
# File lib/seed_report.rb, line 5
def for_model(model, &block)
  initial_count = model.count
  output_heading(model)
  output_initial_count(initial_count)
  block.call
  output_increased_count(model.count - initial_count)
end
heading(model) click to toggle source
# File lib/seed_report.rb, line 25
def heading(model)
  sprintf("%-16s", model.name) + " "
end
increased_count_display(amount) click to toggle source
# File lib/seed_report.rb, line 33
def increased_count_display(amount)
  amount_str = sprintf("%3d", amount)
  amount_colored = amount > 0 ? cyan(amount_str) : amount_str
  ", #{amount_colored} created"
end
initial_count_display(count) click to toggle source
# File lib/seed_report.rb, line 29
def initial_count_display(count)
  "initial count: #{sprintf("%3d", count)}"
end
output_heading(model) click to toggle source
# File lib/seed_report.rb, line 13
def output_heading(model)
  print heading(model)
end
output_increased_count(count) click to toggle source
# File lib/seed_report.rb, line 21
def output_increased_count(count)
  puts increased_count_display(count)
end
output_initial_count(count) click to toggle source
# File lib/seed_report.rb, line 17
def output_initial_count(count)
  print initial_count_display(count)
end