Giter VIP home page Giter VIP logo

command_line_reporter's People

Contributors

ardell avatar bmarini avatar carrum-ci avatar dideler avatar jwoffindin avatar lastobelus avatar maxmeyer avatar rrrene avatar splattael avatar tobijb avatar wbailey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

command_line_reporter's Issues

Table only prints if called from instance method

I noticed that a table is only printed if ran from an instance method. For example, this works

require 'command_line_reporter'

class Example
  include CommandLineReporter

  def run
    table do
      ...
    end
  end
end

Example.new.run

But the following does not

require 'command_line_reporter'

class Example
  include CommandLineReporter

  def self.run
    table do
      ...
    end
  end
end

Example.run

You'll get an error like

example.rb:7:in `run': undefined method `table' for Example:Class (NoMethodError)
    from example.rb:27:in `<main>'

If this is intentional, then the usage example in the README is a bit misleading and could be clarified.

require 'command_line_reporter'

class MyReport
  include CommandLineReporter
  ...
end

Missing Ruby version requirement in GemSpec

This gem will install without error on Ruby 1.9.3 since it does not specify a requirement towards the Ruby version. It will however not work with Ruby 1.9.3 because you are using the %i[array of symbols] literal introduced in Ruby 2.0.

My suggestion would be to run your CI tests against

rvm:
- 2.0.0
- 2.1.9
- 2.2.7
- 2.3.4
- 2.4.1

and to add a Ruby version requirement to your GemSpec:

   gem.required_ruby_version = '~> 2.0'

You could also adapt the syntax of your gem to work on Ruby 1.9.3 if you want still want to support that version.

.ruby-version should not be in version control

The file .ruby-version should not be checked into your Git repo. It might cause Travis CI to run all your commands with the Ruby version specified in .ruby-version and therefore ignoring the versions you specified in .travis.yml.

For more information, see the recommended .gitignore file, especially the section

# for a library or gem, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# Gemfile.lock
# .ruby-version
# .ruby-gemset

Conflict with colorize

When using colorize gem, the following error is thrown:

TypeError: no implicit conversion of Hash into String
/Users/user/.rvm/gems/ruby-2.3.1/gems/colored-1.2/lib/colored.rb:70:in `colorize'
/Users/user/.rvm/gems/ruby-2.3.1/gems/colorize-0.8.1/lib/colorize/class_methods.rb:98:in `block (2 levels) in color_methods'

Don't inherit column width for last column of a row

The code here currently sets width (along with some other attributes) on every column to the width of the corresponding column of the first row of the table.

That works well for all columns except the last when the lines are close to wrapping in a terminal window. With the current setup, if the first row is wider than the user's terminal, it will wrap, and because of the above behavior, so will all the other lines because they'll be right-padded with spaces to match the width of the first row.

I'd propose changing the code to only inherit width for the last column of a row if the text in that column is longer than the first rows's width. Either that, or just don't right-pad the last column of each row on output regardless of the column's width.

spacing == 0 issue

Param spacing => 0 doesn't work for table (only if param >0 it works ok)

Fixed for myself by adding

if lines != 0

to vertical_spacing function:

  def vertical_spacing(lines = 1)
    puts "\n" * lines if lines != 0
  rescue
    raise ArgumentError
  end

Report output is throwing some wild characters

My sample.rb

require 'command_line_reporter'
include CommandLineReporter

header title: 'STARTING SCRIPT', width: 80, align: 'center', rule: true, bold: true, timestamp: true

When I run this file ruby sample.rb I see below characters instead of a horizontal line

image

Am I missing on setting any encoders?

Using command_line_reporter v4.0.3, Ruby 2.6.3 on Windows 10

reporting into a string?!

I love it! I'm doing lots of import-scripts and the reporter is extremely handy for that. But I'm also having some import-jobs that run in delayed_job: they do report into the logs, but I'm also storing a report in the database to display it on the website (in a simple

-block).  Is there a simple way to report everything into a string and show this string later?!

Issue with newrelic_rpm

Hi Wes!

I updated my newrelic_rpm from 3.6.6.147 to 3.9.1.236, and started getting:
"..../gems/command_line_reporter-3.3.2/lib/command_line_reporter.rb:45:in `rescue in formatter='"

Looks like the newrelic gem is doing this "@log.formatter = Proc.new ..." around line 167 of agent_logger.rb, which is conflicting with your formatter= method.

I tried a quick hack with this:

