Permalink
Browse files

Updated generators to be rails3-compatible, bumped version due to rai…

…ls2 support currently being broken.
  • Loading branch information...
1 parent f3eb454 commit b9460ac699e1c013c9660e6bf5066e3b45232919 @natescherer committed Aug 28, 2010
View
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>apn_on_rails</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ </buildSpec>
+ <natures>
+ <nature>org.radrails.rails.core.railsnature</nature>
+ </natures>
+</projectDescription>
View
@@ -2,15 +2,15 @@
Gem::Specification.new do |s|
s.name = %q{apn_on_rails}
- s.version = "0.3.0.20090731235503"
+ s.version = "0.3.1rails3"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["markbates"]
- s.date = %q{2009-07-31}
+ s.date = %q{2010-08-28}
s.description = %q{apn_on_rails was developed by: markbates}
s.email = %q{mark@markbates.com}
s.extra_rdoc_files = ["README", "LICENSE"]
- s.files = ["lib/apn_on_rails/apn_on_rails.rb", "lib/apn_on_rails/app/models/apn/base.rb", "lib/apn_on_rails/app/models/apn/device.rb", "lib/apn_on_rails/app/models/apn/notification.rb", "lib/apn_on_rails/libs/connection.rb", "lib/apn_on_rails/libs/feedback.rb", "lib/apn_on_rails/tasks/apn.rake", "lib/apn_on_rails/tasks/db.rake", "lib/apn_on_rails.rb", "lib/apn_on_rails_tasks.rb", "README", "LICENSE", "generators/apn_migrations_generator.rb", "generators/templates/apn_migrations/001_create_apn_devices.rb", "generators/templates/apn_migrations/002_create_apn_notifications.rb", "generators/templates/apn_migrations/003_alter_apn_devices.rb"]
+ s.files = ["lib/apn_on_rails/apn_on_rails.rb", "lib/apn_on_rails/app/models/apn/base.rb", "lib/apn_on_rails/app/models/apn/device.rb", "lib/apn_on_rails/app/models/apn/notification.rb", "lib/apn_on_rails/libs/connection.rb", "lib/apn_on_rails/libs/feedback.rb", "lib/apn_on_rails/tasks/apn.rake", "lib/apn_on_rails/tasks/db.rake", "lib/apn_on_rails.rb", "lib/apn_on_rails_tasks.rb", "README", "LICENSE", "lib/generators/apn_on_rails/apn_migrations_generator.rb", "lib/generators/apn_on_rails/templates/001_create_apn_devices.rb", "lib/generators/apn_on_rails/templates/002_create_apn_notifications.rb", "lib/generators/apn_on_rails/templates/003_alter_apn_devices.rb"]
s.homepage = %q{http://www.metabates.com}
s.require_paths = ["lib"]
s.rubyforge_project = %q{magrathea}
@@ -1,31 +0,0 @@
-require 'rails_generator'
-# Generates the migrations necessary for APN on Rails.
-# This should be run upon install and upgrade of the
-# APN on Rails gem.
-#
-# $ ruby script/generate apn_migrations
-class ApnMigrationsGenerator < Rails::Generator::Base
-
- def manifest # :nodoc:
- record do |m|
- timestamp = Time.now.utc.strftime("%Y%m%d%H%M%S")
- db_migrate_path = File.join('db', 'migrate')
-
- m.directory(db_migrate_path)
-
- Dir.glob(File.join(File.dirname(__FILE__), 'templates', 'apn_migrations', '*.rb')).sort.each_with_index do |f, i|
- f = File.basename(f)
- f.match(/\d+\_(.+)/)
- timestamp = timestamp.succ
- if Dir.glob(File.join(db_migrate_path, "*_#{$1}")).empty?
- m.file(File.join('apn_migrations', f),
- File.join(db_migrate_path, "#{timestamp}_#{$1}"),
- {:collision => :skip})
- end
- end
-
- end # record
-
- end # manifest
-
-end # ApnMigrationsGenerator
@@ -4,6 +4,7 @@
module ApnOnRails
class Railtie < Rails::Railtie
+ root_path = File.expand_path(File.join(File.dirname(__FILE__), '../..'))
initializer 'configuration' do |app|
configatron.apn.set_default(:passphrase, '')
configatron.apn.set_default(:port, 2195)
@@ -25,6 +26,9 @@ class Railtie < Rails::Railtie
configatron.apn.feedback.set_default(:cert, configatron.apn.cert)
end
end
+ generators do
+ require File.join(root_path, 'lib/generators/apn_on_rails/apn_migrations_generator')
+ end
end
end
@@ -0,0 +1,31 @@
+require 'rails/generators/active_record'
+
+# Generates the migrations necessary for APN on Rails.
+# This should be run upon install and upgrade of the
+# APN on Rails gem.
+#
+# $ rails g apn_migrations
+
+class ApnMigrationsGenerator < Rails::Generators::Base
+ argument :name, :default => "migration"
+ include Rails::Generators::Migration
+
+ def self.source_root
+ @source_root ||= File.join(File.dirname(__FILE__), 'templates')
+ end
+
+ def self.next_migration_number(dirname)
+ if ActiveRecord::Base.timestamped_migrations
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
+ else
+ "%.3d" % (current_migration_number(dirname) + 1)
+ end
+ end
+
+ def create_migrations
+ migration_template '001_create_apn_devices.rb', 'db/migrate/001_create_apn_devices.rb'
+ migration_template '002_create_apn_notifications.rb', 'db/migrate/002_create_apn_notifications.rb'
+ migration_template '003_alter_apn_devices.rb', 'db/migrate/003_alter_apn_devices.rb'
+ end
+
+end # ApnMigrationsGenerator

0 comments on commit b9460ac

Please sign in to comment.