Class: RubyLens::Index::RubydexAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/rubylens/index/rubydex_adapter.rb

Defined Under Namespace

Classes: ReferenceSummary

Constant Summary collapse

TEST_SEGMENTS =
%w[test tests spec specs feature features].freeze
1_024
CONSTANT_REFERENCE_ATTRIBUTION_LIMIT =
CONSTANT_REFERENCE_LINK_LIMIT * 2

Instance Method Summary collapse

Constructor Details

#initialize(manifest) ⇒ RubydexAdapter

Returns a new instance of RubydexAdapter.



18
19
20
21
22
23
24
25
# File 'lib/rubylens/index/rubydex_adapter.rb', line 18

def initialize(manifest)
  @manifest = manifest
  @source_path_cache = {}
  @workspace_location_cache = {}
  @definition_scope_by_uri = {}
  @package_index_by_uri = {}
  @indexed_package_document_paths = Set.new
end

Instance Method Details

#indexObject



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
# File 'lib/rubylens/index/rubydex_adapter.rb', line 27

def index
  graph = Rubydex::Graph.new(workspace_path: @manifest.root.to_s)
  index_errors = graph.index_all(@manifest.files)
  @indexed_package_document_paths, documents_with_paths = resolve_documents(graph)
  graph.resolve
  integrity_failures = graph.check_integrity
  collected = collect_declarations(graph.declarations)
  rspec = RSpecExtractor.new(
    graph: graph,
    manifest: @manifest,
    package_document_paths: @indexed_package_document_paths,
    documents_with_paths: documents_with_paths,
  ).call
  workspace = workspace_namespaces(
    collected.fetch(:workspace_records),
    rspec.groups,
    collected.fetch(:workspace_definition_ranges),
  )
  reference_summary = workspace_reference_summary(
    graph,
    workspace,
    collected.fetch(:dependency_ordinal_by_name),
  )
  category_stats = collected.fetch(:category_stats)
  category_stats.fetch("tests")[0] += rspec.groups.length
  category_stats.fetch("tests")[2] += rspec.method_count

  {
    "schema" => "rubylens.snapshot.v9",
    "project_name" => project_name,
    "namespace_names" => workspace.fetch(:namespace_names),
    "namespaces" => build_workspace_rows(workspace, reference_summary.inbound_counts),
    "constant_reference_links" => reference_summary.links,
    "category_stats" => category_stats,
    "dependency_signal_maxima" => collected.fetch(:dependency_signal_maxima),
    "packages" => build_package_rows(collected.fetch(:dependency_packages)),
    "dependency_systems" => build_dependency_system_rows,
    "dependency_warnings" => @manifest.respond_to?(:dependency_warnings) ? @manifest.dependency_warnings : [],
    "warning_counts" => {
      "manifest" => @manifest.warnings.length,
      "index" => index_errors.length,
      "integrity" => integrity_failures.length,
    },
  }
end