Sha256: b77c02e43b44839756e4bad90b84d6e14a3e6311676c8ebc18b23d3bbcf66093

Contents?: true

Size: 1.42 KB

Versions: 14

Compression:

Stored size: 1.42 KB

Contents

class CmsGenerator < Rails::Generators::Base
  
  include Rails::Generators::Migration
  include Thor::Actions
  
  source_root File.expand_path('../../..', __FILE__)
  
  def generate_migration
    destination   = File.expand_path('db/migrate/01_create_cms.rb', self.destination_root)
    migration_dir = File.dirname(destination)
    destination   = self.class.migration_exists?(migration_dir, 'create_cms')
    
    if destination
      puts "\e[0m\e[31mFound existing cms_create.rb migration. Remove it if you want to regenerate.\e[0m"
    else
      migration_template 'db/migrate/01_create_cms.rb', 'db/migrate/create_cms.rb'
    end
  end
  
  def generate_initialization
    copy_file 'config/initializers/comfortable_mexican_sofa.rb', 'config/initializers/comfortable_mexican_sofa.rb'
  end
  
  def generate_public_assets
    directory 'public/stylesheets/comfortable_mexican_sofa', 'public/stylesheets/comfortable_mexican_sofa'
    directory 'public/javascripts/comfortable_mexican_sofa', 'public/javascripts/comfortable_mexican_sofa'
    directory 'public/images/comfortable_mexican_sofa', 'public/images/comfortable_mexican_sofa'
  end
  
  def show_readme
    readme 'lib/generators/README'
  end
  
  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
  
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.0.43 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.0.42 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.0.41 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.0.40 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.0.39 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.0.38 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.0.37 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.0.36 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.0.35 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.0.34 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.0.33 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.0.32 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.0.31 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.0.30 lib/generators/cms_generator.rb