Dud require for Plist gem

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)
[email protected]_hash[‘serverMAC’][host_name]
end

def get_mac_by_printer(printer_name)
[email protected]_hash[‘printers’][printer_name][‘printerHost’]
[email protected]_hash[‘serverMAC’][host_name]
end

def get_broadcast_ip
[email protected]_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.

Sorry, I’m a muppet.

require ‘rubygems’ was the missing ingredient.

D’oh!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs