class UsZipcode::ModelsGenerator
Public Class Methods
new(*args, &block)
click to toggle source
Calls superclass method
# File lib/generators/us_zipcode/models_generator.rb, line 7 def initialize(*args, &block) super migration_template 'migration.rb', "db/migrate/create_us_zipcode_models.rb" end
next_migration_number(dirname)
click to toggle source
Implement the required interface for Rails::Generators::Migration. taken from github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
# File lib/generators/us_zipcode/models_generator.rb, line 28 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
add_gems()
click to toggle source
# File lib/generators/us_zipcode/models_generator.rb, line 16 def add_gems add_gem "mocha", :group => :test end
create_models()
click to toggle source
# File lib/generators/us_zipcode/models_generator.rb, line 20 def create_models template 'zipcode_model.rb', "app/models/zipcode.rb" template 'county_model.rb', "app/models/county.rb" template 'state_model.rb', "app/models/state.rb" end
create_rakefile()
click to toggle source
# File lib/generators/us_zipcode/models_generator.rb, line 36 def create_rakefile template 'zipcodes.rake', "lib/tasks/zipcodes.rake" end
generate_models()
click to toggle source
# File lib/generators/us_zipcode/models_generator.rb, line 12 def generate_models # puts ">>> generate_zipcodes:" end