Class: Elastics::SetupGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Elastics::SetupGenerator
- Defined in:
- lib/generators/elastics/setup/setup_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_config_elastics_file ⇒ Object
- #ask_base_name ⇒ Object
- #create_elastics_dir ⇒ Object
- #create_initializer_file ⇒ Object
- #show_setup_message ⇒ Object
Class Method Details
.banner ⇒ Object
5 6 7 |
# File 'lib/generators/elastics/setup/setup_generator.rb', line 5 def self. "rails generate elastics:setup" end |
Instance Method Details
#add_config_elastics_file ⇒ Object
15 16 17 |
# File 'lib/generators/elastics/setup/setup_generator.rb', line 15 def add_config_elastics_file template 'elastics_config.yml', Rails.root.join('config', 'elastics.yml') end |
#ask_base_name ⇒ Object
9 10 11 12 13 |
# File 'lib/generators/elastics/setup/setup_generator.rb', line 9 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 => 'Elasticsearch', :hint => '[<enter>=Elasticsearch]') @extender_name = "#{@module_name}Extender" end |
#create_elastics_dir ⇒ Object
23 24 25 26 27 |
# File 'lib/generators/elastics/setup/setup_generator.rb', line 23 def create_elastics_dir template 'elastics_dir/elastics.rb.erb', Rails.root.join('app', 'elastics', "#{@module_name.underscore}.rb") template 'elastics_dir/elastics.yml.erb', Rails.root.join('app', 'elastics', "#{@module_name.underscore}.yml") template 'elastics_dir/elastics_extender.rb.erb', Rails.root.join('app', 'elastics', "#{@extender_name.underscore}.rb") end |
#create_initializer_file ⇒ Object
19 20 21 |
# File 'lib/generators/elastics/setup/setup_generator.rb', line 19 def create_initializer_file template 'elastics_initializer.rb.erb', Rails.root.join('config', 'initializers', 'elastics.rb') end |
#show_setup_message ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/generators/elastics/setup/setup_generator.rb', line 30 def Prompter.say "\n Setup done!\n\n During prototyping, remember also:\n\n 1. each time you include a new Elastics::ModelIndexer\n you should add its name to the config.elastics_model in \"config/initializers/elastics.rb\"\n\n 2. each time you include a new Elastics::ActiveModel\n you should add its name to the config.elastics_active_model in \"config/initializers/elastics.rb\"\n\n 3. each time you add/change a elastics.parent relation you should reindex\n\n The complete documentation is available at https://github.com/elastics/elastics-doc/doc\n If you have any problem with Elastics, please report the issue at https://github.com/elastics/elastics/issues.\n text\nend\n", :style => :green |