Module: Styleyt::StyleytHelper

Included in:
PreviewGenerator, ThemeGenerator
Defined in:
lib/generators/styleyt/styleyt_helper.rb

Constant Summary collapse

SASS_TEMPLATES_DIRECTORY =

Path to the sass template directory

'../../../templates/stylesheets'
PREVIEW_DIRECTORY =

Path to the preview directory

'../../../templates/preview'
COMPILED_PREVIEW_DIRECTORY =
PREVIEW_DIRECTORY + '/compiled'
HAML_FILES =
'*.haml'
SASS_FILES =
'*.s[c|a]ss'

Instance Method Summary collapse

Instance Method Details

#ask_for_themeObject

Asks which theme should be used



22
23
24
25
26
27
# File 'lib/generators/styleyt/styleyt_helper.rb', line 22

def ask_for_theme
  theme = ask "Available themes: #{available_themes}\nWhich theme would you like to install?"
  theme = 'default' if theme.empty?

  theme
end

#available_themesObject

Returns the available themes



32
33
34
35
36
# File 'lib/generators/styleyt/styleyt_helper.rb', line 32

def available_themes
  Dir.chdir(File.join(File.dirname(__FILE__), SASS_TEMPLATES_DIRECTORY, 'themes')) do
    Dir.glob("*").join(',')
  end
end

#remove_file_suffix(file) ⇒ Object

Returns the filename without any extensions



56
57
58
# File 'lib/generators/styleyt/styleyt_helper.rb', line 56

def remove_file_suffix(file)
  file.split('.').first
end

#src_root_dirObject

Returns the source route directory



48
49
50
# File 'lib/generators/styleyt/styleyt_helper.rb', line 48

def src_root_dir
  File.join(File.dirname(__FILE__), SASS_TEMPLATES_DIRECTORY)
end

#theme_directory(theme) ⇒ Object

Returns the theme directories



41
42
43
# File 'lib/generators/styleyt/styleyt_helper.rb', line 41

def theme_directory(theme)
  File.join(File.dirname(__FILE__), SASS_TEMPLATES_DIRECTORY, 'themes', theme)
end