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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/generators/instance/instance_generator.rb', line 38
def manifest
md5 = Digest::MD5.new
now = Time.now
md5 << now.to_s
md5 << String(now.usec)
md5 << String(rand(0))
md5 << String($$)
md5 << @app_name
secret = ActiveSupport::SecureRandom.hex(64)
root = File.expand_path(SPREE_ROOT)
script_options = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] }
dispatcher_options = { :chmod => 0755, :shebang => options[:shebang] }
record do |m|
m.directory ""
base_dirs = %w(config config/environments config/initializers db log script public vendor/plugins vendor/extensions)
text_files = %w(CHANGELOG CONTRIBUTORS LICENSE INSTALL README.markdown)
environments = Dir["#{root}/config/environments/*.rb"]
scripts = Dir["#{root}/script/**/*"].reject { |f| f =~ /(destroy|generate)$/ }
public_files = ["public/.htaccess.example"] + Dir["#{root}/public/**/*"]
frozen_gems = Dir["#{root}/vendor/gems/**/*"]
files = base_dirs + text_files + environments + scripts + public_files + frozen_gems
files.map! { |f| f = $1 if f =~ %r{^#{root}/(.+)$}; f }
files.sort!
files.each do |file|
case
when File.directory?("#{root}/#{file}")
m.directory file
when file =~ %r{^script/}
m.file spree_root(file), file, script_options
when file =~ %r{^public/dispatch}
m.file spree_root(file), file, dispatcher_options
when file =~ %r{^public/robots\.txt}
m.file spree_root(file), file unless options[:demo]
else
m.file spree_root(file), file
end
end
m.file "instance_generate", "script/generate", script_options
m.template "databases/#{options[:db]}.yml", "config/database.yml", :assigns => {
:app_name => File.basename(File.expand_path(@destination_root)),
:socket => options[:db] == "mysql" ? mysql_socket_location : nil
}
m.file "instance_rakefile", "Rakefile"
m.file "instance_routes.rb", "config/routes.rb"
m.file "../../../../db/seeds.rb", "db/seeds.rb"
m.template "../../../../config/environment.rb", "config/environment.rb", :assigns => { :app_name => @app_name, :app_secret_key_to_be_replaced_in_real_app_by_generator => secret }
m.file "../../../../config/boot.rb", "config/boot.rb"
m.template "session_store.rb", "config/initializers/session_store.rb", :assigns => { :app_name => @app_name, :app_secret_key_to_be_replaced_in_real_app_by_generator => secret }
%w{backtrace_silencers inflections locales mime_types new_rails_defaults paperclip spree compass}.each do |initializer|
m.file "../../../../config/initializers/#{initializer}.rb", "config/initializers/#{initializer}.rb"
end
m.file "../../../../config/spree_permissions.yml", "config/spree_permissions.yml"
if options[:demo]
m.file "demo_mongrel_cluster.yml", "config/mongrel_cluster.yml"
m.file "demo_robots.txt", "public/robots.txt"
end
end
end
|