Sha256: 1d6c7b474195448fc107e03229244c14eceb73c183eecb9076270fb72b805949

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

module Berkshelf
  class BaseFormatter
    class << self
      #
      # @macro formatter_method
      #   @method $1(*args)
      #     Create a formatter method for the declaration
      #
      def formatter_method(name)
        class_eval <<-EOH, __FILE__, __LINE__ + 1
          def #{name}(*args)
            raise AbstractFunction,
              "##{name} must be implemented on \#{self.class.name}!"
          end
        EOH
      end
    end

    # UI methods
    formatter_method :deprecation
    formatter_method :error
    formatter_method :msg
    formatter_method :warn

    # Object methods
    formatter_method :fetch
    formatter_method :install
    formatter_method :list
    formatter_method :outdated
    formatter_method :package
    formatter_method :search
    formatter_method :show
    formatter_method :skipping
    formatter_method :uploaded
    formatter_method :use
    formatter_method :vendor
    formatter_method :version

    # The cleanup hook is defined by subclasses and is called by the CLI.
    def cleanup_hook; end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
berkshelf-3.0.1 lib/berkshelf/formatters/base.rb
berkshelf-3.0.0 lib/berkshelf/formatters/base.rb
berkshelf-3.0.0.rc1 lib/berkshelf/formatters/base.rb