-#!/usr/bin/ruby
-=begin
-Copyright 2008 Grégory Burri
-
-This file is part of Euphorik.
-
-Euphorik is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-Euphorik is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Euphorik. If not, see <http://www.gnu.org/licenses/>.
-=end
+#!/usr/bin/ruby\r
+# coding: utf8\r
+=begin\r
+Copyright 2008 Grégory Burri\r
+\r
+This file is part of Euphorik.\r
+\r
+Euphorik is free software: you can redistribute it and/or modify\r
+it under the terms of the GNU General Public License as published by\r
+the Free Software Foundation, either version 3 of the License, or\r
+(at your option) any later version.\r
+\r
+Euphorik is distributed in the hope that it will be useful,\r
+but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License\r
+along with Euphorik. If not, see <http://www.gnu.org/licenses/>.\r
+=end\r
\r
#TODO :\r
-# - mettre à jour les numéros de versions en appelant le script "cope_num_version.rb"\r
-# - création de unit tests (voir eunit) et validation avant la mise en prod
-
-# Utilisation :
-# tools.rb <commande> <args>
-# commandes :
-# \r
+# - mettre à jour les numéros de versions (créer une classe)\r
+# - création de unit tests (voir eunit) et validation avant la mise en prod\r
+# - faire une classe qui vérifie tous les js avec jslint\r
+\r
+# Classe permettant la vérification du code JS pas jslint.\r
+# Passe en revu chaque fichier js de manière récursive à partir d'un dossier de départ.s\r
+class VerifJS \r
+ \r
+ def initialize(dossier)\r
+ @dossier = dossier\r
+ end\r
+ \r
+ def verifier\r
+ verifierRecu(@dossier)\r
+ end\r
+ \r
+ def verifierRecu(dossier)\r
+ Dir.foreach(dossier){|fichier|\r
+ if fichier != '.' and fichier != '..' and File.directory?(fichier) and fichier != 'dirs'\r
+ if not verifierRecu(dossier + '/' + fichier)\r
+ return false\r
+ end\r
+ elsif fichier[-3, 3] == '.js'\r
+ puts "== Vérification de #{dossier}/#{fichier} =="\r
+ system("java org.mozilla.javascript.tools.shell.Main jslint.js #{dossier}/#{fichier}")\r
+ if $?.exitstatus > 0\r
+ return false\r
+ end\r
+ end\r
+ }\r
+ return true\r
+ end\r
+end\r
+\r
+\r
\r
class MiseEnProd\r
@@rep_remote = '/var/www/euphorik'\r
@@host = 'euphorik.ch'\r
@@opt_rsync = ''\r
\r
- def initialize \r
+ def initialize \r
end \r
\r
def creer_remote_rep(rep) \r
end\r
\r
def creer_repertoire_bd \r
- # création du repertoire BD\r
+ # création du repertoire BD\r
creer_remote_rep('BD')\r
creer_remote_rep('BD/backup')\r
`ssh #{@@host} "chmod g+w #{@@rep_remote}/BD"`\r
end\r
\r
# css, images, html, etc..\r
- def copier_partie_statique
- copier_fichier_html("index.yaws")
-
- ####print `rsync #{$opt_rsync} index.yaws #{$host}:#{$rep_remote}`\r
- #print `rsync #{$opt_rsync} favicon.ico #{$host}:#{$rep_remote}`\r
- #print `rsync #{$opt_rsync} -r css #{$host}:#{$rep_remote}`\r
- #print `rsync #{$opt_rsync} -r pages #{$host}:#{$rep_remote}`\r
- #print `rsync #{$opt_rsync} -r --exclude 'autres' img #{$host}:#{$rep_remote}` \r
- end
-
- # Copie un fichier html, enlève les balises qui ont comme attribut : prod="delete"
- def copier_fichier_htm(fichier)
-
+ def copier_partie_statique \r
+ print `rsync #{$opt_rsync} index.yaws #{$host}:#{$rep_remote}`\r
+ print `rsync #{$opt_rsync} favicon.ico #{$host}:#{$rep_remote}`\r
+ print `rsync #{$opt_rsync} -r css #{$host}:#{$rep_remote}`\r
+ print `rsync #{$opt_rsync} -r pages #{$host}:#{$rep_remote}`\r
+ print `rsync #{$opt_rsync} -r --exclude 'autres' img #{$host}:#{$rep_remote}` \r
end\r
\r
- # contrôle des fichiers js à l'aide de jslint\r
- # @return false si une erreur est survenue durant la vérification\r
- def check_js\r
- \r
- end\r
-\r
# minification et package des fichiers js dans euphorik.js\r
def pack_js\r
# copie des js avec minification\r
end\r
\r
def maj\r
- # execution du script de mise à jour\r
+ # execution du script de mise à jour\r
print `cat tools/mise_en_prod.erl | ssh #{$host} "cat > /tmp/mise_en_prod.erl"`\r
print `ssh #{$host} "chmod u+x /tmp/mise_en_prod.erl; /tmp/mise_en_prod.erl; rm /tmp/mise_en_prod.erl"`\r
end\r
-end
+end\r
+\r
+\r
+v = VerifJS.new("../js")\r
+v.verifier()
\ No newline at end of file