Class: Atreides::Generators::AtreidesGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Atreides::Generators::AtreidesGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/atreides/atreides_generator.rb
Class Method Summary collapse
-
.next_migration_number(dirname) ⇒ Object
Implement the required interface for Rails::Generators::Migration.
- .source_root ⇒ Object
Instance Method Summary collapse
Class Method Details
.next_migration_number(dirname) ⇒ Object
Implement the required interface for Rails::Generators::Migration.
16 17 18 19 20 21 22 23 |
# File 'lib/generators/atreides/atreides_generator.rb', line 16 def self.next_migration_number(dirname) next_migration_number = current_migration_number(dirname) + 1 if ActiveRecord::Base. [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max else "%.3d" % next_migration_number end end |
.source_root ⇒ Object
11 12 13 |
# File 'lib/generators/atreides/atreides_generator.rb', line 11 def self.source_root @source_root ||= File.join(File.dirname(__FILE__), '..', 'templates') end |
Instance Method Details
#create_configuration_file ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/generators/atreides/atreides_generator.rb', line 42 def create_configuration_file copy_file 'initializer.rb', 'config/initializers/atreides.rb' copy_file 'string_extensions.rb', 'config/initializers/string_extensions.rb' copy_file 'new_relic.rb', 'config/initializers/new_relic.rb' copy_file 'unicorn.rb', 'config/unicorn.rb' copy_file 'settings.yml', 'config/settings.yml' copy_file 'oembed.yml', 'config/oembed.yml' copy_file 'delayed_job.rb', 'config/initializers/delayed_job.rb' copy_file 'Procfile', 'Procfile' gsub_file 'config/application.rb', 'config.active_record.whitelist_attributes = true', 'config.active_record.whitelist_attributes = false' remove_file 'public/index.html' remove_file 'assets/images/rails.png' end |
#create_migration_file ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/generators/atreides/atreides_generator.rb', line 25 def create_migration_file generate('acts_as_taggable_on:migration') generate('delayed_job:active_record') generate('devise:install') %w(create_videos create_photos create_orders create_posts create_pages create_likes create_messages create_features create_products create_line_items create_links create_votes create_tweets create_sessions create_sites create_content_parts add_userid_to_resources devise_create_users add_role_to_users create_preferences).each do |f| src = "#{f}.rb" dst = "db/migrate/#{src}" migration_template(src, dst) rescue puts $! end end |