Class: Rails::AppBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/rails/generators/rails/app/app_generator.rb

Instance Method Summary collapse

Instance Method Details

#appObject



55
56
57
# File 'lib/rails/generators/rails/app/app_generator.rb', line 55

def app
  directory 'app'
end

#configObject



59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/rails/generators/rails/app/app_generator.rb', line 59

def config
  empty_directory "config"

  inside "config" do
    template "routes.rb"
    template "application.rb"
    template "environment.rb"

    directory "environments"
    directory "initializers"
    directory "locales"
  end
end

#configruObject



47
48
49
# File 'lib/rails/generators/rails/app/app_generator.rb', line 47

def configru
  template "config.ru"
end

#database_ymlObject



73
74
75
# File 'lib/rails/generators/rails/app/app_generator.rb', line 73

def database_yml
  template "config/databases/#{@options[:database]}.yml", "config/database.yml"
end

#dbObject



77
78
79
# File 'lib/rails/generators/rails/app/app_generator.rb', line 77

def db
  directory "db"
end

#docObject



81
82
83
# File 'lib/rails/generators/rails/app/app_generator.rb', line 81

def doc
  directory "doc"
end

#gemfileObject



43
44
45
# File 'lib/rails/generators/rails/app/app_generator.rb', line 43

def gemfile
  template "Gemfile"
end

#gitignoreObject



51
52
53
# File 'lib/rails/generators/rails/app/app_generator.rb', line 51

def gitignore
  copy_file "gitignore", ".gitignore"
end

#imagesObject



105
106
107
# File 'lib/rails/generators/rails/app/app_generator.rb', line 105

def images
  directory "public/images"
end

#javascriptsObject



113
114
115
116
117
118
119
120
# File 'lib/rails/generators/rails/app/app_generator.rb', line 113

def javascripts
  unless options[:skip_prototype]
    directory "public/javascripts"
  else
    empty_directory_with_gitkeep "public/javascripts"
    create_file "public/javascripts/application.js"
  end
end

#libObject



85
86
87
88
# File 'lib/rails/generators/rails/app/app_generator.rb', line 85

def lib
  empty_directory "lib"
  empty_directory_with_gitkeep "lib/tasks"
end

#logObject



90
91
92
93
94
95
96
97
98
99
# File 'lib/rails/generators/rails/app/app_generator.rb', line 90

def log
  empty_directory "log"

  inside "log" do
    %w( server production development test ).each do |file|
      create_file "#{file}.log"
      chmod "#{file}.log", 0666, :verbose => false
    end
  end
end

#public_directoryObject



101
102
103
# File 'lib/rails/generators/rails/app/app_generator.rb', line 101

def public_directory
  directory "public", "public", :recursive => false
end

#rakefileObject



35
36
37
# File 'lib/rails/generators/rails/app/app_generator.rb', line 35

def rakefile
  template "Rakefile"
end

#readmeObject



39
40
41
# File 'lib/rails/generators/rails/app/app_generator.rb', line 39

def readme
  copy_file "README"
end

#scriptObject



122
123
124
125
126
127
# File 'lib/rails/generators/rails/app/app_generator.rb', line 122

def script
  directory "script" do |content|
    "#{shebang}\n" + content
  end
  chmod "script", 0755, :verbose => false
end

#stylesheetsObject



109
110
111
# File 'lib/rails/generators/rails/app/app_generator.rb', line 109

def stylesheets
  empty_directory_with_gitkeep "public/stylesheets"
end

#testObject



129
130
131
# File 'lib/rails/generators/rails/app/app_generator.rb', line 129

def test
  directory "test"
end

#tmpObject



133
134
135
136
137
138
139
140
141
# File 'lib/rails/generators/rails/app/app_generator.rb', line 133

def tmp
  empty_directory "tmp"

  inside "tmp" do
    %w(sessions sockets cache pids).each do |dir|
      empty_directory(dir)
    end
  end
end

#vendor_pluginsObject



143
144
145
# File 'lib/rails/generators/rails/app/app_generator.rb', line 143

def vendor_plugins
  empty_directory_with_gitkeep "vendor/plugins"
end