Module: Tapioca::ShimsHelper

Extended by:
T::Helpers, T::Sig
Included in:
Cli
Defined in:
lib/tapioca/helpers/shims_helper.rb

Instance Method Summary collapse

Instance Method Details

#duplicated_nodes_from_index(index, shim_rbi_dir) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/tapioca/helpers/shims_helper.rb', line 29

def duplicated_nodes_from_index(index, shim_rbi_dir)
  duplicates = {}
  say("Looking for duplicates... ")
  index.keys.each do |key|
    nodes = index[key]
    next unless shims_have_duplicates?(nodes, shim_rbi_dir)
    duplicates[key] = nodes
  end
  say(" Done", :green)
  duplicates
end

#index_rbis(index, kind, dir) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/tapioca/helpers/shims_helper.rb', line 12

def index_rbis(index, kind, dir)
  return unless Dir.exist?(dir) && !Dir.empty?(dir)

  say("Loading #{kind} RBIs from #{dir}... ")
  files = Dir.glob("#{dir}/**/*.rbi").sort

  trees = files.map do |file|
    RBI::Parser.parse_file(file)
  rescue RBI::ParseError => e
    say_error("\nWarning: #{e} (#{e.location})", :yellow)
  end.compact

  index.visit_all(trees)
  say(" Done", :green)
end