Class: ParlezGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration, Thor::Actions
Defined in:
lib/generators/parlez_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



33
34
35
36
37
# File 'lib/generators/parlez_generator.rb', line 33

def self.next_migration_number(dirname)
  orm = Rails.configuration.generators.options[:rails][:orm]
  require "rails/generators/#{orm}"
  "#{orm.to_s.camelize}::Generators::Base".constantize.next_migration_number(dirname)
end

Instance Method Details

#generate_initializationObject



25
26
27
# File 'lib/generators/parlez_generator.rb', line 25

def generate_initialization
  copy_file 'config/initializers/parlez.rb', 'config/initializers/parlez.rb'
end

#generate_migrationObject



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/generators/parlez_generator.rb', line 8

def generate_migration
  destination   = File.expand_path('db/migrate/01_setup_parlez.rb', self.destination_root)
  migration_dir = File.dirname(destination)
  destination   = self.class.migration_exists?(migration_dir, 'setup_parlez')

  if destination
    puts "\e[0m\e[31mFound an existing setup_parlez.rb migration. Manually remove it to re-create it.\e[0m"
  else
    migration_template 'db/migrate/01_setup_parlez.rb', 'db/migrate/setup_parlez.rb'
  end
end

#generate_public_assetsObject



20
21
22
23
# File 'lib/generators/parlez_generator.rb', line 20

def generate_public_assets
  directory 'public/stylesheets/sass/parlez'
  directory 'public/javascripts/parlez'
end

#show_readmeObject



29
30
31
# File 'lib/generators/parlez_generator.rb', line 29

def show_readme
  readme 'lib/generators/README'
end