Skip to content

Instantly share code, notes, and snippets.

@ktat
Created February 8, 2011 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ktat/816833 to your computer and use it in GitHub Desktop.
Save ktat/816833 to your computer and use it in GitHub Desktop.
import JPA translations to perldocjp directory
#!/usr/bin/perl
use strict;
use File::Slurp qw/slurp/;
use LWP::Simple qw/get/;
my $jpa_dir = '/home/ktat/git/github/jpa-translation/';
my $assets_dir = '/home/ktat/git/github/PJP/assets/perldoc.jp/docs/modules/';
copy_to_pjp_assets($jpa_dir, $assets_dir);
sub copy_to_pjp_assets {
my ($jpa_dir, $assets_dir) = @_;
my $jpa_github = get 'https://github.com/jpa/repositories';
my @translations = $jpa_github =~m{<a href="/jpa/([\w\-]+-Doc-JA)">}sg;
mkdir $jpa_dir if not -e $jpa_dir;
chdir $jpa_dir or die $!;
foreach my $doc (@translations) {
my ($module) = $doc =~ m{^(.+)-Doc-JA} or die "$doc doesn't seem to be translation";
if (not -e $jpa_dir . $doc) {
system "git clone https://github.com/jpa/$doc.git";
}
chdir $jpa_dir . $doc or die $!;
system "git pull > /dev/null";
if (my ($version) = slurp('META.yml') =~m{version: ([\d\.]+)}is) {
mkdir $assets_dir . $module . '-' . $version;
system "git archive master | tar -x -C " . $assets_dir . $module . '-'. $version;
}
chdir "..";
}
return \@translations;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment