Sha256: 754a4f9d0fb3c69cfd938abaa322bf921c833449d459547efc5cbdba3bb5e776

Contents?: true

Size: 1.13 KB

Versions: 6

Compression:

Stored size: 1.13 KB

Contents

require 'boson/view'

module Boson
  if defined? BinRunner
    class BinRunner
      module Viewable
        def print_usage_header
          super
          puts "GLOBAL OPTIONS"
          View.enable
        end
      end
      extend Viewable
    end
  end

  class BareRunner
    module Viewable
      def init
        View.enable
        super
      end
    end
    extend Viewable
  end

  class OptionParser
    module Viewable
      def get_fields_and_options(fields, options)
        (fields << :default).uniq! if options.delete(:local) || options[:fields] == '*'
        fields, opts = super(fields, options)
        fields.delete(:default) if fields.include?(:default) && opts.all? {|e| e[:default].nil? }
        [fields, opts]
      end

      def default_render_options #:nodoc:
        {:header_filter=>:capitalize, :description=>false, :filter_any=>true,
          :filter_classes=>{Array=>[:join, ',']}, :hide_empty=>true}
      end

      def render_table(fields, arr, options)
        options = default_render_options.merge(:fields=>fields).merge(options)
        View.render arr, options
      end
    end
    include Viewable
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
boson-more-0.3.1 lib/boson/viewable.rb
boson-more-0.3.0 lib/boson/viewable.rb
boson-more-0.2.2 lib/boson/viewable.rb
boson-more-0.2.1 lib/boson/viewable.rb
boson-more-0.2.0 lib/boson/viewable.rb
boson-more-0.1.0 lib/boson/viewable.rb