diff options
author | The Bundler Bot <bot@bundler.io> | 2017-05-14 11:36:59 +0000 |
---|---|---|
committer | The Bundler Bot <bot@bundler.io> | 2017-05-14 11:36:59 +0000 |
commit | 396692631648eda130bdd291e91895fa37e75478 (patch) | |
tree | f193d1a04cea9e80352fd86575d2484f05684b06 | |
parent | 31297d10a33e095e2f4b523b99264f777eb0238d (diff) | |
parent | a52076c06ad77f8dd1b2df7c0763e45ff7369ff0 (diff) | |
download | bundler-396692631648eda130bdd291e91895fa37e75478.tar.gz |
Auto merge of #5660 - bundler:seg-ensure-man, r=colby-swandale
Ensure that manpages are always built when running specs
Fixes #5657 by ensuring manpages are always built, much like how `Spec::Rubygems.setup` ensures gem dependencies are always installed
\c @colby-swandale
-rw-r--r-- | Rakefile | 23 | ||||
-rw-r--r-- | man/index.txt | 15 | ||||
-rw-r--r-- | spec/spec_helper.rb | 1 | ||||
-rw-r--r-- | spec/support/manpages.rb | 13 |
4 files changed, 34 insertions, 18 deletions
@@ -70,7 +70,7 @@ namespace :spec do sh "sudo apt-get install graphviz -y 2>&1 | tail -n 2" # Install the gems with a consistent version of RubyGems - sh "gem update --system 2.6.11" + sh "gem update --system 2.6.12" $LOAD_PATH.unshift("./spec") require "support/rubygems_ext" @@ -240,12 +240,15 @@ begin namespace :man do directory "man" + 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/ + manual_section = ".1" unless basename =~ /\.(\d+)\Z/ roff = "man/#{basename}#{manual_section}" + index << [ronn, File.basename(roff)] + file roff => ["man", ronn] do sh "#{Gem.ruby} -S ronn --roff --pipe #{ronn} > #{roff}" end @@ -257,9 +260,23 @@ begin task :build_all_pages => "#{roff}.txt" end + 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 + task :build_all_pages => "index.txt" + task :clean do leftovers = Dir["man/*"].reject do |f| - File.extname(f) == ".ronn" || f == "man/index.txt" + File.extname(f) == ".ronn" end rm leftovers if leftovers.any? end diff --git a/man/index.txt b/man/index.txt deleted file mode 100644 index e3b38c46db..0000000000 --- a/man/index.txt +++ /dev/null @@ -1,15 +0,0 @@ -Gemfile(5) gemfile.5 -bundle-install bundle-install.1 -bundle-update bundle-update.1 -bundle-package bundle-package.1 -bundle-exec bundle-exec.1 -bundle-config bundle-config.1 -bundle-platform bundle-platform.1 -bundle-gem bundle-gem.1 -bundle-clean bundle-clean.1 -bundle-check bundle-check.1 -bundle-init bundle-init.1 -bundle-inject bundle-inject.1 -bundle-open bundle-open.1 -bundle-show bundle-show.1 -bundle-viz bundle-viz.1 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 297d81f531..0a6b696fe7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -40,6 +40,7 @@ end $debug = false +Spec::Manpages.setup Spec::Rubygems.setup FileUtils.rm_rf(Spec::Path.gem_repo1) ENV["RUBYOPT"] = "#{ENV["RUBYOPT"]} -r#{Spec::Path.root}/spec/support/hax.rb" diff --git a/spec/support/manpages.rb b/spec/support/manpages.rb new file mode 100644 index 0000000000..f6a4a4ab51 --- /dev/null +++ b/spec/support/manpages.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true +module Spec + module Manpages + def self.setup + man_path = Spec::Path.root.join("man") + return if man_path.children(false).select {|file| file.extname == ".ronn" }.all? do |man| + Dir[man_path.join("#{man.to_s[0..-6]}*.txt").to_s].any? + end + + system(Spec::Path.root.join("bin", "rake").to_s, "man:build") || raise("Failed building man pages") + end + end +end |