class ResponseMate::Commands::List
Command which performs the operations required by ‘response_mate list`
Public Instance Methods
run()
click to toggle source
Run the command based on args, options provided
# File lib/response_mate/commands/list.rb, line 4 def run # rubocop:disable Metrics/AbcSize environment = ResponseMate::Environment.new(options[:environment]) options[:manifest] = ResponseMate::Manifest.new(options[:requests_manifest], environment) puts available_keys.join("\n") << "\n\n" action = ask_action return if action == :no perform_action(action, ask_key(available_keys)) end
Private Instance Methods
ask_action()
click to toggle source
# File lib/response_mate/commands/list.rb, line 23 def ask_action choose do |menu| menu.prompt = 'Want to perform any of the actions above?' menu.choices(:record, :inspect, :no) end end
ask_key(available_keys)
click to toggle source
# File lib/response_mate/commands/list.rb, line 30 def ask_key(available_keys) choose do |menu| menu.prompt = 'Which one?' menu.choices(*available_keys) end.to_s end
available_keys()
click to toggle source
# File lib/response_mate/commands/list.rb, line 19 def available_keys options[:manifest].requests.map { |r| r.key.to_sym } end
perform_action(action, key)
click to toggle source
# File lib/response_mate/commands/list.rb, line 37 def perform_action(action, key) case action when :record ResponseMate::Recorder.new(options).record([key]) when :inspect ResponseMate::Inspector.new(options).inspect_key(key) end end