Class: TemplateGeneratorService

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#filepathObject (readonly)

Returns the value of attribute filepath.



8
9
10
# File 'app/services/template_generator_service.rb', line 8

def filepath
  @filepath
end

#themeObject (readonly)

Returns the value of attribute theme.



8
9
10
# File 'app/services/template_generator_service.rb', line 8

def theme
  @theme
end

#theme_templateObject (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

#generateObject



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