Class: Opinio::Generators::InstallGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/generators/opinio/install/install_generator.rb', line 29

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

Instance Method Details

#add_dependency_gemObject



25
26
27
# File 'lib/generators/opinio/install/install_generator.rb', line 25

def add_dependency_gem
  gem "kaminari"
end

#generate_initializerObject



17
18
19
# File 'lib/generators/opinio/install/install_generator.rb', line 17

def generate_initializer
  template "initializers/opinio.erb", "config/initializers/opinio.rb"
end

#generate_migrationObject



13
14
15
# File 'lib/generators/opinio/install/install_generator.rb', line 13

def generate_migration
  migration_template "migrations/create_model.rb", "db/migrate/create_#{table_name}", {:assigns => {:name => name, :table_name => table_name}}
end

#generate_modelObject



9
10
11
# File 'lib/generators/opinio/install/install_generator.rb', line 9

def generate_model
  template "models/model.rb", "app/models/#{file_name}.rb"
end

#generate_routeObject



21
22
23
# File 'lib/generators/opinio/install/install_generator.rb', line 21

def generate_route
  route "opinio_model"
end