Module: Glue::Generator

Extended by:
Generator, Helper
Included in:
Generator
Defined in:
lib/glue/generator.rb

Instance Method Summary collapse

Methods included from Helper

run

Instance Method Details

#generate!(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/glue/generator.rb', line 6

def generate!(options={})
  templates = File.expand_path(File.dirname(__FILE__) + "/../../templates")
  output = File.expand_path(options[:path])
  
  # create root directory
  run "creating #{Colorize.yellow(output, :style => :underscore)} directory" do
    FileUtils.mkdir_p(output)
  end
  
  # create public directory
  run %(creating #{Colorize.yellow("public")} directory) do
    # FileUtils.mkdir_p File.join(output, "public")
  end
  
  # create javascripts directory
  run %(creating #{Colorize.yellow("public/javascripts")} directory) do
    FileUtils.mkdir_p File.join(output, "public/javascripts")
  end
  
  # create images directory
  run %(creating #{Colorize.yellow("public/images")} directory) do
    FileUtils.mkdir_p File.join(output, "public/images")
  end
  
  # create views directory
  run %(creating #{Colorize.yellow("views/layouts")} directory) do
    FileUtils.mkdir_p File.join(output, "views/layouts")
  end
  
  # create config directory
  run %(creating #{Colorize.yellow("config")} directory) do
    FileUtils.mkdir_p File.join(output, "config")
  end
  
  # copy rake file
  run %( copying #{Colorize.yellow("config/glue.yml")}) do
    FileUtils.cp File.join(templates, "glue.yml"), File.join(output, "config/glue.yml")
  end
  
  # copy stylesheet file
  run %( copying #{Colorize.yellow("views/stylesheets/style.sass")}) do
    FileUtils.mkdir_p File.join(output, "views/stylesheets")
    FileUtils.cp File.join(templates, "style.sass"), File.join(output, "views/stylesheets/style.sass")
  end
  
  # copy rake file
  run %( copying #{Colorize.yellow("Rakefile")}) do
    FileUtils.cp File.join(templates, "Rakefile"), File.join(output, "Rakefile")
  end
  
  # copy helper file
  run %( copying #{Colorize.yellow("config/helper.rb")}) do
    FileUtils.cp File.join(templates, "helper.rb"), File.join(output, "config/helper.rb")
  end
  
  # copy layout.haml
  run %( copying #{Colorize.yellow("views/layouts/main.haml")}) do
    FileUtils.cp File.join(templates, "main.haml"), File.join(output, "views/layouts/main.haml")
  end
  
  # copy index.haml
  run %( copying #{Colorize.yellow("views/index.haml")}) do
    FileUtils.cp File.join(templates, "index.haml"), File.join(output, "views/index.haml")
  end
  
  # copy 404.haml
  run %( copying #{Colorize.yellow("views/404.haml")}) do
    FileUtils.cp File.join(templates, "404.haml"), File.join(output, "views/404.haml")
  end
  
  # copy _footer.haml
  run %( copying #{Colorize.yellow("views/_footer.haml")}) do
    FileUtils.cp File.join(templates, "_footer.haml"), File.join(output, "views/_footer.haml")
  end
  
  # copy .htaccess
  run %( copying #{Colorize.yellow("public/.htaccess")}) do
    FileUtils.cp File.join(templates, "htaccess"), File.join(output, "public/.htaccess")
  end
  
  # copy robots.txt
  run %( copying #{Colorize.yellow("public/robots.txt")}) do
    FileUtils.cp File.join(templates, "robots.txt"), File.join(output, "public/robots.txt")
  end
end