top of page

Documentation

  Rubin version 1.0 released Feb 2023
  A Ruby environment.                                                                                              rubinsystem@gmail.com 

 This file is a basic run through of the system.
To run rubin you can run "launch.rb" from the install directory.

  Topics:
    System Directories
    System Files & Components
    Apps
    The Class Directory
    About System Config and Features
    Building and running apps.

  System Directories.
 
  There is a default tree of directories built when rubin installs.
  /rubin/data                                                     all kinds of data lives here
  /rubin/app                                                       apps and programs 
  /rubin/bin                                                         interpreters and other exes
  /rubin/class                                                     you can store project files here, they are run automatically on boot
  /rubin/shortcuts                                            meant for lnk files but can run rb files externally(from the caller)
  /rubin/system                                                system scripts are stored here
  /rubin/data/appdata                                    apps can store data here
  /rubin/data/backups                                    various copies of stuff can go here, system versions for example
  /rubin/data/config                                        system config is here but any program can store config here
  /rubin/data/components                                  non system component files
  /rubin/data/definitions                              definition files compiled with export classes are kept here
  /rubin/data/fileio                                          FileIO_Binding can be set to eval to/from files, lol
  /rubin/data/logs                                            logs go here duh
  /rubin/data/scripts                                       ect script files
  /rubin/data/sys                                             
  /rubin/data/sys/instance                          insance data on installation instances running
  /rubin/data/temp                                        a dir that is auto cleaned based on age and access frequency*
rubin/data/user                                           a dir that is pretty unused for now
You can access these paths globally with SYSTEM.dirs or SYSTEM.appdatadir / SYSTEM.datadir for example.

System Files and Components

  The system directory follows a rule system, any file in it besides 'rubin.rb', the 'definitions.rb' or
  'deamond.rb', will be treated as a system component and loaded, all classes in a component are declared
  then initialized into an instance variable sharing their name. Component files can have names like
  String.component.rb to indicate what context the system should evaluate the component onto. If no
  named context is present components initialize on rubin system by default. The component system is
  still under active development and the load_component method hasnt been rewritten in this version.
  Components are intended to be files of class definitions, they will all be declared when loaded
  and placed in instance variables on  the local context. After all the classes are intialized they
  will all be checked for a post_initialize method and it will be called if they have one, but only
  after all classes are initialized.

  The daemond file.

   The system daemond is a class object whos sole job is to run the daemond files contents on main
   context after running embedded system threads. The daemond class also holds a threadpool that
   can be used to hold references to threads anywhere in the program. The daemond will be imporved soon.

  The definitions file.

  The definitions file is an installer included definition, if config 9 is set to true rubin will look for this
  file when booting, it can also be set to an array and a list of names of files in /rubin/data/definitions.
  Just set to false or [] to just not load any definition files. The purpose of definition files is either to
  redefine classes and or function as large ruby method libraries. They will be really common methods
  that share code across ruby programs.
  Keep note that for now definitions automatically evaluate on Rubin_System class objects context, later it will be configurable so you can run definitions on main and other contexts***********


  Apps and app development.
   
  The app directory stores two types of apps, an app can be what ever named rb file, or a folder with
  an rb file inside sharing its name as an entry point, as this point i call it a program. Apps can store data
  and work with it in their install dir but its better to use /rubin/data/appdata and make a folder
  with the apps name to work with. This dir is called appdatadir.

  when you run an app using SYSTEM.run "appname", rubin evaluates the file, then looks at two
  reserved variables, @app and @threads. After evaluating the app those values will be set by the
  app file and carry over after eval when then system continues to check for an app object and threads.
  if it finds them it ads references to them into @thread_pool and @apps.

  Apps dont have to return links of them self to the system, it just helps with interconectivity of apps.
  apps are free to have what ever file and folder structure in their install directory and appdata


  The Class Directory
 
  Also known as classdir, this directory is either configured to load every ruby script or not. You can add files here you want to run every time you run rubin. Files that run here arent intended to contain apps or your main work code but it can if you want, the actual intended purpose of the class directory is to run redefinition of existing objects as well as new ones,
  they can be used to set up common environments for your apps. Class files can be exported into a definitions file, and visa
  versa. Config index 0 = true for load classdir on startup.

  About System Config

  If you use config, youll get an array of both names and the values. if you use config like this config(1,true)
  you can set the value, if you just use config(1) you will get the value back, you cam also use the config
  items name instead of its number.

  You also get a method show_config or its alias config? which prints a nice numbered list of config values
  next to their name. You have altconfig.cfg files which can point to a config file by name, the system will
  always load that config if an altconfig file exists, preconfig files can exist in multiples with numbered names
  the system will load the lowest numbered preconfig file and then delete it and start up.
  If no preconfig or altconfig files exist the system will load default config: config.cfg

  System Boot order

 1. check work directory, check system, prepare boot.
