Class: Awestruct::Commands::Init

Inherits:
Object
  • Object
show all
Defined in:
lib/awestruct/commands/init.rb

Constant Summary

BASE_MANIFEST =
Manifest.new {

Instance Method Summary (collapse)

Constructor Details

- (Init) initialize(dir = Dir.pwd, framework = 'compass', scaffold = true)

A new instance of Init



16
17
18
19
20
# File 'lib/awestruct/commands/init.rb', line 16

def initialize(dir=Dir.pwd,framework='compass',scaffold=true)
  @dir       = dir
  @framework = framework
  @scaffold  = scaffold
end

Instance Method Details

- (Object) run



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/awestruct/commands/init.rb', line 22

def run()
  manifest = Manifest.new( BASE_MANIFEST )
  manifest.install_compass( @framework )
  scaffold_name = ( @framework == 'compass' ? 'blueprint' : @framework )
  if ( @scaffold )
    manifest.copy_file( '_layouts/base.html.haml', File.join( File.dirname(__FILE__), "/frameworks/#{scaffold_name}/base_layout.html.haml" ) )
    if ( File.file? File.join( File.dirname(__FILE__), "/frameworks/#{scaffold_name}/base_index.html.haml" ) )
      manifest.copy_file( 'index.html.haml', File.join( File.dirname(__FILE__), "/frameworks/#{scaffold_name}/base_index.html.haml" ) )
    else
      manifest.copy_file( 'index.html.haml', File.join( File.dirname(__FILE__), "/frameworks/base_index.html.haml" ) )
    end
    manifest.touch_file( '_config/site.yml' )
  end
  manifest.perform( @dir )
end