Binaries and generators with different names

0 views
Skip to first unread message

Orion

unread,
Feb 6, 2008, 12:22:50 PM2/6/08
to RubiGen
Hey Nic,

First off, I build all of our gems using newgem and rubigen (they're
awesome!!!). I am working on a gem for my company to manage all of
our logging utilities and following my companies standard practice I
have one binary 'logging_utility' which IT will use to do all the
necessary commands. I am using RubiGen to build a generator to
install the necessary Log4J libraries to run our logger. However, I
am having a hell of a time getting the Generator to load because the
generator is named different than the binary (which I would like to do
since logging_utility does a lot more than just install libraries).

I know in your documentation that you said that binary needs to be
named the same as the generator, but is there anyway to get around
this?

Here is a code snippet that I am trying:

when "install_loghub"
require File.join(File.dirname(__FILE__), '../lib/sonic_logger/
server/boot')
config = SonicLogger::Cluster.instance
hl = HighLine.new
pd_str = "--> "
pd_left = 35
install_dir = args[0] || config.loghub_lib_dir
exit(0) unless hl.agree("Install loghub library in the
#{install_dir} directory? (y/n)")

hl.say "Generating library..."
require 'rubigen/scripts/generate'
RubiGen::Base.use_application_sources! :loghub_lib
RubiGen::Scripts::Generate.new.run([install_dir], :generator =>
'loghub_lib')

# Rewrite configuration file
if install_dir != config.loghub_lib_dir
hl.say "Updating configuration file..."
SonicLogger::Cluster.configure(:loghub_directory => install_dir)
end
puts "Done."

I get the folllow error message when I try the command:

[root@OrionFoot sonic_logger]# ruby bin/logger_utility install_loghub
Install loghub library in the /usr/local/loghub directory? (y/n)
y
Generating library...
Couldn't find 'loghub_lib' generator

Orion

unread,
Feb 6, 2008, 1:49:38 PM2/6/08
to RubiGen
Nevermind.

This does actually work but it turns out the gem has to be installed
instead of just running the executable straight out of the development
directory.

Thanks

Nic Williams

unread,
Feb 6, 2008, 3:12:11 PM2/6/08
to rub...@googlegroups.com
Oh, you can't find the generator unless its an installed gem? Yeah that's probably true by default.

You can add additional paths to the search for generators, into the script/generate method, but its a bit convoluted and you'd need to do it for every gem you needed it to work for.

If its a real problem, I can have a think about something else. Perhaps have a ~/.rubigen config file that adds other paths to search for gems-in-development to find generators.

Cheers
Nic

--
Dr Nic Williams
http://drnicacademy.com - Ruby/Rails training/dev around the world
http://drnicwilliams.com - Ruby/Rails/Javascript/Web2.0
(skype) nicwilliams
(p) +61 412 002 126 / +61 7 3113 3033
(mail) PO Box 583 Ashgrove 4060 QLD Aus
Reply all
Reply to author
Forward
0 new messages