module Lorj

© Copyright 2014 Hewlett-Packard Development Company, L.P.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

© Copyright 2014 Hewlett-Packard Development Company, L.P.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

© Copyright 2014 Hewlett-Packard Development Company, L.P.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

© Copyright 2014 Hewlett-Packard Development Company, L.P.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

© Copyright 2014 Hewlett-Packard Development Company, L.P.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

© Copyright 2014 Hewlett-Packard Development Company, L.P.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Module Lorj which contains several classes.

Those classes describes :

this task to make it to work.

Module Lorj which contains several classes.

Those classes describes :

this task to make it to work.

Lorj implements Lorj::BaseDefinition core internal functions

Module Lorj which contains several classes.

Those classes describes :

this task to make it to work.

Module Lorj which contains several classes.

Those classes describes :

this task to make it to work.

Module Lorj which contains several classes.

Those classes describes :

this task to make it to work.

Module Lorj which contains several classes.

Those classes describes :

this task to make it to work.

Module Lorj which contains several classes.

Those classes describes :

this task to make it to work.

Module Lorj which contains several classes.

Those classes describes :

this task to make it to work.

© Copyright 2014 Hewlett-Packard Development Company, L.P.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Module Lorj which contains several classes.

Those classes describes :

this task to make it to work.

Module Lorj implements ERBConfig, and initialization functions for Lorj::BaseDefinition

Module Lorj which contains several classes.

Those classes describes :

object creation/etc…

mapping and setup this task to make it to work.

Define process module management in Lorj

lorj module

Lorj Module Compatibility

Lorj version

Lorj implements Lorj::Accounts

Lorj implements Lorj::AccountConfig

Lorj implements Lorj::Account

Definition of Lorj::Config

Lorj module implements Lorj::Config Lorj exposes defaults, as attribute to access the Lorj::Defaults instance.

Lorj module implements Lorj::Config Lorj exposes defaults, as attribute to access the Lorj::Defaults instance.

Constants

DATE
VERSION

Public Class Methods

account_import(key, import_data, name = nil) click to toggle source

Function to import an encrypted Hash as a Lorj Account.

The encrypted Hash will be decrypted by the key provided. The content of the hash will be stored in the 'account' layer of config.

For details on how import work, look in account_data_import

  • Args :

    • key : key to use to decrypt the 'enc_hash'.

    • import_data : import data. This data is structured as follow:

      • :enc_data : The encrypted account data.

      • :processes: Array or models + controllers to load.

    • name : Optional. Name of the account.

  • returns:

    • core : Core object, with loaded model, created during the import.

  • Raises : No exceptions

# File lib/core/core_import_export.rb, line 40
def self.account_import(key, import_data, name = nil)
  import_data = YAML.load(import_data)
  hash = Lorj::SSLCrypt.get_encrypted_value(import_data[:enc_data], key,
                                            'Encrypted account data')

  data = YAML.load(hash)

  processes = import_data[:processes]

  processes.each do |p|
    next unless p.key?(:process_module)

    PrcLib.debug("Loading module '#{p[:process_module]}' from GEM lib '%s'",
                 p[:lib_name])
    begin
      require "#{p[:lib_name]}"
    rescue => e
      PrcLib.error("Unable to load module '#{p[:process_module]}'\n%s", e)
    end
  end

  core = Lorj::Core.new(Lorj::Account.new, processes)
  core.account_import(data, name)

  core
end
debug(iLevel, sMsg, *p) click to toggle source

Internal Lorj function to debug lorj.

  • Args :

    • iLevel : value between 1 to 5. Setting 5 is the most verbose!

    • sMsg : Array of string or symbols. keys tree to follow and check

      existence in yVal.
  • Returns :

    • nothing

  • Raises : No exceptions

# File lib/lorj.rb, line 73
def self::debug(iLevel, sMsg, *p)
  PrcLib.core_level = 0 if PrcLib.core_level.nil?

  if iLevel <= PrcLib.core_level
    message = format('-%s- %s', iLevel, sMsg)

    PrcLib.debug(message, *p)
  end
end

Public Instance Methods

data(data = nil) click to toggle source

Lorj::defaults exposes the application defaults and Config Lorj metadata.

You can set the Application layer of meta data, replacing load from defaults.yaml

  • Args

    • data : Optionnal initialized Application layer meta data.

# File lib/lorj_meta.rb, line 754
def data(data = nil)
  return @metadata unless @metadata.nil?

  unless data.is_a?(Hash)
    data = {}
    # TODO: Replace load from defaults.yaml to a dedicated meta file def.
    if Lorj.defaults.data.key?(:setup)
      data[:setup] = Lorj.defaults.data[:setup]
      Lorj.defaults.data.delete(:setup)
    end
    if Lorj.defaults.data.key?(:sections)
      data[:sections] = Lorj.defaults.data[:sections]
      Lorj.defaults.data.delete(:sections)
    end
  end
  @metadata = Lorj::MetaAppConfig.new data

  @metadata
end
declare_process(process_name, path, properties = {}) click to toggle source

Any Lorj process module will need to declare itself to Lorj with this function.

  • args :

    • process_name: name of the process declared to Lorj. This name must be unique. Otherwise the declaration won't happen.

    • path : Path where process dir structure are located. at least, it expects to find the process/<name>.rb Each controllers found will be added as well. It must be controllers/<controller_name>/<controller_name>.rb You can change 'controllers' by any name, with :controllers_dir

    • +properties : required.

      • :controllers_dir : Name of the controllers directory. By default 'controllers'

      • :lib_name : name of the gem library declaring the process.

The process will be added in Lorj.processes Hash
# File lib/core/core.rb, line 513
def declare_process(process_name, path, properties = {})
  unless properties.is_a?(Hash) && properties[:lib_name].is_a?(String)
    puts("Lorj: process module error: '#{__method__}"\
         "('#{process_name}', '#{path}', #{properties})' requires :lib_name"\
         "\nat line #{caller[0]}")
    return nil
  end
  process_data = Lorj::ProcessResource.new(process_name, path, properties)

  if process_data.nil?
    puts("Lorj: process module error: '#{process_name}' fails to be "\
         "declared:\n"\
         "process_name: '#{process_name}'\n"\
         "path        : '#{path}'\n"\
         "properties  : #{properties.to_yaml}")
    return nil
  end

  @processes = {} if @processes.nil?

  if process_data.process.nil?
    puts("Lorj: process module error: process failure:\n"\
         "process_name: '#{process_name}'\n"\
         "path        : '#{path}'\n"\
         "properties  : #{properties.to_yaml}")
    return nil
  end

  process_name = process_data.name

  @processes[process_name] = process_data unless @processes.key?(process_name)

  process_data
end
defaults() click to toggle source

Lorj::defaults exposes the application defaults and Config Lorj metadata.

# File lib/lorj_defaults.rb, line 272
def defaults
  return @defaults unless @defaults.nil?
  @defaults = Defaults.new

  @defaults.load

  @defaults
end
processes() click to toggle source
# File lib/core/core.rb, line 548
def processes
  @processes = {} if @processes.nil?
  @processes
end