class DomesticateMonkeys::View
Attributes
snapshot[R]
Public Class Methods
new(snapshot = nil)
click to toggle source
# File lib/domesticate_monkeys/constants/view.rb, line 7 def initialize(snapshot = nil) @snapshot = snapshot || Snapshot.new end
Public Instance Methods
all(path_filter = nil)
click to toggle source
parsed CLI option methods
# File lib/domesticate_monkeys/constants/view.rb, line 13 def all(path_filter = nil) tracks = @snapshot.multi_tracks tracks = filter_tracks_by_path(tracks, path_filter) if path_filter tracks.values.each { |track| track.print } # Return nil in order to avoid a lengthy print of the @snapshot. return nil end
app()
click to toggle source
# File lib/domesticate_monkeys/constants/view.rb, line 23 def app all(app_name) end
overview()
click to toggle source
# File lib/domesticate_monkeys/constants/view.rb, line 27 def overview app_header = header_text("#{app_monkeys_count} Monkeys within our own application").red puts app_header app all_header = header_text("#{all_monkeys_count} Monkeys through the whole application, including third party software").yellow puts all_header all end
Private Instance Methods
all_monkeys_count()
click to toggle source
# File lib/domesticate_monkeys/constants/view.rb, line 58 def all_monkeys_count @snapshot.multi_tracks.count end
app_monkeys_count()
click to toggle source
# File lib/domesticate_monkeys/constants/view.rb, line 54 def app_monkeys_count filter_tracks_by_path(@snapshot.multi_tracks, app_name).count end
app_name()
click to toggle source
# File lib/domesticate_monkeys/constants/view.rb, line 47 def app_name app_class = Rails.application.class # Support both the new Module#module_parent and the deprecated Module#parent methods (Rails 6.1) top_class = app_class.respond_to?(:module_parent) ? app_class.module_parent : app_class.parent app_name = top_class.name.snakecase end
filter_tracks_by_path(tracks, path_filter)
click to toggle source
Helper methods
# File lib/domesticate_monkeys/constants/view.rb, line 41 def filter_tracks_by_path(tracks, path_filter) tracks.select do |_method, track| track.sources.any? { |source| source.snakecase.include?(path_filter.snakecase) && source.exclude?("/vendor/") } end end
header_text(text)
click to toggle source
# File lib/domesticate_monkeys/constants/view.rb, line 62 def header_text(text) <<~EOL #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# #{text} #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# EOL end