ADD FIX#3
[euphorik.git] / tools / tools.rb
index 2a5a1fe..ec0950e 100644 (file)
@@ -1,5 +1,5 @@
 #!/usr/bin/ruby\r
-# coding: utf8\r
+# coding: utf-8\r
 =begin\r
 Copyright 2008 Grégory Burri\r
 \r
@@ -52,6 +52,33 @@ class VerifJS
       }\r
       return true\r
    end\r
+end
+
+# Classe de gestion de la version
+class Version    
+   # @param dossier la racine du site (par exemple "/var/www/euphorik"
+   def initialize(dossier)
+      @dossier = dossier
+      File.open(@dossier + '/VERSION') {|file|
+         @version = file.readline()
+      }
+      # les fichiers HTML dans lesquels mettre à jour la version
+      @fichiers  = ['/pages/about.html']
+      @balise = /(<span.+?class.*?=.*?"version".*?>).*?(<\/span>)/
+   end
+   
+   # met à jour la version dans les fichiers @fichiers
+   def  maj   
+      @fichiers.each{|fichier|
+         fichier = @dossier + fichier
+         lines = IO.readlines(fichier)
+         File.open(fichier, 'w') {|io|
+            lines.each{|l|
+               io.write(l.sub(@balise){|m| $1 + @version + $2})
+            }
+         }   
+      }
+   end
 end\r
 \r
 \r
@@ -130,5 +157,8 @@ class MiseEnProd
 end\r
 \r
 \r
-v = VerifJS.new("../js")\r
-v.verifier()
\ No newline at end of file
+#verifJS = VerifJS.new("../js")\r
+#verifJS.verifier()
+
+#version = Version.new("..")
+#version.maj()