lib/shhh/application.rb in shhh-1.6.1 vs lib/shhh/application.rb in shhh-1.6.2
- old
+ new
@@ -12,11 +12,11 @@
:key_handler,
:result
def initialize(opts)
self.opts = opts
- self.opts_hash = opts.to_hash
+ self.opts_hash = opts.respond_to?(:to_hash) ? opts.to_hash : opts
self.args = ::Shhh::App::Args.new(opts_hash)
initialize_input_handler
initialize_key_handler
initialize_action
end
@@ -35,11 +35,11 @@
raise Shhh::Errors::NoPrivateKeyFound.new('Private key is required') unless self.key
end
unless command
raise Shhh::Errors::InsufficientOptionsError.new(
- 'Can not determine what to do from the options ' + opts.keys.reject { |k| !opts[k] }.to_s)
+ 'Can not determine what to do from the options ' + opts_hash.keys.reject { |k| !opts[k] }.to_s)
end
self.result = command.execute
return result
@@ -60,19 +60,16 @@
def command
@command_class ||= Shhh::App::Commands.find_command_class(opts)
@command ||= @command_class.new(self) if @command_class
end
- private
-
- def error(hash)
- hash
- end
-
def editor
ENV['EDITOR'] || '/bin/vi'
end
+ def error(hash)
+ hash
+ end
def initialize_input_handler(handler = ::Shhh::App::Input::Handler.new)
self.input_handler = handler
end