Class: Awestruct::CLI::Init

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

Constant Summary collapse

BASE_MANIFEST =
Manifest.new {
  mkdir('_config')
  mkdir('_layouts')
  mkdir('_ext')
  copy_file('_ext/pipeline.rb', Init.framework_path('base_pipeline.rb'))
  copy_file('.awestruct_ignore', Init.framework_path('base_awestruct_ignore'))
  copy_file('Rakefile', Init.framework_path('base_Rakefile'))
  mkdir('stylesheets')
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Init.



24
25
26
27
28
# File 'lib/awestruct/cli/init.rb', line 24

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

Class Method Details

.framework_path(path, framework = nil) ⇒ Object



10
11
12
# File 'lib/awestruct/cli/init.rb', line 10

def self.framework_path(path, framework = nil)
  File.join [File.dirname(__FILE__), '..', 'frameworks', framework, path].compact
end

Instance Method Details

#framework_path(path, framework = nil) ⇒ Object



73
74
75
# File 'lib/awestruct/cli/init.rb', line 73

def framework_path(path, framework = nil)
  Init.framework_path path, framework
end

#runObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/awestruct/cli/init.rb', line 30

def run()
  manifest = Manifest.new(BASE_MANIFEST)
  scaffold_name = @framework
  manifest.template_file('Gemfile', Init.framework_path('base_Gemfile'), {:framework => @framework})

  lib = nil
  case @framework
    when 'compass'
      scaffold_name = 'blueprint'
    when 'bootstrap'
      lib = 'bootstrap-sass'
    when 'foundation'
      lib = 'zurb-foundation'
    when '960'
      lib = 'ninesixty'
  end
  require lib unless lib.nil?
  manifest.install_compass(@framework)
  if (@scaffold)
    manifest.copy_file('_config/site.yml', framework_path('base_site.yml'), :overwrite => true)
    manifest.copy_file('_layouts/base.html.haml', framework_path('base_layout.html.haml', scaffold_name))
    base_index = framework_path('base_index.html.haml', scaffold_name)
    if File.file? base_index
      manifest.copy_file('index.html.haml', base_index)
    else
      manifest.copy_file('index.html.haml', framework_path('base_index.html.haml'))
    end

    humans_txt = framework_path('humans.txt')
    if File.file? humans_txt
      manifest.copy_file('humans.txt', humans_txt, :overwrite => true)
    end

    manifest.touch_file('_config/site.yml')
    manifest.add_requires('_ext/pipeline.rb', [lib]) unless lib.nil?
    if scaffold_name == 'foundation'
      manifest.remove_file('index.html')
      manifest.remove_file('MIT-LICENSE.txt')
    end
  end
  manifest.perform(@dir)
end