require 'sale' require 'csv' def parse_csv(csv_file) csv_opts = { :col_sep => ";", :skip_lines => /^(Notes|The |;)/, :headers => true, :converters => :all, } sales = [] CSV.foreach(csv_file, csv_opts) do |row| if row.count > 0 sales << SalesReporter::Sale.new(row["Date"], row["revenue EUR"], row["quantity"], row["Country"], row["Shop"]) end end sales end def load_reports Dir[File.join('lib', 'reports', '*.rb')].each do |f| require File.expand_path(f, File.dirname(__FILE__)) end end sales = parse_csv(ARGV[0]) load_reports SalesReporter::Reports::SalesByDate.render(sales) SalesReporter::Reports::SalesByCountry.render(sales) SalesReporter::Reports::SalesByShop.render(sales)