lib/core/core_process_setup.rb
# Setup process.
# The setup process is used to ask the end user to provide some data.
# You can call it before you run an action, or during a configution setting
# of your application.
#
# setup will be exposed to the end user per several steps, and config data
# to ask in a specific order, with optionnally some explanations, possible
# values (hard coded list of values or queried from the model) and default
# value.
#
# Ex:
# Step 1 description : *Provider configuration*:
# explanation        : You are going to setup your account information
#   ask a config data: Enter my account name:  |myuser|
#   ask others data  : Enter ...
# Step 2 description : *Another configuration to setup*:
#   ask several data : Enter ...
# etc...
#
# Steps are predefined in the application defaults.yaml from
# /:setup/:ask_step
# Commonly, each step can define the following options:
# - :desc:            Required. Define the step description.
#                     ERB template enable. To get config data,
#                     type <%= config[...] %>
# - :explanation:  |- Optional. Define a multiline explanation. This is
#                     printed out in brown color.
#                     ERB template enable. To get config data, type
#                     <%= config[...] %>
#
# For details or more options, see core_model.rb
#
# config data are initially identified by the Object model dependency.
# (See obj_needs model declaration.)
#
# The 'object_type' passed as parameter is the top level object in object
# dependency.
# each config data are sorted by object dependencies and additionnal options
# defined in the application defaults.yaml at:
# /:section/<section name>/<data>/ See lib/core/code_model.rb
#
# setup will ask only data which are configured with :account => true
# /:section/<section name>/<data>/:account => true
#
# Additional config data can added to the list thanks to:
# /:setup/:ask_step/*:add/*
#
# Commonly, each data can define the following options:
# - :account:           Optional. default: False
#                       => setup will ask the data only if :account is true
# - :desc:              Required if :account is true. String. default: nil
#                       => Description
# - :explanation:  |-   Print a multiline explanation before asking the data
#                       ERB template enable. To get config data,
#                       type <%= config[...] %>
# - :ask_sort:          Number sort position.
# - :after:             Name of the previous <Data> to ask before the
#                       current one.
# - :depends_on:        Additional data dependency.
# - :default_value:     Default value at setup time.
# - :validate:          Regular expression to validate end user input
#                       during setup.
# - :list_values:       Additional options to get a list of possible values.
# - :post_step_function Function to call after data asked to the user.
#   This function must return a boolean:
#   - true : The data is accepted and setup will go further.
#   - false: The data is NOT accepted and setup will ask the data again.
#     setup will loop until the function is happy with (return true)
# - :pre_step_function  Function to call before data is asked to the user.
#   This function must return a boolean:
#   - true : setup will ask the data.
#   - false: setup will skip asking the data.
#
# For details or more options, see core_model.rb
#
# Setup is based on a config object which requires to have at least
# following functions:
# - value = get(key, default)
# - set(key, value)
# You can create you own config class, derived from Lorj::Config.
#
# When setup has done to ask data to the user, the config object is updated.
# It is up to you and your application to decide what you want to do with
# those data.
# Usually, if your application uses setup to setup an account settings
# Lorj::Account or some local application defaults Lorj::Config, you may
# want to save them to a configuration file.
# If you are using Lorj::Account, use function ac_save
# If you are using Lorj::Config, use function config_save
#
# * *Args* :
#   - +ObjectType+   : Top object type to ask.
#
# * *Returns* :
#   - nothing.
#
# * *Raises* :
#
Setup process.
The setup process is used to ask the end user to provide some data.
You can call it before you run an action, or during a configution setting
of your application.

setup will be exposed to the end user per several steps, and config data
to ask in a specific order, with optionnally some explanations, possible
values (hard coded list of values or queried from the model) and default
value.





For details or more options, see core_model.rb

config data are initially identified by the Object model dependency.
(See obj_needs model declaration.)

The 'object_type' passed as parameter is the top level object in object
dependency.

setup will ask only data which are configured with :account => true
:section///:account => true

Additional config data can added to the list thanks to:
:setup/:ask_step:add

Commonly, each data can define the following options:
:account:           Optional.

For details or more options, see core_model.rb

Setup is based on a config object which requires to have at least
following functions:
value = get(key, default)
set(key, value)
You can create you own config class, derived from Lorj::Config.

When setup has done to ask data to the user, the config object is updated.
It is up to you and your application to decide what you want to do with
those data.
Usually, if your application uses setup to setup an account settings
Lorj::Account or some local application defaults Lorj::Config, you may
want to save them to a configuration file.
If you are using Lorj::Account, use function ac_save
If you are using Lorj::Config, use function config_save

*Args* :
+ObjectType+   : Top object type to ask.

*Returns* :
nothing.

*Raises* .
Setup process . The setup process is used to ask the end user to provide some data . You can call it before you run an action or during a configution setting of your application . setup will be exposed to the end user per several steps and config data to ask in a specific order with optionnally some explanations possible values ( hard coded list of values or queried from the model ) and default value . For details or more options see core_model . rb config data are initially identified by the Object model dependency . ( See obj_needs model declaration . ) The ' object_type ' passed as parameter is the top level object in object dependency . setup will ask only data which are configured with : account = > true : section /// : account = > true Additional config data can added to the list thanks to : : setup / : ask_step : add Commonly each data can define the following options : : account : Optional . For details or more options see core_model . rb Setup is based on a config object which requires to have at least following functions : value = get ( key default ) set ( key value ) You can create you own config class derived from Lorj :: Config . When setup has done to ask data to the user the config object is updated . It is up to you and your application to decide what you want to do with those data . Usually if your application uses setup to setup an account settings Lorj :: Account or some local application defaults Lorj :: Config you may want to save them to a configuration file . If you are using Lorj :: Account use function ac_save If you are using Lorj :: Config use function config_save * Args * : + ObjectType + : Top object type to ask . * Returns * : nothing . * Raises * .
def _setup_data_position?(order, data_to_check)
      meta = _get_meta_data(data_to_check)
      return nil if meta.nil?
      return nil unless meta.rh_exist?(:after) || meta.rh_exist?(:before)
      after = meta.rh_get(:after)
      before = meta.rh_get(:before)
      after_index = nil
      before_index = nil
      order.each do |k, attrs|
        attrs.each do |attr_name|
          after_index = [k, attrs.index(attr_name) + 1] if after == attr_name
          before_index = [k, attrs.index(attr_name)] if before == attr_name
        end
      end
      return nil if after_index.nil? && before_index.nil?
      [after_index, before_index, after, before]
    end
def _setup_data_position? ( order , data_to_check ) meta = _get_meta_data ( data_to_check ) return nil if meta . nil? return nil unless meta . rh_exist? ( :after ) || meta . rh_exist? ( :before ) after = meta . rh_get ( :after ) before = meta . rh_get ( :before ) after_index = nil before_index = nil order . each do | k , attrs | attrs . each do | attr_name | after_index = [ k , attrs . index ( attr_name ) + 1 ] if after == attr_name before_index = [ k , attrs . index ( attr_name ) ] if before == attr_name end end return nil if after_index . nil? && before_index . nil? [ after_index , before_index , after , before ] end
Setup process.
Setup process .
order
<not_specific>
data_to_check
<not_specific>