| 1 | package Amazon::API::BuildInfo; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use Carp; | ||
| 7 | use Amazon::API::Utils qw(slurp_json); | ||
| 8 | use English qw(-no_match_vars); | ||
| 9 | |||
| 10 | use File::ShareDir qw(dist_file); | ||
| 11 | use JSON; | ||
| 12 | |||
| 13 | our $GIT_SHA = 'a579e96d3cea75fae728b31a50a98530f1c274a4'; | ||
| 14 | our $GIT_DIRTY = 'a579e96d3cea75fae728b31a50a98530f1c274a4'; | ||
| 15 | our $VERSION = '2.8.2'; | ||
| 16 | |||
| 17 | ######################################################################## | ||
| 18 | sub version { | ||
| 19 | ######################################################################## | ||
| 20 | my ($self) = @_; | ||
| 21 | |||
| 22 | my $botocore_version_file = eval { | ||
| 23 | return 'botocore-version.json' | ||
| 24 | if -e 'botocore-version.json'; | ||
| 25 | |||
| 26 | return dist_file( 'Amazon-API', 'botocore-version.json' ); | ||
| 27 | }; | ||
| 28 | |||
| 29 | croak "ERROR: could not read botocore-version.json\n$EVAL_ERROR" | ||
| 30 | if !$botocore_version_file || $EVAL_ERROR; | ||
| 31 | |||
| 32 | my $botocore_version = slurp_json($botocore_version_file); | ||
| 33 | |||
| 34 | return { commit => $GIT_SHA, version => $VERSION, dirty => $GIT_DIRTY, botocore_version => $botocore_version }; | ||
| 35 | } | ||
| 36 | |||
| 37 | ######################################################################## | ||
| 38 | sub botocore_version { | ||
| 39 | ######################################################################## | ||
| 40 | my ($self) = @_; | ||
| 41 | |||
| 42 | my $version = $self->version(); | ||
| 43 | |||
| 44 | return @{ $version->{botocore_version} }{qw(version commit)}; | ||
| 45 | } | ||
| 46 | |||
| 47 | 1; | ||
| 48 | |||
| 49 | __END__ |