forked from PRX/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.
handle error event on log_connection_exception should be a class method
- Loading branch information
Showing
2 changed files
with
43 additions
and
40 deletions.
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,31 +1,33 @@ | |||
require 'rails_generator' | require 'rails_generator' | ||
require 'rails/generators/migration' | |||
# Generates the migrations necessary for APN on Rails. | # Generates the migrations necessary for APN on Rails. | ||
# This should be run upon install and upgrade of the | # This should be run upon install and upgrade of the | ||
# APN on Rails gem. | # APN on Rails gem. | ||
# | # | ||
# $ ruby script/generate apn_migrations | # $ ruby script/generate apn_migrations | ||
class ApnMigrationsGenerator < Rails::Generator::Base | class ApnMigrationsGenerator < Rails::Generator::Base | ||
|
desc "Generates the migrations necessary for APN on Rails." | ||
|
|||
def manifest # :nodoc: | def manifest # :nodoc: | ||
record do |m| | record do |m| | ||
timestamp = Time.now.utc.strftime("%Y%m%d%H%M%S") | timestamp = Time.now.utc.strftime("%Y%m%d%H%M%S") | ||
db_migrate_path = File.join('db', 'migrate') | db_migrate_path = File.join('db', 'migrate') | ||
|
|||
m.directory(db_migrate_path) | m.directory(db_migrate_path) | ||
|
|||
Dir.glob(File.join(File.dirname(__FILE__), 'templates', 'apn_migrations', '*.rb')).sort.each_with_index do |f, i| | Dir.glob(File.join(File.dirname(__FILE__), 'templates', 'apn_migrations', '*.rb')).sort.each_with_index do |f, i| | ||
f = File.basename(f) | f = File.basename(f) | ||
f.match(/\d+\_(.+)/) | f.match(/\d+\_(.+)/) | ||
timestamp = timestamp.succ | timestamp = timestamp.succ | ||
if Dir.glob(File.join(db_migrate_path, "*_#{$1}")).empty? | if Dir.glob(File.join(db_migrate_path, "*_#{$1}")).empty? | ||
m.file(File.join('apn_migrations', f), | m.file(File.join('apn_migrations', f), | ||
File.join(db_migrate_path, "#{timestamp}_#{$1}"), | File.join(db_migrate_path, "#{timestamp}_#{$1}"), | ||
{:collision => :skip}) | {:collision => :skip}) | ||
end | end | ||
end | end | ||
|
|||
end # record | end # record | ||
|
|||
end # manifest | end # manifest | ||
|
|||
end # ApnMigrationsGenerator | end # ApnMigrationsGenerator |
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