On this page
Module: Padrino::Generators::Actions
Overview
Common actions needed to support project and component generation.
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary
#already_exists?(name, project_name = nil) ⇒ Boolean
Returns true if constant name already exists.#app_skeleton(app, tiny = false) ⇒ Object
Generates standard and tiny applications within a project.#apply_component_for(choice, component) ⇒ Object
Returns the related module for a given component and option.#apply_default_fields(fields) ⇒ Array<String>
Apply default field types.#check_app_existence(app) ⇒ Object
Raise SystemExit if the app does not exist.#destination_root(*paths) ⇒ String
Returns the root for this Thor class (also aliased as destination root).#empty_directory_with_keep_file(destination, config = {}) ⇒ Object
Creates an empty directory with .keep file.#execute_component_setup(component, choice) ⇒ Object
Performs the necessary generator for a given component choice.#fetch_app_name(app = 'app') ⇒ String
Returns the app_name for the application at root.#fetch_component_choice(component) ⇒ String
Returns the component choice stored within the .component file of an application.#fetch_project_name(app = 'app') ⇒ String
Returns the namespace for the project.#in_app_root? ⇒ Boolean
Returns true if inside a Padrino application.#include_component_module_for(component, choice = nil) ⇒ Object
Includes the component module for the given component and choice.#initializer(name, data = nil) ⇒ Object
Registers and creates initializer.#inject_into_file(destination, *args, &block) ⇒ Object
Avoids editing destination file if it does not exist.#insert_hook(include_text, where) ⇒ Object
Inserts an hook before or after load in our boot.rb.#insert_into_gemfile(name, options = {}) ⇒ Object
Inserts a required gem into the Gemfile to add the bundler dependency.#insert_middleware(include_text, app = nil) ⇒ Object
Inserts a middleware inside app.rb.#invalid_fields(fields) ⇒ Array<String>
Returns the field with an unacceptable name(for symbol) else returns nil.#keep_file(destination) ⇒ Object
Creates an empty .keep file.#middleware(name, source) ⇒ Object
Creates and inserts middleware.#recognize_path ⇒ Object
Recognizes the path of application.#require_contrib(contrib) ⇒ Object
Insert the regired gem and add in boot.rb custom contribs.#require_dependencies(*gem_names) ⇒ Object
Adds all the specified gems into the Gemfile for bundler.#resolve_valid_choice(component) ⇒ String
Prompts the user if necessary until a valid choice is returned for the component.#retrieve_component_config(target) ⇒ Hash
Loads the component config back into a hash.#run_bundler ⇒ Object
Run the bundler.#store_component_choice(key, value) ⇒ Symbol
Set the component choice in the .component file of the application.#store_component_config(destination, opts = {}) ⇒ Object
Creates a component_config file at the destination containing all component options.#test? ⇒ Boolean
Return true if our project has test component.#tiny? ⇒ Boolean
Return true if we have a tiny skeleton.#valid_choice?(component, choice) ⇒ Boolean
Returns true if the option passed is a valid choice for component.#valid_constant?(name) ⇒ Exception
Ensures that project name is valid, else raise an NameError.#validate_namespace(name) ⇒ Object
Validates namespace name (controller name, etc.) or fails with an error.
Instance Method Details
#already_exists?(name, project_name = nil) ⇒ Boolean
Returns true if constant name already exists.
#app_skeleton(app, tiny = false) ⇒ Object
Generates standard and tiny applications within a project.
#apply_component_for(choice, component) ⇒ Object
Returns the related module for a given component and option.
#apply_default_fields(fields) ⇒ Array<String>
Apply default field types.
#check_app_existence(app) ⇒ Object
Raise SystemExit if the app does not exist.
#destination_root(*paths) ⇒ String
Returns the root for this Thor class (also aliased as destination root).
#empty_directory_with_keep_file(destination, config = {}) ⇒ Object
Creates an empty directory with .keep file
#execute_component_setup(component, choice) ⇒ Object
Performs the necessary generator for a given component choice.
#fetch_app_name(app = 'app') ⇒ String
Returns the app_name for the application at root.
#fetch_component_choice(component) ⇒ String
Returns the component choice stored within the .component file of an application.
#fetch_project_name(app = 'app') ⇒ String
Returns the namespace for the project.
#in_app_root? ⇒ Boolean
Returns true if inside a Padrino application.
#include_component_module_for(component, choice = nil) ⇒ Object
Includes the component module for the given component and choice. It determines the choice using .components file.
#initializer(name, data = nil) ⇒ Object
Registers and creates initializer.
#inject_into_file(destination, *args, &block) ⇒ Object
Avoids editing destination file if it does not exist.
#insert_hook(include_text, where) ⇒ Object
Inserts an hook before or after load in our boot.rb.
#insert_into_gemfile(name, options = {}) ⇒ Object
Inserts a required gem into the Gemfile to add the bundler dependency.
#insert_middleware(include_text, app = nil) ⇒ Object
Inserts a middleware inside app.rb.
#invalid_fields(fields) ⇒ Array<String>
Returns the field with an unacceptable name(for symbol) else returns nil.
#keep_file(destination) ⇒ Object
Creates an empty .keep file
#middleware(name, source) ⇒ Object
Creates and inserts middleware.
#recognize_path ⇒ Object
Recognizes the path of application.
#require_contrib(contrib) ⇒ Object
Insert the regired gem and add in boot.rb custom contribs.
#require_dependencies(*gem_names) ⇒ Object
Adds all the specified gems into the Gemfile for bundler.
#resolve_valid_choice(component) ⇒ String
Prompts the user if necessary until a valid choice is returned for the component.
#retrieve_component_config(target) ⇒ Hash
Loads the component config back into a hash.
#run_bundler ⇒ Object
Run the bundler.
#store_component_choice(key, value) ⇒ Symbol
Set the component choice in the .component file of the application.
#store_component_config(destination, opts = {}) ⇒ Object
Creates a component_config file at the destination containing all component options. Content is a YAMLized version of a hash containing component name mapping to chosen value.
#test? ⇒ Boolean
Return true if our project has test component.
#tiny? ⇒ Boolean
Return true if we have a tiny skeleton.
#valid_choice?(component, choice) ⇒ Boolean
Returns true if the option passed is a valid choice for component.
#valid_constant?(name) ⇒ Exception
Ensures that project name is valid, else raise an NameError.
#validate_namespace(name) ⇒ Object
Validates namespace name (controller name, etc.) or fails with an error.
© 2010–2020 Padrino
Licensed under the MIT License.
https://www.rubydoc.info/github/padrino/padrino-framework/Padrino/Generators/Actions