mirror of
https://github.com/athityakumar/colorls.git
synced 2024-09-19 05:31:23 +02:00
524a9b6ed2
The last change to a file is not necessarily the one with the latest author date, but we want to get the last time the man page was changed (on some branch) and thus it makes more sense to use the commit date rather than the author date.
48 lines
1.1 KiB
Ruby
48 lines
1.1 KiB
Ruby
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 do |task|
|
|
task.requires << 'rubocop-rspec'
|
|
end
|
|
|
|
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 = IO.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
|
|
IO.write('man/colorls.1', doc.convert('roff'))
|
|
end
|
|
|
|
desc 'Build the Zsh completion file'
|
|
file 'zsh/_colorls' => ['lib/colorls/flags.rb'] do
|
|
ruby "exe/colorls '--*-completion-zsh=colorls' > zsh/_colorls"
|
|
end
|
|
|
|
task default: %w[spec rubocop]
|