flor 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +9 -0
- data/CREDITS.md +21 -0
- data/LICENSE.txt +4 -1
- data/Makefile +4 -0
- data/README.md +8 -0
- data/flor.gemspec +10 -10
- data/lib/flor.rb +2 -2
- data/lib/flor/changes.rb +3 -3
- data/lib/flor/colours.rb +14 -8
- data/lib/flor/conf.rb +63 -58
- data/lib/flor/core.rb +4 -4
- data/lib/flor/core/executor.rb +65 -29
- data/lib/flor/core/node.rb +37 -20
- data/lib/flor/core/procedure.rb +182 -40
- data/lib/flor/core/texecutor.rb +125 -52
- data/lib/flor/djan.rb +111 -82
- data/lib/flor/dollar.rb +31 -30
- data/lib/flor/flor.rb +314 -237
- data/lib/flor/id.rb +7 -2
- data/lib/flor/log.rb +250 -245
- data/lib/flor/parser.rb +72 -38
- data/lib/flor/pcore/_arr.rb +10 -10
- data/lib/flor/pcore/_att.rb +49 -14
- data/lib/flor/pcore/_coll.rb +18 -0
- data/lib/flor/pcore/_obj.rb +23 -7
- data/lib/flor/pcore/_pat_.rb +1 -1
- data/lib/flor/pcore/_pat_guard.rb +8 -0
- data/lib/flor/pcore/_pat_obj.rb +3 -3
- data/lib/flor/pcore/_pat_or.rb +4 -0
- data/lib/flor/pcore/_pat_regex.rb +24 -0
- data/lib/flor/pcore/_skip.rb +4 -0
- data/lib/flor/pcore/_val.rb +0 -1
- data/lib/flor/pcore/all.rb +111 -0
- data/lib/flor/pcore/any.rb +83 -0
- data/lib/flor/pcore/arith.rb +35 -6
- data/lib/flor/pcore/break.rb +39 -1
- data/lib/flor/pcore/case.rb +82 -4
- data/lib/flor/pcore/cmp.rb +7 -7
- data/lib/flor/pcore/collect.rb +50 -0
- data/lib/flor/pcore/cond.rb +17 -3
- data/lib/flor/pcore/cursor.rb +8 -2
- data/lib/flor/pcore/detect.rb +45 -0
- data/lib/flor/pcore/each.rb +52 -0
- data/lib/flor/pcore/empty.rb +60 -0
- data/lib/flor/pcore/filter.rb +94 -0
- data/lib/flor/pcore/find.rb +67 -0
- data/lib/flor/pcore/for_each.rb +65 -0
- data/lib/flor/pcore/includes.rb +32 -0
- data/lib/flor/pcore/inject.rb +55 -0
- data/lib/flor/pcore/iterator.rb +151 -0
- data/lib/flor/pcore/keys.rb +60 -0
- data/lib/flor/pcore/length.rb +34 -7
- data/lib/flor/pcore/logo.rb +18 -0
- data/lib/flor/pcore/loop.rb +4 -0
- data/lib/flor/pcore/map.rb +77 -46
- data/lib/flor/pcore/match.rb +8 -2
- data/lib/flor/pcore/matchr.rb +4 -5
- data/lib/flor/pcore/move.rb +3 -3
- data/lib/flor/pcore/noeval.rb +13 -0
- data/lib/flor/pcore/not.rb +16 -0
- data/lib/flor/pcore/on.rb +172 -0
- data/lib/flor/pcore/on_cancel.rb +54 -0
- data/lib/flor/pcore/on_error.rb +68 -0
- data/lib/flor/pcore/rand.rb +2 -2
- data/lib/flor/pcore/range.rb +2 -1
- data/lib/flor/pcore/reduce.rb +124 -0
- data/lib/flor/pcore/reverse.rb +46 -0
- data/lib/flor/pcore/select.rb +72 -0
- data/lib/flor/pcore/set.rb +8 -0
- data/lib/flor/pcore/stall.rb +10 -0
- data/lib/flor/pcore/to_array.rb +61 -0
- data/lib/flor/pcore/until.rb +34 -0
- data/lib/flor/punit/cancel.rb +30 -5
- data/lib/flor/punit/ccollect.rb +11 -0
- data/lib/flor/punit/cmap.rb +10 -5
- data/lib/flor/punit/concurrence.rb +42 -51
- data/lib/flor/punit/cron.rb +33 -0
- data/lib/flor/punit/do_trap.rb +42 -0
- data/lib/flor/punit/every.rb +48 -13
- data/lib/flor/punit/graft.rb +3 -3
- data/lib/flor/punit/on_timeout.rb +38 -0
- data/lib/flor/punit/schedule.rb +69 -6
- data/lib/flor/punit/signal.rb +54 -0
- data/lib/flor/punit/sleep.rb +1 -1
- data/lib/flor/punit/task.rb +4 -1
- data/lib/flor/punit/trap.rb +188 -13
- data/lib/flor/tools/shell.rb +408 -62
- data/lib/flor/tools/shell_out.rb +31 -0
- data/lib/flor/unit.rb +1 -1
- data/lib/flor/unit/caller.rb +177 -0
- data/lib/flor/unit/executor.rb +1 -0
- data/lib/flor/unit/ganger.rb +15 -21
- data/lib/flor/unit/hook.rb +1 -1
- data/lib/flor/unit/hooker.rb +22 -10
- data/lib/flor/unit/loader.rb +22 -22
- data/lib/flor/unit/logger.rb +63 -36
- data/lib/flor/unit/models.rb +6 -1
- data/lib/flor/unit/models/execution.rb +12 -1
- data/lib/flor/unit/models/message.rb +7 -0
- data/lib/flor/unit/models/trap.rb +31 -17
- data/lib/flor/unit/scheduler.rb +18 -10
- data/lib/flor/unit/storage.rb +83 -23
- data/lib/flor/unit/waiter.rb +1 -2
- metadata +96 -52
- data/lib/flor/deep.rb +0 -144
- data/lib/flor/punit/on.rb +0 -57
- data/lib/flor/unit/runner.rb +0 -84
- data/match.md +0 -22
data/lib/flor/unit/waiter.rb
CHANGED
@@ -68,7 +68,6 @@ module Flor
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
#executor, message = @queue.shift
|
72
71
|
@queue.shift[1]
|
73
72
|
end
|
74
73
|
end
|
@@ -98,7 +97,7 @@ module Flor
|
|
98
97
|
oontimeout = opts[:on_timeout] || opts[:ontimeout] || 'fail'
|
99
98
|
|
100
99
|
case owait
|
101
|
-
when true
|
100
|
+
when nil, true
|
102
101
|
[ [ [ nil, %w[ failed terminated ] ] ], # serie
|
103
102
|
otimeout,
|
104
103
|
oontimeout,
|
metadata
CHANGED
@@ -1,110 +1,129 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.15.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- John Mettraux
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2018-06-15 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: munemo
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
- - ">="
|
20
21
|
- !ruby/object:Gem::Version
|
21
22
|
version: 1.0.1
|
22
23
|
type: :runtime
|
23
24
|
prerelease: false
|
24
25
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.0'
|
30
|
+
- - ">="
|
28
31
|
- !ruby/object:Gem::Version
|
29
32
|
version: 1.0.1
|
30
33
|
- !ruby/object:Gem::Dependency
|
31
34
|
name: raabro
|
32
35
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
36
|
requirements:
|
35
|
-
- -
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.1'
|
40
|
+
- - ">="
|
36
41
|
- !ruby/object:Gem::Version
|
37
|
-
version: 1.1.
|
42
|
+
version: 1.1.5
|
38
43
|
type: :runtime
|
39
44
|
prerelease: false
|
40
45
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
46
|
requirements:
|
43
|
-
- -
|
47
|
+
- - "~>"
|
44
48
|
- !ruby/object:Gem::Version
|
45
|
-
version: 1.1
|
49
|
+
version: '1.1'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 1.1.5
|
46
53
|
- !ruby/object:Gem::Dependency
|
47
54
|
name: fugit
|
48
55
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
56
|
requirements:
|
51
|
-
- -
|
57
|
+
- - "~>"
|
52
58
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
59
|
+
version: '1.1'
|
54
60
|
type: :runtime
|
55
61
|
prerelease: false
|
56
62
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
63
|
requirements:
|
59
|
-
- -
|
64
|
+
- - "~>"
|
60
65
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
66
|
+
version: '1.1'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: dense
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '1.1'
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.1.1
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '1.1'
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 1.1.1
|
62
87
|
- !ruby/object:Gem::Dependency
|
63
88
|
name: sequel
|
64
89
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
90
|
requirements:
|
67
|
-
- - ~>
|
91
|
+
- - "~>"
|
68
92
|
- !ruby/object:Gem::Version
|
69
93
|
version: '4'
|
70
|
-
type: :
|
94
|
+
type: :runtime
|
71
95
|
prerelease: false
|
72
96
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
97
|
requirements:
|
75
|
-
- - ~>
|
98
|
+
- - "~>"
|
76
99
|
- !ruby/object:Gem::Version
|
77
100
|
version: '4'
|
78
101
|
- !ruby/object:Gem::Dependency
|
79
102
|
name: rspec
|
80
103
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
104
|
requirements:
|
83
|
-
- -
|
105
|
+
- - "~>"
|
84
106
|
- !ruby/object:Gem::Version
|
85
|
-
version: 3.
|
107
|
+
version: '3.7'
|
86
108
|
type: :development
|
87
109
|
prerelease: false
|
88
110
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
111
|
requirements:
|
91
|
-
- -
|
112
|
+
- - "~>"
|
92
113
|
- !ruby/object:Gem::Version
|
93
|
-
version: 3.
|
114
|
+
version: '3.7'
|
94
115
|
- !ruby/object:Gem::Dependency
|
95
116
|
name: terminal-table
|
96
117
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
118
|
requirements:
|
99
|
-
- -
|
119
|
+
- - ">="
|
100
120
|
- !ruby/object:Gem::Version
|
101
121
|
version: '0'
|
102
122
|
type: :development
|
103
123
|
prerelease: false
|
104
124
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
125
|
requirements:
|
107
|
-
- -
|
126
|
+
- - ">="
|
108
127
|
- !ruby/object:Gem::Version
|
109
128
|
version: '0'
|
110
129
|
description: A Ruby workflow engine (ruote next generation)
|
@@ -114,16 +133,21 @@ executables: []
|
|
114
133
|
extensions: []
|
115
134
|
extra_rdoc_files: []
|
116
135
|
files:
|
136
|
+
- CHANGELOG.md
|
137
|
+
- CREDITS.md
|
138
|
+
- LICENSE.txt
|
117
139
|
- Makefile
|
140
|
+
- README.md
|
141
|
+
- flor.gemspec
|
142
|
+
- lib/flor.rb
|
118
143
|
- lib/flor/changes.rb
|
119
144
|
- lib/flor/colours.rb
|
120
145
|
- lib/flor/conf.rb
|
146
|
+
- lib/flor/core.rb
|
121
147
|
- lib/flor/core/executor.rb
|
122
148
|
- lib/flor/core/node.rb
|
123
149
|
- lib/flor/core/procedure.rb
|
124
150
|
- lib/flor/core/texecutor.rb
|
125
|
-
- lib/flor/core.rb
|
126
|
-
- lib/flor/deep.rb
|
127
151
|
- lib/flor/djan.rb
|
128
152
|
- lib/flor/dollar.rb
|
129
153
|
- lib/flor/errors.rb
|
@@ -138,6 +162,7 @@ files:
|
|
138
162
|
- lib/flor/pcore/_arr.rb
|
139
163
|
- lib/flor/pcore/_atom.rb
|
140
164
|
- lib/flor/pcore/_att.rb
|
165
|
+
- lib/flor/pcore/_coll.rb
|
141
166
|
- lib/flor/pcore/_dump.rb
|
142
167
|
- lib/flor/pcore/_err.rb
|
143
168
|
- lib/flor/pcore/_obj.rb
|
@@ -146,20 +171,34 @@ files:
|
|
146
171
|
- lib/flor/pcore/_pat_guard.rb
|
147
172
|
- lib/flor/pcore/_pat_obj.rb
|
148
173
|
- lib/flor/pcore/_pat_or.rb
|
174
|
+
- lib/flor/pcore/_pat_regex.rb
|
149
175
|
- lib/flor/pcore/_skip.rb
|
150
176
|
- lib/flor/pcore/_val.rb
|
177
|
+
- lib/flor/pcore/all.rb
|
178
|
+
- lib/flor/pcore/any.rb
|
151
179
|
- lib/flor/pcore/apply.rb
|
152
180
|
- lib/flor/pcore/arith.rb
|
153
181
|
- lib/flor/pcore/break.rb
|
154
182
|
- lib/flor/pcore/case.rb
|
155
183
|
- lib/flor/pcore/cmp.rb
|
184
|
+
- lib/flor/pcore/collect.rb
|
156
185
|
- lib/flor/pcore/cond.rb
|
157
186
|
- lib/flor/pcore/cursor.rb
|
158
187
|
- lib/flor/pcore/define.rb
|
188
|
+
- lib/flor/pcore/detect.rb
|
159
189
|
- lib/flor/pcore/do_return.rb
|
190
|
+
- lib/flor/pcore/each.rb
|
160
191
|
- lib/flor/pcore/echo.rb
|
192
|
+
- lib/flor/pcore/empty.rb
|
161
193
|
- lib/flor/pcore/fail.rb
|
194
|
+
- lib/flor/pcore/filter.rb
|
195
|
+
- lib/flor/pcore/find.rb
|
196
|
+
- lib/flor/pcore/for_each.rb
|
162
197
|
- lib/flor/pcore/if.rb
|
198
|
+
- lib/flor/pcore/includes.rb
|
199
|
+
- lib/flor/pcore/inject.rb
|
200
|
+
- lib/flor/pcore/iterator.rb
|
201
|
+
- lib/flor/pcore/keys.rb
|
163
202
|
- lib/flor/pcore/length.rb
|
164
203
|
- lib/flor/pcore/logo.rb
|
165
204
|
- lib/flor/pcore/loop.rb
|
@@ -170,20 +209,30 @@ files:
|
|
170
209
|
- lib/flor/pcore/noeval.rb
|
171
210
|
- lib/flor/pcore/noret.rb
|
172
211
|
- lib/flor/pcore/not.rb
|
212
|
+
- lib/flor/pcore/on.rb
|
213
|
+
- lib/flor/pcore/on_cancel.rb
|
214
|
+
- lib/flor/pcore/on_error.rb
|
173
215
|
- lib/flor/pcore/push.rb
|
174
216
|
- lib/flor/pcore/rand.rb
|
175
217
|
- lib/flor/pcore/range.rb
|
218
|
+
- lib/flor/pcore/reduce.rb
|
219
|
+
- lib/flor/pcore/reverse.rb
|
220
|
+
- lib/flor/pcore/select.rb
|
176
221
|
- lib/flor/pcore/sequence.rb
|
177
222
|
- lib/flor/pcore/set.rb
|
178
223
|
- lib/flor/pcore/stall.rb
|
224
|
+
- lib/flor/pcore/to_array.rb
|
179
225
|
- lib/flor/pcore/twig.rb
|
180
226
|
- lib/flor/pcore/until.rb
|
181
227
|
- lib/flor/punit/cancel.rb
|
228
|
+
- lib/flor/punit/ccollect.rb
|
182
229
|
- lib/flor/punit/cmap.rb
|
183
230
|
- lib/flor/punit/concurrence.rb
|
231
|
+
- lib/flor/punit/cron.rb
|
232
|
+
- lib/flor/punit/do_trap.rb
|
184
233
|
- lib/flor/punit/every.rb
|
185
234
|
- lib/flor/punit/graft.rb
|
186
|
-
- lib/flor/punit/
|
235
|
+
- lib/flor/punit/on_timeout.rb
|
187
236
|
- lib/flor/punit/schedule.rb
|
188
237
|
- lib/flor/punit/signal.rb
|
189
238
|
- lib/flor/punit/sleep.rb
|
@@ -193,6 +242,9 @@ files:
|
|
193
242
|
- lib/flor/to_string.rb
|
194
243
|
- lib/flor/tools/env.rb
|
195
244
|
- lib/flor/tools/shell.rb
|
245
|
+
- lib/flor/tools/shell_out.rb
|
246
|
+
- lib/flor/unit.rb
|
247
|
+
- lib/flor/unit/caller.rb
|
196
248
|
- lib/flor/unit/executor.rb
|
197
249
|
- lib/flor/unit/ganger.rb
|
198
250
|
- lib/flor/unit/hook.rb
|
@@ -201,49 +253,41 @@ files:
|
|
201
253
|
- lib/flor/unit/journal.rb
|
202
254
|
- lib/flor/unit/loader.rb
|
203
255
|
- lib/flor/unit/logger.rb
|
256
|
+
- lib/flor/unit/models.rb
|
204
257
|
- lib/flor/unit/models/execution.rb
|
258
|
+
- lib/flor/unit/models/message.rb
|
205
259
|
- lib/flor/unit/models/pointer.rb
|
206
260
|
- lib/flor/unit/models/timer.rb
|
207
261
|
- lib/flor/unit/models/trace.rb
|
208
262
|
- lib/flor/unit/models/trap.rb
|
209
|
-
- lib/flor/unit/models.rb
|
210
|
-
- lib/flor/unit/runner.rb
|
211
263
|
- lib/flor/unit/scheduler.rb
|
212
264
|
- lib/flor/unit/spooler.rb
|
213
265
|
- lib/flor/unit/storage.rb
|
214
266
|
- lib/flor/unit/taskers.rb
|
215
267
|
- lib/flor/unit/waiter.rb
|
216
268
|
- lib/flor/unit/wlist.rb
|
217
|
-
- lib/flor/unit.rb
|
218
|
-
- lib/flor.rb
|
219
|
-
- flor.gemspec
|
220
|
-
- LICENSE.txt
|
221
|
-
- CHANGELOG.md
|
222
|
-
- match.md
|
223
|
-
- README.md
|
224
269
|
homepage: http://github.com/floraison
|
225
270
|
licenses:
|
226
271
|
- MIT
|
272
|
+
metadata: {}
|
227
273
|
post_install_message:
|
228
274
|
rdoc_options: []
|
229
275
|
require_paths:
|
230
276
|
- lib
|
231
277
|
required_ruby_version: !ruby/object:Gem::Requirement
|
232
|
-
none: false
|
233
278
|
requirements:
|
234
|
-
- -
|
279
|
+
- - ">="
|
235
280
|
- !ruby/object:Gem::Version
|
236
281
|
version: '0'
|
237
282
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
238
|
-
none: false
|
239
283
|
requirements:
|
240
|
-
- -
|
284
|
+
- - ">="
|
241
285
|
- !ruby/object:Gem::Version
|
242
286
|
version: '0'
|
243
287
|
requirements: []
|
244
288
|
rubyforge_project:
|
245
|
-
rubygems_version:
|
289
|
+
rubygems_version: 2.7.6
|
246
290
|
signing_key:
|
247
|
-
specification_version:
|
291
|
+
specification_version: 4
|
248
292
|
summary: A Ruby workflow engine
|
249
293
|
test_files: []
|
data/lib/flor/deep.rb
DELETED
@@ -1,144 +0,0 @@
|
|
1
|
-
|
2
|
-
module Flor
|
3
|
-
|
4
|
-
# deep.rb
|
5
|
-
#
|
6
|
-
# functions for deep getting/setting in structures
|
7
|
-
|
8
|
-
def self.to_array_index(o)
|
9
|
-
|
10
|
-
return 0 if o == 'first'
|
11
|
-
return -1 if o == 'last'
|
12
|
-
return o if o.is_a?(Integer)
|
13
|
-
nil
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.split_deep_path(k)
|
17
|
-
|
18
|
-
return k if k.is_a?(Array)
|
19
|
-
|
20
|
-
k
|
21
|
-
.scan(/(?:\.?(-?\d+)|\.?([^\.\[]+)|\[(-?\d+)\]|\[([^\[\]]+)\])/)
|
22
|
-
.collect { |doti, dots, squi, squs|
|
23
|
-
if doti
|
24
|
-
doti.to_i
|
25
|
-
elsif dots
|
26
|
-
dots
|
27
|
-
elsif squi
|
28
|
-
squi.to_i
|
29
|
-
else
|
30
|
-
s0 = squs[0, 1]
|
31
|
-
(s0 == "'" || s0 == '"') ? squs[1..-2] : squs
|
32
|
-
end }
|
33
|
-
end
|
34
|
-
|
35
|
-
# Returns a symbol in case of failure.
|
36
|
-
#
|
37
|
-
def self.deep_get(o, k)
|
38
|
-
|
39
|
-
return o unless k
|
40
|
-
|
41
|
-
split_deep_path(k).inject([ o, [] ]) do |(val, seen), kk|
|
42
|
-
|
43
|
-
seen << kk
|
44
|
-
|
45
|
-
case val
|
46
|
-
when Array
|
47
|
-
i = to_array_index(kk)
|
48
|
-
return seen.join('.').to_sym unless i
|
49
|
-
[ val[i], seen ]
|
50
|
-
when Hash
|
51
|
-
[ val[kk], seen ]
|
52
|
-
else
|
53
|
-
return seen[0..-2].join('.').to_sym
|
54
|
-
end
|
55
|
-
|
56
|
-
end.first
|
57
|
-
end
|
58
|
-
|
59
|
-
def self.deep_set(o, k, v)
|
60
|
-
|
61
|
-
ks = split_deep_path(k)
|
62
|
-
key = ks.pop
|
63
|
-
col = deep_get(o, ks)
|
64
|
-
|
65
|
-
case col
|
66
|
-
when Symbol
|
67
|
-
col
|
68
|
-
when Array
|
69
|
-
i = to_array_index(key)
|
70
|
-
return ks.join('.').to_sym unless i
|
71
|
-
col[i] = v
|
72
|
-
when Hash
|
73
|
-
col[key] = v
|
74
|
-
else
|
75
|
-
ks.join('.').to_sym
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def self.deep_insert(o, k, v)
|
80
|
-
|
81
|
-
ks = split_deep_path(k)
|
82
|
-
key = ks.pop
|
83
|
-
col = deep_get(o, ks)
|
84
|
-
|
85
|
-
case col
|
86
|
-
when Symbol
|
87
|
-
col
|
88
|
-
when Array
|
89
|
-
i = to_array_index(key)
|
90
|
-
return ks.join('.').to_sym unless i
|
91
|
-
col.insert(i, v)
|
92
|
-
v
|
93
|
-
when Hash
|
94
|
-
col[key] = v
|
95
|
-
else
|
96
|
-
ks.join('.').to_sym
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def self.deep_unset(o, k)
|
101
|
-
|
102
|
-
ks = split_deep_path(k)
|
103
|
-
key = ks.pop
|
104
|
-
col = deep_get(o, ks)
|
105
|
-
|
106
|
-
case col
|
107
|
-
when Symbol
|
108
|
-
col
|
109
|
-
when Array
|
110
|
-
i = to_array_index(key)
|
111
|
-
return ks.join('.').to_sym unless i
|
112
|
-
col.delete_at(i)
|
113
|
-
when Hash
|
114
|
-
col.delete(key)
|
115
|
-
else
|
116
|
-
return ks.join('.').to_sym
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def self.deep_has_key?(o, k)
|
121
|
-
|
122
|
-
val = o
|
123
|
-
ks = split_deep_path(k)
|
124
|
-
|
125
|
-
loop do
|
126
|
-
|
127
|
-
kk = ks.shift
|
128
|
-
|
129
|
-
case val
|
130
|
-
when Array
|
131
|
-
i = to_array_index(kk)
|
132
|
-
break false unless i
|
133
|
-
break (i < 0 ? -i < val.length : i < val.length) if ks.empty?
|
134
|
-
val = val[i]
|
135
|
-
when Hash
|
136
|
-
break val.has_key?(kk.to_s) if ks.empty? # nota bene: #to_s
|
137
|
-
val = val[kk.to_s]
|
138
|
-
else
|
139
|
-
break false
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|