Class: Toppings::Generators::Install::GroupGenerator
- Inherits:
-
BaseGenerator
- Object
- Thor::Group
- BaseGenerator
- Toppings::Generators::Install::GroupGenerator
- Includes:
- Helper::BaseFileHelper
- Defined in:
- lib/toppings/generators/install/group_generator.rb
Overview
the GroupGenerator class provides some default behavior for a given generator, that extends the GroupGenerator.
For each groupfile a new group folder is created and a relative base file is added to it, where included templates will be registered with appropriate import statements.
Template pathes and target pathes become available by convention over the given specific classes base name, where the base name is build upon the classes name with stripped Generator suffix.
Direct Known Subclasses
FontsGenerator, HelperGenerator, LayoutsGenerator, ModulesGenerator, SettingsGenerator, SetupsGenerator
Class Method Summary collapse
-
.source_root ⇒ String
provides a path build upon the base name of a class as source root for the thor template engine.
-
.templates ⇒ Set
registered templates for a group, that will be made available in the setup.
- .with_template(file, options = {}) ⇒ Object
-
.with_templates(*files) ⇒ Array
dsl method to register certain template files, that should be made available for the specific generator.
Instance Method Summary collapse
-
#create_base_import_file ⇒ Object
creating the relative base file for a generator group and appending it to the root file located in the stylesheet root.
-
#create_template_files ⇒ Object
building templated files based on the beforehand registered template files.
Methods inherited from BaseGenerator
Methods included from Helper::PathHelper
#root_file_path, #stylesheets_path
Class Method Details
.source_root ⇒ String
provides a path build upon the base name of a class as source root for the thor template engine.
29 30 31 |
# File 'lib/toppings/generators/install/group_generator.rb', line 29 def source_root template_path.join(base_name) end |
.templates ⇒ Set
registered templates for a group, that will be made available in the setup
58 59 60 |
# File 'lib/toppings/generators/install/group_generator.rb', line 58 def templates @templates ||= Set.new end |
.with_template(file, options = {}) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/toppings/generators/install/group_generator.rb', line 42 def with_template(file, = {}) = .reverse_merge(namespaced: true) library = [:vendor_library] namespaced = [:namespaced] path = [:template_folder] Toppings::SASS_DEPENDENCIES.add(library) if library file = library && namespaced ? "#{library}.#{file}" : file.to_s file = Pathname.new(path).join(file) if path templates << file end |
.with_templates(*files) ⇒ Array
dsl method to register certain template files, that should be made available for the specific generator.
38 39 40 |
# File 'lib/toppings/generators/install/group_generator.rb', line 38 def with_templates(*files) files.each { |file| templates << file } end |
Instance Method Details
#create_base_import_file ⇒ Object
creating the relative base file for a generator group and appending it to the root file located in the stylesheet root.
65 66 67 68 |
# File 'lib/toppings/generators/install/group_generator.rb', line 65 def create_base_import_file create_file index_file_path, skip: true append_import relative_index_name, root_file_path end |
#create_template_files ⇒ Object
building templated files based on the beforehand registered template files
71 72 73 |
# File 'lib/toppings/generators/install/group_generator.rb', line 71 def create_template_files templates.each { |file| group_template_file(file) } if self.templates? end |