lib/cliutils/prefs/pref.rb in cliutils-2.1.4 vs lib/cliutils/prefs/pref.rb in cliutils-2.2.0

- old
+ new

@@ -118,11 +118,11 @@ # evaluations when bad options are provided. _eval_pre if @pre valid_option_chosen = false until valid_option_chosen - response = prompt(@prompt_text, default) + response = messenger.prompt(@prompt_text, default) if validate(response) valid_option_chosen = true @answer = evaluate_behaviors(response) _eval_post if @post else @@ -188,39 +188,39 @@ end # Evaluates the pre-prompt Hash and does the right thing. :) # @return [void] def _eval_pre - info(@pre[:message]) - prompt('Press enter to continue') + messenger.info(@pre[:message]) + messenger.prompt('Press enter to continue') if (@pre[:action]) - action_obj = _init_action(@pre[:action][:name]) + action_obj = _init_action(@pre[:action]) action_obj.run if action_obj end end # Evaluates the post-prompt Hash and does the right thing. :) # @return [void] def _eval_post - info(@post[:message]) - prompt('Press enter to continue') + messenger.info(@post[:message]) + messenger.prompt('Press enter to continue') if (@post[:action]) - action_obj = _init_action(@post[:action][:name]) + action_obj = _init_action(@post[:action]) action_obj.run if action_obj end end # Attempts to instantiate a Pre or Post Action based on name; if # successful, the new object gets placed in @validator_objects # @param [String] path_or_name The path to or name of the Action # @return [void] def _init_action(path_or_name) obj = _load_asset(ASSET_TYPE_ACTION, path_or_name) - unless obj.nil? - obj.parameters = @pre[:action][:parameters] + unless obj.nil? || @pre[:parameters].nil? + obj.parameters = @pre[:parameters] end obj end # Attempts to instantiate a Behavior based on name; if @@ -256,10 +256,10 @@ asset_found = false if File.file?(File.expand_path(path_or_name)) # If the file exists, we're assuming that the user # passed a filepath. asset_found = true - asset_path = File.expand_path(path_or_name) if path_or_name.start_with?('~') + asset_path = File.expand_path(path_or_name) asset_name = File.basename(path_or_name, '.*').camelize end unless asset_found # If the file doesn't exist, look to see if it's been