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

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

Instance Method Summary collapse

Methods included from Command

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

Constructor Details

#initialize(*args) ⇒ Create

Returns a new instance of Create.



232
233
234
235
236
237
238
239
# File 'lib/nesta/commands.rb', line 232

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



246
247
248
249
250
251
252
253
254
255
# File 'lib/nesta/commands.rb', line 246

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



241
242
243
244
# File 'lib/nesta/commands.rb', line 241

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