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(name, options = {}) ⇒ Create

Returns a new instance of Create.



137
138
139
140
141
142
# File 'lib/nesta/commands.rb', line 137

def initialize(name, options = {})
  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



149
150
151
152
153
154
155
# File 'lib/nesta/commands.rb', line 149

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

#make_directoriesObject



144
145
146
147
# File 'lib/nesta/commands.rb', line 144

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