2. Initialize Rubin_System class object, load config data.
3. Check config for ruby gems and install them if they arent already.
4. Check definitions and load if configured. 
5. Load embedded system components then check sysdir for component files.
5. Load all  files in the classdir if configured to.;m
6. Rubin_System runs post_init method, runs autostart apps.
7. Run startup scripts if configured.
8. Starts a repl shell if configured. 
9. System is up if the flow(of eval) wasnt captured by an app or the system shell flow is returned to the
    caller with nil.

Installing the system and using it for the first time.

  When you complete the installer script and open then new rubin installation directory you made,
you will find the system directories, a launcher and a cmd script to start the users installed ruby irb.
Assuming you have ruby installed on windows you will have irb. 
Irb is for catching exceptions the shell could not catch, just load 'launch.rb'. and proceed normally or
attempt to replicate your error. The shell will catch and error log the majority of exceptions you
encounter. The shell saves sessions and you can run the last sessions input again using shell.run_last_session.

  Building an app.
  Here is a simple straight forward modle of an app file

###### App.rb
class App
  def initialize
    @t=nil
  end
  def post_initialize
    @t1=Thread.new{ 100000.times {rand}}
  end
  def shutdown
  end
end
@app=App.new
@app.post_initialize

@threads<<@app.instance_variable_get("@t1")
########

  @app and @threads are system reserved and are collected for data if they happen to 
  contain any after an app file is ran. This will help the system control apps and their threads to interact
  with eachother and the system.
  theres also a shutdown method, if you define one in your app, a system shutdown or restart will check
  to see if its defined for an app and call it if so.

 

  Running apps.
You can get apps in the appdir by calling apps? and run with run 'appname' no extension or path needed.
Running apps go into a Rubin_System instance varibale @apps as an array of data
[appname,instanceid,runtime,appobj,threads]

Running apps can either take flow control or run threads and return control to the system shell.
Apps can evan have their own shell, in oss.rb there is a Shell object class for repl.

  You have the methods apps.get *args "InstanceId" to get running apps, running an app returns its instance id.
  All loaded apps push an array of info into @apps

  System Basics:
 
  You can refer to the keyword cheatsheet file for a list of most important keywords.
 
 
  dir *args           gets / sets workdir
  dirs *args          returns array of system dirs, return a path if given an integer or the name of a dir, i.e: cfgdir,datadir,appdir
  homedir             methods actually exist to access all the system dir paths by name
  @homedir           as well as instance variables, and global variables.

  config?           prints a very readable list of config data.
  config *args      get/set config use indexnumber or cfg name then value as args.
   
  apps?
  scripts?
  shortcuts?
  components?
  definitions?
 
  run(app)
  runs(script)
  load_definition(file)
  load_component(file)
  load_classdir
  import_classdir(name)
  export_classdir(name)
 
  restart *args F to skip dialig
  shutdown *args F

  instance.pop
  con.members?
  con.request("id","script")
  install.size?
  install.generate_installer
  install.generate_package(name)
  install.default_build_package        
  install.install_package(name,dir)
  host.call(cmd)
 
  shell.session
  shell.previous_session
  shell.run_last_session
  shell.sessions
  shell.run_session(session)
 
  @loaded_files
  @loaded_config
  config_files?
  preconfig?
  save_preconfig
  remove_preconfig
  save_altconfig
  read_config(name)
  write_config(name,index,value)
  logs?
  measure_logs
  clean_logs
  read_log(name)
 
 
 
 
And remember you have aliases like lm for local_methods, which shows methods made after a class initialized, iv for instance_variables
and constants to get classes and other objects.
 

bottom of page