lib/cliutils/prefs/pref.rb in cliutils-1.4.0 vs lib/cliutils/prefs/pref.rb in cliutils-1.4.1
- old
+ new
@@ -177,10 +177,11 @@
info(@pre[:message])
prompt('Press enter to continue')
if (@pre[:action])
action_obj = _load_action(@pre[:action])
+ action_obj.pref = self
action_obj.run(@pre[:action_parameters][0])
end
end
# Evaluates the post-prompt Hash and does the right thing. :)
@@ -188,10 +189,11 @@
def _eval_post
info(@post[:message])
if (@post[:action])
action_obj = _load_action(@post[:action])
+ action_obj.pref = self
action_obj.run(@post[:action_parameters][0])
end
end
# Loads a Pref Action, instantiates it (if it exists),
@@ -202,9 +204,10 @@
# @return [Object]
def _load_action(path_or_name)
if File.exist?(path_or_name)
# If the file exists, we're assuming that the user
# passed a filepath.
+ action_path = File.expand_path(path_or_name) if path_or_name.start_with?('~')
action_path = "#{ path_or_name }_action"
action_name = File.basename(path_or_name, '.*').camelize
else
# If it doesn't, we're assuming that the user
# passed a class name.