[yast-devel] Introduce Y2DIR "dir" directory
Hi, in short, I add in ruby bindings automatic inclusion of "dir" repositories in Y2 paths to ruby load path. Reason is to have common place to have pure ruby private ( in sense of not share it with rest of ruby world ) files. Its intended usage is for various modules, classes and other stuff that makes your plugins nicer. Include directory is not good as it contain now translated code and contain some special magic to make it work in ycp-way. Namespace is shared between plugins so it make sense to use own namespace there same way as in "include" directory. Thanks locilka for initial idea. Long story: For code now there is modules, clients and includes. Modules is intended for modules that share its functionality over component system. You can import it. Clients is scripts, that can be executed by Yast2 environment. Include is tricky as it is code snippets that is internally shared, but it has few limitations - It must be included in code, it must be ensured that it is included only once, so it is very limited compared to ruby ( or perl, python ) ability to share code parts. That leads to idea, that we need directory where you can have proprietary parts of code that is intended only for given module and its usage depends on language. Current status is that it is supported only in ruby-bindings, but plan is also to add it to perl and python bindings, if there is someone who is interested in it (e.g. now in perl it must be all in one file or use some tricky loading or write upstream perl library, that can be called). Example demonstration ( not working, just to demonstrate, real example comes after Milestone 4 ): client C: require "services/main_dialog" data = Services.load dialog = MainDialog.new data result = dialog.run if result == :ok Services.save dialog.data end return result dir/services/main_dialog.rb: require "yast" class Services attr_reader :data def initialize ... end def run ... end end Josef -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
Corrupted memory in brain. Directory is of course "lib" like in rails, not "dir". sorry for confusion Josef On Wed, 24 Jul 2013 15:47:31 +0200 Josef Reidinger <jreidinger@suse.cz> wrote:
Hi, in short, I add in ruby bindings automatic inclusion of "dir" repositories in Y2 paths to ruby load path. Reason is to have common place to have pure ruby private ( in sense of not share it with rest of ruby world ) files. Its intended usage is for various modules, classes and other stuff that makes your plugins nicer. Include directory is not good as it contain now translated code and contain some special magic to make it work in ycp-way.
Namespace is shared between plugins so it make sense to use own namespace there same way as in "include" directory.
Thanks locilka for initial idea.
Long story: For code now there is modules, clients and includes. Modules is intended for modules that share its functionality over component system. You can import it. Clients is scripts, that can be executed by Yast2 environment. Include is tricky as it is code snippets that is internally shared, but it has few limitations - It must be included in code, it must be ensured that it is included only once, so it is very limited compared to ruby ( or perl, python ) ability to share code parts. That leads to idea, that we need directory where you can have proprietary parts of code that is intended only for given module and its usage depends on language.
Current status is that it is supported only in ruby-bindings, but plan is also to add it to perl and python bindings, if there is someone who is interested in it (e.g. now in perl it must be all in one file or use some tricky loading or write upstream perl library, that can be called).
Example demonstration ( not working, just to demonstrate, real example comes after Milestone 4 ):
client C:
require "services/main_dialog"
data = Services.load dialog = MainDialog.new data result = dialog.run
if result == :ok Services.save dialog.data end
return result
dir/services/main_dialog.rb: require "yast"
class Services
attr_reader :data
def initialize ... end
def run ... end end
Josef
-- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
On 07/24/2013 04:25 PM, Josef Reidinger wrote:
Corrupted memory in brain. Directory is of course "lib" like in rails, not "dir".
Hi, in short, I add in ruby bindings automatic inclusion of "dir" repositories in Y2 paths to ruby load path. Reason is to have common place to have pure ruby private ( in sense of not share it with rest of ruby world ) files. Its intended usage is for various modules, classes and other stuff that makes your plugins nicer. Include directory is not good as it contain now translated code and contain some special magic to make it work in ycp-way. ... That leads to idea, that we need directory where you can have proprietary parts of code that is intended only for given module and its usage depends on language.
Current status is that it is supported only in ruby-bindings, but plan is also to add it to perl and python bindings, if there is someone who is interested in it (e.g. now in perl it must be all in one file or use some tricky loading or write upstream perl library, that can be called).
Example demonstration ( not working, just to demonstrate, real example comes after Milestone 4 ):
client C: require "services/main_dialog"
return result
dir/services/main_dialog.rb: require "yast"
class Services end
Great, thanks! :) The only piece of information which is missing (or I can't find) is Where is this directory './lib' installed on the system? For instance, this library https://github.com/yast/yast-services-manager/blob/master/src/modules/servic... contains main_dialog function plus its handling and I'd like to put it into some separate file outside /usr/share/YaST2/modules -- because it's not for public usage, it's intended just for the purpose of Yast Services Manager. So, where exactly should I install it? Sources should be IMO in ./lib in https://github.com/yast/yast-services-manager/tree/master/src or am I wrong? Thanks in advance Lukas -- Lukas Ocilka, Cloud & Systems Management Department SUSE LINUX s.r.o., Praha -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
On Tue, Aug 13, 2013 at 03:59:44PM +0200, Lukas Ocilka wrote:
The only piece of information which is missing (or I can't find) is Where is this directory './lib' installed on the system?
Ruby bindings look for it under Y2DIR, so it is /usr/share/YaST2/lib by default. The makefiles/devtools don't contain any helpers for that currently.
For instance, this library https://github.com/yast/yast-services-manager/blob/master/src/modules/servic... contains main_dialog function plus its handling and I'd like to put it into some separate file outside /usr/share/YaST2/modules -- because it's not for public usage, it's intended just for the purpose of Yast Services Manager.
So, where exactly should I install it? Sources should be IMO in ./lib in https://github.com/yast/yast-services-manager/tree/master/src or am I wrong?
Yes, it goes alongside clients and modules under src. -- Martin Vidner, Cloud & Systems Management Team http://en.opensuse.org/User:Mvidner Kuracke oddeleni v restauraci je jako fekalni oddeleni v bazenu
On 08/14/2013 11:43 AM, Martin Vidner wrote:
On Tue, Aug 13, 2013 at 03:59:44PM +0200, Lukas Ocilka wrote:
The only piece of information which is missing (or I can't find) is Where is this directory './lib' installed on the system?
Ruby bindings look for it under Y2DIR, so it is /usr/share/YaST2/lib by default.
Wouldn't it be better to have it in /usr/share/YaST2/${module_name}/lib instead? It's a private library for that module and can potentially collide with any library belonging to another Yast module. That's what we have for includes. Own directory makes a real privacy ;)
The makefiles/devtools don't contain any helpers for that currently.
Vlado, what about rake :)?
So, where exactly should I install it? Sources should be IMO in ./lib in https://github.com/yast/yast-services-manager/tree/master/src or am I wrong?
Yes, it goes alongside clients and modules under src.
Good, would be nice to have this in some Ruby skeleton. Bye Lukas -- Lukas Ocilka, Cloud & Systems Management Department SUSE LINUX s.r.o., Praha -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
Dne 15.8.2013 14:00, Lukas Ocilka napsal(a):
On 08/14/2013 11:43 AM, Martin Vidner wrote:
On Tue, Aug 13, 2013 at 03:59:44PM +0200, Lukas Ocilka wrote:
The only piece of information which is missing (or I can't find) is Where is this directory './lib' installed on the system?
Ruby bindings look for it under Y2DIR, so it is /usr/share/YaST2/lib by default.
Wouldn't it be better to have it in /usr/share/YaST2/${module_name}/lib instead? It's a private library for that module and can potentially collide with any library belonging to another Yast module.
You should create a subdirectory there, like /usr/share/YaST2/lib/${module_name}/. It's the same as includes (/usr/share/YaST2/include/${module_name}/). This should avoid collisions.
The makefiles/devtools don't contain any helpers for that currently.
I can look at it later to make it unified... -- Ladislav Slezák Appliance department / YaST Developer Lihovarská 1060/12 190 00 Prague 9 / Czech Republic tel: +420 284 028 960 lslezak@suse.com SUSE -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
participants (4)
-
Josef Reidinger
-
Ladislav Slezak
-
Lukas Ocilka
-
Martin Vidner