Browser-Open-0.04/0000755000175000017500000000000011726507644014135 5ustar cafrankscafranksBrowser-Open-0.04/Changes0000644000175000017500000000115711726507031015422 0ustar cafrankscafranksRevision history for Browser-Open 0.04 2012-03-09 - Added support for MSWin32. RT #58862 - Added browser list for freebsd. RT #61758 - Added sensible-browser option for linux. RT #56544 0.03 Mon Nov 9 23:52:13 UTC 2009 - Fixed tests to work better in case no command is found - added more commands, courtesy of the App::SD::CLI::Command::Browser - added a `open_browser_cmd_all()` 0.02 Sat Oct 17 12:24:03 UTC 2009 - added a bunch of alternatives for Linux 0.01 Sat Oct 17 11:40:08 UTC 2009 - first released version - first implementation Browser-Open-0.04/xt/0000755000175000017500000000000011726507644014570 5ustar cafrankscafranksBrowser-Open-0.04/xt/release-pod-syntax.t0000644000175000017500000000044711726507031020474 0ustar cafrankscafranks#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use Test::More; eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; all_pod_files_ok();Browser-Open-0.04/xt/release-meta-yaml.t0000644000175000017500000000045411726507031020252 0ustar cafrankscafranks#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use Test::More; eval "use Test::CPAN::Meta"; plan skip_all => "Test::CPAN::Meta required for testing META.yml" if $@; meta_yaml_ok();Browser-Open-0.04/xt/author/0000755000175000017500000000000011726507644016072 5ustar cafrankscafranksBrowser-Open-0.04/xt/author/10-open.t0000644000175000017500000000061711726507031017430 0ustar cafrankscafranks#!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for testing by the author'); } } use strict; use warnings; use Test::More; use Browser::Open qw( open_browser ); my $ok = open_browser('http://127.0.0.1/'); ok(defined($ok), 'Found command to open a browser'); is($ok, 0, 'No problems running command'); done_testing();Browser-Open-0.04/xt/release-pod-coverage.t0000644000175000017500000000076411726507031020743 0ustar cafrankscafranks#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use Test::More; eval "use Test::Pod::Coverage 1.08"; plan skip_all => "Test::Pod::Coverage 1.08 required for testing POD coverage" if $@; eval "use Pod::Coverage::TrustPod"; plan skip_all => "Pod::Coverage::TrustPod required for testing POD coverage" if $@; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' });Browser-Open-0.04/xt/smoke/0000755000175000017500000000000011726507644015706 5ustar cafrankscafranksBrowser-Open-0.04/xt/smoke/20-discover.t0000644000175000017500000000067411726507031020125 0ustar cafrankscafranks#!perl BEGIN { unless ($ENV{AUTOMATED_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for "smoke bot" testing'); } } use strict; use warnings; use Test::More; use Browser::Open qw( open_browser_cmd_all ); ## Ignore $^O restrictions for a moment my $cmd = open_browser_cmd_all(); diag("Found '$cmd' for '$^O'") if $cmd; pass('thank you for your time to make Browser::Open better'); done_testing();Browser-Open-0.04/lib/0000755000175000017500000000000011726507644014703 5ustar cafrankscafranksBrowser-Open-0.04/lib/Browser/0000755000175000017500000000000011726507644016326 5ustar cafrankscafranksBrowser-Open-0.04/lib/Browser/Open.pm0000644000175000017500000001076411726507031017563 0ustar cafrankscafrankspackage Browser::Open; our $VERSION = '0.04'; use strict; use warnings; use Carp; use File::Spec::Functions qw( catfile ); use parent 'Exporter'; @Browser::Open::EXPORT_OK = qw( open_browser open_browser_cmd open_browser_cmd_all ); my @known_commands = ( ['', $ENV{BROWSER}], ['darwin', '/usr/bin/open', 1], ['cygwin', 'start'], ['MSWin32', 'start', undef, 1], ['solaris', 'xdg-open'], ['solaris', 'firefox'], ['linux', 'sensible-browser'], ['linux', 'xdg-open'], ['linux', 'x-www-browser'], ['linux', 'www-browser'], ['linux', 'htmlview'], ['linux', 'gnome-open'], ['linux', 'gnome-moz-remote'], ['linux', 'kfmclient'], ['linux', 'exo-open'], ['linux', 'firefox'], ['linux', 'seamonkey'], ['linux', 'opera'], ['linux', 'mozilla'], ['linux', 'iceweasel'], ['linux', 'netscape'], ['linux', 'galeon'], ['linux', 'opera'], ['linux', 'w3m'], ['linux', 'lynx'], ['freebsd', 'xdg-open'], ['freebsd', 'gnome-open'], ['freebsd', 'gnome-moz-remote'], ['freebsd', 'kfmclient'], ['freebsd', 'exo-open'], ['freebsd', 'firefox'], ['freebsd', 'seamonkey'], ['freebsd', 'opera'], ['freebsd', 'mozilla'], ['freebsd', 'netscape'], ['freebsd', 'galeon'], ['freebsd', 'opera'], ['freebsd', 'w3m'], ['freebsd', 'lynx'], ['', 'open'], ['', 'start'], ); ################################## sub open_browser { my ($url, $all) = @_; croak('Missing required parameter $url, ') unless $url; my $cmd = $all ? open_browser_cmd_all() : open_browser_cmd(); return unless $cmd; return system($cmd, $url); } sub open_browser_cmd { return _check_all_cmds($^O); } sub open_browser_cmd_all { return _check_all_cmds(''); } ################################## sub _check_all_cmds { my ($filter) = @_; foreach my $spec (@known_commands) { my ($osname, $cmd, $exact, $no_search) = @$spec; next unless $cmd; next if $osname && $filter && $osname ne $filter; next if $no_search && !$filter && $osname ne $^O; return $cmd if $exact && -x $cmd; return $cmd if $no_search; $cmd = _search_in_path($cmd); return $cmd if $cmd; } return; } sub _search_in_path { my $cmd = shift; for my $path (split(/:/, $ENV{PATH})) { next unless $path; my $file = catfile($path, $cmd); return $file if -x $file; } return; } 1; __END__ =head1 NAME Browser::Open - open a browser in a given URL =head1 VERSION version 0.03 =head1 SYNOPSIS use Browser::Open qw( open_browser ); ### Try commands specific to the current Operating System my $ok = open_browser($url); # ! defined($ok): no recognized command found # $ok == 0: command found and executed # $ok != 0: command found, error while executing ### Try all known commands my $ok = open_browser($url, 1); =head1 DESCRIPTION The functions optionaly exported by this module allows you to open URLs in the user browser. A set of known commands per OS-name is tested for presence, and the first one found is executed. With an optional parameter, all known commands are checked. The L<"open_browser"> uses the C function to execute the command. If you want more control, you can get the command with the L<"open_browser_cmd"> or L<"open_browser_cmd_all"> functions and then use whatever method you want to execute it. =head1 API All functions are B exported by default. You must ask for them explicitly. =head2 open_browser my $ok = open_browser($url, $all); Find an appropriate command and executes it with your C<$url>. If C<$all> is false, the default, only commands that match the current OS will be tested. If true, all known commands will be tested. If no command was found, returns C. If a command is found, returns the exit code of the execution attempt, 0 for success. See the C for more information about this exit code. If no C<$url> is given, an exception will be thrown: C<< Missing required parameter $url >>. =head2 open_browser_cmd my $cmd = open_browser_cmd(); Returns the best command found to open a URL on your system. If no command was found, returns C. =head2 open_browser_cmd_all my $cmd = open_browser_cmd_all(); Returns the first command found to open a URL. If no command was found, returns C. =head1 AUTHOR Pedro Melo, C<< >> =head1 COPYRIGHT & LICENSE Copyright 2009 Pedro Melo. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cutBrowser-Open-0.04/Makefile.PL0000644000175000017500000000072411726507630016105 0ustar cafrankscafranks use strict; use warnings; use ExtUtils::MakeMaker; WriteMakefile( DISTNAME => 'Browser-Open', NAME => 'Browser::Open', AUTHOR => "Pedro\ Melo\ \", ABSTRACT => "open\ a\ browser\ in\ a\ given\ URL", VERSION => '0.04', EXE_FILES => [ qw() ], (eval { ExtUtils::MakeMaker->VERSION(6.31) } ? (LICENSE => 'perl') : ()), PREREQ_PM => { "Test::More" => '0.92', "parent" => '0', }, test => {TESTS => 't/*.t'} ); Browser-Open-0.04/t/0000755000175000017500000000000011726507644014400 5ustar cafrankscafranksBrowser-Open-0.04/t/00-load.t0000644000175000017500000000026011726507031015705 0ustar cafrankscafranks#!perl use strict; use warnings; use Test::More; use Browser::Open; pass("Compiled Browser::Open $INC{'Browser/Open.pm'}, version $Browser::Open::VERSION"); done_testing(); Browser-Open-0.04/t/01-basic.t0000644000175000017500000000124411726507031016053 0ustar cafrankscafranks#!perl use strict; use warnings; use Test::More; use Browser::Open qw( open_browser open_browser_cmd open_browser_cmd_all ); my $cmd = open_browser_cmd(); if ($cmd) { ok($cmd, "got command '$cmd'"); SKIP: { skip "Won't test execution on MSWin32", 1 if $^O eq 'MSWin32'; ok(-x $cmd, '... and we can execute it'); } diag("Found '$cmd' for '$^O'"); ok(open_browser_cmd_all(), '... and the all commands version is also ok'); } else { $cmd = open_browser_cmd_all(); if ($cmd) { pass("Found command in the 'all' version ($cmd)"); } else { diag("$^O - need more data"); pass("We can't make popcorn without corn"); } } done_testing(); Browser-Open-0.04/MANIFEST0000644000175000017500000000046211726507644015270 0ustar cafrankscafranksChanges dist.ini lib/Browser/Open.pm Makefile.PL MANIFEST This list of files README t/00-load.t t/01-basic.t xt/author/10-open.t xt/release-meta-yaml.t xt/release-pod-coverage.t xt/release-pod-syntax.t xt/smoke/20-discover.t META.yml Module meta-data (added by MakeMaker) Browser-Open-0.04/META.yml0000644000175000017500000000106111726507644015404 0ustar cafrankscafranks--- #YAML:1.0 name: Browser-Open version: 0.04 abstract: open a browser in a given URL author: - Pedro Melo license: perl distribution_type: module configure_requires: ExtUtils::MakeMaker: 0 build_requires: ExtUtils::MakeMaker: 0 requires: parent: 0 Test::More: 0.92 no_index: directory: - t - inc generated_by: ExtUtils::MakeMaker version 6.56 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 Browser-Open-0.04/README0000644000175000017500000000044311726507031015004 0ustar cafrankscafranks This archive contains the distribution Browser-Open, version 0.03: open a browser in a given URL This software is copyright (c) 2009 by Pedro Melo. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.