Created
July 16, 2010 14:51
-
-
Save ayumin/478453 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# -*- coding: utf-8 -*- | |
require "optparse" | |
require "yaml" | |
require "kconv" | |
=begin | |
conf = {} | |
OptionParser.new do |opt| | |
opt.on("-p PACKAGES_YML","--packages") do |v| | |
conf[:packages_yml] = v | |
end | |
opt.on("-d DIRECTORY") do |v| | |
conf[:out_dir] = v || "doc" | |
end | |
opt.parse!(ARGV) | |
end | |
p conf | |
p ARGV[0] | |
__END__ | |
=end | |
class Packages | |
def initialize(yaml_file) | |
packages = YAML.load(yaml_file) | |
@@table = {} | |
packages.each do |key, values| | |
values.each do |value| | |
@@table[value] = key | |
end | |
end | |
end | |
def self.[](key) | |
@@table[key] | |
end | |
end | |
def convert(infile_path, outfile_path) | |
File.open(infile_path) do |infile| | |
package_name = Packages[infile] ||"other" | |
File.open(outfile_path,"w") do |outfile| | |
outfile.puts "package com.accenture.forcefactory.#{package_name};".tosjis | |
outfile.puts "import java.util.*;".tosjis | |
# | |
outline = infile.read.gsub(%r{\"},%q{\\\"}).gsub(%r{\'},%q{"}) | |
outline = outline.gsub(/virtual with sharing/, '') | |
outfile.puts(outline.tosjis) | |
end | |
end | |
end | |
begin | |
p "******" | |
Dir.mkdir("doc") | |
Dir.mkdir("tmp") | |
rescue | |
end | |
Packages.new(<<_YAML_) | |
Abstract: | |
- AbstractCSVFile.cls | |
_YAML_ | |
Dir.foreach(ARGV[0]) do |path| | |
if path =~ /cls$/ | |
p "#{ARGV[0]}\\#{path}" | |
p "tmp\\#{path.sub(/cls$/,'java')}" | |
convert("#{ARGV[0]}\\#{path}","tmp\\#{path.sub(/cls$/,'java')}") | |
end | |
end | |
system "set CLASSPATH" | |
system "javadoc -d doc tmp\\*.java" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment