From 22f70237d6d96ca368f73e4f23ccc6b0c6c27d59 Mon Sep 17 00:00:00 2001 From: Dave Cross Date: Mon, 18 Nov 2024 12:03:44 +0000 Subject: [PATCH] Fix the previous fix --- ChangeLog.md | 14 +++++++ lib/Amazon/Sites.pm | 89 ++++++++++++++++++++++----------------------- 2 files changed, 58 insertions(+), 45 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index a0fd6d8..aa1a455 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.1.9] - 2024-11-18 + +### Fixed + +- Fix the previous fix + +## [0.1.8] - 2024-11-18 + +### Fixed + +- Worked out why we needed the 'package' statement + +- Fixed the problem and removed the statement + ## [0.1.7] - 2024-08-30 ### Fixed diff --git a/lib/Amazon/Sites.pm b/lib/Amazon/Sites.pm index ee41b91..0669788 100644 --- a/lib/Amazon/Sites.pm +++ b/lib/Amazon/Sites.pm @@ -34,22 +34,22 @@ use Feature::Compat::Class; use feature 'signatures'; no warnings 'experimental::signatures'; -our $VERSION = '0.1.7'; +our $VERSION = '0.1.9'; -class Amazon::Sites { +class Amazon::Sites; - use Amazon::Site (); +use Amazon::Site (); - field $include :param = []; - field $exclude :param = []; - field $assoc_codes :param = {}; - field %sites = _init_sites($assoc_codes, $include, $exclude); +field $include :param = []; +field $exclude :param = []; +field $assoc_codes :param = {}; +field %sites = _init_sites($assoc_codes, $include, $exclude); - ADJUST { - if (@$include and @$exclude) { - die "You can't specify both include and exclude"; - } +ADJUST { + if (@$include and @$exclude) { + die "You can't specify both include and exclude"; } +} =head1 METHODS @@ -81,7 +81,7 @@ L objects. =cut - method sites_hash { return %sites } +method sites_hash { return %sites } =head2 site($code) @@ -89,7 +89,7 @@ Given a two-letter country code, returns the corresponding L objec =cut - method site ($code) { return $sites{$code} } +method site ($code) { return $sites{$code} } =head2 sites @@ -97,37 +97,37 @@ Returns a list of L objects, sorted by the sort order. =cut - method sites { - my @sites = sort { - $a->sort <=> $b->sort; - } values %sites; +method sites { + my @sites = sort { + $a->sort <=> $b->sort; + } values %sites; - return @sites; - } + return @sites; +} - sub _init_sites($assoc_codes, $include, $exclude) { - my %sites; - my @cols = qw[code country tldn currency sort]; +sub _init_sites($assoc_codes, $include, $exclude) { + my %sites; + my @cols = qw[code country tldn currency sort]; - my $where = tell main::DATA; + my $where = tell DATA; - while () { - chomp; - my %site; - @site{@cols} = split /\t/; + while () { + chomp; + my %site; + @site{@cols} = split /\t/; - next if @$include and not grep { $site{code} eq $_ } @$include; - next if @$exclude and grep { $site{code} eq $_ } @$exclude; + next if @$include and not grep { $site{code} eq $_ } @$include; + next if @$exclude and grep { $site{code} eq $_ } @$exclude; - $site{assoc_code} = $assoc_codes->{$site{code}} if $assoc_codes->{$site{code}}; + $site{assoc_code} = $assoc_codes->{$site{code}} if $assoc_codes->{$site{code}}; - $sites{$site{code}} = Amazon::Site->new(%site); - } + $sites{$site{code}} = Amazon::Site->new(%site); + } - seek main::DATA, $where, 0; + seek DATA, $where, 0; - return %sites; - } + return %sites; +} =head2 codes @@ -135,9 +135,9 @@ Returns a list of the two-letter country codes, sorted by the sort order. =cut - method codes { - return sort keys %sites; - } +method codes { + return sort keys %sites; +} =head2 asin_urls @@ -146,14 +146,13 @@ codes and the values are the corresponding ASIN URLs. =cut - method asin_urls ($asin) { - my %urls; - for my $site ($self->sites) { - $urls{$site->code} = $site->asin_url($asin); - } - - return %urls; +method asin_urls ($asin) { + my %urls; + for my $site ($self->sites) { + $urls{$site->code} = $site->asin_url($asin); } + + return %urls; } 1;