lib/ronin/ui/output/output.rb in ronin-0.3.0 vs lib/ronin/ui/output/output.rb in ronin-1.0.0.pre1

- old
+ new

@@ -1,9 +1,9 @@ # # Ronin - A Ruby platform for exploit development and security research. # -# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com) +# Copyright (c) 2006-2010 Hal Brodigan (postmodern.mod3 at gmail.com) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. @@ -16,129 +16,105 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # -require 'ronin/ui/output/handler' +require 'ronin/ui/output/terminal/color' module Ronin module UI module Output + @mode = :quiet + @handler = Terminal::Color + # # @return [Boolean] # Specifies whether verbose output is enabled. # # @since 0.3.0 # def Output.verbose? - (@@ronin_verbose ||= :quiet) == :verbose + @mode == :verbose end # # @return [Boolean] # Specifies whether quiet output is enabled. # # @since 0.3.0 # def Output.quiet? - (@@ronin_verbose ||= :quiet) == :quiet + @mode == :quiet end # # @return [Boolean] # Specifies whether silent output is enabled. # # @since 0.3.0 # def Output.silent? - (@@ronin_verbose ||= :quiet) == :silent + @mode == :silent end # - # Changes the verbose mode. + # Enables verbose output. # - # @param [Boolean] mode - # The new verbose mode. + # @return [Output] # - # @return [Boolean] - # The new verbose mode. + # @since 1.0.0 # - # @since 0.3.0 - # - def Output.verbose=(mode) - if mode - @@ronin_verbose = :verbose - else - @@ronin_verbose = :quiet - end - - return mode + def Output.verbose! + @mode = :verbose + return self end # - # Changes verbose output. + # Disables verbose output. # - # @param [Boolean] mode - # The new quiet mode. + # @return [Output] # - # @return [Boolean] - # The new quiet mode. + # @since 1.0.0 # - # @since 0.3.0 - # - def Output.quiet=(mode) - if mode - @@ronin_verbose = :quiet - else - @@ronin_verbose = :verbose - end - - return mode + def Output.quiet! + @mode = :quiet + return self end # - # Changes verbose output. + # Disables all output. # - # @param [Boolean] mode - # The new quiet mode. + # @return [Output] # - # @return [Boolean] - # The new quiet mode. + # @since 1.0.0 # - # @since 0.3.0 - # - def Output.silent=(mode) - if mode - @@ronin_verbose = :silent - else - @@ronin_verbose = :quiet - end - - return mode + def Output.silent! + @mode = :silent + return self end # # @return [Ronin::UI::Output::Handler] # The current Output handler. # # @since 0.3.0 # def Output.handler - @@ronin_output ||= Handler + @handler end # # Sets the current Output handler. # # @param [Handler] new_handler - # The new output handler to use. Must provide the +puts+, - # +print_info+, +print_debug+, +print_warning+ and +print_error+ + # The new output handler to use. Must provide the `puts`, + # `print_info`, `print_debug`, `print_warning` and `print_error` # class methods. # # @since 0.3.0 # def Output.handler=(new_handler) - @@ronin_output = new_handler + @handler = new_handler end end end end