Class: Maglev::SectionGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Maglev::SectionGenerator
- Defined in:
- lib/generators/maglev/section_generator.rb
Defined Under Namespace
Classes: BlockSetting, SectionSetting
Instance Attribute Summary collapse
-
#blocks ⇒ Object
readonly
Returns the value of attribute blocks.
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#section_name ⇒ Object
readonly
Returns the value of attribute section_name.
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
-
#theme_name ⇒ Object
readonly
Returns the value of attribute theme_name.
Instance Method Summary collapse
- #build_settings ⇒ Object
- #create_section_files ⇒ Object
- #select_category ⇒ Object
- #set_section_name ⇒ Object
- #verify_categories_exist ⇒ Object
- #verify_theme_exists ⇒ Object
Instance Attribute Details
#blocks ⇒ Object (readonly)
Returns the value of attribute blocks.
13 14 15 |
# File 'lib/generators/maglev/section_generator.rb', line 13 def blocks @blocks end |
#category ⇒ Object (readonly)
Returns the value of attribute category.
13 14 15 |
# File 'lib/generators/maglev/section_generator.rb', line 13 def category @category end |
#section_name ⇒ Object (readonly)
Returns the value of attribute section_name.
13 14 15 |
# File 'lib/generators/maglev/section_generator.rb', line 13 def section_name @section_name end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
13 14 15 |
# File 'lib/generators/maglev/section_generator.rb', line 13 def settings @settings end |
#theme_name ⇒ Object (readonly)
Returns the value of attribute theme_name.
13 14 15 |
# File 'lib/generators/maglev/section_generator.rb', line 13 def theme_name @theme_name end |
Instance Method Details
#build_settings ⇒ Object
37 38 39 40 |
# File 'lib/generators/maglev/section_generator.rb', line 37 def build_settings @settings = extract_section_settings @blocks = extract_blocks end |
#create_section_files ⇒ Object
42 43 44 |
# File 'lib/generators/maglev/section_generator.rb', line 42 def create_section_files directory 'app' end |
#select_category ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/generators/maglev/section_generator.rb', line 27 def select_category @category = ['category'] return if @category.present? && categories.include?(@category) say 'You have to select a category for your section. Please check your Maglev theme.yml file to manage them.', :blue @category = ask 'Please choose a category', limited_to: categories, default: categories.first end |
#set_section_name ⇒ Object
15 16 17 |
# File 'lib/generators/maglev/section_generator.rb', line 15 def set_section_name @section_name = ['name'] || file_name.humanize end |
#verify_categories_exist ⇒ Object
23 24 25 |
# File 'lib/generators/maglev/section_generator.rb', line 23 def verify_categories_exist raise Thor::Error, set_color('ERROR: You must add categories to your theme.', :red) if categories.blank? end |
#verify_theme_exists ⇒ Object
19 20 21 |
# File 'lib/generators/maglev/section_generator.rb', line 19 def verify_theme_exists raise Thor::Error, set_color('ERROR: You must first create a theme.', :red) if theme.nil? end |