Skip to content

Commit

Permalink
Merge pull request #1 from mannih/main
Browse files Browse the repository at this point in the history
Create .selenium/perl-client automatically and don't hard-code .selen…
  • Loading branch information
teodesian authored Feb 8, 2021
2 parents 51cc5bf + 96053d9 commit 39e19c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion lib/Selenium/Client.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use Carp qw{confess};
use File::Path qw{make_path};
use File::HomeDir();
use File::Slurper();
use File::Spec();
use Sub::Install();
use Net::EmptyPort();
use Capture::Tiny qw{capture_merged};
Expand Down Expand Up @@ -136,8 +137,11 @@ sub new($class,%options) {
$options{auto_close} //= 1;
$options{browser} //= '';

#create client_dir and log-dir
my $dir = File::Spec->catdir( $options{client_dir},"perl-client" );
make_path($dir);
#Grab the spec
$options{spec} = Selenium::Specification::read($options{version},$options{nofetch});
$options{spec}= Selenium::Specification::read($options{client_dir},$options{version},$options{nofetch});

my $self = bless(\%options, $class);
$self->{sessions} = [];
Expand Down
8 changes: 4 additions & 4 deletions lib/Selenium/Specification.pm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ our %spec_urls = (
our $browser = HTTP::Tiny->new();
my %state;
my $parse = [];
my $dir = File::Spec->catdir( File::HomeDir::my_home(),".selenium","specs" );
our $method = {};

=head1 SUBROUTINES
Expand All @@ -50,9 +49,10 @@ Reads the copy of the provided spec type, and fetches it if a cached version is
=cut

sub read($type='stable', $nofetch=1) {
sub read($client_dir, $type='stable', $nofetch=1) {
my $dir = File::Spec->catdir( $client_dir,"specs" );
my $file = File::Spec->catfile( "$dir","$type.json");
fetch( once => $nofetch );
fetch( once => $nofetch, dir => $dir );
die "could not write $file: $@" unless -f $file;
my $buf = File::Slurper::read_text($file);
my $array = JSON::MaybeXS::decode_json($buf);
Expand All @@ -69,7 +69,7 @@ Builds a spec hash based upon the WC3 specification documents, and writes it to

#TODO needs to grab args and argtypes still
sub fetch (%options) {
$dir = $options{dir} if $options{dir};
my $dir = $options{dir};

my $rc = 0;
foreach my $spec ( sort keys(%spec_urls) ) {
Expand Down

0 comments on commit 39e19c1

Please sign in to comment.