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/browser_app_base.rb', line 34
def self.create(arg)
dir = arg[:dir]
app = arg[:app]
puts "create application base #{dir}"
FileUtils.mkdir_p dir
FileUtils.mkdir_p dir + "/lib/"
FileUtils.mkdir_p dir + "/bin/"
path = File.dirname(File.expand_path(__FILE__)) + "/../"
Dir.glob("#{path}/lib/template/*") do |f|
puts "#{f} => #{dir}/lib"
FileUtils.cp_r f, "#{dir}/lib"
end
if app
app_file = get_app_file(app)
puts "#{path}/bin/start_sample.rb #{dir}/bin/start_#{app_file}"
FileUtils.cp_r "#{path}/bin/start_sample.rb", "#{dir}/bin/start_#{app_file}"
FileUtils.cp_r "#{path}/bin/start_sample.rb", "#{dir}/bin/start_#{app_file.gsub(/rb$/,"rbw")}"
load_app = <<"EOS"
require '#{app_file}'
$app = #{get_app_name(app)}.new
EOS
File.open("#{dir}/lib/app_load.rb", "w") do |f|
f.write load_app
end
puts "create #{app_file}"
new_file = "#{dir}/lib/#{app_file}"
FileUtils.cp("#{dir}/lib/my_app_sample.rb", new_file)
buf = File.binread(new_file)
File.binwrite(new_file, buf.gsub(/MyApp/, get_app_name(app)))
end
end
|