class DlJusyoJp::Generators::InstallGenerator
Public Class Methods
source_root()
click to toggle source
# File lib/generators/dl_jusyo_jp/install_generator.rb, line 9 def self.source_root File.expand_path("../templates", __FILE__) end
Public Instance Methods
copy_initializer()
click to toggle source
# File lib/generators/dl_jusyo_jp/install_generator.rb, line 13 def copy_initializer template '../templates/initializers/dl_jusyo_jp.rb', 'config/initializers/dl_jusyo_jp.rb' end
copy_models()
click to toggle source
# File lib/generators/dl_jusyo_jp/install_generator.rb, line 17 def copy_models Dir["#{self.class.source_root}/models/*.rb"].sort.each do |filepath| name = File.basename(filepath) to_path = 'app/models' template("models/#{name}", "#{to_path}/#{name}") end end
create_migrations()
click to toggle source
# File lib/generators/dl_jusyo_jp/install_generator.rb, line 25 def create_migrations Dir["#{self.class.source_root}/migrations/*.rb"].sort.each do |filepath| name = File.basename(filepath) to_path = 'db/migrate' # TODO: something wrong... if Dir.glob("#{to_path}/[0-9]*_*.rb").grep(/\d+_#{name}$/).blank? template("migrations/#{name}", "#{to_path}/#{Time.zone.now.strftime('%Y%m%d%H%M%S')}_#{name}") end end end