1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
10 | ruby language support (C) Novell Inc. |
11 \----------------------------------------------------------------------/
13 Author: Duncan Mac-Vicar <dmacvicar@suse.de>
15 This program is free software; you can redistribute it and/or
16 modify it under the terms of the GNU General Public License
17 as published by the Free Software Foundation; either version
18 2 of the License, or (at your option) any later version.
22 #define y2log_component "Y2Ruby"
23 #include <ycp/y2log.h>
24 #include <ycp/pathsearch.h>
26 #include "Y2RubyComponent.h"
28 #include "YRubyNamespace.h"
32 Y2RubyComponent::Y2RubyComponent()
34 // Actual creation of a Ruby interpreter is postponed until one of the
35 // YRuby static methods is used. They handle that.
37 y2milestone( "Creating Y2RubyComponent" );
41 Y2RubyComponent::~Y2RubyComponent()
43 y2milestone( "Destroying Y2RubyComponent" );
48 void Y2RubyComponent::result( const YCPValue & )
52 Y2Namespace *Y2RubyComponent::import (const char* name)
54 y2milestone("Creating namespace for import '%s'", name);
55 // TODO where to look for it
56 // must be the same in Y2CCRuby and Y2RubyComponent
57 string module = YCPPathSearch::find (YCPPathSearch::Module, string (name) + ".rb");
60 y2internal ("Couldn't find %s after Y2CCRuby pointed to us", name);
63 y2milestone("Found in '%s'", module.c_str());
64 module.erase (module.size () - 3 /* strlen (".pm") */);
66 args->add (YCPString(/*module*/ name));
67 args->add (YCPString(/*module*/ module));
69 YRuby::loadModule (args);
70 y2milestone("Module '%s' loaded", name);
71 // introspect, create data structures for the interpreter
72 Y2Namespace *ns = new YRubyNamespace (name);