diff options
Diffstat (limited to 'vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples')
9 files changed, 349 insertions, 0 deletions
diff --git a/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/data.csv b/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/data.csv new file mode 100644 index 0000000..2af8d47 --- /dev/null +++ b/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/data.csv @@ -0,0 +1,4 @@ +First Name,Last Name,Email +TJ,Holowaychuk,tj@vision-media.ca +Bob,Someone,bob@vision-media.ca +Joe,Whatever,joe@vision-media.ca diff --git a/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/examples.rb b/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/examples.rb new file mode 100755 index 0000000..ebf6893 --- /dev/null +++ b/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/examples.rb @@ -0,0 +1,83 @@ +$:.unshift File.dirname(__FILE__) + '/../lib' +require 'terminal-table/import' + +puts +puts table(['a', 'b'], [1, 2], [3, 4]) + +puts +puts table(['name', 'content'], ['ftp.example.com', '1.1.1.1'], ['www.example.com', '|lalalala|lalala|']) + +puts +t = table ['a', 'b'] +t.style = {:padding_left => 2, :width => 80} +t << [1, 2] +t << [3, 4] +t << :separator +t << [4, 6] +puts t + +puts +user_table = table do |v| + v.title = "Contact Information" + v.headings = 'First Name', 'Last Name', 'Email' + v << %w( TJ Holowaychuk tj@vision-media.ca ) + v << %w( Bob Someone bob@vision-media.ca ) + v << %w( Joe Whatever bob@vision-media.ca ) +end +puts user_table + +puts +user_table = table do |v| + v.style.width = 80 + v.headings = 'First Name', 'Last Name', 'Email' + v << %w( TJ Holowaychuk tj@vision-media.ca ) + v << %w( Bob Someone bob@vision-media.ca ) + v << %w( Joe Whatever bob@vision-media.ca ) +end +puts user_table + +puts +user_table = table do + self.headings = 'First Name', 'Last Name', 'Email' + add_row ['TJ', 'Holowaychuk', 'tj@vision-media.ca'] + add_row ['Bob', 'Someone', 'bob@vision-media.ca'] + add_row ['Joe', 'Whatever', 'joe@vision-media.ca'] + add_separator + add_row ['Total', { :value => '3', :colspan => 2, :alignment => :right }] + align_column 1, :center +end +puts user_table + +puts +user_table = table do + self.headings = ['First Name', 'Last Name', {:value => 'Phones', :colspan => 2, :alignment => :center}] + add_row ['Bob', 'Someone', '123', '456'] + add_row :separator + add_row ['TJ', 'Holowaychuk', {:value => "No phones\navaiable", :colspan => 2, :alignment => :center}] + add_row :separator + add_row ['Joe', 'Whatever', '4324', '343242'] +end +puts user_table + +rows = [] +rows << ['Lines', 100] +rows << ['Comments', 20] +rows << ['Ruby', 70] +rows << ['JavaScript', 30] +puts table([nil, 'Lines'], *rows) + +rows = [] +rows << ['Lines', 100] +rows << ['Comments', 20] +rows << ['Ruby', 70] +rows << ['JavaScript', 30] +puts table(nil, *rows) + +rows = [] +rows << ['Lines', 100] +rows << ['Comments', 20] +rows << ['Ruby', 70] +rows << ['JavaScript', 30] +table = table([{ :value => 'Stats', :colspan => 2, :alignment => :center }], *rows) +table.align_column 1, :right +puts table diff --git a/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/examples_unicode.rb b/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/examples_unicode.rb new file mode 100755 index 0000000..56717e3 --- /dev/null +++ b/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/examples_unicode.rb @@ -0,0 +1,89 @@ +#!/usr/bin/env ruby + +$:.unshift File.dirname(__FILE__) + '/../lib' +require 'terminal-table/import' + +Terminal::Table::Style.defaults = { :border => :unicode_round } +# Terminal::Table::UnicodeThickEdgeBorder.new() + +puts +puts table(['a', 'b'], [1, 2], [3, 4]) + +puts +puts table(['name', 'content'], ['ftp.example.com', '1.1.1.1'], ['www.example.com', '|lalalala|lalala|']) + +puts +t = table ['a', 'b'] +t.style = {:padding_left => 2, :width => 80} +t << [1, 2] +t << [3, 4] +t << :separator +t << [4, 6] +puts t + +puts +user_table = table do |v| + v.title = "Contact Information" + v.headings = 'First Name', 'Last Name', 'Email' + v << %w( TJ Holowaychuk tj@vision-media.ca ) + v << %w( Bob Someone bob@vision-media.ca ) + v << %w( Joe Whatever bob@vision-media.ca ) +end +puts user_table + +puts +user_table = table do |v| + v.style.width = 80 + v.headings = 'First Name', 'Last Name', 'Email' + v << %w( TJ Holowaychuk tj@vision-media.ca ) + v << %w( Bob Someone bob@vision-media.ca ) + v << %w( Joe Whatever bob@vision-media.ca ) +end +puts user_table + +puts +user_table = table do + self.headings = 'First Name', 'Last Name', 'Email' + add_row ['TJ', 'Holowaychuk', 'tj@vision-media.ca'] + add_row ['Bob', 'Someone', 'bob@vision-media.ca'] + add_row ['Joe', 'Whatever', 'joe@vision-media.ca'] + add_separator + add_row ['Total', { :value => '3', :colspan => 2, :alignment => :right }] + align_column 1, :center +end +puts user_table + +puts +user_table = table do + self.headings = ['First Name', 'Last Name', {:value => 'Phones', :colspan => 2, :alignment => :center}] + #add_row ['Bob', 'Someone', '123', '456'] + add_row [{:value => "Bob Someone", :colspan => 3, :alignment => :center}, '123456'] + add_row :separator + add_row ['TJ', 'Holowaychuk', {:value => "No phones\navaiable", :colspan => 2, :alignment => :center}] + add_row :separator + add_row ['Joe', 'Whatever', '4324', '343242'] +end +puts user_table + +rows = [] +rows << ['Lines', 100] +rows << ['Comments', 20] +rows << ['Ruby', 70] +rows << ['JavaScript', 30] +puts table([nil, 'Lines'], *rows) + +rows = [] +rows << ['Lines', 100] +rows << ['Comments', 20] +rows << ['Ruby', 70] +rows << ['JavaScript', 30] +puts table(nil, *rows) + +rows = [] +rows << ['Lines', 100] +rows << ['Comments', 20] +rows << ['Ruby', 70] +rows << ['JavaScript', 30] +table = table([{ :value => 'Stats', :colspan => 2, :alignment => :center }], *rows) +table.align_column 1, :right +puts table diff --git a/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/issue100.rb b/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/issue100.rb new file mode 100755 index 0000000..41527be --- /dev/null +++ b/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/issue100.rb @@ -0,0 +1,34 @@ +#!/usr/bin/env ruby + +# Methods to suppress left/right borders using border_left & border_right + +require_relative "../lib/terminal-table" +table = Terminal::Table.new do |t| + t.headings = ['id', 'name'] + t.rows = [[1, 'One'], [2, 'Two'], [3, 'Three']] + t.style = { :border_left => false, :border_top => false, :border_bottom => false } +end + +puts table +puts + +# no right +table.style = {:border_right => false } +puts table +puts + +# no right +table.style = {:border_left => true } +puts table +puts + +table.style.border = Terminal::Table::UnicodeBorder.new +puts table + + +table.style = {:border_right => false, :border_left => true } +puts table + +table.style = {:border_right => true, :border_left => false } +puts table + diff --git a/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/issue111.rb b/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/issue111.rb new file mode 100755 index 0000000..a7a6c71 --- /dev/null +++ b/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/issue111.rb @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative "../lib/terminal-table" +puts Terminal::Table.new(headings: ['heading A', 'heading B'], rows: [['a', 'b'], ['a', 'b']], style: {border: Terminal::Table::MarkdownBorder.new}) + diff --git a/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/issue118.rb b/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/issue118.rb new file mode 100755 index 0000000..e94eb71 --- /dev/null +++ b/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/issue118.rb @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby + +require_relative '../lib/terminal-table' + +puts Terminal::Table.new(headings: ['a', 'b', 'c', 'd'], style: { border: :unicode }) + +puts + +tbl = Terminal::Table.new do |t| + t.style = { border: :unicode } + t.add_separator + t.add_separator + t.add_row ['x','y','z'] + t.add_separator + t.add_separator +end +puts tbl + +puts + +puts Terminal::Table.new(headings: [['a', 'b', 'c', 'd'], ['cat','dog','frog','mouse']], style: { border: :unicode }) + +puts + +puts Terminal::Table.new(headings: ['a', 'b', 'c', 'd']) + +puts + +tbl = Terminal::Table.new do |t| + t.add_separator + t.add_separator + t.add_row ['x','y','z'] + t.add_separator + t.add_separator +end +puts tbl diff --git a/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/issue95.rb b/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/issue95.rb new file mode 100755 index 0000000..e6ddbf8 --- /dev/null +++ b/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/issue95.rb @@ -0,0 +1,42 @@ +#!/usr/bin/env ruby +require 'colorize' +require_relative '../lib/terminal-table.rb' + +original_sample_data = [ +["Sep 2016", 33, [-38, -53.52], 46, [-25, -35.21]], +["Oct 2016", 35, [2, 6.06], 50, [4, 8.69]] +] + +table = Terminal::Table.new headings: ["Month".cyan,"Monthly IT".cyan,"IT Difference OPM".cyan, +"Monthly OOT".cyan,"OOT Difference OPM".cyan], rows: original_sample_data + +table.style = { padding_left: 2, padding_right: 2, border_x: "-".blue, border_y: "|".blue, border_i: "+".blue } + +puts table + +puts "" +puts "^ good table" +puts "v wonky table" +puts "" + +split_column_sample_data = [ +["Sep 2016", 33, -38, -53.52, 46, -25, -35.21], +["Oct 2016", 35, 2, 6.06, 50, 4, 8.69] +] + +table = Terminal::Table.new headings: ["Month".cyan,"Monthly IT".cyan, +{value: "IT Difference OPM".cyan, colspan: 2}, "Monthly OOT".cyan, +{value: "OOT Difference OPM".cyan, colspan: 2}], rows: split_column_sample_data + +table.style = { padding_left: 2, padding_right: 2, border_x: "-".blue, border_y: "|".blue, border_i: "+".blue } + +puts table + + +table = Terminal::Table.new headings: ["Month","Monthly IT", +{value: "IT Difference OPM", colspan: 2}, "Monthly OOT", +{value: "OOT Difference OPM", colspan: 2}], rows: split_column_sample_data + +table.style = { padding_left: 2, padding_right: 2, border_x: "-".blue, border_y: "|".cyan, border_i: "+" } + +puts table diff --git a/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/show_csv_table.rb b/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/show_csv_table.rb new file mode 100755 index 0000000..1bb368a --- /dev/null +++ b/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/show_csv_table.rb @@ -0,0 +1,34 @@ +#!/usr/bin/env ruby + +require "csv" +$LOAD_PATH << "#{__dir__}/../lib" +require "terminal-table" + +# +# Usage: +# ./show_csv_table.rb data.csv +# cat data.csv | ./show_csv_table.rb +# cat data.csv | ./show_csv_table.rb - +# +# +# Reads a CSV from $stdin if no argument given, or argument is '-' +# otherwise interprets first cmdline argument as the CSV filename +# +use_stdin = ARGV[0].nil? || (ARGV[0] == '-') +io_object = use_stdin ? $stdin : File.open(ARGV[0], 'r') +csv = CSV.new(io_object) + +# +# Convert to an array for use w/ terminal-table +# The assumption is that this is a pretty small spreadsheet. +# +csv_array = csv.to_a + +user_table = Terminal::Table.new do |v| + v.style = { :border => :unicode_round } # >= v3.0.0 + v.title = "Some Title" + v.headings = csv_array[0] + v.rows = csv_array[1..-1] +end + +puts user_table diff --git a/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/strong_separator.rb b/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/strong_separator.rb new file mode 100755 index 0000000..52ad195 --- /dev/null +++ b/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/examples/strong_separator.rb @@ -0,0 +1,23 @@ +#!/usr/bin/env ruby +require_relative "../lib/terminal-table" + +# +# An example of how to manually add separators with non-default +# border_type to enable a footer row. +# +table = Terminal::Table.new do |t| + # set the style + t.style = { border: :unicode_thick_edge } + + # header row + t.headings = ['fruit', 'count'] + + # some row data + t.add_row ['apples', 7] + t.add_row ['bananas', 19] + t.add_separator border_type: :strong + # footer row + t.add_row ['total', 26] +end + +puts table.render |
