[rubygems/rubygems] Install man files when bundler installed as a default gem
https://github.com/rubygems/rubygems/commit/28d6d77d81
This commit is contained in:
parent
64e89713da
commit
ece1690105
Notes:
git
2020-05-08 14:14:17 +09:00
@ -168,15 +168,20 @@ By default, this RubyGems will install gem as:
|
||||
extend MakeDirs
|
||||
|
||||
lib_dir, bin_dir = make_destination_dirs install_destdir
|
||||
man_dir = make_man_dir install_destdir
|
||||
|
||||
install_lib lib_dir
|
||||
|
||||
install_man man_dir
|
||||
|
||||
install_executables bin_dir
|
||||
|
||||
remove_old_bin_files bin_dir
|
||||
|
||||
remove_old_lib_files lib_dir
|
||||
|
||||
remove_old_man_files man_dir
|
||||
|
||||
install_default_bundler_gem bin_dir
|
||||
|
||||
if mode = options[:dir_mode]
|
||||
@ -329,6 +334,21 @@ By default, this RubyGems will install gem as:
|
||||
end
|
||||
end
|
||||
|
||||
def install_man(man_dir)
|
||||
mans = { 'Bundler' => 'bundler/man' }
|
||||
mans.each do |tool, path|
|
||||
say "Installing #{tool} manpages" if @verbose
|
||||
|
||||
bundler_man1_files = bundler_man1_files_in(path)
|
||||
bundler_man5_files = bundler_man5_files_in(path)
|
||||
|
||||
Dir.chdir path do
|
||||
install_file_list(bundler_man1_files, "#{man_dir}/man1")
|
||||
install_file_list(bundler_man5_files, "#{man_dir}/man5")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def install_rdoc
|
||||
gem_doc_dir = File.join Gem.dir, 'doc'
|
||||
rubygems_name = "rubygems-#{Gem::VERSION}"
|
||||
@ -443,6 +463,30 @@ By default, this RubyGems will install gem as:
|
||||
return lib_dir, bin_dir
|
||||
end
|
||||
|
||||
def make_man_dir(install_destdir)
|
||||
man_dir = generate_default_man_dir(install_destdir)
|
||||
|
||||
mkdir_p man_dir, :mode => 0755
|
||||
|
||||
return man_dir
|
||||
end
|
||||
|
||||
def generate_default_man_dir(install_destdir)
|
||||
prefix = options[:prefix]
|
||||
|
||||
if prefix.empty?
|
||||
man_dir = RbConfig::CONFIG['mandir']
|
||||
else
|
||||
man_dir = File.join prefix, 'man'
|
||||
end
|
||||
|
||||
unless install_destdir.empty?
|
||||
man_dir = File.join install_destdir, man_dir.gsub(/^[a-zA-Z]:/, '')
|
||||
end
|
||||
|
||||
man_dir
|
||||
end
|
||||
|
||||
def generate_default_dirs(install_destdir)
|
||||
prefix = options[:prefix]
|
||||
site_or_vendor = options[:site_or_vendor]
|
||||
@ -487,6 +531,20 @@ By default, this RubyGems will install gem as:
|
||||
end
|
||||
end
|
||||
|
||||
# for installation of bundler as default gems
|
||||
def bundler_man1_files_in(dir)
|
||||
Dir.chdir dir do
|
||||
Dir['bundle*.1{,.txt}']
|
||||
end
|
||||
end
|
||||
|
||||
# for installation of bundler as default gems
|
||||
def bundler_man5_files_in(dir)
|
||||
Dir.chdir dir do
|
||||
Dir['gemfile.5{,.txt}']
|
||||
end
|
||||
end
|
||||
|
||||
def bundler_template_files
|
||||
Dir.chdir "bundler/lib" do
|
||||
(Dir[File.join('bundler', 'templates', '**', '{*,.*}')]).
|
||||
@ -554,6 +612,21 @@ abort "#{deprecation_message}"
|
||||
end
|
||||
end
|
||||
|
||||
def remove_old_man_files(man_dir)
|
||||
man_dirs = { man_dir => "bundler/man" }
|
||||
man_dirs.each do |old_man_dir, new_man_dir|
|
||||
man1_files = bundler_man1_files_in(new_man_dir)
|
||||
|
||||
old_man1_dir = "#{old_man_dir}/man1"
|
||||
|
||||
old_man1_files = bundler_man1_files_in(old_man1_dir)
|
||||
|
||||
man1_to_remove = old_man1_files - man1_files
|
||||
|
||||
remove_file_list(man1_to_remove, old_man1_dir)
|
||||
end
|
||||
end
|
||||
|
||||
def show_release_notes
|
||||
release_notes = File.join Dir.pwd, 'History.txt'
|
||||
|
||||
|
@ -28,6 +28,10 @@ class TestGemCommandsSetupCommand < Gem::TestCase
|
||||
bundler/exe/bundle
|
||||
bundler/lib/bundler.rb
|
||||
bundler/lib/bundler/b.rb
|
||||
bundler/man/bundle-b.1
|
||||
bundler/man/bundle-b.1.txt
|
||||
bundler/man/gemfile.5
|
||||
bundler/man/gemfile.5.txt
|
||||
]
|
||||
|
||||
create_dummy_files(filelist)
|
||||
@ -159,6 +163,16 @@ class TestGemCommandsSetupCommand < Gem::TestCase
|
||||
@cmd.rb_files_in('lib').sort
|
||||
end
|
||||
|
||||
def test_bundler_man1_files_in
|
||||
assert_equal %w[bundle-b.1 bundle-b.1.txt],
|
||||
@cmd.bundler_man1_files_in('bundler/man').sort
|
||||
end
|
||||
|
||||
def test_bundler_man5_files_in
|
||||
assert_equal %w[gemfile.5 gemfile.5.txt],
|
||||
@cmd.bundler_man5_files_in('bundler/man').sort
|
||||
end
|
||||
|
||||
def test_install_lib
|
||||
@cmd.extend FileUtils
|
||||
|
||||
@ -173,6 +187,19 @@ class TestGemCommandsSetupCommand < Gem::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
def test_install_man
|
||||
@cmd.extend FileUtils
|
||||
|
||||
Dir.mktmpdir 'man' do |dir|
|
||||
@cmd.install_man dir
|
||||
|
||||
assert_path_exists File.join("#{dir}/man1", 'bundle-b.1')
|
||||
assert_path_exists File.join("#{dir}/man1", 'bundle-b.1.txt')
|
||||
assert_path_exists File.join("#{dir}/man5", 'gemfile.5')
|
||||
assert_path_exists File.join("#{dir}/man5", 'gemfile.5.txt')
|
||||
end
|
||||
end
|
||||
|
||||
def test_install_default_bundler_gem
|
||||
@cmd.extend FileUtils
|
||||
|
||||
@ -266,6 +293,29 @@ class TestGemCommandsSetupCommand < Gem::TestCase
|
||||
files_that_stay.each {|file| assert_path_exists file }
|
||||
end
|
||||
|
||||
def test_remove_old_man_files
|
||||
man = File.join @install_dir, 'man'
|
||||
|
||||
ruby_1 = File.join man, 'man1', 'ruby.1'
|
||||
bundle_b_1 = File.join man, 'man1', 'bundle-b.1'
|
||||
bundle_b_1_txt = File.join man, 'man1', 'bundle-b.1.txt'
|
||||
bundle_old_b_1 = File.join man, 'man1', 'bundle-old_b.1'
|
||||
bundle_old_b_1_txt = File.join man, 'man1', 'bundle-old_b.1.txt'
|
||||
gemfile_5 = File.join man, 'man5', 'gemfile.5'
|
||||
gemfile_5_txt = File.join man, 'man5', 'gemfile.5.txt'
|
||||
|
||||
files_that_go = [bundle_old_b_1, bundle_old_b_1_txt]
|
||||
files_that_stay = [ruby_1, bundle_b_1, bundle_b_1_txt, gemfile_5, gemfile_5_txt]
|
||||
|
||||
create_dummy_files(files_that_go + files_that_stay)
|
||||
|
||||
@cmd.remove_old_man_files man
|
||||
|
||||
files_that_go.each {|file| refute_path_exists file }
|
||||
|
||||
files_that_stay.each {|file| assert_path_exists file }
|
||||
end
|
||||
|
||||
def test_show_release_notes
|
||||
@default_external = @ui.outs.external_encoding
|
||||
@ui.outs.set_encoding Encoding::US_ASCII
|
||||
|
Loading…
x
Reference in New Issue
Block a user