Module: Tapioca::ShimsHelper
Constant Summary collapse
- SORBET_PAYLOAD_URL =
"https://github.com/sorbet/sorbet/tree/master/rbi"
Instance Method Summary collapse
- #duplicated_nodes_from_index(index, shim_rbi_dir) ⇒ Object
- #index_payload(index, dir) ⇒ Object
- #index_rbis(index, kind, dir) ⇒ Object
- #location_to_payload_url(loc, path_prefix:) ⇒ Object
Instance Method Details
#duplicated_nodes_from_index(index, shim_rbi_dir) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/tapioca/helpers/shims_helper.rb', line 34 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_payload(index, dir) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/tapioca/helpers/shims_helper.rb', line 14 def index_payload(index, dir) return unless Dir.exist?(dir) say("Loading Sorbet payload... ") files = Dir.glob("#{dir}/**/*.rbi").sort parse_and_index_files(index, files) say(" Done", :green) end |
#index_rbis(index, kind, dir) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/tapioca/helpers/shims_helper.rb', line 24 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 parse_and_index_files(index, files) say(" Done", :green) end |
#location_to_payload_url(loc, path_prefix:) ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/tapioca/helpers/shims_helper.rb', line 48 def location_to_payload_url(loc, path_prefix:) return loc.to_s unless path_prefix url = loc.file || "" return loc.to_s unless url.start_with?(path_prefix) url = url.sub(path_prefix, SORBET_PAYLOAD_URL) url = "#{url}#L#{loc.begin_line}" url end |