Class: Rea::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/rea/install/install_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(path) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/generators/rea/install/install_generator.rb', line 4

def self.next_migration_number(path)
  unless @prev_migration_nr
    @prev_migration_nr = Time.parse("2012-10-10").utc.strftime("%Y%m%d%H%M%S").to_i
  else
    @prev_migration_nr += 1
  end
  @prev_migration_nr.to_s
end

Instance Method Details

#copy_migrationsObject



13
14
15
16
17
18
19
# File 'lib/generators/rea/install/install_generator.rb', line 13

def copy_migrations
  base_path = Pathname.new(self.class.source_root)
  Dir[File.join(self.class.source_root, '*.rb')].each do |full_path|
    path = Pathname.new(full_path).relative_path_from(base_path).to_s
    migration_template path, "db/migrate/"+path.gsub(/\d+_([\w\d\.]+)/, '\1')
  end
end

#install_rea_initializerObject



21
22
23
24
25
26
27
# File 'lib/generators/rea/install/install_generator.rb', line 21

def install_rea_initializer
  initializer "rea.rb" do
    data = "Rea.setup do |application|\n"
    data << "end"
    data
  end
end