[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Dud require for Plist gem.

Adam Penny

4/24/2008 12:55:00 AM

Hi there,

I'm sorry about this, I'm just working on my first ruby script which
goes as follows:

require 'Plist'
require 'optparse'
#Class for handling the plist file.
class PlistHash
def initialize(path)
@path=path
@plist_hash=Plist::parse_xml(@path)
end

def get_mac_by_host(host_name)
mac=@plist_hash['serverMAC'][host_name]
end

def get_mac_by_printer(printer_name)
host_name=@plist_hash['printers'][printer_name]['printerHost']
mac=@plist_hash['serverMAC'][host_name]
end

def get_broadcast_ip
broadcast_ip=@plist_hash['broadcastIP']
end
end

plist=PlistHash.new('/Library/Preferences/com.apple.wopol.plist')
opts=OptionParser.new
opts.on("-h", "--host HOSTNAME", String) {|val|
plist.get_mac_by_host(val)}
opts.parse(ARGV)


When I try to run this I get the following error:
ruby PlistHash.rb -h PennyG5.local
PlistHash.rb:1:in `require': no such file to load -- Plist (LoadError)
from PlistHash.rb:1

Yet if I type require 'Plist' in irb it's accepted. What am I missing
here.
Thanks for your help people and many apologies if it's something really
dumb.
--
Posted via http://www.ruby-....

1 Answer

Adam Penny

4/24/2008 1:52:00 AM

0

Sorry, I'm a muppet.

require 'rubygems' was the missing ingredient.

D'oh!
--
Posted via http://www.ruby-....