[p4ruby] Creating client from scratch

Dale Quigg daleq at messagegate.com
Thu Feb 28 18:33:40 PST 2008

I got an answer off-list.

	spec._view = spec._view =[ a, b ]
is what I need to get it to work.

Thanks Jeff!


-----Original Message-----
From: p4ruby-bounces at perforce.com [mailto:p4ruby-bounces at perforce.com] On Behalf Of Dale Quigg
Sent: Thursday, February 28, 2008 4:04 PM
To: p4ruby at perforce.com
Subject: [p4ruby] Creating client from scratch


I want to create a client from scratch (specifically the view spec)

I can use the code below to get the client created, but the resulting view spec contains (in my case)
	//test/... //dq-auto-1/test/...
	//messagegate/... //dq-auto-1/messagegate/...
	//depot/... //dq-auto-1/depot/...
	//messagegate/foo/... //dq-auto-1/foo/...
	//messagegate/bar/... //dq-auto-1/bar/...

All I want are the last two lines that I added.

I'm sure this is a basic question, but I don't see how to iterate through spec._view and make changes.

If I add code to my example like;
	spec._view = ""
prior to adding my entries, the resulting client has no reference to View:

Also, doing something like;
  spec._view = spec._view << "//messagegate/bar/... //" << ClientName << "/bar/..."
gives pretty odd results.  I'm sure there is some reason for this, and I'm fine with creating a variable and using it like in my example.

Thanks for any help.

--- begin sample ---

require "P4"
p4 = P4.new

ClientName = "dq-auto-1"

  spec = p4.fetch_client( ClientName )

  a = "//messagegate/foo/... //" << ClientName << "/foo/..."
  b = "//messagegate/bar/... //" << ClientName << "/bar/..."
  spec._view = spec._view <<  a
  spec._view = spec._view <<  b
  spec._description	= ClientName << " description"
  p4.save_client( spec )

rescue P4Exception
  p4.errors.each { |e| $stderr.puts( e ) }

--- end sample ---

Dale Quigg  |||  Senior Build / Configuration / Installation Engineer
MessageGate  |||  Enterprise Email Governance

p4ruby mailing list
p4ruby at perforce.com

More information about the p4ruby mailing list