Sha256: fa4f193e877ce3bf0688b8a79ac295da26c4865d0fcb203f3204419b3e3660af

Contents?: true

Size: 1.31 KB

Versions: 21

Compression:

Stored size: 1.31 KB

Contents

require 'csv'
require 'open-uri'
require 'time'

namespace 'usman' do
  namespace 'import' do
    namespace 'master_data' do

      desc "Import all data in sequence"
      task 'all' => :environment do

        import_list = ["roles"]
        
        import_list.each do |item|
          print "Importing #{item.titleize} \t".yellow
          begin
            Rake::Task["usman: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

      ["Role"].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)
          path = Usman::Engine.root.join('db', 'master_data', "#{cls_name.constantize.table_name}.csv")
          cls_name.constantize.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

21 entries across 21 versions & 1 rubygems

Version Path
usman-0.3.9 lib/tasks/usman/master_data.rake
usman-0.3.8 lib/tasks/usman/master_data.rake
usman-0.3.7 lib/tasks/usman/master_data.rake
usman-0.3.6 lib/tasks/usman/master_data.rake
usman-0.3.5 lib/tasks/usman/master_data.rake
usman-0.3.4 lib/tasks/usman/master_data.rake
usman-0.3.3 lib/tasks/usman/master_data.rake
usman-0.3.2 lib/tasks/usman/master_data.rake
usman-0.3.1 lib/tasks/usman/master_data.rake
usman-0.3.0 lib/tasks/usman/master_data.rake
usman-0.2.11 lib/tasks/usman/master_data.rake
usman-0.2.10 lib/tasks/usman/master_data.rake
usman-0.2.9 lib/tasks/usman/master_data.rake
usman-0.2.8 lib/tasks/usman/master_data.rake
usman-0.2.7 lib/tasks/usman/master_data.rake
usman-0.2.6 lib/tasks/usman/master_data.rake
usman-0.2.5 lib/tasks/usman/master_data.rake
usman-0.2.3 lib/tasks/usman/master_data.rake
usman-0.2.2 lib/tasks/usman/master_data.rake
usman-0.2.1 lib/tasks/usman/master_data.rake