Class: Flex::SetupGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/flex/setup/setup_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details



7
8
9
# File 'lib/generators/flex/setup/setup_generator.rb', line 7

def self.banner
  "rails generate flex:setup"
end

Instance Method Details

#add_config_flex_fileObject



17
18
19
# File 'lib/generators/flex/setup/setup_generator.rb', line 17

def add_config_flex_file
  template 'flex_config.yml', Rails.root.join('config', 'flex.yml')
end

#ask_base_nameObject



11
12
13
14
15
# File 'lib/generators/flex/setup/setup_generator.rb', line 11

def ask_base_name
  @module_name   = Prompter.ask('Please, enter a class name for your Search class. Choose a name not defined in your app.',
                                :default => 'FlexSearch', :hint => '[<enter>=FlexSearch]')
  @extender_name = "#{@module_name}Extender"
end

#create_flex_dirObject



25
26
27
28
29
# File 'lib/generators/flex/setup/setup_generator.rb', line 25

def create_flex_dir
  template 'flex_dir/es.rb.erb',          Rails.root.join('app', 'flex', "#{@module_name.underscore}.rb")
  template 'flex_dir/es.yml.erb',         Rails.root.join('app', 'flex', "#{@module_name.underscore}.yml")
  template 'flex_dir/es_extender.rb.erb', Rails.root.join('app', 'flex', "#{@extender_name.underscore}.rb")
end

#create_initializer_fileObject



21
22
23
# File 'lib/generators/flex/setup/setup_generator.rb', line 21

def create_initializer_file
  template 'flex_initializer.rb.erb', Rails.root.join('config', 'initializers', 'flex.rb')
end

#show_setup_messageObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/generators/flex/setup/setup_generator.rb', line 32

def show_setup_message
  Prompter.say "\n  Setup done!\n\n  During prototyping, remember also:\n\n    1. each time you include a new Flex::ModelIndexer\n       you should add its name to the config.flex_model in \"config/initializers/flex.rb\"\n\n    2. each time you include a new Flex::ActiveModel\n       you should add its name to the config.flex_active_model in \"config/initializers/flex.rb\"\n\n    3. each time you add/change a flex.parent relation you should reindex\n\n  The complete documentation is available at https://github.com/ddnexus/flex-doc/doc\n  If you have any problem with Flex, please report the issue at https://github.com/ddnexus/flex/issues.\n  text\nend\n", :style => :green