Sha256: 01c5cbc2604e8ae3973a106bbaffd07e39a6e293adab715da1e9f143e1f152f0

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

DEFAULT_REPORT_OPTIONS = {
  :show_never_called_candidates_section?  => false,
  :show_bad_candidates_section?           => false,
  :show_empty_classes?                    => false
}

def options
  Object.new.tap do |o|
    def o.show_never_called_candidates_section?
      (ENV['PP_OPTIONS'] =~ /--show-never-called/) || DEFAULT_REPORT_OPTIONS[:show_never_called_candidates_section?]
    end

    def o.show_bad_candidates_section?
      (ENV['PP_OPTIONS'] =~ /--show-bad-candidates/) || DEFAULT_REPORT_OPTIONS[:show_bad_candidates_section?]
    end

    def o.show_empty_classes?
      (ENV['PP_OPTIONS'] =~ /--show-empty-classes/) || DEFAULT_REPORT_OPTIONS[:show_empty_classes?]
    end
  end
end

def options_footer_parts
  parts = []
  DEFAULT_REPORT_OPTIONS.keys.each do |key|
    display       = "--#{key}".gsub('_', '-')
    current_value = options.send(key)
    is_default    = DEFAULT_REPORT_OPTIONS[key] == current_value
    parts << [display, (is_default ? '*' : ' '), current_value]
  end
  longest_value_length = parts.map(&:first).map(&:length).max || 0
  parts.each do |p|
    p[0] = p[0].ljust(longest_value_length)
  end
  parts
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
private_please-0.0.5 lib/private_please/reporter/helpers/options_helpers.rb