class Object

Public Instance Methods

filter(data, params = {}) click to toggle source
# File lib/greenhat/pry_helpers.rb, line 34
def filter(data, params = {})
  result = data.clone
  params.each do |k, v|
    result.select! do |row|
      if row.key? k.to_sym
        row[k.to_sym].include? v
      else
        false
      end
    end
  end

  result
end
show(data) click to toggle source
# File lib/greenhat/pry_helpers.rb, line 1
def show(data)
  pastel = Pastel.new
  TTY::Pager.page do |pager|
    data.each do |e|
      table = TTY::Table.new(header: e.keys, rows: [e], orientation: :vertical)
      # do some work with the line

      output = table.render(:unicode, multiline: false) do |renderer|
        renderer.border.style = :cyan
        # renderer.filter = ->(val, row_index, col_index) do
        #   val.ai
        # end

        renderer.filter = lambda { |val, _row_index, col_index|
          puts val.class unless val.instance_of? String
          if col_index == 1
            if val.numeric?
              pastel.red.blue(val)
            else
              val
            end
          else
            val
          end
          # .ai(raw: true).gsub('"','')
        }
      end

      pager.write("\n#{output}") # write line to the pager
    end
  end
end
version() click to toggle source
# File lib/greenhat/pry_helpers.rb, line 49
def version
  Thing.find_by(name: 'gitlab_version_manifest_json').data.build_version
end