Ruby jad file generation

Jad bylų generavimas su ruby.

  1.  
  2. require 'rubygems'
  3. require 'zip/zip'
  4.  
  5. filename = "game.jar"
  6. res = [
  7. "MIDlet-Jar-URL: #{filename}",
  8. "MIDlet-Jar-Size: #{File.size(filename)}"
  9. ]
  10. valid_params = [
  11. /MIDlet-Name:/,
  12. /MIDlet-Version:/,
  13. /MIDlet-Vendor:/,
  14. /MicroEdition-Profile:/,
  15. /MicroEdition-Configuration:/,
  16. /MIDlet-\d:/
  17. ]
  18. Zip::ZipFile.open(filename) do |fs|
  19. fs.read("META-INF/MANIFEST.MF").split("\r\n").each do |line|
  20. valid_params.each do |vp|
  21. res << line if line =~ vp
  22. end
  23. end
  24. end
  25.  
  26. File.open("#{File.basename(filename, ".jar")}.jad", "wb") do |f|
  27. f.write res.join("\r\n")
  28. end
  29.  

Leave a Comment