Class: RubyLens::Index::RubydexAdapter

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

Defined Under Namespace

Classes: DefinitionSummary

Constant Summary collapse

TEST_SEGMENTS =
%w[test tests spec specs feature features].freeze

Instance Method Summary collapse

Constructor Details

#initialize(manifest) ⇒ RubydexAdapter

Returns a new instance of RubydexAdapter.



24
25
26
27
28
29
# File 'lib/rubylens/index/rubydex_adapter.rb', line 24

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

Instance Method Details

#indexObject



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

def index
  graph = Rubydex::Graph.new(workspace_path: @manifest.root.to_s)
  index_errors = graph.index_all(@manifest.files)
  @indexed_package_document_paths = indexed_package_document_paths(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,
  ).call
  workspace = workspace_namespaces(collected.fetch(:workspace_records), rspec.groups)
  inbound_references = inbound_workspace_references(graph, workspace.fetch(: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.v6",
    "project_name" => project_name,
    "components" => workspace.fetch(:component_counts),
    "namespace_names" => workspace.fetch(:namespace_names),
    "namespaces" => build_workspace_rows(workspace, inbound_references),
    "category_stats" => category_stats,
    "dependency_signal_maxima" => collected.fetch(:dependency_aggregation).signal_maxima,
    "packages" => build_package_rows(collected.fetch(:dependency_aggregation)),
    "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