Class: Tableficate::ThemeGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/tableficate/theme/theme_generator.rb

Constant Summary collapse

VIEW_PATH =
'app/views/tableficate'

Instance Method Summary collapse

Instance Method Details

#create_themeObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/generators/tableficate/theme/theme_generator.rb', line 11

def create_theme
  empty_directory(VIEW_PATH)

  if partial
    if partial =~ /\//
      partial =~ /^(.*)\/(.*)$/
      extra_dirs   = $1
      partial_name = $2

      empty_directory("#{VIEW_PATH}/#{file_name}/#{extra_dirs}")

      copy_file("#{extra_dirs}/_#{partial_name}.html.erb", "#{VIEW_PATH}/#{file_name}/#{extra_dirs}/_#{partial_name}.html.erb")
    else
      copy_file("_#{partial}.html.erb", "#{VIEW_PATH}/#{file_name}/_#{partial}.html.erb")
    end
  else
    directory('', "#{VIEW_PATH}/#{file_name}")
  end
end