Class: Sourced::Rails::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
ActiveRecord::Generators::Migration
Defined in:
lib/sourced/rails/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#copy_bin_fileObject



37
38
39
40
# File 'lib/sourced/rails/install_generator.rb', line 37

def copy_bin_file
  copy_file 'bin_sourced', 'bin/sourced'
  chmod 'bin/sourced', 0o755
end

#copy_initializer_fileObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/sourced/rails/install_generator.rb', line 15

def copy_initializer_file
  create_file 'config/initializers/sourced.rb' do
    "      # frozen_string_literal: true\n\n      require 'sourced'\n      require 'sourced/backends/active_record_backend'\n\n      # This table prefix is used to generate the initial database migrations.\n      # If you change the table prefix here,\n      # make sure to migrate your database to the new table names.\n      Sourced::Backends::ActiveRecordBackend.table_prefix = '\#{table_prefix}'\n\n      # Configure Sors to use the ActiveRecord backend\n      Sourced.configure do |config|\n        config.backend = Sourced::Backends::ActiveRecordBackend.new\n        config.logger = Rails.logger\n      end\n    CONTENT\n  end\nend\n"

#create_migration_fileObject



42
43
44
# File 'lib/sourced/rails/install_generator.rb', line 42

def create_migration_file
  migration_template 'create_sourced_tables.rb.erb', File.join(db_migrate_path, 'create_sourced_tables.rb')
end