Sha256: 104161ed0a6887cc747a92497b7b106eecd195e90fd62b5d5ca330a9688663fc
Contents?: true
Size: 1.9 KB
Versions: 65
Compression:
Stored size: 1.9 KB
Contents
# frozen_string_literal: true require 'avm/tools/core_ext' module Avm module Tools class Runner class AppSrc class Subs PADDING = ' ' runner_with :help, :output do desc 'Output source\'s subs.' bool_opt '-i', '--info' bool_opt '-R', '--recursive' bool_opt '-t', '--tree' end def run start_banner run_output end def start_banner infov 'Include PATH', runner_context.call(:subject).subs_include_path infov 'Exclude PATH', runner_context.call(:subject).subs_exclude_path infov 'Count', runner_context.call(:subject).subs.count end def output_content b = [] runner_context.call(:subject).subs.each do |sub| b += sub_output_content_lines(sub, 0) end b.map { |line| "#{line}\n" }.join end def sub_info_label(sub) return '' unless parsed.info? ' [' + { 'CLASS' => sub.class.name }.map { |k, v| "#{k}: #{v}" }.join(', ') + ']' end def sub_label(sub, level) sub_self_label(sub, level) + sub_info_label(sub) end def sub_self_label(sub, level) if parsed.tree? (PADDING * level) + sub.relative_path.to_s else sub.path.relative_path_from(runner_context.call(:subject).path).to_s end end def sub_output_content_lines(sub, level) [sub_label(sub, level)] + sub_subs_output_content_lines(sub, level) end def sub_subs_output_content_lines(sub, level) return [] unless parsed.recursive? sub.subs.flat_map { |sub_sub| sub_output_content_lines(sub_sub, level + 1) } end end end end end end
Version data entries
65 entries across 65 versions & 2 rubygems