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
@@ -331,7 +331,7 @@ module Lorj
|
|
331
331
|
list.each do |oElem|
|
332
332
|
is_found = true
|
333
333
|
sQuery.each do |key, value|
|
334
|
-
|
334
|
+
unless _qs_check_query_valid?(oElem, key, value)
|
335
335
|
is_found = false
|
336
336
|
break
|
337
337
|
end
|
@@ -340,6 +340,20 @@ module Lorj
|
|
340
340
|
end
|
341
341
|
end
|
342
342
|
|
343
|
+
def _qs_check_query_valid?(elem, key, value)
|
344
|
+
if value.is_a?(Array)
|
345
|
+
path = value.clone
|
346
|
+
v = path.pop
|
347
|
+
return false if elem[key].nil?
|
348
|
+
where = elem[key].rh_get(path)
|
349
|
+
return true if where.is_a?(Array) && where.flatten.include?(v)
|
350
|
+
return true if where == v
|
351
|
+
else
|
352
|
+
return true if elem[key] == value
|
353
|
+
end
|
354
|
+
false
|
355
|
+
end
|
356
|
+
|
343
357
|
def _qs_info_init(sInfoMsg)
|
344
358
|
info = {
|
345
359
|
:notfound => "No %s '%s' found",
|
data/lib/core/lorj_data.rb
CHANGED
@@ -12,6 +12,14 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
+
file_dir = File.join(File.dirname(__FILE__), 'compat')
|
16
|
+
compat_version = RUBY_VERSION[0..2]
|
17
|
+
file = File.basename(__FILE__)
|
18
|
+
|
19
|
+
lib = File.join(file_dir, compat_version, file)
|
20
|
+
lib = File.join(file_dir, file) unless File.exist?(lib)
|
21
|
+
load lib if File.exist?(lib)
|
22
|
+
|
15
23
|
# - Lorj::Data : Defines how to manage Objects data between processes,
|
16
24
|
# controllers and internally in the core of Lorj.
|
17
25
|
module Lorj
|
@@ -205,24 +213,6 @@ module Lorj
|
|
205
213
|
get(*key)
|
206
214
|
end
|
207
215
|
|
208
|
-
# Set Lorj::data attribute value for an :object
|
209
|
-
#
|
210
|
-
# * *Args* :
|
211
|
-
# - +keys+ : attribute keys
|
212
|
-
# - +value+: Value to set
|
213
|
-
#
|
214
|
-
# * *Returns* :
|
215
|
-
# true
|
216
|
-
#
|
217
|
-
# * *Raises* :
|
218
|
-
# No exceptions
|
219
|
-
#
|
220
|
-
def []=(*key, value)
|
221
|
-
return false if @type == :list
|
222
|
-
@data.rh_set(value, :attrs, key)
|
223
|
-
true
|
224
|
-
end
|
225
|
-
|
226
216
|
# Get value from Lorj::data
|
227
217
|
# Depending on Lorj::Data type, you can get:
|
228
218
|
# - :object
|
@@ -482,6 +472,8 @@ module Lorj
|
|
482
472
|
@is_registered = false
|
483
473
|
self
|
484
474
|
end
|
475
|
+
|
476
|
+
include Lorj::DataRubySpec::Public
|
485
477
|
end
|
486
478
|
|
487
479
|
#
|
data/lib/core/lorj_keypath.rb
CHANGED
@@ -49,6 +49,15 @@ module Lorj
|
|
49
49
|
# puts oKey.tree # => [:test,:test2,:test3]
|
50
50
|
# puts oKey.key_tree # => ':test/:test2/:test3'
|
51
51
|
#
|
52
|
+
# oKey = KeyPath([:test, '{/.*/}', :test3])
|
53
|
+
# puts oKey.to_s # => 'test/{\/.*\/}/test3'
|
54
|
+
# puts oKey.key # => :test3
|
55
|
+
# puts oKey.key[0] # => :test
|
56
|
+
# puts oKey.key[1] # => '{/.*/}'
|
57
|
+
# puts oKey.fpath # => ':test/{\/.*\/}/:test3'
|
58
|
+
# puts oKey.tree # => [:test, '{/.*/}',:test3]
|
59
|
+
# puts oKey.key_tree # => ':test/{\/.*\/}/:test3'
|
60
|
+
#
|
52
61
|
class KeyPath
|
53
62
|
def initialize(sKeyPath = nil, max_level = -1)
|
54
63
|
@keypath = []
|
@@ -83,22 +92,24 @@ module Lorj
|
|
83
92
|
|
84
93
|
def fpath
|
85
94
|
return nil if @keypath.length == 0
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
95
|
+
akey = @keypath.clone
|
96
|
+
akey.each_index do |i|
|
97
|
+
akey[i] = akey[i].gsub(%r{/}, '\/') if akey[i].is_a?(String)
|
98
|
+
next unless akey[i].is_a?(Symbol)
|
99
|
+
akey[i] = ':' + akey[i].to_s
|
90
100
|
end
|
91
|
-
|
101
|
+
akey.join('/')
|
92
102
|
end
|
93
103
|
|
94
104
|
def to_s
|
95
105
|
return nil if @keypath.length == 0
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
106
|
+
akey = @keypath.clone
|
107
|
+
akey.each_index do |i|
|
108
|
+
akey[i] = akey[i].gsub(%r{/}, '\/') if akey[i].is_a?(String)
|
109
|
+
next unless akey[i].is_a?(Symbol)
|
110
|
+
akey[i] = akey[i].to_s
|
100
111
|
end
|
101
|
-
|
112
|
+
akey.join('/')
|
102
113
|
end
|
103
114
|
|
104
115
|
def key(iIndex = -1)
|
@@ -116,11 +127,21 @@ module Lorj
|
|
116
127
|
# rubocop: disable Style/RegexpLiteral
|
117
128
|
if %r{[^\\/]?/[^/]} =~ sKeyPath || %r{:[^:/]} =~ sKeyPath
|
118
129
|
# rubocop: enable Style/RegexpLiteral
|
119
|
-
|
120
|
-
|
130
|
+
res = []
|
131
|
+
# split then rejoin / prefixed by \
|
132
|
+
sKeyPath.split('/').each do |s|
|
133
|
+
if res[-1] && res[-1].match(/\\$/)
|
134
|
+
res[-1][-1] = ''
|
135
|
+
res[-1] += '/' + s
|
136
|
+
else
|
137
|
+
res << s
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
121
141
|
res.each_index do |iIndex|
|
122
|
-
|
123
|
-
|
142
|
+
# Ruby 1.8 : 'ab'[1] => 98 and 'ab'[1, 1] => 'b'
|
143
|
+
# Ruby 1.9 + : 'ab'[1] => 'b' and 'ab'[1, 1] => 'b'
|
144
|
+
res[iIndex] = res[iIndex][1..-1].to_sym if res[iIndex][0, 1] == ':'
|
124
145
|
end
|
125
146
|
@keypath = res
|
126
147
|
else
|
data/lib/lorj/compat.rb
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
# encoding: UTF-8
|
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
|
+
# Ruby 1.8 case
|
18
|
+
module Kernel
|
19
|
+
# Defined in ruby 1.9
|
20
|
+
unless defined?(__callee__)
|
21
|
+
def __callee__
|
22
|
+
caller[0] =~ /`([^']*)'/ && Regexp.last_match(1)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Lorj Module Compatibility
|
28
|
+
module Lorj
|
29
|
+
# BaseProcess Compatibility
|
30
|
+
class BaseProcess
|
31
|
+
# Adapt instance_methods
|
32
|
+
def self._instance_methods
|
33
|
+
# Ruby 1.8 : Object.instance_methods => Array of string
|
34
|
+
# Ruby 1.9+ : Object.instance_methods => Array of symbol
|
35
|
+
return instance_methods unless RUBY_VERSION.match(/1\.8/)
|
36
|
+
|
37
|
+
instance_methods.collect(&:to_sym)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Redefine string representation of Array
|
43
|
+
class Array
|
44
|
+
def to_s
|
45
|
+
'[' + map do |a|
|
46
|
+
if a.is_a?(String)
|
47
|
+
"\"#{a}\""
|
48
|
+
elsif a.is_a?(Symbol)
|
49
|
+
":#{a}"
|
50
|
+
else
|
51
|
+
a.to_s
|
52
|
+
end
|
53
|
+
end.join(', ') + ']'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Redefine string representation of Hash
|
58
|
+
class Hash
|
59
|
+
def to_s
|
60
|
+
local = []
|
61
|
+
each do |a, b|
|
62
|
+
if a.is_a?(String)
|
63
|
+
k = "\"#{a}\""
|
64
|
+
elsif a.is_a?(Symbol)
|
65
|
+
k = ":#{a}"
|
66
|
+
else
|
67
|
+
k = a.to_s
|
68
|
+
end
|
69
|
+
|
70
|
+
if b.is_a?(String)
|
71
|
+
v = "\"#{b}\""
|
72
|
+
elsif b.is_a?(Symbol)
|
73
|
+
v = ":#{b}"
|
74
|
+
else
|
75
|
+
v = b.to_s
|
76
|
+
end
|
77
|
+
local << "#{k}=>#{v}"
|
78
|
+
end
|
79
|
+
'{' + local.join(', ') + '}'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# Support for encode 64 without \n
|
84
|
+
module Base64
|
85
|
+
# Returns the Base64-encoded version of +bin+.
|
86
|
+
# This method complies with RFC 4648.
|
87
|
+
# No line feeds are added.
|
88
|
+
def strict_encode64(bin)
|
89
|
+
[bin].pack('m0')
|
90
|
+
end
|
91
|
+
|
92
|
+
# Returns the Base64-decoded version of +str+.
|
93
|
+
# This method complies with RFC 4648.
|
94
|
+
# ArgumentError is raised if +str+ is incorrectly padded or contains
|
95
|
+
# non-alphabet characters. Note that CR or LF are also rejected.
|
96
|
+
def strict_decode64(str)
|
97
|
+
str.unpack('m0').first
|
98
|
+
end
|
99
|
+
end
|
data/lib/lorj/version.rb
CHANGED
data/lib/lorj.rb
CHANGED
data/lib/lorj_account.rb
CHANGED
data/lib/lorj_defaults.rb
CHANGED
data/lib/lorj_meta.rb
CHANGED
@@ -18,6 +18,14 @@
|
|
18
18
|
require 'rubygems'
|
19
19
|
require 'yaml'
|
20
20
|
|
21
|
+
file_dir = File.join(File.dirname(__FILE__), 'compat')
|
22
|
+
compat_version = RUBY_VERSION[0..2]
|
23
|
+
file = File.basename(__FILE__)
|
24
|
+
|
25
|
+
lib = File.join(file_dir, compat_version, file)
|
26
|
+
lib = File.join(file_dir, file) unless File.exist?(lib)
|
27
|
+
load lib if File.exist?(lib)
|
28
|
+
|
21
29
|
# Lorj module implements Lorj::Config
|
22
30
|
# Lorj exposes defaults, as attribute to access the Lorj::Defaults instance.
|
23
31
|
module Lorj
|
@@ -484,6 +492,11 @@ module Lorj
|
|
484
492
|
|
485
493
|
arr = p_get(:keys => [:keys, data])
|
486
494
|
return nil unless arr.is_a?(Array) && arr[0]
|
495
|
+
if /1\.8/ =~ RUBY_VERSION && arr.length > 1
|
496
|
+
PrcLib.warning('Avoid using Lorj::MetaAppConfig.first_section(%s) with'\
|
497
|
+
' Ruby 1.8 and searching for the first section as it do'\
|
498
|
+
' not preserve the order of Hash keys.', data)
|
499
|
+
end
|
487
500
|
[arr[0], data]
|
488
501
|
end
|
489
502
|
|
@@ -644,22 +657,6 @@ module Lorj
|
|
644
657
|
p_set(:keys => keys, :name => layer, :value => options)
|
645
658
|
end
|
646
659
|
|
647
|
-
# layer setting function
|
648
|
-
#
|
649
|
-
# * *Args*
|
650
|
-
# - +type+ : :sections by default. Define the section type name.
|
651
|
-
# - +section+ : Symbol. Section name of the data to define.
|
652
|
-
# - +keys+ : 1 Symbol or more Symbols. Name of the data and options.
|
653
|
-
# - +options+ : Hash. List of options
|
654
|
-
#
|
655
|
-
# * *Returns*
|
656
|
-
# - The value set or nil
|
657
|
-
#
|
658
|
-
def []=(type, section, *keys, options)
|
659
|
-
return nil if keys.length == 0
|
660
|
-
set(type, section, keys, options)
|
661
|
-
end
|
662
|
-
|
663
660
|
# section/data removal function
|
664
661
|
#
|
665
662
|
# * *Args*
|
@@ -741,6 +738,8 @@ module Lorj
|
|
741
738
|
|
742
739
|
p_set(:keys => keys, :name => layer, :value => value.merge(options))
|
743
740
|
end
|
741
|
+
|
742
|
+
include Lorj::MetaRubySpec::Public
|
744
743
|
end
|
745
744
|
|
746
745
|
module_function
|
data/lorj.gemspec
CHANGED
@@ -30,18 +30,23 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_development_dependency 'bundler'
|
31
31
|
spec.add_development_dependency 'rake', '~> 10.0'
|
32
32
|
spec.add_development_dependency 'rspec', '~> 3.1.0'
|
33
|
-
spec.add_development_dependency '
|
34
|
-
spec.add_development_dependency 'byebug' unless less_than_two
|
33
|
+
spec.add_development_dependency 'rdoc'
|
35
34
|
spec.rdoc_options << \
|
36
35
|
'--title Lorj - The Process Controllers framework system' << \
|
37
36
|
'--main README.md'
|
38
37
|
|
39
|
-
spec.add_runtime_dependency 'config_layers', '~>0.1.
|
40
|
-
# spec.add_runtime_dependency 'git', '>=1.2.7'
|
41
|
-
# spec.add_runtime_dependency 'rbx-require-relative', '~>0.0.7'
|
38
|
+
spec.add_runtime_dependency 'config_layers', '~>0.1.4'
|
42
39
|
spec.add_runtime_dependency 'highline', '~> 1.6.21'
|
43
40
|
spec.add_runtime_dependency 'ansi', '>= 1.4.3'
|
44
|
-
# spec.add_runtime_dependency 'bundler'
|
45
41
|
spec.add_runtime_dependency 'encryptor', '1.3.0'
|
46
|
-
|
42
|
+
spec.add_runtime_dependency 'json'
|
43
|
+
if RUBY_VERSION.match(/1\.8/)
|
44
|
+
spec.add_development_dependency "ruby-debug"
|
45
|
+
elsif RUBY_VERSION.match(/1\.9/)
|
46
|
+
spec.add_development_dependency "debugger"
|
47
|
+
spec.add_development_dependency "rubocop", "~> 0.30.0"
|
48
|
+
else
|
49
|
+
spec.add_development_dependency "byebug"
|
50
|
+
spec.add_development_dependency "rubocop", "~> 0.30.0"
|
51
|
+
end
|
47
52
|
end
|
@@ -15,189 +15,230 @@
|
|
15
15
|
# See the License for the specific language governing permissions and
|
16
16
|
# limitations under the License.
|
17
17
|
|
18
|
-
|
18
|
+
require 'rubygems'
|
19
|
+
require 'spec_helper'
|
19
20
|
|
20
21
|
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib/core')
|
21
22
|
|
22
|
-
require '
|
23
|
+
require 'lorj'
|
23
24
|
|
24
|
-
describe 'Lorj::KeyPath
|
25
|
-
context '
|
25
|
+
describe 'Lorj::KeyPath' do
|
26
|
+
context '.new(:test)' do
|
26
27
|
before(:all) do
|
27
28
|
@o_key = Lorj::KeyPath.new(:test)
|
28
29
|
end
|
29
|
-
it '
|
30
|
+
it '#length return 1' do
|
30
31
|
expect(@o_key.length).to eq(1)
|
31
32
|
end
|
32
|
-
it '
|
33
|
+
it '#to_s return "test"' do
|
33
34
|
expect(@o_key.to_s).to eq('test')
|
34
35
|
end
|
35
|
-
it '
|
36
|
+
it '#key return :test' do
|
36
37
|
expect(@o_key.key).to eq(:test)
|
37
38
|
end
|
38
|
-
it '
|
39
|
+
it '#key(0) return :test' do
|
39
40
|
expect(@o_key.key(0)).to eq(:test)
|
40
41
|
end
|
41
|
-
it '
|
42
|
+
it '#key(1) return nil' do
|
42
43
|
expect(@o_key.key(1)).to eq(nil)
|
43
44
|
end
|
44
|
-
it '
|
45
|
+
it '#fpath return ":test"' do
|
45
46
|
expect(@o_key.fpath).to eq(':test')
|
46
47
|
end
|
47
|
-
it '
|
48
|
+
it '#tree return :test' do
|
48
49
|
expect(@o_key.key).to eq(:test)
|
49
50
|
end
|
50
|
-
it '
|
51
|
+
it '#key_tree return :test' do
|
51
52
|
expect(@o_key.key_tree).to eq(:test)
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
55
|
-
context '
|
56
|
+
context '.new([:test,:test2,:test3])' do
|
56
57
|
before(:all) do
|
57
58
|
@o_key = Lorj::KeyPath.new([:test, :test2, :test3])
|
58
59
|
end
|
59
|
-
it '
|
60
|
+
it '#length return 3' do
|
60
61
|
expect(@o_key.length).to eq(3)
|
61
62
|
end
|
62
|
-
it '
|
63
|
+
it '#to_s return "test/test2/test"' do
|
63
64
|
expect(@o_key.to_s).to eq('test/test2/test3')
|
64
65
|
end
|
65
|
-
it '
|
66
|
+
it '#key return :test3' do
|
66
67
|
expect(@o_key.key).to eq(:test3)
|
67
68
|
end
|
68
|
-
it '
|
69
|
+
it '#key(0) return :test' do
|
69
70
|
expect(@o_key.key(0)).to eq(:test)
|
70
71
|
end
|
71
|
-
it '
|
72
|
+
it '#key(1) return :test2' do
|
72
73
|
expect(@o_key.key(1)).to eq(:test2)
|
73
74
|
end
|
74
|
-
it '
|
75
|
+
it '#fpath return ":test/:test2/:test3"' do
|
75
76
|
expect(@o_key.fpath).to eq(':test/:test2/:test3')
|
76
77
|
end
|
77
|
-
it '
|
78
|
+
it '#tree return [:test, :test2, :test3]' do
|
78
79
|
expect(@o_key.tree).to eq([:test, :test2, :test3])
|
79
80
|
end
|
80
|
-
it '
|
81
|
+
it '#key_tree return ":test/:test2/:test"' do
|
81
82
|
expect(@o_key.key_tree).to eq(':test/:test2/:test3')
|
82
83
|
end
|
83
84
|
end
|
84
85
|
|
85
|
-
context '
|
86
|
+
context '.new([:test, "/", :test3])' do
|
87
|
+
before(:all) do
|
88
|
+
@o_key = Lorj::KeyPath.new([:test, '/', :test3])
|
89
|
+
end
|
90
|
+
it '#length return 3' do
|
91
|
+
expect(@o_key.length).to eq(3)
|
92
|
+
end
|
93
|
+
it '#to_s return "test/\//test"' do
|
94
|
+
expect(@o_key.to_s).to eq('test/\//test3')
|
95
|
+
end
|
96
|
+
it '#key return :test3' do
|
97
|
+
expect(@o_key.key).to eq(:test3)
|
98
|
+
end
|
99
|
+
it '#key(0) return :test' do
|
100
|
+
expect(@o_key.key(0)).to eq(:test)
|
101
|
+
end
|
102
|
+
it '#key(1) return "/"' do
|
103
|
+
expect(@o_key.key(1)).to eq('/')
|
104
|
+
end
|
105
|
+
it '#fpath return ":test/\//:test3"' do
|
106
|
+
expect(@o_key.fpath).to eq(':test/\//:test3')
|
107
|
+
end
|
108
|
+
it '#tree return [:test, "/", :test3]' do
|
109
|
+
expect(@o_key.tree).to eq([:test, '/', :test3])
|
110
|
+
end
|
111
|
+
it '#key_tree return ":test/\//:test3"' do
|
112
|
+
expect(@o_key.key_tree).to eq(':test/\//:test3')
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
context '.new(":test/\//test3")' do
|
117
|
+
before(:all) do
|
118
|
+
@o_key = Lorj::KeyPath.new(':test/\//test3')
|
119
|
+
end
|
120
|
+
it 'is equivalent to .new([:test, "/", "test3"])' do
|
121
|
+
compare = Lorj::KeyPath.new([:test, '/', 'test3'])
|
122
|
+
expect(@o_key.tree).to eq(compare.tree)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
context '.new("test1/test2")' do
|
86
127
|
before(:all) do
|
87
128
|
@o_key = Lorj::KeyPath.new('test1/test2')
|
88
129
|
end
|
89
|
-
it '
|
130
|
+
it '#length return 2' do
|
90
131
|
expect(@o_key.length).to eq(2)
|
91
132
|
end
|
92
|
-
it '
|
133
|
+
it '#to_s return "test1/test2"' do
|
93
134
|
expect(@o_key.to_s).to eq('test1/test2')
|
94
135
|
end
|
95
|
-
it '
|
136
|
+
it '#key return "test2"' do
|
96
137
|
expect(@o_key.key).to eq('test2')
|
97
138
|
end
|
98
|
-
it '
|
139
|
+
it '#key(0) return "test"' do
|
99
140
|
expect(@o_key.key(0)).to eq('test1')
|
100
141
|
end
|
101
|
-
it '
|
142
|
+
it '#key(1) return "test2"' do
|
102
143
|
expect(@o_key.key(1)).to eq('test2')
|
103
144
|
end
|
104
|
-
it '
|
145
|
+
it '#fpath return "test1/test2"' do
|
105
146
|
expect(@o_key.fpath).to eq('test1/test2')
|
106
147
|
end
|
107
|
-
it '
|
148
|
+
it '#tree return %w(test1 test2)' do
|
108
149
|
expect(@o_key.tree).to eq(%w(test1 test2))
|
109
150
|
end
|
110
|
-
it '
|
151
|
+
it '#key_tree return "test1/test2"' do
|
111
152
|
expect(@o_key.key_tree).to eq('test1/test2')
|
112
153
|
end
|
113
154
|
end
|
114
155
|
|
115
|
-
context '
|
156
|
+
context '.new(":test")' do
|
116
157
|
before(:all) do
|
117
158
|
@o_key = Lorj::KeyPath.new(':test')
|
118
159
|
end
|
119
|
-
it '
|
160
|
+
it '#length return 1' do
|
120
161
|
expect(@o_key.length).to eq(1)
|
121
162
|
end
|
122
|
-
it '
|
163
|
+
it '#to_s return "test"' do
|
123
164
|
expect(@o_key.to_s).to eq('test')
|
124
165
|
end
|
125
|
-
it '
|
166
|
+
it '#key return :test' do
|
126
167
|
expect(@o_key.key).to eq(:test)
|
127
168
|
end
|
128
|
-
it '
|
169
|
+
it '#key(0) return :test' do
|
129
170
|
expect(@o_key.key(0)).to eq(:test)
|
130
171
|
end
|
131
|
-
it '
|
172
|
+
it '#key(1) return nil' do
|
132
173
|
expect(@o_key.key(1)).to eq(nil)
|
133
174
|
end
|
134
|
-
it '
|
175
|
+
it '#fpath return ":test"' do
|
135
176
|
expect(@o_key.fpath).to eq(':test')
|
136
177
|
end
|
137
|
-
it '
|
178
|
+
it '#tree return [:test]' do
|
138
179
|
expect(@o_key.tree).to eq([:test])
|
139
180
|
end
|
140
|
-
it '
|
181
|
+
it '#key_tree return :test' do
|
141
182
|
expect(@o_key.key_tree).to eq(:test)
|
142
183
|
end
|
143
184
|
end
|
144
185
|
|
145
|
-
context '
|
186
|
+
context '.new("test")' do
|
146
187
|
before(:all) do
|
147
188
|
@o_key = Lorj::KeyPath.new('test')
|
148
189
|
end
|
149
|
-
it '
|
190
|
+
it '#length return 1' do
|
150
191
|
expect(@o_key.length).to eq(1)
|
151
192
|
end
|
152
|
-
it '
|
193
|
+
it '#to_s return "test"' do
|
153
194
|
expect(@o_key.to_s).to eq('test')
|
154
195
|
end
|
155
|
-
it '
|
196
|
+
it '#key return "test"' do
|
156
197
|
expect(@o_key.key).to eq('test')
|
157
198
|
end
|
158
|
-
it '
|
199
|
+
it '#key(0) return "test"' do
|
159
200
|
expect(@o_key.key(0)).to eq('test')
|
160
201
|
end
|
161
|
-
it '
|
202
|
+
it '#key(1) return nil' do
|
162
203
|
expect(@o_key.key(1)).to eq(nil)
|
163
204
|
end
|
164
|
-
it '
|
205
|
+
it '#fpath return "test"' do
|
165
206
|
expect(@o_key.fpath).to eq('test')
|
166
207
|
end
|
167
|
-
it '
|
208
|
+
it '#tree return "test"' do
|
168
209
|
expect(@o_key.tree).to eq(['test'])
|
169
210
|
end
|
170
|
-
it '
|
211
|
+
it '#key_tree return "test"' do
|
171
212
|
expect(@o_key.key_tree).to eq('test')
|
172
213
|
end
|
173
214
|
end
|
174
215
|
|
175
|
-
context '
|
216
|
+
context '.new(nil)' do
|
176
217
|
before(:all) do
|
177
218
|
@o_key = Lorj::KeyPath.new(nil)
|
178
219
|
end
|
179
|
-
it '
|
220
|
+
it '#length return 0' do
|
180
221
|
expect(@o_key.length).to eq(0)
|
181
222
|
end
|
182
|
-
it '
|
223
|
+
it '#to_s return nil' do
|
183
224
|
expect(@o_key.to_s).to eq(nil)
|
184
225
|
end
|
185
|
-
it '
|
226
|
+
it '#key return nil' do
|
186
227
|
expect(@o_key.key).to eq(nil)
|
187
228
|
end
|
188
|
-
it '
|
229
|
+
it '#key(0) return nil' do
|
189
230
|
expect(@o_key.key(0)).to eq(nil)
|
190
231
|
end
|
191
|
-
it '
|
232
|
+
it '#key(1) return nil' do
|
192
233
|
expect(@o_key.key(1)).to eq(nil)
|
193
234
|
end
|
194
|
-
it '
|
235
|
+
it '#fpath return nil' do
|
195
236
|
expect(@o_key.fpath).to eq(nil)
|
196
237
|
end
|
197
|
-
it '
|
238
|
+
it '#tree return []' do
|
198
239
|
expect(@o_key.tree).to eq([])
|
199
240
|
end
|
200
|
-
it '
|
241
|
+
it '#key_tree return nil' do
|
201
242
|
expect(@o_key.key_tree).to eq(nil)
|
202
243
|
end
|
203
244
|
end
|