Sha256: 4446559612914a4f5d649c76a23325d58a04c0fda8088f63bc54f6bb4dd758f9

Contents?: true

Size: 932 Bytes

Versions: 1

Compression:

Stored size: 932 Bytes

Contents

namespace :active_unimod do
  namespace :database do 
    
    # TODO - add a flag for which way to relsove discrepancies.
    desc "Updates unimod database from website."
    task :update do
      require File.expand_path(RAILS_ROOT + "/config/environment")
      require 'active_unimod/database'
      
      inconsistencies = ActiveUnimod::Database.update_from_web(nil, ENV["OVERWRITE"])
    
      unless inconsistencies.empty?
        require 'pp'
        puts "found #{inconsistencies.length} inconsistent #{inconsistencies.length > 1 ? 'entries' : 'entry'}:"
        inconsistencies.each do |record, existing|
          puts "#{record.class.table_name}(#{record.id})\n  expected #{PP.singleline_pp(record.attributes, "")}\n  but was  #{PP.singleline_pp(existing.attributes, "")}"
        end
      
        puts
        puts "inconsistent entries WERE NOT updated"
      end
    end
    
  end  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_unimod_generator-0.1.0 lib/active_unimod_tasks.rb