Skip to content

Commit

Permalink
fix: set version when generating subtasks
Browse files Browse the repository at this point in the history
  • Loading branch information
karenetheridge committed Dec 1, 2018
1 parent 319813d commit a22db41
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
19 changes: 17 additions & 2 deletions generate-tasks
Expand Up @@ -6,6 +6,7 @@
use 5.014; # s///r
use Config::Any;
use Path::Tiny;
use Dist::Zilla::Plugin::RewriteVersion;

sub get_config
{
Expand All @@ -20,9 +21,20 @@ sub get_config
$data->{$config_file};
}

sub get_version
{
return $ENV{V} if $ENV{V};

my $content = path('lib/Task/Kensho.pm')->slurp_utf8;
my $assign_regex = Dist::Zilla::Plugin::RewriteVersion->assign_re();
my ($quote, $version) = $content =~ m{^$assign_regex[^\n]*$}ms;
return $version;
}

sub generate_task
{
my $task_module = shift;
my $version = shift;
my $distname = $task_module =~ s/::/-/gr;

path($distname)->remove_tree({ safe => 0 });
Expand All @@ -45,6 +57,7 @@ sub generate_task

my $content = path($to_copy{$destination})->slurp_utf8;
$content =~ s/__DIST_NAME__/$distname/g;
$content =~ s/__DIST_VERSION__/$version/g;

path($destination)->spew_utf8($content);
}
Expand All @@ -58,10 +71,12 @@ sub generate_task
sub stuff
{
my $config = get_config();
my $version = get_version();

foreach my $task_module (sort keys %$config)
{
say "\ngenerating task for $task_module";
generate_task($task_module);
say "\ngenerating task for $task_module $version";
generate_task($task_module, $version);
}
}

Expand Down
3 changes: 1 addition & 2 deletions inc/SubTaskPluginBundle.pm
Expand Up @@ -55,8 +55,7 @@ sub configure
my $module_data = $self->data_for($module);

my @plugins = (
# VersionProvider
[ 'RewriteVersion' => { ':version' => '0.004', global => 1, add_tarball_name => 0 } ],
# no VersionProvider: it is hardcoded in dist.ini

# Gather Files
[ 'Git::GatherDir' => { ':version' => '2.016', exclude_match => '^inc', exclude_filename => [ 'dist.ini', 'modules.yml', 'META.json', 'README.md', 'README.pod' ] } ],
Expand Down
2 changes: 1 addition & 1 deletion subtask_templates/Module.pm
Expand Up @@ -3,7 +3,7 @@ use warnings;
package {{ ($module = $dist->name) =~ s/-/::/g; $module }};
# ABSTRACT: A Glimpse at an Enlightened Perl: {{ $config_data->{$module}{description} }}

our $VERSION = '0.39';
our $VERSION = '{{ $dist->version }}';

__END__
=pod
Expand Down
1 change: 1 addition & 0 deletions subtask_templates/dist.ini
Expand Up @@ -3,6 +3,7 @@ author = Chris Prather <chris@prather.org>
copyright_holder = Chris Prather
copyright_year = 2008
license = Perl_5
version = __DIST_VERSION__

[=inc::SubTaskPluginBundle]
distname = __DIST_NAME__

0 comments on commit a22db41

Please sign in to comment.