Class: Tennpipes::Generators::Component
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Tennpipes::Generators::Component
- Includes:
- Actions, Tennpipes::Generators::Components::Actions, Thor::Actions
- Defined in:
- lib/tennpipes-init/generators/component.rb
Overview
Responsible for add components within a Tennpipes project.
Class Method Summary collapse
Instance Method Summary collapse
-
#setup_components ⇒ Object
For each component, retrieve a valid choice and then execute the associated generator.
Methods included from Tennpipes::Generators::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
12 |
# File 'lib/tennpipes-init/generators/component.rb', line 12 def self.; "tennpipes-init component [options]"; end |
.source_root ⇒ Object
11 |
# File 'lib/tennpipes-init/generators/component.rb', line 11 def self.source_root; File.(File.dirname(__FILE__)); end |
Instance Method Details
#setup_components ⇒ Object
For each component, retrieve a valid choice and then execute the associated generator.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/tennpipes-init/generators/component.rb', line 29 def setup_components self.destination_root = [:root] if in_app_root? @_components = .dup.slice(*self.class.component_types) @app_name = ([:app] || "App").gsub(/\W/, '_').camelize if @_components.values.delete_if(&:blank?).empty? self.class.start(["-h"]) say say "Current Selected Components:" list = [] self.class.component_types.each do |comp| list << [comp, fetch_component_choice(comp)] end print_table(list, :indent => 2) exit end self.class.component_types.each do |comp| next if @_components[comp].blank? choice = @_components[comp] = resolve_valid_choice(comp) existing = fetch_component_choice(comp) if existing != 'none' && existing != choice next unless yes?("Switch #{comp} to '#{choice}' from '#{existing}' ?[yes/no]:") end @project_name = fetch_component_choice(:namespace) if comp.to_s == 'test' && !already_exists?(@app_name, @project_name) say "#{@project_name}::#{@app_name} does not exist." say "Please, change app name." next end execute_component_setup(comp, choice) store_component_choice(comp, choice) if comp.to_s == 'orm' && choice.to_s != 'none' inject_into_file destination_root('Rakefile'), "TennpipesTasks.use(:database)\n", :before => "TennpipesTasks.init" inject_into_file destination_root('Rakefile'), "TennpipesTasks.use(#{choice.to_sym.inspect})\n", :before => "TennpipesTasks.init" end end else say 'You are not at the root of a Tennpipes application! (config/boot.rb not found)' end end |