Sha256: a0c00abf366161b032b8b6125dd22b5f93342b6d0f6f48ddf963a3e6f07ff11b

Contents?: true

Size: 1.5 KB

Versions: 9

Compression:

Stored size: 1.5 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 generate_cms_seeds
    directory 'db/cms_seeds', 'db/cms_seeds'
  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

9 entries across 9 versions & 2 rubygems

Version Path
comfortable_mexican_sofa-1.0.51 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.0.50 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.0.49 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.0.48 lib/generators/cms_generator.rb
lucy_cms-0.0.1 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.0.47 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.0.46 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.0.45 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.0.44 lib/generators/cms_generator.rb