lorj 1.0.11 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Dockerfile +19 -0
- data/Rakefile +48 -7
- data/build/build_with_proxy.sh +49 -0
- data/files/bundle.sh +19 -0
- data/files/proxy.sh +23 -0
- data/lib/compat/1.8/lorj_meta.rb +44 -0
- data/lib/compat/lorj_meta.rb +40 -0
- data/lib/core/compat/1.8/core_object_data.rb +36 -0
- data/lib/core/compat/1.8/lorj_data.rb +41 -0
- data/lib/core/compat/core_object_data.rb +33 -0
- data/lib/core/compat/lorj_data.rb +39 -0
- data/lib/core/core.rb +21 -0
- data/lib/core/core_internal.rb +3 -1
- data/lib/core/core_object_data.rb +14 -10
- data/lib/core/core_object_params.rb +1 -1
- data/lib/core/core_process.rb +20 -5
- data/lib/core/core_setup_encrypt.rb +4 -2
- data/lib/core/definition.rb +3 -1
- data/lib/core/lorj_basecontroller.rb +15 -2
- data/lib/core/lorj_baseprocess.rb +15 -1
- data/lib/core/lorj_data.rb +10 -18
- data/lib/core/lorj_keypath.rb +35 -14
- data/lib/lorj/compat.rb +99 -0
- data/lib/lorj/version.rb +2 -2
- data/lib/lorj.rb +1 -0
- data/lib/lorj_account.rb +1 -0
- data/lib/lorj_defaults.rb +1 -1
- data/lib/lorj_meta.rb +15 -16
- data/lorj.gemspec +12 -7
- data/spec/05_lorj_keypath_spec.rb +98 -57
- data/spec/06_lorj_object_data_spec.rb +15 -15
- data/spec/09_prc_spec.rb +3 -0
- data/spec/10_lorj_log_spec.rb +2 -3
- data/spec/11_lorj_defaults_spec.rb +2 -3
- data/spec/12_lorj_config_spec.rb +2 -1
- data/spec/13_lorj_account_spec.rb +2 -1
- data/spec/20_lorj_meta_spec.rb +14 -10
- data/spec/21_lorj_processes_spec.rb +7 -5
- data/spec/22_lorj_core_spec.rb +2 -4
- data/spec/spec_helper.rb +34 -0
- metadata +60 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 794f05ad532df448906a4c02b3a8037b3633ead3
|
4
|
+
data.tar.gz: b5f2c8e2dcd69cee39b5ed7931765878581b6e20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d9610ee767426066b0507f791c6fbc52764bb42cebdf9479bdd9923a7e7080107dcc0294db7d420e8b287104d1cd290eb316464287669845ec78b6cfaf684b4
|
7
|
+
data.tar.gz: 113d5adb2e583a57ca190a7c9b41c78328beb41f357974cb1db8d6bf0a20522030719978e332bb44c01f392c5d54c5968f4f17b2c523248b8e604cebb0bdfbf3
|
data/Dockerfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
FROM centos:6
|
2
|
+
|
3
|
+
COPY files/proxy.sh /tmp/proxy.sh
|
4
|
+
RUN /tmp/proxy.sh
|
5
|
+
|
6
|
+
RUN yum -y install \
|
7
|
+
libffi-devel \
|
8
|
+
libxml2-devel \
|
9
|
+
libxslt-devel \
|
10
|
+
perl \
|
11
|
+
ruby \
|
12
|
+
rubygems \
|
13
|
+
ruby-devel \
|
14
|
+
; yum -y groupinstall "Development tools" \
|
15
|
+
; yum clean all
|
16
|
+
|
17
|
+
RUN gem install --no-rdoc --no-ri bundler rake rspec && rm -fr /root/.gem
|
18
|
+
|
19
|
+
COPY files/bundle.sh /tmp/bundle.sh
|
data/Rakefile
CHANGED
@@ -16,11 +16,18 @@
|
|
16
16
|
|
17
17
|
require 'bundler/gem_tasks'
|
18
18
|
require 'rspec/core/rake_task'
|
19
|
-
require 'rubocop/rake_task'
|
19
|
+
require 'rubocop/rake_task' unless RUBY_VERSION.match(/1\.8/)
|
20
20
|
require 'rdoc/task'
|
21
|
+
require 'json'
|
21
22
|
|
22
23
|
task :default => [:lint, :spec]
|
23
24
|
|
25
|
+
desc 'Run all specs (locally + docker).'
|
26
|
+
task :spec => [:spec_local, :spec18]
|
27
|
+
|
28
|
+
desc 'Run acceptance test (docker - specs).'
|
29
|
+
task :acceptance => [:spec18]
|
30
|
+
|
24
31
|
desc 'Generate lorj documentation'
|
25
32
|
RDoc::Task.new do |rdoc|
|
26
33
|
rdoc.main = 'README.md'
|
@@ -28,16 +35,50 @@ RDoc::Task.new do |rdoc|
|
|
28
35
|
end
|
29
36
|
|
30
37
|
desc 'Run the specs.'
|
31
|
-
RSpec::Core::RakeTask.new do |t|
|
38
|
+
RSpec::Core::RakeTask.new(:spec_local) do |t|
|
32
39
|
t.pattern = 'spec/*_spec.rb'
|
33
40
|
t.rspec_opts = '-f doc'
|
34
41
|
end
|
35
42
|
|
36
|
-
|
37
|
-
|
38
|
-
task
|
39
|
-
|
40
|
-
|
43
|
+
if RUBY_VERSION.match(/1\.8/)
|
44
|
+
desc 'no lint with ruby 1.8'
|
45
|
+
task :lint
|
46
|
+
else
|
47
|
+
desc 'Run RuboCop on the project'
|
48
|
+
RuboCop::RakeTask.new(:lint) do |task|
|
49
|
+
task.formatters = ['progress']
|
50
|
+
task.verbose = true
|
51
|
+
task.fail_on_error = true
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# rubocop: disable Style/SpecialGlobalVars
|
56
|
+
|
57
|
+
desc 'Run spec with docker for ruby 1.8'
|
58
|
+
task :spec18 do
|
59
|
+
begin
|
60
|
+
`docker`
|
61
|
+
rescue
|
62
|
+
puts 'Unable to run spec against ruby 1.8: docker not found'
|
63
|
+
else
|
64
|
+
cmd = 'build/build_with_proxy.sh -t ruby/1.8'
|
65
|
+
puts "Running #{cmd}"
|
66
|
+
system(cmd)
|
67
|
+
image_id = `docker images ruby/1.8`.split("\n")[1].split[2]
|
68
|
+
res = `docker inspect -f '{{json .}}' lorj`
|
69
|
+
c_img = ''
|
70
|
+
c_img = JSON.parse(res)['Image'][0..11] if $?.exitstatus == 0
|
71
|
+
|
72
|
+
if $?.exitstatus == 0 && image_id == c_img && ENV['RSPEC_DEBUG'].nil?
|
73
|
+
system('docker start -ai lorj')
|
74
|
+
else
|
75
|
+
`docker rm lorj` if $?.exitstatus == 0
|
76
|
+
cmd = "docker run -e RSPEC_DEBUG=#{ENV['RSPEC_DEBUG']} -it --name "\
|
77
|
+
'lorj -v $(pwd):/src -w /src ruby/1.8 /tmp/bundle.sh'
|
78
|
+
puts "Running #{cmd}"
|
79
|
+
system(cmd)
|
80
|
+
end
|
81
|
+
end
|
41
82
|
end
|
42
83
|
|
43
84
|
task :build => [:lint, :spec]
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
#
|
3
|
+
# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
function usage
|
18
|
+
{
|
19
|
+
echo "usage is $0 [--help][-t user/repo:version]
|
20
|
+
where :
|
21
|
+
- help: is the current help
|
22
|
+
- t : Tag the image built. Respect the tag format use by docker -t option.
|
23
|
+
"
|
24
|
+
}
|
25
|
+
|
26
|
+
if [ "p$1" = "p--help" ]
|
27
|
+
then
|
28
|
+
usage
|
29
|
+
exit
|
30
|
+
fi
|
31
|
+
|
32
|
+
if [ "p$1" = "p-t" ] && [ "p$2" != "" ]
|
33
|
+
then
|
34
|
+
TAG="-t $2"
|
35
|
+
fi
|
36
|
+
|
37
|
+
if [ "$http_proxy" = "" ]
|
38
|
+
then
|
39
|
+
echo "Currently, no proxy is set. Running docker without proxy"
|
40
|
+
docker build $TAG
|
41
|
+
exit
|
42
|
+
fi
|
43
|
+
|
44
|
+
mkdir .tmp
|
45
|
+
awk '$0 ~ /RUN \/tmp\/proxy.sh/ { print "ENV http_proxy '"$http_proxy"'" }
|
46
|
+
$0 ~ // { print $0 } ' Dockerfile > .tmp/Dockerfile
|
47
|
+
cp -rp files tmp .tmp/
|
48
|
+
docker build $TAG .tmp
|
49
|
+
rm -fr .tmp
|
data/files/bundle.sh
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
#
|
3
|
+
# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
cd /src
|
18
|
+
bundle
|
19
|
+
rake spec_local
|
data/files/proxy.sh
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
#
|
3
|
+
# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
if [ "$http_proxy" != "" ]
|
18
|
+
then
|
19
|
+
echo "proxy setting to '$http_proxy'"
|
20
|
+
export http_proxy=$http_proxy
|
21
|
+
export https_proxy=$http_proxy
|
22
|
+
sed -i -e '/^\[main\]/aproxy='"$http_proxy" /etc/yum.conf
|
23
|
+
fi
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
|
18
|
+
module Lorj
|
19
|
+
# Specific ALL Ruby functions, but incompatible with some other version.
|
20
|
+
module MetaRubySpec
|
21
|
+
# Public functions
|
22
|
+
module Public
|
23
|
+
# layer setting function
|
24
|
+
#
|
25
|
+
# * *Args*
|
26
|
+
# - +type+ : :sections by default. Define the section type name.
|
27
|
+
# - +section+ : Symbol. Section name of the data to define.
|
28
|
+
# - +keys+ : 1 Symbol or more Symbols. Name of the data and options.
|
29
|
+
# - +options+ : Hash. List of options
|
30
|
+
#
|
31
|
+
# * *Returns*
|
32
|
+
# - The value set or nil
|
33
|
+
#
|
34
|
+
def []=(type, section, *prop)
|
35
|
+
keys = prop.clone
|
36
|
+
options = {}
|
37
|
+
options = keys.pop if keys[-1].is_a?(Hash)
|
38
|
+
|
39
|
+
return nil if keys.length == 0
|
40
|
+
set(type, section, keys, options)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
|
18
|
+
module Lorj
|
19
|
+
# Specific ALL Ruby functions, but incompatible with some other version.
|
20
|
+
module MetaRubySpec
|
21
|
+
# Public functions
|
22
|
+
module Public
|
23
|
+
# layer setting function
|
24
|
+
#
|
25
|
+
# * *Args*
|
26
|
+
# - +type+ : :sections by default. Define the section type name.
|
27
|
+
# - +section+ : Symbol. Section name of the data to define.
|
28
|
+
# - +keys+ : 1 Symbol or more Symbols. Name of the data and options.
|
29
|
+
# - +options+ : Hash. List of options
|
30
|
+
#
|
31
|
+
# * *Returns*
|
32
|
+
# - The value set or nil
|
33
|
+
#
|
34
|
+
def []=(type, section, *keys, options)
|
35
|
+
return nil if keys.length == 0
|
36
|
+
set(type, section, keys, options)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
|
18
|
+
module Lorj
|
19
|
+
# Specific ALL Ruby functions, but incompatible with some other version.
|
20
|
+
module ObjectDataRubySpec
|
21
|
+
# Public functions
|
22
|
+
module Public
|
23
|
+
# Functions used to set simple data/Object for controller/process function
|
24
|
+
# call.
|
25
|
+
# TODO: to revisit this function, as we may consider simple data, as
|
26
|
+
# Lorj::Data object
|
27
|
+
def []=(*prop)
|
28
|
+
key = prop.clone
|
29
|
+
value = key.pop
|
30
|
+
|
31
|
+
return nil if [:object, :query].include?(key[0])
|
32
|
+
@params.rh_set(value, key)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Lorj
|
16
|
+
# Specific ALL Ruby functions, but incompatible with some other version.
|
17
|
+
module DataRubySpec
|
18
|
+
# Public functions
|
19
|
+
module Public
|
20
|
+
# Set Lorj::data attribute value for an :object
|
21
|
+
#
|
22
|
+
# * *Args* :
|
23
|
+
# - +keys+ : attribute keys
|
24
|
+
# - +value+: Value to set
|
25
|
+
#
|
26
|
+
# * *Returns* :
|
27
|
+
# true
|
28
|
+
#
|
29
|
+
# * *Raises* :
|
30
|
+
# No exceptions
|
31
|
+
#
|
32
|
+
def []=(*prop)
|
33
|
+
key = prop.clone
|
34
|
+
value = key.pop
|
35
|
+
return false if @type == :list
|
36
|
+
@data.rh_set(value, :attrs, key)
|
37
|
+
true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
|
18
|
+
module Lorj
|
19
|
+
# Specific ALL Ruby functions, but incompatible with some other version.
|
20
|
+
module ObjectDataRubySpec
|
21
|
+
# Public functions
|
22
|
+
module Public
|
23
|
+
# Functions used to set simple data/Object for controller/process function
|
24
|
+
# call.
|
25
|
+
# TODO: to revisit this function, as we may consider simple data, as
|
26
|
+
# Lorj::Data object
|
27
|
+
def []=(*key, value)
|
28
|
+
return nil if [:object, :query].include?(key[0])
|
29
|
+
@params.rh_set(value, key)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Lorj
|
16
|
+
# Specific ALL Ruby functions, but incompatible with some other version.
|
17
|
+
module DataRubySpec
|
18
|
+
# Public functions
|
19
|
+
module Public
|
20
|
+
# Set Lorj::data attribute value for an :object
|
21
|
+
#
|
22
|
+
# * *Args* :
|
23
|
+
# - +keys+ : attribute keys
|
24
|
+
# - +value+: Value to set
|
25
|
+
#
|
26
|
+
# * *Returns* :
|
27
|
+
# true
|
28
|
+
#
|
29
|
+
# * *Raises* :
|
30
|
+
# No exceptions
|
31
|
+
#
|
32
|
+
def []=(*key, value)
|
33
|
+
return false if @type == :list
|
34
|
+
@data.rh_set(value, :attrs, key)
|
35
|
+
true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/core/core.rb
CHANGED
@@ -294,6 +294,27 @@ module Lorj
|
|
294
294
|
@core_object.process_setup(oCloudObj)
|
295
295
|
end
|
296
296
|
|
297
|
+
# Function to add an object to Lorj cache.
|
298
|
+
#
|
299
|
+
# This function is typically used when a previous query has been
|
300
|
+
# executed and you want to keep the object in lorj cache.
|
301
|
+
# Lorj cache is used by create/delete/etc... To avoid requerying or
|
302
|
+
# creating those objects (+dependencies) if missing.
|
303
|
+
#
|
304
|
+
# * *Args* :
|
305
|
+
# - +oObject+ : object to register.
|
306
|
+
# - +sObjectType+ : Object type to register.
|
307
|
+
# By default, the object type is determined by the Object itself
|
308
|
+
# if this object is an ObjectData. Otherwise, you need to define the
|
309
|
+
# object type.
|
310
|
+
#
|
311
|
+
# * *Raises* :
|
312
|
+
# No exceptions
|
313
|
+
def register(oObject, sObjectType = nil) #:doc:
|
314
|
+
return nil if !oObject || !@core_object
|
315
|
+
@core_object.register(oObject, sObjectType)
|
316
|
+
end
|
317
|
+
|
297
318
|
# Core parameters are:
|
298
319
|
# the_config : Optional. An instance of a configuration system which *HAVE*
|
299
320
|
# to provide get/set/exist?/[]/[]=
|
data/lib/core/core_internal.rb
CHANGED
@@ -467,7 +467,9 @@ module Lorj
|
|
467
467
|
|
468
468
|
match_found = the_process_class.scan(/_[a-z]/)
|
469
469
|
if match_found
|
470
|
-
|
470
|
+
# Ruby 1.8 : 'ab'[1] => 98 and 'ab'[1, 1] => 'b'
|
471
|
+
# Ruby 1.9 + : 'ab'[1] => 'b' and 'ab'[1, 1] => 'b'
|
472
|
+
match_found.each { |str| the_process_class[str] = str[1, 1].capitalize }
|
471
473
|
end
|
472
474
|
|
473
475
|
the_process_class
|
@@ -16,6 +16,14 @@
|
|
16
16
|
|
17
17
|
# rubocop: disable Metrics/AbcSize
|
18
18
|
|
19
|
+
file_dir = File.join(File.dirname(__FILE__), 'compat')
|
20
|
+
compat_version = RUBY_VERSION[0..2]
|
21
|
+
file = File.basename(__FILE__)
|
22
|
+
|
23
|
+
lib = File.join(file_dir, compat_version, file)
|
24
|
+
lib = File.join(file_dir, file) unless File.exist?(lib)
|
25
|
+
load lib if File.exist?(lib)
|
26
|
+
|
19
27
|
# Module Lorj which contains several classes.
|
20
28
|
#
|
21
29
|
# Those classes describes :
|
@@ -130,15 +138,6 @@ module Lorj
|
|
130
138
|
value
|
131
139
|
end
|
132
140
|
|
133
|
-
# Functions used to set simple data/Object for controller/process function
|
134
|
-
# call.
|
135
|
-
# TODO: to revisit this function, as we may consider simple data, as
|
136
|
-
# Lorj::Data object
|
137
|
-
def []=(*key, value)
|
138
|
-
return nil if [:object, :query].include?(key[0])
|
139
|
-
@params.rh_set(value, key)
|
140
|
-
end
|
141
|
-
|
142
141
|
# Add function. Add a Lorj::Data (data or list) to the ObjectData list.
|
143
142
|
#
|
144
143
|
# key can be an array, a string (converted to a symbol) or a symbol.
|
@@ -236,10 +235,13 @@ module Lorj
|
|
236
235
|
|
237
236
|
def type?(key)
|
238
237
|
return nil unless @params.rh_exist?(key)
|
239
|
-
return :DataObject if @params[key].
|
238
|
+
return :DataObject if @params[key].class == Lorj::Data &&
|
239
|
+
@params[key].type == :object
|
240
240
|
:data
|
241
241
|
end
|
242
242
|
|
243
|
+
alias :'otype?' :'type?' if RUBY_VERSION =~ /1\.8/ # rubocop: disable Alias
|
244
|
+
|
243
245
|
def to_s
|
244
246
|
str = "-- Lorj::ObjectData --\n"
|
245
247
|
str += "Usage internal\n" if @internal
|
@@ -247,6 +249,8 @@ module Lorj
|
|
247
249
|
str
|
248
250
|
end
|
249
251
|
|
252
|
+
include Lorj::ObjectDataRubySpec::Public
|
253
|
+
|
250
254
|
private
|
251
255
|
|
252
256
|
# Get function
|
@@ -112,7 +112,7 @@ module Lorj
|
|
112
112
|
end
|
113
113
|
|
114
114
|
if param_options[:decrypt].is_a?(TrueClass)
|
115
|
-
value = _get_encrypted_value(value, _get_encrypt_key)
|
115
|
+
value = _get_encrypted_value(value, _get_encrypt_key, attr_name)
|
116
116
|
end
|
117
117
|
|
118
118
|
return unless param_options[:mapping]
|
data/lib/core/core_process.rb
CHANGED
@@ -127,7 +127,10 @@ module Lorj
|
|
127
127
|
|
128
128
|
proc = PrcLib.model.meta_obj.rh_get(object_type, :lambdas, :delete_e)
|
129
129
|
|
130
|
-
|
130
|
+
if proc.nil?
|
131
|
+
_remove_instant_config(hConfig)
|
132
|
+
return nil
|
133
|
+
end
|
131
134
|
|
132
135
|
# Check required parameters
|
133
136
|
_process_load_dependencies(object_type, proc, :delete_e, __callee__)
|
@@ -208,11 +211,17 @@ module Lorj
|
|
208
211
|
|
209
212
|
# Check if we can re-use a previous query
|
210
213
|
list = query_cache(object_type, hQuery)
|
211
|
-
|
214
|
+
unless list.nil?
|
215
|
+
_remove_instant_config(hConfig)
|
216
|
+
return list
|
217
|
+
end
|
212
218
|
|
213
219
|
proc = PrcLib.model.meta_obj.rh_get(object_type, :lambdas, :query_e)
|
214
220
|
|
215
|
-
|
221
|
+
if proc.nil?
|
222
|
+
_remove_instant_config(hConfig)
|
223
|
+
return nil
|
224
|
+
end
|
216
225
|
|
217
226
|
# Check required parameters
|
218
227
|
_process_load_dependencies(object_type, proc, :query_e, __callee__)
|
@@ -293,7 +302,10 @@ module Lorj
|
|
293
302
|
|
294
303
|
proc = PrcLib.model.meta_obj.rh_get(object_type, :lambdas, :get_e)
|
295
304
|
|
296
|
-
|
305
|
+
if proc.nil?
|
306
|
+
_remove_instant_config(hConfig)
|
307
|
+
return nil
|
308
|
+
end
|
297
309
|
|
298
310
|
# Check required parameters
|
299
311
|
_process_load_dependencies(object_type, proc, :get_e, __callee__)
|
@@ -356,7 +368,10 @@ module Lorj
|
|
356
368
|
|
357
369
|
proc = PrcLib.model.meta_obj.rh_get(object_type, :lambdas, :update_e)
|
358
370
|
|
359
|
-
|
371
|
+
if proc.nil?
|
372
|
+
_remove_instant_config(hConfig)
|
373
|
+
return nil
|
374
|
+
end
|
360
375
|
|
361
376
|
_process_load_dependencies(object_type, proc, :update_e, __callee__)
|
362
377
|
|
@@ -13,6 +13,7 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
require 'highline/import'
|
16
|
+
require 'encryptor'
|
16
17
|
|
17
18
|
# Module Lorj which contains several classes.
|
18
19
|
#
|
@@ -83,7 +84,7 @@ module Lorj
|
|
83
84
|
return '' if enc_value.nil?
|
84
85
|
value_hidden = ''
|
85
86
|
begin
|
86
|
-
value_hidden = '*' * _get_encrypted_value(enc_value, entr).length
|
87
|
+
value_hidden = '*' * _get_encrypted_value(enc_value, entr, sDesc).length
|
87
88
|
rescue => e
|
88
89
|
PrcLib.error('Unable to decrypt your %s. You will need to re-enter it.'\
|
89
90
|
'\n%s', sDesc, e.message)
|
@@ -101,13 +102,14 @@ module Lorj
|
|
101
102
|
# *parameters*:
|
102
103
|
# - +default+ : encrypted default value
|
103
104
|
# - +entropy+ : Entropy Hash
|
105
|
+
# - +sDesc+ : data description
|
104
106
|
#
|
105
107
|
# *return*:
|
106
108
|
# - value : decrypted value.
|
107
109
|
#
|
108
110
|
# *raise*:
|
109
111
|
#
|
110
|
-
def _get_encrypted_value(enc_value, entr)
|
112
|
+
def _get_encrypted_value(enc_value, entr, sDesc)
|
111
113
|
return '' if enc_value.nil?
|
112
114
|
begin
|
113
115
|
Encryptor.decrypt(
|
data/lib/core/definition.rb
CHANGED
@@ -691,7 +691,9 @@ module Lorj
|
|
691
691
|
handlers_dcl.each_key do |key|
|
692
692
|
next unless handlers_options.key?(key)
|
693
693
|
|
694
|
-
|
694
|
+
# Warning! Use BaseProcess._instance_methods Compatibility function
|
695
|
+
# instead of BaseProcess.instance_methods
|
696
|
+
unless process_context._instance_methods.include?(handlers_options[key])
|
695
697
|
PrcLib.dcl_fail("'%s' parameter requires a valid instance method"\
|
696
698
|
" '%s' in the process '%s'.",
|
697
699
|
key, handlers_options[key], process_context)
|
@@ -87,8 +87,21 @@ module Lorj
|
|
87
87
|
# * *Raises* :
|
88
88
|
# - +Error+ if the key do not exist.
|
89
89
|
def required?(oParams, *key)
|
90
|
-
|
91
|
-
|
90
|
+
if oParams.exist?(key)
|
91
|
+
if RUBY_VERSION =~ /1\.8/
|
92
|
+
# debugger # rubocop: disable Lint/Debugger
|
93
|
+
if oParams.otype?(*key) == :DataObject &&
|
94
|
+
oParams[key, :ObjectData].empty?
|
95
|
+
controller_error '%s is empty.', key
|
96
|
+
end
|
97
|
+
else
|
98
|
+
if oParams.type?(*key) == :DataObject &&
|
99
|
+
oParams[key, :ObjectData].empty?
|
100
|
+
controller_error '%s is empty.', key
|
101
|
+
end
|
102
|
+
end
|
103
|
+
return
|
104
|
+
end
|
92
105
|
controller_error '%s is not set.', key
|
93
106
|
end
|
94
107
|
end
|