Class: Nesta::Commands::Theme::Create

Inherits:
Object
  • Object
show all
Includes:
Command
Defined in:
lib/nesta/commands/theme/create.rb

Instance Method Summary collapse

Methods included from Command

#copy_template, #copy_templates, #fail, #run_process, #template_root, #update_config_yaml

Constructor Details

#initialize(*args) ⇒ Create


9
10
11
12
13
14
15
16
# File 'lib/nesta/commands/theme/create.rb', line 9

def initialize(*args)
  name = args.shift
  options = args.shift || {}
  name.nil? && (raise UsageError.new('name not specified'))
  @name = name
  @theme_path = Nesta::Path.themes(@name)
  fail("#{@theme_path} already exists") if File.exist?(@theme_path)
end

Instance Method Details

#executeObject


23
24
25
26
27
28
29
30
31
32
# File 'lib/nesta/commands/theme/create.rb', line 23

def execute
  make_directories
  copy_templates(
    'themes/README.md' => "#{@theme_path}/README.md",
    'themes/app.rb' => "#{@theme_path}/app.rb",
    'themes/views/layout.haml' => "#{@theme_path}/views/layout.haml",
    'themes/views/page.haml' => "#{@theme_path}/views/page.haml",
    'themes/views/master.sass' => "#{@theme_path}/views/master.sass"
  )
end

#make_directoriesObject


18
19
20
21
# File 'lib/nesta/commands/theme/create.rb', line 18

def make_directories
  FileUtils.mkdir_p(File.join(@theme_path, 'public', @name))
  FileUtils.mkdir_p(File.join(@theme_path, 'views'))
end