Class: Avm::Tools::Runner::Source::Subs

Inherits:
Object
  • Object
show all
Defined in:
lib/avm/tools/runner/source/subs.rb

Constant Summary collapse

PADDING =
'  '

Instance Method Summary collapse

Instance Method Details

#output_contentObject



28
29
30
31
32
33
34
# File 'lib/avm/tools/runner/source/subs.rb', line 28

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

#runObject



17
18
19
20
# File 'lib/avm/tools/runner/source/subs.rb', line 17

def run
  start_banner
  run_output
end

#start_bannerObject



22
23
24
25
26
# File 'lib/avm/tools/runner/source/subs.rb', line 22

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

#sub_info_label(sub) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/avm/tools/runner/source/subs.rb', line 36

def sub_info_label(sub)
  return '' unless parsed.info?

  ' [' + { # rubocop:disable Style/StringConcatenation
    'CLASS' => sub.class.name,
    'SCM' => sub.scm.class.name
  }.map { |k, v| "#{k}: #{v}" }.join(', ') + ']'
end

#sub_label(sub, level) ⇒ Object



45
46
47
# File 'lib/avm/tools/runner/source/subs.rb', line 45

def sub_label(sub, level)
  sub_self_label(sub, level) + sub_info_label(sub)
end

#sub_output_content_lines(sub, level) ⇒ Object



57
58
59
# File 'lib/avm/tools/runner/source/subs.rb', line 57

def sub_output_content_lines(sub, level)
  [sub_label(sub, level)] + sub_subs_output_content_lines(sub, level)
end

#sub_self_label(sub, level) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/avm/tools/runner/source/subs.rb', line 49

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

#sub_subs_output_content_lines(sub, level) ⇒ Object



61
62
63
64
65
# File 'lib/avm/tools/runner/source/subs.rb', line 61

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