Sha256: 0db2db2bd9347c2efa9d646b3476df8eddb6fb0bd704d44dc84d4222a10d8166

Contents?: true

Size: 1.96 KB

Versions: 45

Compression:

Stored size: 1.96 KB

Contents

class CmsGenerator < Rails::Generators::Base
  
  require 'rails/generators/active_record'
  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
    return if ComfortableMexicanSofa.asset_pipeline_enabled?
    directory 'app/assets/stylesheets/comfortable_mexican_sofa',  'public/stylesheets/comfortable_mexican_sofa'
    directory 'app/assets/javascripts/comfortable_mexican_sofa',  'public/javascripts/comfortable_mexican_sofa'
    directory 'app/assets/images/comfortable_mexican_sofa',       'public/images/comfortable_mexican_sofa'
    
    gsub_file 'public/stylesheets/comfortable_mexican_sofa/content.css',
      '/assets/comfortable_mexican_sofa/', '/images/comfortable_mexican_sofa/'
    gsub_file 'public/stylesheets/comfortable_mexican_sofa/widgets.css',
      '/assets/comfortable_mexican_sofa/', '/images/comfortable_mexican_sofa/'
    gsub_file 'public/stylesheets/comfortable_mexican_sofa/jquery_ui.css',
      '/assets/comfortable_mexican_sofa/', '/images/comfortable_mexican_sofa/'
  end
  
  def generate_cms_seeds
    directory 'db/cms_fixtures', 'db/cms_fixtures'
  end
  
  def show_readme
    readme 'lib/generators/README'
  end
  
  def self.next_migration_number(dirname)
    ActiveRecord::Generators::Base.next_migration_number(dirname)
  end
  
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.6.2 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.6.1 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.6.0 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.5.11 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.5.10 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.5.9 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.5.8 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.5.7 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.5.6 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.5.5 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.5.4 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.5.3 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.5.2 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.5.1 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.5.0 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.4.22 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.4.21 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.4.20 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.4.19 lib/generators/cms_generator.rb
comfortable_mexican_sofa-1.4.18 lib/generators/cms_generator.rb