Class: Releaf::Generators::InstallGenerator

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

Direct Known Subclasses

Dummy::Generators::InstallGenerator

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(path) ⇒ Object


10
11
12
13
14
15
16
17
18
# File 'lib/generators/releaf/install_generator.rb', line 10

def self.next_migration_number(path)
  unless @prev_migration_nr
    @prev_migration_nr =  ActiveRecord::Generators::Base.next_migration_number(path).to_i
  else
    @prev_migration_nr += 1
  end

  @prev_migration_nr.to_s
end

Instance Method Details

#install_buildersObject


57
58
59
# File 'lib/generators/releaf/install_generator.rb', line 57

def install_builders
  copy_files 'builders', 'app/builders'
end

#install_configsObject


49
50
51
# File 'lib/generators/releaf/install_generator.rb', line 49

def install_configs
  copy_files 'config', 'config'
end

#install_controllersObject


61
62
63
# File 'lib/generators/releaf/install_generator.rb', line 61

def install_controllers
  copy_files 'controllers', 'app/controllers'
end

#install_deviseObject


22
23
24
25
26
27
28
# File 'lib/generators/releaf/install_generator.rb', line 22

def install_devise
  # prevent dummy app from installing devise one more time
  if self.class == Releaf::Generators::InstallGenerator
    generate "devise:install"
    generate "dragonfly"
  end
end

#install_initializerObject


30
31
32
# File 'lib/generators/releaf/install_generator.rb', line 30

def install_initializer
  copy_files 'initializers', 'config/initializers'
end

#install_migrationsObject


34
35
36
37
38
# File 'lib/generators/releaf/install_generator.rb', line 34

def install_migrations
  get_file_list('migrations').each do |migration|
    migration_template "migrations/#{migration}", "db/migrate/#{migration}"
  end
end

#install_modelsObject


45
46
47
# File 'lib/generators/releaf/install_generator.rb', line 45

def install_models
  copy_files 'models', 'app/models'
end

#install_seedsObject


40
41
42
43
# File 'lib/generators/releaf/install_generator.rb', line 40

def install_seeds
  seed_path = File.expand_path('../templates', __FILE__) + "/seeds/seeds.rb"
  append_to_file 'db/seeds.rb', File.read(seed_path)
end

#install_viewsObject


53
54
55
# File 'lib/generators/releaf/install_generator.rb', line 53

def install_views
  copy_files 'views', 'app/views'
end