From 49cbfec38ddc8d5264969022a38d8d78c441e64b Mon Sep 17 00:00:00 2001
From: Alexandre Morignot <erdnaxeli@cervoi.se>
Date: Mon, 16 Feb 2015 12:32:28 +0100
Subject: [PATCH] no more FindBin

---
 Sam.pl                                | 19 +++++-----
 {lib => Sam}/Logging.pm               |  2 +-
 {lib => Sam}/commands/add.pm          |  2 +-
 {lib => Sam}/commands/addUser.pm      |  2 +-
 {lib => Sam}/commands/edit.pm         |  2 +-
 {lib => Sam}/commands/getUsers.pm     |  2 +-
 {lib => Sam}/commands/list.pm         |  2 +-
 {lib => Sam}/commands/parser.pm       | 53 +++++++++++++--------------
 {lib => Sam}/sites/parser.pm          | 16 ++++----
 {lib => Sam}/sites/residentadvisor.pm |  2 +-
 10 files changed, 49 insertions(+), 53 deletions(-)
 rename {lib => Sam}/Logging.pm (99%)
 rename {lib => Sam}/commands/add.pm (95%)
 rename {lib => Sam}/commands/addUser.pm (97%)
 rename {lib => Sam}/commands/edit.pm (97%)
 rename {lib => Sam}/commands/getUsers.pm (97%)
 rename {lib => Sam}/commands/list.pm (98%)
 rename {lib => Sam}/commands/parser.pm (79%)
 rename {lib => Sam}/sites/parser.pm (77%)
 rename {lib => Sam}/sites/residentadvisor.pm (94%)

diff --git a/Sam.pl b/Sam.pl
index f609ebd..c2aceeb 100755
--- a/Sam.pl
+++ b/Sam.pl
@@ -9,12 +9,11 @@ use JSON;
 use Module::Reload;
 use FindBin;
 
-use lib "$FindBin::Bin/lib/";
-use Logging;
-use commands::parser;
-use sites::parser;
+use Sam::Logging;
+use Sam::commands::parser;
+use Sam::sites::parser;
 
-my $log = Logging->new('STDOUT', 1);
+my $log = Sam::Logging->new('STDOUT', 1);
 
 # config
 my $serveur = 'IRC.iiens.net';
@@ -78,8 +77,8 @@ sub cycle
 
 sub setConf 
 {
-    commands::parser::setConf($nick, $irc, $dbh, $log, \%lastID);
-    sites::parser::setConf($nick, $irc, $dbh, $log, \%lastID);
+    Sam::commands::parser::setConf($nick, $irc, $dbh, $log, \%lastID);
+    Sam::sites::parser::setConf($nick, $irc, $dbh, $log, \%lastID);
 }
 
 
@@ -125,7 +124,7 @@ sub on_query
     my @args = ($kernel, $user, \@fake_chan, $msg);
 
     my $fake_chan = \@fake_chan;
-    return if (commands::parser::exec(@args));
+    return if (Sam::commands::parser::exec(@args));
 
 	if ($msg =~ m/^!/ && $nick eq $admin) {
 		my $commande = ( $msg =~ m/^!([^ ]*)/ )[0]; 
@@ -162,8 +161,8 @@ sub on_speak
 
 	my ($nick,$mask) = split(/!/,$user);
 
-    commands::parser::exec(@args);
-    sites::parser::exec(@args);
+    Sam::commands::parser::exec(@args);
+    Sam::sites::parser::exec(@args);
 }
 
 # Boucle des events
diff --git a/lib/Logging.pm b/Sam/Logging.pm
similarity index 99%
rename from lib/Logging.pm
rename to Sam/Logging.pm
index 6b7085b..e3d7cf1 100644
--- a/lib/Logging.pm
+++ b/Sam/Logging.pm
@@ -1,4 +1,4 @@
-package Logging;
+package Sam::Logging;
 
 # ==============[ Classe pour gérer les logs correctement ]============== #
 #  Date : 29/10/2010                                                      #
diff --git a/lib/commands/add.pm b/Sam/commands/add.pm
similarity index 95%
rename from lib/commands/add.pm
rename to Sam/commands/add.pm
index 964dffc..922c1ac 100644
--- a/lib/commands/add.pm
+++ b/Sam/commands/add.pm
@@ -1,4 +1,4 @@
-package commands::add;
+package Sam::commands::add;
 
 require Exporter;
 our @ISA = qw(Exporter);
