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

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

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Create

Returns a new instance of Create.



5
6
7
8
9
10
11
12
13
14
# File 'lib/nesta/commands/theme/create.rb', line 5

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)
  if File.exist?(@theme_path)
    Nesta.fail_with("#{@theme_path} already exists")
  end
end

Instance Method Details

#execute(process) ⇒ Object



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

def execute(process)
  make_directories
  {
    '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"
  }.each do |src, dest|
    Nesta::Commands::Template.new(src).copy_to(dest, binding)
  end
end

#make_directoriesObject



16
17
18
19
# File 'lib/nesta/commands/theme/create.rb', line 16

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