38 def formatter=(type = 'nested')
39 return type if type.class != String
40 name = type.capitalize + 'Formatter'
41 klass = %W{CommandLineReporter #{name}}.inject(Kernel) {|s,c| s.const_get(c)}
42
43 # Each formatter is a singleton that responds to #instance
44 @Formatter = klass.instance
45 rescue
46 raise ArgumentError, 'Invalid formatter specified'
47 end

which seemed to stop things from crashing, but haven't had much time to see if this is appropriate or not. Any thoughts?

undefined method `align' for nil:NilClass (NoMethodError)

I want to have a header with full width, but have the error below:

code:

require 'command_line_reporter'
class AccountInfo
  include CommandLineReporter

  def initialize
    table(border: true, width: 80) do
      row header: true do
        column('Account Info', width: 80)
      end
      row do
        column('balance', width: 40)
        column('9999', width: 40)
      end
    end
  end
end
AccountInfo.new

error:

~/.rvm/gems/ruby-2.3.1/gems/command_line_reporter-4.0.0/lib/command_line_reporter/table.rb:111:in `block in use_positional_attrs': undefined method `align' for nil:NilClass (NoMethodError)
	from /Users/victor/.rvm/gems/ruby-2.3.1/gems/command_line_reporter-4.0.0/lib/command_line_reporter/table.rb:110:in `each'
	from /Users/victor/.rvm/gems/ruby-2.3.1/gems/command_line_reporter-4.0.0/lib/command_line_reporter/table.rb:110:in `use_positional_attrs'
	from /Users/victor/.rvm/gems/ruby-2.3.1/gems/command_line_reporter-4.0.0/lib/command_line_reporter/table.rb:99:in `block in inherit_column_attrs'
	from /Users/victor/.rvm/gems/ruby-2.3.1/gems/command_line_reporter-4.0.0/lib/command_line_reporter/table.rb:98:in `each'
	from /Users/victor/.rvm/gems/ruby-2.3.1/gems/command_line_reporter-4.0.0/lib/command_line_reporter/table.rb:98:in `each_with_index'
	from /Users/victor/.rvm/gems/ruby-2.3.1/gems/command_line_reporter-4.0.0/lib/command_line_reporter/table.rb:98:in `inherit_column_attrs'
	from /Users/victor/.rvm/gems/ruby-2.3.1/gems/command_line_reporter-4.0.0/lib/command_line_reporter/table.rb:25:in `add'
	from /Users/victor/.rvm/gems/ruby-2.3.1/gems/command_line_reporter-4.0.0/lib/command_line_reporter.rb:123:in `row'
	from account_info.rb:10:in `block in initialize'
	from ~/.rvm/gems/ruby-2.3.1/gems/command_line_reporter-4.0.0/lib/command_line_reporter.rb:115:in `table'
	from account_info.rb:6:in `initialize'
	from account_info.rb:17:in `new'
	from account_info.rb:17:in `<main>'

Warnings when using command_line_reporter

Running ruby with warnings yields the following warnings:

/Users/me/Documents/tool/vendor/bundle/ruby/2.1.0/gems/command_line_reporter-3.3.6/lib/command_line_reporter/formatter/progress.rb:10: warning: `*' interpreted as argument prefix
/Users/me/Documents/tool/vendor/bundle/ruby/2.1.0/gems/command_line_reporter-3.3.6/lib/command_line_reporter/formatter/progress.rb:33: warning: method redefined; discarding old indicator
/Users/me/Documents/tool/vendor/bundle/ruby/2.1.0/gems/command_line_reporter-3.3.6/lib/command_line_reporter/formatter/nested.rb:36: warning: method redefined; discarding old message_string
/Users/me/Documents/tool/vendor/bundle/ruby/2.1.0/gems/command_line_reporter-3.3.6/lib/command_line_reporter/formatter/nested.rb:40: warning: method redefined; discarding old complete_string
/Users/me/Documents/tool/vendor/bundle/ruby/2.1.0/gems/command_line_reporter-3.3.6/lib/command_line_reporter/formatter/nested.rb:44: warning: method redefined; discarding old indent_size
/Users/me/Documents/tool/vendor/bundle/ruby/2.1.0/gems/command_line_reporter-3.3.6/lib/command_line_reporter/column.rb:27: warning: method redefined; discarding old size

Separator issue

separator function doesn't return it correctly for me:

def separator(type = 'middle')
  left, center, right, bar = use_utf8? ? utf8_separator(type) : ascii_separator

  separator_str = left + self.rows[0].columns.map {|c| bar * (c.width + 2)}.join(center) + right
  separator_str.send(self.border_color) if self.border_color
end

But it works ok if i add to end of the function

     return separator_str string

Don't print colors when not on a TTY

When piping to another command or to a file the colors shouldn't be printed. Otherwise the output when running commands in a cron job for example is pretty horrible. Here's a snippet of a command I run via cron:

┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ ^[[1m^[[34m Repo Name ^[[0m^[[0m ┃ ^[[1m^[[31mOpen PRs ^[[0m^[[0m ┃ ^[[1m^[[31mIssues ^[[0m^[[0m ┃ ^[[1m^[[31mOldest PR ^[[0m^[[0m ┃ ^[[1m^[[31mOldest Iss^[[0m^[[0m ┃

Borders not working

Hi, my borders are invisible with:

table border: true do
    # ...
end

See this screenshot.

Ubuntu 12.04.4, Ruby 2.1.1, XTerm. Tested with stable and your GitHub master branch.

Table formatting broken in v3.3.3

Commit a59d00e breaks the table formatting, and v3.3.3 which was just released contains that commit.

Before (GitHub slightly messes up the alignment)

┏━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┓
┃ NAME                 ┃                   ADDRESS      ┃ CITY            ┃ 
┣━━━━━━━━━━━━━━━━━━━━━━╊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╊━━━━━━━━━━━━━━━━━┫
┃ Caesar               ┃              1 Appian Way      ┃ Rome            ┃ 
┣━━━━━━━━━━━━━━━━━━━━━━╊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╊━━━━━━━━━━━━━━━━━┫
┃ Richard Feynman      ┃             1 Golden Gate      ┃ Quantum Field   ┃ 
┗━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━┛

After


┃ NAME                 ┃                   ADDRESS      ┃ CITY            ┃ 

┃ Caesar               ┃              1 Appian Way      ┃ Rome            ┃ 

┃ Richard Feynman      ┃             1 Golden Gate      ┃ Quantum Field   ┃ 


I first noticed this when I was developing from HEAD for my patches, but I assumed the fault was somehow in my dev environment. Then I upgraded the gem from v3.3.2 to v3.3.3 and noticed the issue again.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.