Class: Refinery::SearchGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/refinery/search/search_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/generators/refinery/search/search_generator.rb', line 12

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

Instance Method Details

#append_load_seed_dataObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/generators/refinery/search/search_generator.rb', line 33

def append_load_seed_data
  create_file 'db/seeds.rb' unless File.exists?(File.join(destination_root, 'db', 'seeds.rb'))
  append_file 'db/seeds.rb', :verbose => true do
    <<-EOH

# Added by Refinery CMS Search engine
Refinery::Search::Engine.load_seed
    EOH
  end
end

#copy_initializerObject



29
30
31
# File 'lib/generators/refinery/search/search_generator.rb', line 29

def copy_initializer
    copy_file "03_initializer.rb", "config/initializers/refinery/search.rb"
end

#create_migration_fileObject



20
21
22
23
# File 'lib/generators/refinery/search/search_generator.rb', line 20

def create_migration_file
  migration_template '01_create_search_page.rb', 'db/migrate/create_search_page.rb'
  sleep 1
end

#pg_search_migrationObject



25
26
27
# File 'lib/generators/refinery/search/search_generator.rb', line 25

def pg_search_migration
  migration_template '02_create_pg_search_table.rb', 'db/migrate/create_pg_search_table.rb'
end