Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Mock man:build task on jruby
Browse files Browse the repository at this point in the history
So that `rake install:local` at least works.
  • Loading branch information
deivid-rodriguez committed Apr 12, 2019
1 parent def9856 commit 0df0cc4
Showing 1 changed file with 51 additions and 47 deletions.
98 changes: 51 additions & 47 deletions Rakefile
Expand Up @@ -199,68 +199,72 @@ task :rubocop do
end

namespace :man do
ronn_dep = development_dependencies.find do |dep|
dep.name == "ronn"
end

ronn_requirement = ronn_dep.requirement.to_s
if RUBY_ENGINE == "jruby"
task(:build) {}
else
ronn_dep = development_dependencies.find do |dep|
dep.name == "ronn"
end

begin
gem "ronn", ronn_requirement
ronn_requirement = ronn_dep.requirement.to_s

require "ronn"
rescue LoadError
task(:build) { abort "We couln't activate ronn (#{ronn_requirement}). Try `gem install ronn:'#{ronn_requirement}'` to be able to build the help pages" }
else
directory "man"
begin
gem "ronn", ronn_requirement

index = []
sources = Dir["man/*.ronn"].map {|f| File.basename(f, ".ronn") }
sources.map do |basename|
ronn = "man/#{basename}.ronn"
manual_section = ".1" unless basename =~ /\.(\d+)\Z/
roff = "man/#{basename}#{manual_section}"
require "ronn"
rescue LoadError
task(:build) { abort "We couln't activate ronn (#{ronn_requirement}). Try `gem install ronn:'#{ronn_requirement}'` to be able to build the help pages" }
else
directory "man"

index << [ronn, File.basename(roff)]
index = []
sources = Dir["man/*.ronn"].map {|f| File.basename(f, ".ronn") }
sources.map do |basename|
ronn = "man/#{basename}.ronn"
manual_section = ".1" unless basename =~ /\.(\d+)\Z/
roff = "man/#{basename}#{manual_section}"

file roff => ["man", ronn] do
sh "#{Gem.ruby} -S ronn --roff --pipe #{ronn} > #{roff}"
end
index << [ronn, File.basename(roff)]

file "#{roff}.txt" => roff do
sh "groff -Wall -mtty-char -mandoc -Tascii #{roff} | col -b > #{roff}.txt"
end
file roff => ["man", ronn] do
sh "#{Gem.ruby} -S ronn --roff --pipe #{ronn} > #{roff}"
end

task :build_all_pages => "#{roff}.txt"
end
file "#{roff}.txt" => roff do
sh "groff -Wall -mtty-char -mandoc -Tascii #{roff} | col -b > #{roff}.txt"
end

file "index.txt" do
index.map! do |(ronn, roff)|
[File.read(ronn).split(" ").first, roff]
task :build_all_pages => "#{roff}.txt"
end
index = index.sort_by(&:first)
justification = index.map {|(n, _f)| n.length }.max + 4
File.open("man/index.txt", "w") do |f|
index.each do |name, filename|
f << name.ljust(justification) << filename << "\n"

file "index.txt" do
index.map! do |(ronn, roff)|
[File.read(ronn).split(" ").first, roff]
end
index = index.sort_by(&:first)
justification = index.map {|(n, _f)| n.length }.max + 4
File.open("man/index.txt", "w") do |f|
index.each do |name, filename|
f << name.ljust(justification) << filename << "\n"
end
end
end
end
task :build_all_pages => "index.txt"
task :build_all_pages => "index.txt"

task :clean do
leftovers = Dir["man/*"].reject do |f|
File.extname(f) == ".ronn"
task :clean do
leftovers = Dir["man/*"].reject do |f|
File.extname(f) == ".ronn"
end
rm leftovers if leftovers.any?
end
rm leftovers if leftovers.any?
end

desc "Build the man pages"
task :build => ["man:clean", "man:build_all_pages"]
desc "Build the man pages"
task :build => ["man:clean", "man:build_all_pages"]

desc "Remove all built man pages"
task :clobber do
rm_rf "lib/bundler/man"
desc "Remove all built man pages"
task :clobber do
rm_rf "lib/bundler/man"
end
end
end
end
Expand Down

0 comments on commit 0df0cc4

Please sign in to comment.