Class: TypeTracer::TypeFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/type_tracer/type_fetcher.rb

Class Method Summary collapse

Class Method Details

.fetch_sampled_typesObject



9
10
11
12
13
14
15
# File 'lib/type_tracer/type_fetcher.rb', line 9

def fetch_sampled_types
  url = TypeTracer.config.sampled_types_url
  puts "Using sampled types from: #{url}\n\n"
  json = Net::HTTP.get(URI.parse(url))
  save_types_locally(json)
  JSON.parse(json).deep_symbolize_keys
end

.save_types_locally(types_json) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/type_tracer/type_fetcher.rb', line 17

def save_types_locally(types_json)
  root_path = TypeTracer.config.type_check_root_path
  folder = File.join(root_path, 'tmp', 'type_tracer')
  FileUtils.mkdir_p(folder)
  file = File.join(folder, 'sampled_types.json')
  File.write(file, types_json)
end