Sha256: 65eedde5fa325b329bbdd70910b82ef6e1323cab63ec58b489652a64995acfe8
Contents?: true
Size: 734 Bytes
Versions: 3
Compression:
Stored size: 734 Bytes
Contents
namespace :geocode do desc "Geocode all objects without coordinates." task :all => :environment do class_name = ENV['CLASS'] || ENV['class'] sleep_timer = ENV['SLEEP'] || ENV['sleep'] raise "Please specify a CLASS (model)" unless class_name klass = class_from_string(class_name) klass.not_geocoded.each do |obj| obj.geocode; obj.save sleep(sleep_timer.to_f) unless sleep_timer.nil? end end end ## # Get a class object from the string given in the shell environment. # Similar to ActiveSupport's +constantize+ method. # def class_from_string(class_name) parts = class_name.split("::") constant = Object parts.each do |part| constant = constant.const_get(part) end constant end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
geocoder2-0.1.1 | lib/tasks/geocoder2.rake |
geocoder2-0.1.0 | lib/tasks/geocoder2.rake |
geocoder-1.1.9 | lib/tasks/geocoder.rake |