Class: Omen::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
ActiveRecord::Generators::Migration
Defined in:
lib/generators/omen/install/install_generator.rb

Overview

Everything installing this gem writes into a host: three migrations and one initializer. Not the roles or the database function, which are a rake task, because a copy of those would drift from what the gem goes on to expect and nothing would detect it.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_pathsArray<String>

Both, since the migrations are shipped where they run from rather than as templates.

Returns:

  • (Array<String>)

    where a file being copied is looked for.



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

def self.source_paths
  [ File.expand_path('templates', __dir__), Omen::Engine.root.join('db/migrate').to_s ]
end

Instance Method Details

#copy_initializervoid

This method returns an undefined value.



26
27
28
# File 'lib/generators/omen/install/install_generator.rb', line 26

def copy_initializer
  template 'omen.rb', 'config/initializers/omen.rb'
end

#copy_migrationsvoid

This method returns an undefined value.

Copied rather than read off the gem, so the host owns the files and their timestamps.



19
20
21
22
23
# File 'lib/generators/omen/install/install_generator.rb', line 19

def copy_migrations
  Dir.children(Omen::Engine.root.join('db/migrate')).sort.each do |name|
    migration_template name, "db/migrate/#{name.split('_', 2).last}"
  end
end