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 :
-
processes (
BaseProcess
) : How to create/delete/edit/query object. -
controler (BaseControler) : If a provider is defined, define how will do
object creation/etc...
-
definition(
BaseDefinition
): Functions to declare objects, query/data mappingand setup
this task to make it to work.
-
controler functions: controller functions called by
Lorj::BaseProcess
.
-
Lorj::Core
:Lorj
exposed interface.-
Initialization functions
-
-
Lorj::Model
:Model
class reference.
Module Lorj
which contains several classes.
Those classes describes :
-
processes (
BaseProcess
) : How to create/delete/edit/query object. -
controler (BaseControler) : If a provider is defined, define how will do
object creation/etc...
-
definition(
BaseDefinition
): Functions to declare objects, query/data mappingand setup
this task to make it to work.
Lorj
implements Lorj::BaseDefinition
core internal functions
-
process functions: Process functions called by
Core
orBaseProcess
.
Module Lorj
which contains several classes.
Those classes describes :
-
processes (
BaseProcess
) : How to create/delete/edit/query object. -
controler (BaseControler) : If a provider is defined, define how will do
object creation/etc...
-
definition(
BaseDefinition
): Functions to declare objects, query/data mappingand setup
this task to make it to work.
Module Lorj
which contains several classes.
Those classes describes :
-
processes (
BaseProcess
) : How to create/delete/edit/query object. -
controler (BaseControler) : If a provider is defined, define how will do
object creation/etc...
-
definition(
BaseDefinition
): Functions to declare objects, query/data mappingand setup
this task to make it to work.
Module Lorj
which contains several classes.
Those classes describes :
-
processes (
BaseProcess
) : How to create/delete/edit/query object. -
controler (BaseControler) : If a provider is defined, define how will do
object creation/etc...
-
definition(
BaseDefinition
): Functions to declare objects, query/data mappingand setup
this task to make it to work.
Module Lorj
which contains several classes.
Those classes describes :
-
processes (
BaseProcess
) : How to create/delete/edit/query object. -
controler (BaseControler) : If a provider is defined, define how will do
object creation/etc...
-
definition(
BaseDefinition
): Functions to declare objects, query/data mappingand setup
this task to make it to work.
Module Lorj
which contains several classes.
Those classes describes :
-
processes (
BaseProcess
) : How to create/delete/edit/query object. -
controler (BaseControler) : If a provider is defined, define how will do
object creation/etc...
-
definition(
BaseDefinition
): Functions to declare objects, query/data mappingand setup
this task to make it to work.
Module Lorj
which contains several classes.
Those classes describes :
-
processes (
BaseProcess
) : How to create/delete/edit/query object. -
controler (BaseControler) : If a provider is defined, define how will do
object creation/etc...
-
definition(
BaseDefinition
): Functions to declare objects, query/data mappingand setup
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 :
-
processes (
BaseProcess
) : How to create/delete/edit/query object. -
controler (BaseControler) : If a provider is defined, define how will do
object creation/etc...
-
definition(
BaseDefinition
): Functions to declare objects, query/data mappingand setup
this task to make it to work.
Module Lorj
implements ERBConfig
, and initialization functions for Lorj::BaseDefinition
-
Lorj::BaseProcess
: Process functions to call create/delete/edit/query processes on other objects.
-
Lorj::Data
: Defines how to manage Objects data between processes, controllers and internally in the core ofLorj
.
Module Lorj
which contains several classes.
Those classes describes :
-
processes (
BaseProcess
) : How to create/delete/edit/query object. -
controler (BaseControler) : If a provider is defined, define how will do
object creation/etc…
-
definition(
BaseDefinition
): Functions to declare objects, query/data
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
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
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 checkexistence 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
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
Any Lorj
process module will need to declare itself to Lorj
with this function.
-
args :
-
process_name
: name of the process declared toLorj
. 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
# File lib/core/core.rb, line 548 def processes @processes = {} if @processes.nil? @processes end