summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBodo Tasche <bodo@wannawork.de>2016-10-30 14:10:40 +0100
committerBodo Tasche <bodo@wannawork.de>2016-10-30 18:06:58 +0100
commit8f6970c5465d9aa6d002d2f2b7f03ba82ddde9b5 (patch)
treea0427a25756ed518524d8594c57ae030b6dabcdf
parentced83655d9643e804079a4f2a6967536a4f8b981 (diff)
downloadbundler-8f6970c5465d9aa6d002d2f2b7f03ba82ddde9b5.tar.gz
Move man pages to man folder
The gem-man gem searches for the man pages in the man folder. This pr fixes this and also creates correct names for the manpages. A manpage always needs the section number in the filename.
-rw-r--r--.gitignore2
-rw-r--r--Rakefile12
-rw-r--r--bundler.gemspec2
-rw-r--r--lib/bundler/cli.rb29
-rw-r--r--spec/commands/exec_spec.rb10
-rw-r--r--spec/commands/help_spec.rb16
6 files changed, 32 insertions, 39 deletions
diff --git a/.gitignore b/.gitignore
index bd5d29dc7b..88730f82cd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,6 +11,8 @@
# output from ronn
/lib/bundler/man/
+man/*
+!man/*.ronn
# rspec failure tracking
.rspec_status
diff --git a/Rakefile b/Rakefile
index 178d481655..149f09f3da 100644
--- a/Rakefile
+++ b/Rakefile
@@ -238,14 +238,15 @@ begin
require "ronn"
namespace :man do
- directory "lib/bundler/man"
+ directory "man"
sources = Dir["man/*.ronn"].map {|f| File.basename(f, ".ronn") }
sources.map do |basename|
ronn = "man/#{basename}.ronn"
- roff = "lib/bundler/man/#{basename}"
+ manual_section = ".1" unless basename =~ /.*(\d+)\Z/
+ roff = "man/#{basename}#{manual_section}"
- file roff => ["lib/bundler/man", ronn] do
+ file roff => ["man", ronn] do
sh "#{Gem.ruby} -S ronn --roff --pipe #{ronn} > #{roff}"
end
@@ -257,9 +258,8 @@ begin
end
task :clean do
- leftovers = Dir["lib/bundler/man/*"].reject do |f|
- basename = File.basename(f).sub(/\.(txt|ronn)/, "")
- sources.include?(basename)
+ leftovers = Dir["man/*"].reject do |f|
+ File.extname(f) == ".ronn" || f == "man/index.txt"
end
rm leftovers if leftovers.any?
end
diff --git a/bundler.gemspec b/bundler.gemspec
index f67c538fd6..8188886ded 100644
--- a/bundler.gemspec
+++ b/bundler.gemspec
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
s.files = `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
# we don't check in man pages, but we need to ship them because
# we use them to generate the long-form help for each command.
- s.files += Dir.glob("lib/bundler/man/**/*")
+ s.files += Dir.glob("man/**/*")
s.bindir = "exe"
s.executables = %w(bundle bundler)
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 37556f4926..136626731a 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -61,30 +61,21 @@ module Bundler
def help(cli = nil)
case cli
- when "gemfile" then command = "gemfile.5"
+ when "gemfile" then command = "gemfile"
when nil then command = "bundle"
else command = "bundle-#{cli}"
end
- manpages = %w(
- bundle
- bundle-config
- bundle-exec
- bundle-gem
- bundle-install
- bundle-package
- bundle-update
- bundle-platform
- gemfile.5
- )
-
- if manpages.include?(command)
- root = File.expand_path("../man", __FILE__)
-
- if Bundler.which("man") && root !~ %r{^file:/.+!/META-INF/jruby.home/.+}
- Kernel.exec "man #{root}/#{command}"
+ man_path = File.expand_path("../../../man", __FILE__)
+ man_pages = Hash[Dir.glob(File.join(man_path, "*")).grep(/.*\.\d*\Z/).collect do |f|
+ [File.basename(f, ".*"), f]
+ end]
+
+ if man_pages.include?(command)
+ if Bundler.which("man") && man_path !~ %r{^file:/.+!/META-INF/jruby.home/.+}
+ Kernel.exec "man #{man_pages[command]}"
else
- puts File.read("#{root}/#{command}.txt")
+ puts File.read("#{man_path}/#{File.basename(man_pages[command])}.txt")
end
elsif command_path = Bundler.which("bundler-#{cli}")
Kernel.exec(command_path, "--help")
diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb
index 4dc47919de..8a9d0b83c3 100644
--- a/spec/commands/exec_spec.rb
+++ b/spec/commands/exec_spec.rb
@@ -272,35 +272,35 @@ describe "bundle exec" do
with_fake_man do
bundle "#{exec} --help cat"
end
- expect(out).to include(%(["#{root}/lib/bundler/man/bundle-exec"]))
+ expect(out).to include(%(["#{root}/man/bundle-exec.1"]))
end
it "shows bundle-exec's man page when --help is before exec" do
with_fake_man do
bundle "--help #{exec}"
end
- expect(out).to include(%(["#{root}/lib/bundler/man/bundle-exec"]))
+ expect(out).to include(%(["#{root}/man/bundle-exec.1"]))
end
it "shows bundle-exec's man page when -h is before exec" do
with_fake_man do
bundle "-h #{exec}"
end
- expect(out).to include(%(["#{root}/lib/bundler/man/bundle-exec"]))
+ expect(out).to include(%(["#{root}/man/bundle-exec.1"]))
end
it "shows bundle-exec's man page when --help is after exec" do
with_fake_man do
bundle "#{exec} --help"
end
- expect(out).to include(%(["#{root}/lib/bundler/man/bundle-exec"]))
+ expect(out).to include(%(["#{root}/man/bundle-exec.1"]))
end
it "shows bundle-exec's man page when -h is after exec" do
with_fake_man do
bundle "#{exec} -h"
end
- expect(out).to include(%(["#{root}/lib/bundler/man/bundle-exec"]))
+ expect(out).to include(%(["#{root}/man/bundle-exec.1"]))
end
end
end
diff --git a/spec/commands/help_spec.rb b/spec/commands/help_spec.rb
index d59346f615..380e3be15e 100644
--- a/spec/commands/help_spec.rb
+++ b/spec/commands/help_spec.rb
@@ -16,14 +16,14 @@ describe "bundle help" do
with_fake_man do
bundle "help gemfile"
end
- expect(out).to eq(%(["#{root}/lib/bundler/man/gemfile.5"]))
+ expect(out).to eq(%(["#{root}/man/gemfile.5"]))
end
it "prefixes bundle commands with bundle- when finding the groff files" do
with_fake_man do
bundle "help install"
end
- expect(out).to eq(%(["#{root}/lib/bundler/man/bundle-install"]))
+ expect(out).to eq(%(["#{root}/man/bundle-install.1"]))
end
it "simply outputs the txt file when there is no man on the path" do
@@ -55,28 +55,28 @@ describe "bundle help" do
with_fake_man do
bundle "install --help"
end
- expect(out).to eq(%(["#{root}/lib/bundler/man/bundle-install"]))
+ expect(out).to eq(%(["#{root}/man/bundle-install.1"]))
end
it "is called when the --help flag is used before the command" do
with_fake_man do
bundle "--help install"
end
- expect(out).to eq(%(["#{root}/lib/bundler/man/bundle-install"]))
+ expect(out).to eq(%(["#{root}/man/bundle-install.1"]))
end
it "is called when the -h flag is used before the command" do
with_fake_man do
bundle "-h install"
end
- expect(out).to eq(%(["#{root}/lib/bundler/man/bundle-install"]))
+ expect(out).to eq(%(["#{root}/man/bundle-install.1"]))
end
it "is called when the -h flag is used after the command" do
with_fake_man do
bundle "install -h"
end
- expect(out).to eq(%(["#{root}/lib/bundler/man/bundle-install"]))
+ expect(out).to eq(%(["#{root}/man/bundle-install.1"]))
end
it "has helpful output when using --help flag for a non-existent command" do
@@ -90,11 +90,11 @@ describe "bundle help" do
with_fake_man do
bundle "--help"
end
- expect(out).to eq(%(["#{root}/lib/bundler/man/bundle"]))
+ expect(out).to eq(%(["#{root}/man/bundle.1"]))
with_fake_man do
bundle "-h"
end
- expect(out).to eq(%(["#{root}/lib/bundler/man/bundle"]))
+ expect(out).to eq(%(["#{root}/man/bundle.1"]))
end
end