]> icculus.org git repositories - duncan/yast2-ruby-bindings.git/blob - src/ruby/Y2CCRuby.cc
- Lot of fixes and support for the UI!!!
[duncan/yast2-ruby-bindings.git] / src / ruby / Y2CCRuby.cc
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                                                                      |
10 | ruby language support                              (C) Novell Inc.   |
11 \----------------------------------------------------------------------/
12
13 Author: Duncan Mac-Vicar <dmacvicar@suse.de>
14
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.
19
20 */
21
22 #include "Y2CCRuby.h"
23 #include <ycp/pathsearch.h>
24 #define y2log_component "Y2Ruby"
25 #include <ycp/y2log.h>
26
27 // This is very important: We create one global variable of
28 // Y2CCRuby. Its constructor will register it automatically to
29 // the Y2ComponentBroker, so that will be able to find it.
30 // This all happens before main() is called!
31
32 Y2CCRuby g_y2ccruby;
33
34 Y2Component *Y2CCRuby::provideNamespace (const char *name)
35 {
36   y2debug ("Y2CCRuby::provideNamespace %s", name);
37   if (strcmp (name, "Ruby") == 0)
38   {
39     // low level functions
40
41     // leave implementation to later
42     return 0;
43   }
44   else
45   {
46     // is there a ruby module?
47     // must be the same in Y2CCRuby and Y2RubyComponent
48     string module = YCPPathSearch::find (YCPPathSearch::Module, string (name) + ".rb");
49     
50     if (!module.empty ())
51     {
52       y2milestone("Find module result: '%s'", module.c_str());
53       if (!cruby)
54       {
55         y2milestone("new ruby component");
56         cruby = new Y2RubyComponent();
57       }
58       y2milestone("returning existing ruby component");
59       return cruby;
60     }
61
62     // let someone else try creating the namespace
63     return 0;
64   }
65 }