1 #!/usr/bin/env ruby
2
3 require 'yaml'
4 require 'json'
5
6 puts "Content-Type: text/plain"
7 puts
8
9 if not $root2
10 $root2 = "../.."
11 end
12
13 $version_data_dir = $root2 + "/data/versions"
14
15 def get_last_version
16 x = Dir.new($version_data_dir).each.to_a.sort do |a, b| a.to_i <=> b.to_i end
17 return x.last.to_i
18 end
19
20 def get_version_info version
21 y = YAML.load_file($version_data_dir + "/" + version + ".yaml")
22 # return JSON.generate y
23 return y
24 end
25
26 version_num = get_version_info(get_last_version.to_s);
27
28 puts version_num["version"]
29 #puts version_num["linux_version_short"]
30 #puts get_last_version
31
32 #cmd = $cgi['c']
33
34 #if cmd == "get_last_version"
35 # puts get_last_version
36 #elsif cmd == "get_version_info"
37 # puts get_version_info(get_last_version.to_s)
38 #end
~
感觉ruby还是挺厉害的语言0.0