Class: PoiseBoiler::Helpers::Rake::Year

Inherits:
Halite::HelperBase
  • Object
show all
Defined in:
lib/poise_boiler/helpers/rake/year.rb

Overview

Helper for a Rakefile to install tasks for updating copyright years.

Examples:

Installing tasks

require 'poise_boiler/helpers/rake/year'
PoiseBoiler::Helpers::Rake::Year.install

Updating all copyright years

$ rake year

Updating copyright years on a non-boiler project.

$ git ls-files -z | xargs -0 perl -pi -e "s/Copyright (?:\(c\) )?((?\!$(date +%Y))\\d{4})(-\\d{4})?,/Copyright \\1-$(date +%Y),/gi"

Since:

  • 1.6.0

Instance Method Summary collapse

Instance Method Details

#installvoid

This method returns an undefined value.

Install the rake tasks.

Since:

  • 1.6.0



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/poise_boiler/helpers/rake/year.rb', line 38

def install
  # Delayed so that Rake doesn't need to be loaded to run this file.
  extend ::Rake::DSL

  task 'year' do
    current_year = Time.now.year.to_s
    git_files.each do |path|
      full_path = File.expand_path(path, base)
      update_file(full_path, current_year)
    end
  end
end