colorls/Rakefile
Claudio Bley 7100c41703 Remove man page and zsh completion file
The files are automatically generated, but using rake's `file` task does not
work correctly when the files are checked into the repo since the timestamps are
updated independently of the commit time.

Removing them ensures that these files are always freshly generated before
building the gem and thus are always up-to-date which was often not the case in
the past.
2022-03-21 09:03:21 +01:00

50 lines
1.2 KiB
Ruby

# frozen_string_literal: true
require 'bundler/setup'
require 'rubygems/tasks'
Gem::Tasks.new
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = '--warnings'
end
require 'rubocop/rake_task'
RuboCop::RakeTask.new
desc 'Build the manual'
file 'man/colorls.1' => ['man/colorls.1.ronn', 'lib/colorls/flags.rb'] do
require 'colorls'
require 'date'
require 'ronn'
flags = ColorLS::Flags.new
attributes = {
date: Date.iso8601(`git log -1 --pretty=format:%cI -- man/colorls.1`),
manual: 'colorls Manual',
organization: "colorls #{ColorLS::VERSION}"
}
doc = Ronn::Document.new(nil, attributes) do
template = File.read('man/colorls.1.ronn')
section = ''
flags.options.each do |o|
section += <<OPTION
* `#{o.flags.join('`, `')}`:
#{o.desc.join("<br>\n")}
OPTION
end
template.sub('{{ OPTIONS }}', section)
end
File.write('man/colorls.1', doc.convert('roff'))
end
directory 'zsh'
desc 'Build the Zsh completion file'
file 'zsh/_colorls' => %w[zsh lib/colorls/flags.rb] do
ruby "exe/colorls '--*-completion-zsh=colorls' > zsh/_colorls"
end
task default: %w[spec rubocop man/colorls.1 zsh/_colorls]