forked from jwang/apn_on_rails
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added rake tasks to do migrations and deliver messages.
- Loading branch information
Showing
4 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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) | require File.expand_path(f) | ||
end | end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |