Class: Geocoder::Generators::Maxmind::GeoliteCountryGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Geocoder::Generators::MigrationVersion, Rails::Generators::Migration
Defined in:
lib/generators/geocoder/maxmind/geolite_country_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Geocoder::Generators::MigrationVersion

#migration_version, #rails_5?

Class Method Details

.next_migration_number(dirname) ⇒ Object

Define the next_migration_number method (necessary for the migration_template method to work)


19
20
21
22
23
24
25
26
# File 'lib/generators/geocoder/maxmind/geolite_country_generator.rb', line 19

def self.next_migration_number(dirname)
  if ActiveRecord::Base.timestamped_migrations
    sleep 1 # make sure each time we get a different timestamp
    Time.new.utc.strftime("%Y%m%d%H%M%S")
  else
    "%.3d" % (current_migration_number(dirname) + 1)
  end
end

Instance Method Details

#copy_migration_filesObject


13
14
15
# File 'lib/generators/geocoder/maxmind/geolite_country_generator.rb', line 13

def copy_migration_files
  migration_template "migration/geolite_country.rb", "db/migrate/geocoder_maxmind_geolite_country.rb"
end