Sha256: 6a2513c128d0a1bfb9f48f73a48f25af17a9d57120a8f8b9c501c411ff925da7
Contents?: true
Size: 1.47 KB
Versions: 10
Compression:
Stored size: 1.47 KB
Contents
require 'csv' require 'open-uri' require 'time' namespace 'dhatu' do namespace 'import' do namespace 'master_data' do desc "Import all data in sequence" task 'all' => :environment do import_list = ["features"] import_list.each do |item| print "Importing #{item.titleize} \t".yellow begin Rake::Task["dhatu:import:master_data:#{item}"].invoke rescue ArgumentError => e puts "Loading #{item} - Failed - #{e.message}".red rescue Exception => e puts "Importing #{item.titleize} - Failed - #{e.message}".red puts "Backtrace:\n\t#{e.backtrace.join("\n\t")}" end end puts " " end ["Feature"].each do |cls_name| name = cls_name.underscore.pluralize desc "Import #{cls_name.pluralize}" task name => :environment do verbose = true verbose = false if ["false", "f","0","no","n"].include?(ENV["verbose"].to_s.downcase.strip) destroy_all = false destroy_all = true if ["true", "t","1","yes","y"].include?(ENV["destroy_all"].to_s.downcase.strip) path = Dhatu::Engine.root.join('db', 'master_data', "#{cls_name.constantize.table_name}.csv") cls_name.constantize.destroy_all if destroy_all cls_name.constantize.import_data_file(path, true, verbose) # puts "Importing Completed".green if verbose end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems