class GeoQuery::ResourceGenerator

Public Class Methods

next_migration_number(dirname) click to toggle source
# File lib/generators/geo_query/resource/resource_generator.rb, line 15
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

Public Instance Methods

copy_migrations() click to toggle source
# File lib/generators/geo_query/resource/resource_generator.rb, line 8
def copy_migrations
  copy_migration("add_coordinates_to", name.underscore)

  puts "added coordinates to #{name}"
  puts "rake db:migrate"
end

Private Instance Methods

copy_migration(file, name) click to toggle source
# File lib/generators/geo_query/resource/resource_generator.rb, line 25
def copy_migration(file, name)
  filename = "#{file}_#{name}"
  if self.class.migration_exists?("db/migrate", "#{filename}")
    say_status("skipped", "Migration #{filename}.rb already exists")
  else
    migration_template "#{file}.rb.erb", "db/migrate/#{filename}.rb"
  end
end