public
Description: Vault
Homepage: http://peervoice.com/software/vault
Clone URL: git://github.com/ddollar/vault.git
vault / script / initgeneric
100755 30 lines (24 sloc) 0.732 kb
1
2
3
4
5
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
#!/usr/bin/env ruby
require 'yaml'
 
if ARGV.length != 1
  print "usage: " + $0 + " <project name>\n"
  exit 1
end
 
project_name = ARGV[0]
project_dir = project_name.downcase
 
def file_string_replace (filename, old, new)
  print "processing: " + filename + "\n"
  data = ""
  File.open(filename) do |file|
    file.each_line do |line|
      data += line.sub(old, new)
    end
  end
  File.open(filename,"w") do |file|
    file.puts data
  end
end
 
file_string_replace("app/controllers/application.rb", "generic", project_dir)
file_string_replace("config/database.yml", "generic", project_dir)
file_string_replace("config/deploy.rb", "generic", project_dir)
file_string_replace("config/mongrel_cluster.yml", "generic", project_dir)