Getting Started with Origen
A mechanism is provided to customize the Origen installation to a particular company.
The main customization options that this currently provides are:
- An internal gem server. This can be used to distribute private Origen plugins within your company. When this is defined any new Origen applications that are created will automatically come configured to read from your server in addition to rubygems.org.
- Integration with your company’s email delivery system, allowing your applications to easily send transactional email to their users.
- Integration with your company’s LDAP user authentication system. This API may not be generic enough yet, but it is used within NXP and we are keen to work with anyone who wants to pilot it within another company.
Whenever an application is invoked, one of the first things that Origen will do is search
for a company configuration file called
Starting from the application directory, the file system will be checked for the presence of any valid configuration files within the application’s config or root directories, and then in any of its parent directories until it hits the file system root directory.
It will then check for a configuration file within the directory where Ruby is installed, and then again recursively through any of its parent directories.
If multiple files are found then they will all be applied, with highest priority given to the files that are found first - i.e. those located closest to the current application.
So for example, if everyone in your company uses a common Ruby installation, then you can put a config file somewhere in Ruby’s directory and it will be globally applied.
Alternatively, if all of your users have their workspaces underneath
/proj/origen_site_config.yml may be a good place to put it.
This also provides a mechanism for per-project or even per-application overrides by
adding additional config files higher up the tree.
To create a config file simple copy the default configuration from Origen core and edit it as required.
The values present in this default file are the ones that will be applied by default in an installation where no custom configs are present.
To test if your configuration values are being applied, open a console within an Origen application:
You can then query the current live values via the following API, where the method names correspond directly to the attribute names in the config file:
Origen.site_config.gem_server # => nil Origen.site_config.gem_manage_bundler # => true
The Origen site config has some basic methods to dynamically get, set, and remove values.
Origen.site_config.get(var) #=> gets the current value of a site config variable 'name' #=> if var doesn't exist, nil is returned Origen.site_config.get_all(var) #=> gets all values of a site config variable 'name' #=> returns an array of values, where the higher priority values are earlier in the array #=> i.e., get_all(var).first is the current value and highest priority #=> get_all(var).last is the lowest priority value #=> same as Origen.site_config.add_as_highest(var, value) Origen.site_config[var] #=> same as Origen.site_config.get(var)
Origen.site_config.add_as_highest(var, value) #=> add a new site variable at the highest priority Origen.site_config.add_as_lowest(var, value) #=> add a new site variable at the lowest priority #=> essentially, this sets a new default value Origen.site_config[var] = value #=> same as Origen.site_config.add_as_highest(var, value)
remove_highest(var) #=> remove the highest instance of var #=> returns the value of the variable removed #=> if var doesn't exist, nil is returned remove_all_instances(var) #=> remove all the instances of var #=> returns an array of the values, from highest priority to lowest #=> if var doesn't exist, the an empty array is returned purge(var) #=> aliase to remove_all_instances clear #=> clears the site config completely
Adding New Configuration Files
You can also add a new configuration file that is not in the default paths using the methods below:
# Adds a new site config file as the highest priority add_site_config_as_highest(site_config_file) # Adds a new site config file as the lowest priority add_site_config_as_lowest(site_config_file)
user_install_dirwon't have the desired effect.
falseare not the same. If either of those are undefined (
nil) they will resolve to true. To disable, they must be explicity set to