Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added rake tasks to do migrations and deliver messages.

  • Loading branch information...
commit 8e2a6a31c43258fb4c7fb122894dab3a5583a776 1 parent a50d3e2
@markbates markbates authored
View
3  lib/apn_on_rails.rb
@@ -1,3 +1,4 @@
-Dir.glob(File.join(File.dirname(__FILE__), 'apn_on_rails', '**/*.rb')).each do |f|
+Dir.glob(File.join(File.dirname(__FILE__), 'apn_on_rails', '**/*.rb')).sort.each do |f|
require File.expand_path(f)
end
+
View
17 lib/apn_on_rails/tasks/apn.rake
@@ -0,0 +1,17 @@
+namespace :apn do
+
+ namespace :notifications do
+
+ desc "Deliver all unsent APN notifications."
+ task :deliver => [:environment] do
+ notifications = APN::Notification.all(:conditions => {:sent_at => nil})
+ unless notifications.empty?
+ include ActionView::Helpers::TextHelper
+ RAILS_DEFAULT_LOGGER.info "APN: Attempting to deliver #{pluralize(notifications.size, 'notification')}."
+ APN::Notification.send_notifications(notifications)
+ end
+ end
+
+ end # notifications
+
+end # apn
View
13 lib/apn_on_rails/tasks/db.rake
@@ -0,0 +1,13 @@
+namespace :apn do
+
+ namespace :db do
+
+ desc 'Runs the migrations for apn_on_rails.'
+ task :migrate => [:environment] do
+ puts File.join(File.dirname(__FILE__), '..', '..', 'apn_on_rails', 'db', 'migrate')
+ ActiveRecord::Migrator.up(File.join(File.dirname(__FILE__), '..', '..', 'apn_on_rails', 'db', 'migrate'))
+ end
+
+ end # db
+
+end # apn
View
3  lib/apn_on_rails_tasks.rb
@@ -0,0 +1,3 @@
+Dir.glob(File.join(File.dirname(__FILE__), 'apn_on_rails', 'tasks', '**/*.rake')).each do |f|
+ load File.expand_path(f)
+end
Please sign in to comment.
Something went wrong with that request. Please try again.