Skip to content

Commit 39e19c1

Browse files
authored
Merge pull request #1 from mannih/main
Create .selenium/perl-client automatically and don't hard-code .selen…
2 parents 51cc5bf + 96053d9 commit 39e19c1

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

lib/Selenium/Client.pm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use Carp qw{confess};
1414
use File::Path qw{make_path};
1515
use File::HomeDir();
1616
use File::Slurper();
17+
use File::Spec();
1718
use Sub::Install();
1819
use Net::EmptyPort();
1920
use Capture::Tiny qw{capture_merged};
@@ -136,8 +137,11 @@ sub new($class,%options) {
136137
$options{auto_close} //= 1;
137138
$options{browser} //= '';
138139

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

142146
my $self = bless(\%options, $class);
143147
$self->{sessions} = [];

lib/Selenium/Specification.pm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ our %spec_urls = (
3939
our $browser = HTTP::Tiny->new();
4040
my %state;
4141
my $parse = [];
42-
my $dir = File::Spec->catdir( File::HomeDir::my_home(),".selenium","specs" );
4342
our $method = {};
4443

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

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

7070
#TODO needs to grab args and argtypes still
7171
sub fetch (%options) {
72-
$dir = $options{dir} if $options{dir};
72+
my $dir = $options{dir};
7373

7474
my $rc = 0;
7575
foreach my $spec ( sort keys(%spec_urls) ) {

0 commit comments

Comments
 (0)