Skip to content

Commit

Permalink
Rework conf at the end of ConfExecutor, gh-36
Browse files Browse the repository at this point in the history
  • Loading branch information
jmettraux committed Nov 27, 2020
1 parent e7a2204 commit 465d4ed
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
27 changes: 26 additions & 1 deletion lib/flor/core/texecutor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def has_key?(k)
o.each { |ee| ee['_path'] = path if ee.is_a?(Hash) }
end

o
rework_conf(o)
end

def interpret_path(path, context=nil)
Expand Down Expand Up @@ -299,6 +299,31 @@ def determine_root(path)

ps.last == 'etc' ? File.absolute_path(File.join(dir, '..')) : dir
end

protected

# For now, only the return procedure has to be marshalled back
# to the "return" string, gh-36
#
def rework_conf(o)

case o
when Array
o.collect { |e|
rework_conf(e) }
when Hash
o.inject({}) { |h, (k, v)|
h[k] =
if Flor.is_proc_tree?(v) && v[1]['proc'] == 'return'
'return'
else
rework_conf(v)
end
h }
else
o
end
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/flor/flor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module Flor
signal cancel
terminated failed ceased
idle
]
].freeze

class << self

Expand Down
4 changes: 3 additions & 1 deletion spec/conf_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
version: '3.2.1'
count: 7
blah: [ 'a', 'b', 2 ]
point: return
},
{})

Expand All @@ -32,7 +33,8 @@
'count' => 7,
'blah' => [ 'a', 'b', 2 ],
'_path' => '.',
'root' => '.'
'root' => '.',
'point' => 'return'
})
end

Expand Down

0 comments on commit 465d4ed

Please sign in to comment.