Guest User

Untitled

a guest
Aug 16th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.82 KB | None | 0 0
  1. #!/usr/bin/env perl
  2. use 5.14.2;
  3. use strict;
  4. use warnings;
  5.  
  6. # FILENAME: pvlist.pl
  7. # CREATED: 16/10/11 20:16:03 by Kent Fredric (kentnl) <kentfredric@gmail.com>
  8. # ABSTRACT: Show version history for interesting perl dists
  9.  
  10. use MetaCPAN::API;
  11. use CPAN::Changes;
  12.  
  13. my $mcpan = MetaCPAN::API->new();
  14.  
  15. my (@want_dists) = qw(
  16. App-cpanminus
  17. App-perlbrew
  18. Archive-Peek
  19. B-Hooks-OP-Check-EntersubForCV
  20. Business-Tax-VAT-Validation
  21. Catalyst-Action-REST
  22. Catalyst-Log-Log4perl
  23. Config-GitLike
  24. DBD-CSV
  25. Data-Handle
  26. DateTime-TimeZone-SystemV
  27. DateTime-TimeZone-Tzfile
  28. Devel-PatchPerl
  29. Dist-Zilla-Plugin-GithubMeta
  30. Dist-Zilla-Plugin-Test-Compile
  31. Dist-Zilla-Plugin-Test-Perl-Critic
  32. Dist-Zilla-Plugin-Twitter
  33. Dist-Zilla-PluginBundle-Author-KENTNL
  34. Filesys-Notify-Simple
  35. Filter-Simple
  36. FindBin-libs
  37. Git-Wrapper
  38. HTML-FormHandler
  39. HTML-Packer
  40. HTML-Template-Pro
  41. IO-Interactive
  42. JavaScript-Packer
  43. KiokuDB-Backend-DBI
  44. Lexical-Types
  45. Lingua-EN-Inflect-Phrase
  46. Module-Extract-Namespaces
  47. Module-Runtime
  48. MojoMojo
  49. Mojolicious
  50. MooseX-SetOnce
  51. MooseX-Types-Structured
  52. Net-Google-DataAPI
  53. Net-IPv4Addr
  54. ORLite-Migraate
  55. Object-ID
  56. POE-Component-SSLify
  57. Padre-Plugin-Vi
  58. Plack
  59. Plack-Middleware-ReverseProxy
  60. Pod-Elemental-Transformer-WikiDoc
  61. Scope-Upper
  62. Spark-Form
  63. Task-Spark-Form
  64. Test-LeakTrace
  65. Test-SharedFork
  66. Test-WWW-Mechanize-Catalyst
  67. Web-Scraper
  68. XML-RSS_LibXML
  69. XML-Smart
  70. XML-XSPF
  71. YAML-LibYAML
  72. autobox-Core
  73. autovivification
  74. perl5i
  75. CPANPLUS
  76. CPANPLUS-Dist-Build
  77. Devel-PPPort
  78. ExtUtils-MakeMaker
  79. Unicode-Collate
  80. Catalyst-Runtime
  81. Moose
  82. Class-MOP
  83. perl
  84. Dist-Zilla
  85. Package-Stash
  86. MetaCPAN-API
  87. Class-Load
  88. Dist-Zilla-PluginBundle-RJBS
  89. );
  90.  
  91. my $oldest_date = '2011-09-01T00:00:00.000Z';
  92. my $newest_date = '2012-01-01T00:00:00.000Z';
  93.  
  94. my (@styles) = (
  95. "\e[0m", "\e[1m", "\e[3m", "\e[4m", "\e[7m",
  96. ( ( "\e[1m\e[3m", "\e[1m\e[4m", "\e[1m\e[7m", ), ( "\e[3m\e[4m", "\e[3m\e[7m", ), "\e[4m\e[7m", ),
  97. ( ( "\e[1m\e[3m\e[4m", "\e[1m\e[3m\e7m" ), ( "\e[3m\e[4m\e[7m", ), ),
  98. ( "\e[1m\e[3m\e[4m\e[7m", ),
  99. );
  100.  
  101. my (@fgs) = ( "\e[30m", "\e[31m", "\e[32m", "\e[33m", "\e[34m", "\e[35m", "\e[36m", "\e[37m" );
  102. my (@bgs) = ( "\e[49m", "\e[41m", "\e[42m", "\e[43m", "\e[44m", "\e[45m", "\e[46m", "\e[47m", "\e[40m", );
  103.  
  104. my @bad = (
  105. [ undef, "\e[30m", "\e[40m" ],
  106. [ undef, "\e[30m", "\e[49m" ],
  107. [ undef, "\e[31m", "\e[41m" ],
  108. [ undef, "\e[32m", "\e[42m" ],
  109. [ undef, "\e[33m", "\e[43m" ],
  110. [ undef, "\e[34m", "\e[44m" ],
  111. [ undef, "\e[35m", "\e[45m" ],
  112. [ undef, "\e[36m", "\e[46m" ],
  113. [ undef, "\e[47m", "\e[47m" ],
  114. );
  115.  
  116. sub is_bad {
  117. my ( $style, $fg, $bg ) = @_;
  118. for my $bc (@bad) {
  119. my ( $sm, $fgm, $bgm );
  120. $sm = ( not defined $bc->[0] or $bc->[0] eq $style );
  121. $fgm = ( not defined $bc->[1] or $bc->[1] eq $fg );
  122. $bgm = ( not defined $bc->[2] or $bc->[2] eq $bg );
  123. return 1 if ( $sm and $fgm and $bgm );
  124. }
  125. return;
  126. }
  127.  
  128. my (@colours);
  129.  
  130. for my $bg (@bgs) {
  131. for my $style (@styles) {
  132.  
  133. for my $fg (@fgs) {
  134. next if is_bad( $style, $fg, $bg );
  135. push @colours, $style . $fg . $bg;
  136.  
  137. }
  138. }
  139. }
  140.  
  141. my (@author_color_map) = @colours;
  142. my (@dist_color_map) = @colours;
  143.  
  144. sub next_c {
  145. my $i = $_[0];
  146. my $colour = shift @{$i};
  147. push @{$i}, $colour;
  148. return $colour;
  149.  
  150. }
  151. sub next_colour {
  152. return next_c \@colours;
  153. }
  154.  
  155. my %dist_colours;
  156. my %author_colours;
  157.  
  158. sub author_colour {
  159. return $author_colours{ $_[0] } if exists $author_colours{ $_[0] };
  160. return ( $author_colours{ $_[0] } = next_c \@author_color_map );
  161. }
  162.  
  163. sub dist_colour {
  164. return $dist_colours{ $_[0] } if exists $dist_colours{ $_[0] };
  165. return ( $dist_colours{ $_[0] } = next_c \@dist_color_map );
  166. }
  167.  
  168. sub ac {
  169. return author_colour( $_[0] ) . $_[0] . "\e[0m";
  170. }
  171.  
  172. sub dc {
  173. return dist_colour( $_[0] ) . $_[1] . "\e[0m";
  174. }
  175.  
  176. my $results = $mcpan->post(
  177. 'release',
  178. {
  179. query => {
  180. terms => {
  181. distribution => [ @want_dists, ],
  182. minimum_match => 1,
  183. }
  184. },
  185. filter => {
  186. range => {
  187. date => {
  188. from => $oldest_date,
  189. to => $newest_date,
  190. },
  191. },
  192. },
  193. sort => [
  194. # { 'author' => 'asc', },
  195. { 'date' => 'desc' , }
  196. ],
  197. fields => [qw( author name date distribution )],
  198. size => 1024,
  199. }
  200. );
  201. use Try::Tiny;
  202. use Data::Dump qw( pp );
  203. for my $result ( @{ $results->{hits}->{hits} } ) {
  204.  
  205. my %f = %{ $result->{fields} };
  206. my ( $date, $distribution, $name, $author ) = @f{qw( date distribution name author)};
  207.  
  208. my $file;
  209. try {
  210. $file = $mcpan->source(
  211. author => $author,
  212. release => $name,
  213. path => 'Changes',
  214. );
  215. };
  216. my ( $changes, @releases);
  217. if ( $file ) {
  218. $changes = CPAN::Changes->load_string( $file );
  219. }
  220. if ( $changes ){
  221. @releases = $changes->releases();
  222. }
  223.  
  224. say sprintf "%s - %s/%s\e[0m", $date, ac($author), dc($distribution,$name);
  225. if ( @releases ) {
  226. say $releases[-1]->serialize;
  227. }
  228. }
Add Comment
Please, Sign In to add comment