Is there any way to install man pages using gem specification?
For example, gem install XXX-1.0.0.gem
should install the man page to the system.
Use `gem install -v` You may already be familiar with gem install , but if you add the -v flag, you can specify the version of the gem to install. Using -v you can specify an exact version or use version comparators.
To install a gem, use gem install [gem] . Browsing installed gems is done with gem list . For more information about the gem command, see below or head to RubyGems' docs. There are other sources of libraries though.
What does gem install do? gem install , in its simplest form, does something kind of like this. It grabs the gem and puts its files into a special directory on your system. You can see where gem install will install your gems if you run gem environment (look for the INSTALLATION DIRECTORY: line):
Rubygems currently doesn't support installing manpages for gems.
A patch was submitted to Rubygems a while ago to add support for manpages, but it was rejected.
You can use the gem-man gem to install manpages for gems.
They also offer a "cheating switch" to use the global man: alias man="gem man -s"
I think i have found a solution:
At first, you have to add a native extension to the gem:
my_gem.gemspec:
s.extensions << 'manpage/extconf.rb'
s.files << 'manpage/my_gem.1'
Then gem install
will execute the extconf.rb
and wants to call a Makefile.
make clean
make
make install
So the extconf.rb
can be used to create the Makefile.
You also have to make sure, that there must be at least a dummy Makefile or else the installation will fail.
makefile = "make:\n" \
"\t%s\n" \
"install:\n" \
"\t%s\n" \
"clean:\n" \
"\t%s\n"
if RUBY_PLATFORM =~ /linux/
clean = 'sudo rm -f /usr/local/share/man/man1/my_gem.1.gz'
make = 'gzip my_gem.1'
install = 'sudo cp -r my_gem.1.gz /usr/local/share/man/man1/'
puts
puts 'You need super user privileges to install the manpage for my_gem.'
puts 'Do you want to proceed? (y/n)'
puts 'The gem will be installed anyways.'
input = STDIN.gets.chomp.strip.downcase
if input == 'y' or input == 'yes'
File.write('Makefile', makefile % [make, install, clean])
else
File.write('Makefile', makefile % [':', ':', ':']) # dummy makefile
end
else
File.write('Makefile', makefile % [':', ':', ':']) # dummy makefile
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With