class BundleOutdatedFormatter::Formatter
Formatter
for all formats
Constants
- GEM_REGEXP
- GROUPS_REGEXP
- INSTALLED_REGEXP
- NEWEST_REGEXP
- REQUESTED_REGEXP
Public Class Methods
new(options)
click to toggle source
# File lib/bundle_outdated_formatter/formatter.rb, line 12 def initialize(options) @pretty = options[:pretty] @style = options[:style] @columns = options[:column] @outdated_gems = [] end
Public Instance Methods
read_stdin()
click to toggle source
# File lib/bundle_outdated_formatter/formatter.rb, line 19 def read_stdin @outdated_gems = STDIN.each.to_a.map(&:strip).reject(&:empty?) @outdated_gems.map! do |line| find_gem(line) end @outdated_gems.compact! end
Private Instance Methods
find_gem(line)
click to toggle source
# File lib/bundle_outdated_formatter/formatter.rb, line 31 def find_gem(line) matched = match_gem(line) return unless match_gem?(matched) gems = {} @columns.each do |column| gems[column] = gem_text(matched[column.to_sym], column.to_sym) end gems end
gem_text(text, name)
click to toggle source
# File lib/bundle_outdated_formatter/formatter.rb, line 56 def gem_text(text, name) text ? text[name] : '' end
match_gem(line)
click to toggle source
# File lib/bundle_outdated_formatter/formatter.rb, line 42 def match_gem(line) gems = {} @columns.each do |column| gems[column.to_sym] = self.class.const_get("#{column.upcase}_REGEXP").match(line) end gems end
match_gem?(matched)
click to toggle source
# File lib/bundle_outdated_formatter/formatter.rb, line 50 def match_gem?(matched) @columns.any? do |column| !matched[column.to_sym].nil? end end
xml_formatter()
click to toggle source
# File lib/bundle_outdated_formatter/formatter.rb, line 60 def xml_formatter return REXML::Formatters::Default.new unless @pretty formatter = REXML::Formatters::Pretty.new formatter.compact = true formatter end