Skip to content
Browse files

a few cleanup fixes

  • Loading branch information...
1 parent c5f98b5 commit 4a3758362c97294004b311f3153525f0474ad54e Shmuel Fomberg committed Aug 29, 2011
Showing with 14 additions and 13 deletions.
  1. +1 −1 find_errors.pl
  2. +8 −11 fix_pandas.pl
  3. +5 −1 wordlist.pl → wordlist.pm
View
2 find_errors.pl
@@ -2,7 +2,7 @@
$| = 1;
use LWP::UserAgent;
use Text::SpellChecker;
-require('wordlist.pl');
+use wordlist qw{check_common};
my $ua = new LWP::UserAgent;
print "Hello!\n";
View
19 fix_pandas.pl
@@ -3,7 +3,7 @@
use LWP::UserAgent;
use Text::SpellChecker;
use Net::Twitter;
-require('wordlist.pl');
+use wordlist qw{fix_text check_common};
my $c = 0;
my $token = "";
@@ -54,7 +54,7 @@ sub handle_url {
my $url2 = "https://github.com/".$user."/$repo";
my $res2 = $ua->get($url2);
$c = $c+1;
- if (!$res2->is_success || ($c < 16 && $repo !~ //)) {
+ if (!$res2->is_success || (( $c < 16 ) && ( lenght($repo) > 0 ))) {
print "Missing repo $repo.\n";
my $fork_res = $ua->post("https://github.com/api/v2/json/repos/fork/$ruser/$repo",{login => $user,
token => $token});
@@ -67,16 +67,13 @@ sub handle_url {
print "runing: cd foo; git clone git\@github.com:$user/$repo.git || git clone git\@github.com:$user/$repo.git;cd ..";
`cd foo; git clone git\@github.com:$user/$repo.git || git clone git\@github.com:$user/$repo.git;cd ..`;
#Fix
- my $t = "";
- open (IN, "foo/$repo/$file") or die "Unable to open $file in $repo";
- while ($j = <IN>) {
- $t = $t.$j;
- }
- close(IN);
- open (OUT, ">foo/$repo/$file") or die "Unable to open $file in $repo";
+ open (my $in, "<", "foo/$repo/$file") or die "Unable to open $file in $repo";
+ my $t = do { local $/ = <$in> };
+ close($in);
+ open ($out, ">", "foo/$repo/$file") or die "Unable to open $file in $repo";
my $t = fix_text($t);
- print OUT $t;
- close (OUT);
+ print $out $t;
+ close ($out);
`cd foo;cd $repo; git commit -a -m \"Spelling correction in README\"; git push; sleep 1;git push; cd ..;cd ..`;
my $make_pull_req = 1;
if ($make_pull_req) {
View
6 wordlist.pl → wordlist.pm
@@ -1,3 +1,5 @@
+package wordlist;
+
#stolen from http://cpansearch.perl.org/src/APOCAL/Pod-Spell-CommonMistakes-1.000/lib/Pod/Spell/CommonMistakes/WordList.pm
my %common = (
"abandonning" => "abandoning",
@@ -548,7 +550,7 @@ sub fix_text {
return $text;
}
-sub preserve_case() {
+sub preserve_case {
my ($old, $new) = @_;
my $mask = uc $old ^ $old;
uc $new | $mask .
@@ -573,5 +575,7 @@ sub check_common {
return 0;
}
+use base 'Exporter';
+our @EXPORT = qw{fix_text check_common};
1;

0 comments on commit 4a37583

Please sign in to comment.
Something went wrong with that request. Please try again.