diff --git a/lib/commands/addUser.pm b/Sam/commands/addUser.pm
similarity index 97%
rename from lib/commands/addUser.pm
rename to Sam/commands/addUser.pm
index 77a5eed..acfa6e1 100644
--- a/lib/commands/addUser.pm
+++ b/Sam/commands/addUser.pm
@@ -1,4 +1,4 @@
-package commands::addUser;
+package Sam::commands::addUser;
 
 require Exporter;
 our @ISA = qw(Exporter);
diff --git a/lib/commands/edit.pm b/Sam/commands/edit.pm
similarity index 97%
rename from lib/commands/edit.pm
rename to Sam/commands/edit.pm
index 22e8729..9781940 100644
--- a/lib/commands/edit.pm
+++ b/Sam/commands/edit.pm
@@ -1,4 +1,4 @@
-package commands::edit;
+package Sam::Sam::commands::edit;
 
 require Exporter;
 our @ISA = qw(Exporter);
diff --git a/lib/commands/getUsers.pm b/Sam/commands/getUsers.pm
similarity index 97%
rename from lib/commands/getUsers.pm
rename to Sam/commands/getUsers.pm
index 9d537cd..ac80daa 100644
--- a/lib/commands/getUsers.pm
+++ b/Sam/commands/getUsers.pm
@@ -1,4 +1,4 @@
-package commands::getUsers;
+package Sam::commands::getUsers;
 
 our $dbh;
 our $log;
diff --git a/lib/commands/list.pm b/Sam/commands/list.pm
similarity index 98%
rename from lib/commands/list.pm
rename to Sam/commands/list.pm
index 9d6a62d..a01826d 100644
--- a/lib/commands/list.pm
+++ b/Sam/commands/list.pm
@@ -1,4 +1,4 @@
-package commands::list;
+package Sam::commands::list;
 
 require Exporter;
 our @ISA = qw(Exporter);
diff --git a/lib/commands/parser.pm b/Sam/commands/parser.pm
similarity index 79%
rename from lib/commands/parser.pm
rename to Sam/commands/parser.pm
index 64dabda..a35257a 100644
--- a/lib/commands/parser.pm
+++ b/Sam/commands/parser.pm
@@ -1,4 +1,4 @@
-package commands::parser;
+package Sam::commands::parser;
 
 require Exporter;
 our @ISA = qw(Exporter);
@@ -6,12 +6,11 @@ our @EXPORT_OK = qw(exec);
 
 use strict;
 
-use lib "$FindBin::Bin/lib/";
-use commands::add;
-use commands::list;
-use commands::addUser;
-use commands::edit;
-use commands::getUsers;
+use Sam::commands::add;
+use Sam::commands::list;
+use Sam::commands::addUser;
+use Sam::commands::edit;
+use Sam::commands::getUsers;
 
 my $nick;
 my $irc;
