Permalink
Browse files

rewriting it.

 * I've made subcommands to be functions.
 * Using INI parser - Config::INI::Reader.
 * When you send a token, HTTPS POST is used instead of HTTP GET.
 * It was smart to get that usage.
  • Loading branch information...
1 parent 8279ed2 commit c7ac9430be4d9dcc8c39eb24994fa23e8b87ee59 @xaicron committed Aug 8, 2010
Showing with 317 additions and 314 deletions.
  1. +1 −1 Makefile.PL
  2. +2 −45 lib/App/gh.pm
  3. +314 −268 scripts/gh
View
@@ -12,7 +12,7 @@ requires 'JSON';
requires 'JSON::XS';
requires 'LWP::Simple';
requires 'File::Temp';
-requires 'Exporter::Lite';
+requires 'Config::INI::Reader';
install_script 'scripts/gh';
View
@@ -1,51 +1,8 @@
package App::gh;
use warnings;
use strict;
-use Exporter::Lite;
-
-our @EXPORT = qw(parse_config parse_options get_github_auth);
-
-sub parse_config {
- my ($file) = @_;
- open FH , "<" , $file;
- local $/;
- my $content = <FH>;
- close FH;
- my @parts = split /(?=\[.*?\])/,$content;
-
-
- my %config;
-
- for my $part ( @parts ) {
- if( $part =~ /^\[(\w+)\s+["'](\w+)["']\]/g ) {
- my ($o1 , $o2 ) = ($1, $2);
- $config{ $o1 } ||= {};
- $config{ $o1 }->{ $o2 }
- = parse_options( $part );
- }
- elsif( $part =~ /^\[(.*?)\]/g ) {
- my $key = $1;
- my $options = parse_options( $part );
- $config{ $key } = $options;
- }
- }
- return \%config;
-}
-
-sub parse_options {
- my $part = shift;
- my $options;
- while( $part =~ /^\s*(.*?)\s*=\s*(.*?)\s*$/gm ) {
- my ($name,$value) = ($1,$2);
- $options->{ $name } = $value;
- }
- return $options;
-}
-
-sub get_github_auth {
- my $config = parse_config $ENV{HOME} . "/.gitconfig";
- return $config->{github};
-}
+
+our $VERSION = '0.09';
__END__
Oops, something went wrong.

0 comments on commit c7ac943

Please sign in to comment.