Mailinglist Archive: yast-devel (66 mails)

< Previous Next >
Re: [yast-devel] Ruby code in SCR
On 06/20/2013 03:14 PM, Klaus Kaempf wrote:
This seems to add lots of complexity (and responsability) to
individual modules.

Instead of

chroot.run Network.write(complex_map)

I'd rather see something like

# global 'chroot' call, done by installer
SCR.init("/mnt")
...
Network.write(complex_map)

That's how it works now.

and

module Network

# SCR init still needed if Network is run stand-alone
# it's a no-op if SCR.init was called before
SCR.init
...
SCR.write ...
end

Actually, if no SCR.init (different call name in use currently) SCR automatically uses "/" (no chroot).

It looks good except one thing: It doesn't solve running some Ruby code defined in the Yast library. I still have to create a special agent and call the agent.

What I wanted to solve was: There is a Yast library with some business logic and nice API. In this module, I want to use another Ruby libraries, such as File/Dir to read/modify the system. Right now, I have to use SCR for accessing the system.

Totally hackish solution for this:
--- cut ---
code = '$some_fancy_code_in_ruby'

SCR::Execute(
path('.ruby'),
code
)
--- cut ---

Agent .ruby would then eval() the code.

Sounds horrible but it would do the trick :) I'm not sure about proper testing though.

Lukas

--

Lukas Ocilka, Cloud & Systems Management Department
SUSE LINUX s.r.o., Praha
--
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: yast-devel+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups