Class: Bookmarker::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/bookmarker/install_generator.rb,
lib/generators/bookmarker/bookmarker_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/generators/bookmarker/install_generator.rb', line 21

def self.next_migration_number(dirname)
  if ActiveRecord::Base.timestamped_migrations
    Time.new.utc.strftime("%Y%m%d%H%M%S")
  else
    "%.3d" % (current_migration_number(dirname) + 1)
  end
end

.ormObject



13
14
15
# File 'lib/generators/bookmarker/install_generator.rb', line 13

def self.orm
  Rails::Generators.options[:rails][:orm]
end

.orm_has_migration?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/generators/bookmarker/install_generator.rb', line 17

def self.orm_has_migration?
  [:active_record].include? orm
end

.source_rootObject



17
18
19
# File 'lib/generators/bookmarker/bookmarker_generator.rb', line 17

def self.source_root
  File.join(File.dirname(__FILE__), 'templates', (orm.to_s unless orm.class.eql?(String)) )
end

Instance Method Details

#copy_migrationObject



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

def copy_migration
    migration_template 'migration.rb', 'db/migrate/create_bookmarks_table.rb'
end

#create_migration_fileObject



33
34
35
# File 'lib/generators/bookmarker/bookmarker_generator.rb', line 33

def create_migration_file
    migration_template 'migration.rb', 'db/migrate/create_bookmarks_table.rb'
end