@@ -20,22 +19,22 @@ my $lastID;
 sub setConf {
     my ($nickNew, $ircNew, $dbh, $log, $lastIDnew) = @_;
 
-    $commands::add::dbh = $dbh;
-    $commands::list::dbh = $dbh;
-    $commands::addUser::dbh = $dbh;
-    $commands::edit::dbh = $dbh;
-    $commands::getUsers::dbh = $dbh;
+    $Sam::commands::add::dbh = $dbh;
+    $Sam::commands::list::dbh = $dbh;
+    $Sam::commands::addUser::dbh = $dbh;
+    $Sam::commands::edit::dbh = $dbh;
+    $Sam::commands::getUsers::dbh = $dbh;
 
-    $commands::add::log = $log;
-    $commands::list::log = $log;
-    $commands::addUser::log = $log;
-    $commands::edit::log = $log;
-    $commands::getUsers::log = $log;
+    $Sam::commands::add::log = $log;
+    $Sam::commands::list::log = $log;
+    $Sam::commands::addUser::log = $log;
+    $Sam::commands::edit::log = $log;
+    $Sam::commands::getUsers::log = $log;
 
-    $commands::list::irc = $ircNew;
-    $commands::addUser::irc = $ircNew;
-    $commands::edit::irc = $ircNew;
-    $commands::getUsers::irc = $ircNew;
+    $Sam::commands::list::irc = $ircNew;
+    $Sam::commands::addUser::irc = $ircNew;
+    $Sam::commands::edit::irc = $ircNew;
+    $Sam::commands::getUsers::irc = $ircNew;
 
     $nick = $nickNew;
     $irc = $ircNew;
@@ -67,7 +66,7 @@ sub exec {
 
         $place =~ s/ $//;
 
-        my $id = commands::add::exec($title, $day, $month, $year, $place, $desc);
+        my $id = Sam::commands::add::exec($title, $day, $month, $year, $place, $desc);
         
         if ($id) {
             $lastID->{$chan->[0]} = $id;
@@ -79,23 +78,23 @@ sub exec {
         my $command = $2;
         my $arg = $3;
 
-        commands::edit::exec($id, $command, $arg, $chan);
+        Sam::commands::edit::exec($id, $command, $arg, $chan);
     }
     elsif ($msg =~ /^Sam(?:,|:) +j'y +vais/) {
-        commands::addUser::exec($nick, $lastID->{$chan->[0]}, $chan);
+        Sam::commands::addUser::exec($nick, $lastID->{$chan->[0]}, $chan);
     }
     elsif ($msg =~ /^Sam(?:,|:) +je +vais +à +la +(\d+)/) {
-        commands::addUser::exec($nick, $1, $chan);
+        Sam::commands::addUser::exec($nick, $1, $chan);
     }
     elsif ($msg =~ /^Sam(?:,|:) +qui +va +à +la +(\d+) +?/) {
-        my $id = commands::getUsers::exec($chan->[0], $1);
+        my $id = Sam::commands::getUsers::exec($chan->[0], $1);
 
         if ($id) {
             $lastID->{$chan->[0]} = $id;
         }
     }
     elsif ($msg =~ /^Sam(?:,|:) +liste/) {
-        commands::list::exec($chan);
+        Sam::commands::list::exec($chan);
     }
     elsif ($msg =~ /^Sam(?:,|:) +(help|aide)/) {
 		$irc->yield(privmsg => $nick => 'Sam: <titre de la soirée> le jj/mm/aa @ <salle/lieu> : <description>');
diff --git a/lib/sites/parser.pm b/Sam/sites/parser.pm
similarity index 77%
rename from lib/sites/parser.pm
rename to Sam/sites/parser.pm
index 442ed29..579c7d7 100644
--- a/lib/sites/parser.pm
+++ b/Sam/sites/parser.pm
@@ -1,4 +1,4 @@
-package sites::parser;
+package Sam::sites::parser;
 
 require Exporter;
 our @ISA = qw(Exporter);
@@ -6,12 +6,10 @@ our @EXPORT_OK = qw(exec);
 
 use strict;
 
-use lib "$FindBin::Bin/lib/";
-use commands::add;
-use commands::edit;
+use Sam::commands::add;
+use Sam::commands::edit;
 
-use lib "$FindBin::Bin/lib/sites";
-use residentadvisor;
+use Sam::sites::residentadvisor;
 
 my $nick;
 my $irc;
@@ -33,13 +31,13 @@ sub exec {
     my $id;
 
     if ($msg =~ /^Sam(?:,|:) +https?:\/\/(?:www.residentadvisor.net\/event.aspx\?)([0-9]+)/) {
-        eval { %content = residentadvisor::get($1) };
+        eval { %content = Sam::sites::residentadvisor::get($1) };
 	}
     else {
         return 0;
     }
 
-    $id = commands::add::exec(
+    $id = Sam::commands::add::exec(
             $content{'title'},
             $content{'day'},
             $content{'month'},
@@ -57,7 +55,7 @@ sub exec {
         );
     }
 
-    commands::edit::exec($id, 'url', $content{'url'}, $chan);
+    Sam::commands::edit::exec($id, 'url', $content{'url'}, $chan);
 
     return 1;
 }
diff --git a/lib/sites/residentadvisor.pm b/Sam/sites/residentadvisor.pm
similarity index 94%
rename from lib/sites/residentadvisor.pm
rename to Sam/sites/residentadvisor.pm
index be868b7..0284d5a 100644
--- a/lib/sites/residentadvisor.pm
+++ b/Sam/sites/residentadvisor.pm
@@ -1,4 +1,4 @@
-package residentadvisor;
+package Sam::sites::residentadvisor;
 
 use Inline Python => 'DATA';
 
-- 
GitLab