読者です 読者をやめる 読者になる 読者になる

MTASC用

Ruby

最近rubyをさわっていないのでリハビリ。newproject.rb

#==================================================
# newproject.rb
#

require 'pathname'
require 'fileutils'

# project name input
print "Input project name: "
project_name = STDIN.readline.split(" ")[0]

project = Pathname.pwd + project_name
# make project
if ( project.exist?) 
   puts "Project #{project_name} is exist!"
else
  puts "Create Project: #{project_name}"
  FileUtils.mkdir(project_name, {:verbose => true})
  FileUtils.cd(project.to_s, {:verbose => true}) {|dir|

    puts "create #{project.basename.to_s + ".as"}"
    open(project.basename.to_s + ".as", "w+") {|file|
      file.puts "/*============================================================"
      file.puts " * File: #{project.basename.to_s + ".as"}"
      file.puts " */"
      file.puts ""
      file.puts "class #{project.basename.to_s} {"
      file.puts "    static function main() {"
      file.puts "    }"
      file.puts "}"
    }

    puts "create compile.bat"
    open("compile.bat", "w+") {|file|
      file.puts "mtasc -swf #{project.basename.to_s}.swf -main -header 800:600:20 #{project.basename.to_s}.as"
    }
  }
  puts "Create Project Successed."
end
print "Please Enter: "
STDIN.readline

まだ26日扱いなのか!