Class: BrewOutdatedFormatter::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/brew_outdated_formatter/formatter.rb

Overview

Formatter for all formats

Constant Summary collapse

FORMULA_REGEXP =
/\A(?<formula>.+) \(/
INSTALLED_REGEXP =
/\((?<installed>.+)\)/
CURRENT_REGEXP =
/< ((?<current>.+) \[|(?<current>.+)\z)/
PINNED_REGEXP =
/\[pinned at (?<pinned>.+)\]/
COLUMNS =
%w[formula installed current pinned].freeze

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Formatter

Returns a new instance of Formatter.



11
12
13
14
# File 'lib/brew_outdated_formatter/formatter.rb', line 11

def initialize(options)
  @pretty = options[:pretty]
  @outdated_formulas = []
end

Instance Method Details

#read_stdinObject



16
17
18
19
20
21
22
23
24
# File 'lib/brew_outdated_formatter/formatter.rb', line 16

def read_stdin
  @outdated_formulas = STDIN.each.to_a.map(&:strip).reject(&:empty?)

  @outdated_formulas.map! do |line|
    find_formula(line)
  end

  @outdated_formulas.compact!
end