Class: Tennpipes::Generators::Mailer
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Tennpipes::Generators::Mailer
- Includes:
- Actions, Components::Actions, Thor::Actions
- Defined in:
- lib/tennpipes-init/generators/mailer.rb
Overview
Responsible for the generating mailers and message definitions.
Class Method Summary collapse
Instance Method Summary collapse
-
#create_mailer ⇒ Object
Execute mailer generation.
Methods included from Components::Actions
#controller_actions, #create_helper_files, #current_migration_number, #indent_spaces, #insert_mocking_include, #insert_test_suite_setup, #migration_exist?, #output_migration_file, #output_model_migration, #remove_migration, #return_last_migration_number
Methods included from Actions
#already_exists?, #app_skeleton, #apply_component_for, #apply_default_fields, #ask, #check_app_existence, #destination_root, #empty_directory_with_keep_file, #execute_component_setup, #fetch_app_name, #fetch_component_choice, #fetch_project_name, #in_app_root?, #include_component_module_for, included, #initializer, #inject_into_file, #insert_hook, #insert_into_gemfile, #insert_middleware, #invalid_fields, #keep_file, #middleware, #recognize_path, #require_contrib, #require_dependencies, #resolve_valid_choice, #retrieve_component_config, #run_bundler, #store_component_choice, #store_component_config, #test?, #tiny?, #valid_choice?, #valid_constant?
Class Method Details
.banner ⇒ Object
11 |
# File 'lib/tennpipes-init/generators/mailer.rb', line 11 def self.; 'tennpipes-init mailer [name]'; end |
.source_root ⇒ Object
10 |
# File 'lib/tennpipes-init/generators/mailer.rb', line 10 def self.source_root; File.(File.dirname(__FILE__)); end |
Instance Method Details
#create_mailer ⇒ Object
Execute mailer generation.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/tennpipes-init/generators/mailer.rb', line 32 def create_mailer self.destination_root = [:root] if in_app_root? app = [:app] check_app_existence(app) self.behavior = :revoke if [:destroy] @project_name = [:namespace].underscore.camelize @project_name = fetch_project_name(app) if @project_name.empty? @app_name = fetch_app_name(app) @actions = actions.map(&:to_sym) @short_name = name.to_s.gsub(/_mailer/i, '').underscore.downcase @mailer_basename = @short_name.underscore template "templates/mailer.rb.tt", destination_root(app, 'mailers', "#{@mailer_basename}.rb") empty_directory destination_root(app, 'views', 'mailers', @mailer_basename) else say 'You are not at the root of a Tennpipes application! (config/boot.rb not found)' end end |