Sha256: 906aa9021b9e2d21e92bcf3bc7e480e3197a538048c5bf48fe9f18e2f457ffd9
Contents?: true
Size: 1.73 KB
Versions: 1
Compression:
Stored size: 1.73 KB
Contents
require 'zenbox' require File.join(File.dirname(__FILE__), 'shared_tasks') namespace :zenbox do desc "Verify your zenbox api_key by sending test data to the zenbox service" task :test => :environment do if defined?(RAILS_DEFAULT_LOGGER) # Rails 2 RAILS_DEFAULT_LOGGER.level = Logger::DEBUG else # Rails 3 Rails.logger = Logger.new(STDOUT) Rails.logger.level = Logger::DEBUG Zenbox.configure(true) do |config| config.logger = Rails.logger end end unless Zenbox.configuration.api_key puts "Zenbox needs an API key configured! Check the README to see how to add it." exit end puts "\nPosting dummy data for 'test@example.com'...\n\n" if Zenbox.post "test@example.com", {:test_data => 123} puts "\nZenbox is set up and ready to use!" else puts "\nPlease check your Zenbox configuration or network settings." end puts end desc "Syncs all user data after the model has been marked. Can be run many times without any side-effects" task :sync => :environment do if Zenbox.model.nil? puts "You must set a model to zenbox. Did you remember to user `zenbox_model :fields...` in your User model? " return end model = Zenbox.model.constantize puts "Syncing #{model.all.count} models with Zenbox..." reset = "\r\e[0k" count = model.all.count previous = "" model.all.each_with_index do |model, index| progress = ((index.to_f + 1) / count * 100).round(2) output = "#{progress}%: #{model.email}" print "#{reset}" print " " * (previous.length + 1) print "#{reset}" print output model.zenbox_sync! previous = output end puts " - Finished!" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
zenbox-0.0.8 | lib/zenbox/tasks.rb |