Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I install a man page using gem spec?

Tags:

ruby

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.

like image 403
Harikrishnan R Avatar asked May 17 '11 06:05

Harikrishnan R


People also ask

How do I install a specific version of a gem?

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.

How do I install gem packages?

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.

How does gem install work?

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):


3 Answers

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.

like image 51
Daniel Avatar answered Oct 04 '22 19:10

Daniel


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"

like image 29
J-_-L Avatar answered Oct 04 '22 20:10

J-_-L


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
like image 39
Alu Avatar answered Oct 04 '22 19:10

Alu