Sha256: a0eab7995a0c112dce94e6292b97c3a867acb2d282af794d3aff18c8b9554e70

Contents?: true

Size: 1.39 KB

Versions: 2

Compression:

Stored size: 1.39 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_user :fields...` in your User model? "
      return
    end

    model = Zenbox.model.constantize

    puts "Syncing #{model.all.count} models with Zenbox..." 

    model.all.each do |model|
      model.zenbox_sync!
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
zenbox-0.0.5 lib/zenbox/tasks.rb
zenbox-0.0.4 lib/zenbox/tasks.rb