We see these problems in this area:
- Polluting the Ruby top-level namespaces with names as generic as Installation, Packages or UI.
- Collisions (e.g. Storage is already a module and cannot be used as a namespace).
Let's see some examples:
You can see a complete example in PkgFinishClient.
- PkgFinishClient lives in Yast namespace (although is located in
lib/packages/clients/pkg_finish.rb; more on that, later).
- It inherits from
::Installation::FinishClient, which live outside the YaST namespace (polluting the top-level one).
Source code layout
About source code layout, situation is not that bad but it can be improved. Sometimes is not straightforward to find where a class/module is defined (it's easy enough using grep or the Github search, but I'd prefer a more consistent/predictible way).
Although it's not mandatory, using a single class/module per file and naming the file as the class/module (but replacing CamelCase with snake_case) is the preferred option within the Ruby community.
Going back to
PkgFinishClient, it should live in
pkg_finish_client.rb. And a
class should be defined in
Steffen pointed out that if he requires
yast/storage, he would
expect all storage code to be loaded. And he's right. If you want to
load only a class/file, you can require
In an installed system, all YaST2 Ruby code lives in
/usr/share/YaST2. That's fine for things like modules
/usr/share/YaST2/modules) which are quite YaST-specific. But from a
Ruby developer point of view, libraries should live in
/usr/lib64/ruby/vendor_ruby (or something like that).