8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/ree/cli/indexing/index_project.rb', line 8
def run(project_path:)
ENV['REE_SKIP_ENV_VARS_CHECK'] = 'true'
path = Ree.locate_packages_schema(project_path)
dir = Pathname.new(path).dirname.to_s
Ree.init(dir)
index_hash = {}
index_hash[:classes] = {}
index_hash[:objects] = {}
index_hash[:packages_schema] = {}
index_hash[:packages_schema][:packages] = []
index_hash[:packages_schema][:gem_packages] = []
facade = Ree.container.packages_facade
facade.packages_store.packages.each do |package|
if package.gem?
gem_package_hsh = {}
gem_package_hsh[:name] = package.name
gem_package_hsh[:gem] = package.gem_name
gem_package_hsh[:schema_rpath] = package.schema_rpath
gem_package_hsh[:entry_rpath] = package.entry_rpath
gem_package_hsh[:objects] = package.objects.map {
{
name: _1.name,
schema_rpath: _1.schema_rpath,
file_rpath: _1.rpath,
mount_as: _1.mount_as,
methods: map_fn_methods(_1),
links: _1.links.sort_by(&:object_name).map { |link|
{
Ree::ObjectSchema::Links::TARGET => link.object_name,
Ree::ObjectSchema::Links::PACKAGE_NAME => link.package_name,
Ree::ObjectSchema::Links::AS => link.as,
Ree::ObjectSchema::Links::IMPORTS => link.constants
}
}
}
}
index_hash[:packages_schema][:gem_packages] << gem_package_hsh
next
end
next if package.dir.nil?
facade.load_entire_package(package.name)
package_hsh = index_package_entry(package)
index_hash[:packages_schema][:packages] << package_hsh
index_hash = index_public_methods_for_package_classes(package, index_hash)
end
if facade.get_package(:ree_errors, false)
index_hash = index_exceptions(facade.get_package(:ree_errors), index_hash)
end
JSON.pretty_generate(index_hash)
end
|