wbailey / command_line_reporter

A gem for making it easy to produce a report while a ruby script is executing
Apache License 2.0
432 stars 23 forks source link

Table only prints if called from instance method #18

Open dideler opened 9 years ago

dideler commented 9 years ago

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