Class: LibyearBundler::Reports::Base
- Inherits:
-
Object
- Object
- LibyearBundler::Reports::Base
- Defined in:
- lib/libyear_bundler/reports/base.rb
Overview
Base class for all reporters. Should only be concerned with presentation, nothing else.
Subclasses should implement the ‘#write` method.
Instance Method Summary collapse
-
#initialize(gems, ruby, options, io) ⇒ Base
constructor
‘gems` - Array of `::LibyearBundler::Models::Gem` instances `options` - Instance of `::LibyearBundler::Options`.
- #to_h ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(gems, ruby, options, io) ⇒ Base
‘gems` - Array of `::LibyearBundler::Models::Gem` instances `options` - Instance of `::LibyearBundler::Options`
9 10 11 12 13 14 |
# File 'lib/libyear_bundler/reports/base.rb', line 9 def initialize(gems, ruby, , io) @gems = gems @ruby = ruby @options = @io = io end |
Instance Method Details
#to_h ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/libyear_bundler/reports/base.rb', line 20 def to_h @_to_h ||= begin gems = sorted_gems(@gems) summary = { gems: gems, sum_libyears: 0.0 } gems.each { |gem| increment_metrics_summary(gem, summary) } begin increment_metrics_summary(@ruby, summary) if @ruby.outdated? rescue StandardError => e warn "Unable to calculate libyears for ruby itself: #{e}" end summary end end |
#write ⇒ Object
16 17 18 |
# File 'lib/libyear_bundler/reports/base.rb', line 16 def write raise NoMethodError, "Implement in subclass" end |