Class: TemplateGeneratorService
- Inherits:
-
Object
- Object
- TemplateGeneratorService
- Defined in:
- app/services/template_generator_service.rb
Constant Summary collapse
- DEFAULT_LOCALE =
'en'
- FILE_EXTENSIONS =
{ css: '.css', scss: '.scss', js: '.js', yml: '.yml' }
- IMAGE_EXTENSIONS =
['.png', '.gif', '.jpeg', '.jpg']
- FONT_EXTENSIONS =
['.woff', '.ttf', '.svg', '.eot', '.woff2', '.otf']
Instance Attribute Summary collapse
-
#filepath ⇒ Object
readonly
Returns the value of attribute filepath.
-
#theme ⇒ Object
readonly
Returns the value of attribute theme.
-
#theme_template ⇒ Object
readonly
Returns the value of attribute theme_template.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(filepath, theme) ⇒ TemplateGeneratorService
constructor
A new instance of TemplateGeneratorService.
Constructor Details
#initialize(filepath, theme) ⇒ TemplateGeneratorService
Returns a new instance of TemplateGeneratorService.
10 11 12 13 14 |
# File 'app/services/template_generator_service.rb', line 10 def initialize(filepath, theme) @filepath = filepath @theme = theme @theme_template = build_template end |
Instance Attribute Details
#filepath ⇒ Object (readonly)
Returns the value of attribute filepath.
8 9 10 |
# File 'app/services/template_generator_service.rb', line 8 def filepath @filepath end |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
8 9 10 |
# File 'app/services/template_generator_service.rb', line 8 def theme @theme end |
#theme_template ⇒ Object (readonly)
Returns the value of attribute theme_template.
8 9 10 |
# File 'app/services/template_generator_service.rb', line 8 def theme_template @theme_template end |
Instance Method Details
#generate ⇒ Object
16 17 18 19 20 |
# File 'app/services/template_generator_service.rb', line 16 def generate return nil if(image_file?(filepath) || font_directory?(filepath)) theme_template.assign_attributes(template_attributes) theme_template.save end |