Sha256: 3805e33b34ec5940cfc2ec3da66bfe667715e3a031d67c087ddb0556afff8ed3

Contents?: true

Size: 954 Bytes

Versions: 154

Compression:

Stored size: 954 Bytes

Contents

# frozen-string-literal: true
#
# The pretty_table extension adds Sequel::Dataset#print and the
# Sequel::PrettyTable class for creating nice-looking plain-text
# tables.  Example:
#
#   +--+-------+
#   |id|name   |
#   |--+-------|
#   |1 |fasdfas|
#   |2 |test   |
#   +--+-------+
#
# You can load this extension into specific datasets:
#
#   ds = DB[:table]
#   ds = ds.extension(:pretty_table)
#
# Or you can load it into all of a database's datasets, which
# is probably the desired behavior if you are using this extension:
#
#   DB.extension(:pretty_table)
#
# Related module: Sequel::DatasetPrinter

#
module Sequel
  extension :_pretty_table

  module DatasetPrinter
    # Pretty prints the records in the dataset as plain-text table.
    def print(*cols)
      ds = naked
      rows = ds.all
      Sequel::PrettyTable.print(rows, cols.empty? ? ds.columns : cols)
    end
  end

  Dataset.register_extension(:pretty_table, DatasetPrinter)
end

Version data entries

154 entries across 135 versions & 2 rubygems

Version Path
tdiary-5.1.2 vendor/bundle/ruby/2.7.0/gems/sequel-5.32.0/lib/sequel/extensions/pretty_table.rb
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/sequel-5.26.0/lib/sequel/extensions/pretty_table.rb
sequel-5.32.0 lib/sequel/extensions/pretty_table.rb
sequel-5.31.0 lib/sequel/extensions/pretty_table.rb
sequel-5.30.0 lib/sequel/extensions/pretty_table.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/sequel-5.26.0/lib/sequel/extensions/pretty_table.rb
tdiary-5.1.1 vendor/bundle/ruby/2.7.0/gems/sequel-5.29.0/lib/sequel/extensions/pretty_table.rb
sequel-5.29.0 lib/sequel/extensions/pretty_table.rb
sequel-5.28.0 lib/sequel/extensions/pretty_table.rb
sequel-5.27.0 lib/sequel/extensions/pretty_table.rb
tdiary-5.1.0 vendor/bundle/gems/sequel-5.26.0/lib/sequel/extensions/pretty_table.rb
sequel-5.26.0 lib/sequel/extensions/pretty_table.rb
sequel-5.25.0 lib/sequel/extensions/pretty_table.rb
sequel-5.24.0 lib/sequel/extensions/pretty_table.rb
sequel-5.23.0 lib/sequel/extensions/pretty_table.rb
sequel-5.22.0 lib/sequel/extensions/pretty_table.rb
sequel-5.21.0 lib/sequel/extensions/pretty_table.rb
sequel-5.20.0 lib/sequel/extensions/pretty_table.rb
tdiary-5.0.13 vendor/bundle/gems/sequel-5.18.0/lib/sequel/extensions/pretty_table.rb
sequel-5.19.0 lib/sequel/extensions/pretty_table.rb