Class: RubyLens::ArtModelBuilder

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

Defined Under Namespace

Classes: Dependencies, Namespaces, Packages

Constant Summary collapse

SCHEMA =
"rubylens.art.v13"
SIGNAL_FIELDS =
%w[ancestorDepth definitionSites reopenings descendants references members].freeze
NAMESPACE_SIGNAL_COLUMNS =

Namespace row columns carrying the six signals, aligned with SIGNAL_FIELDS.

(3..8).freeze

Instance Method Summary collapse

Constructor Details

#initialize(seed: 0x51A7_E11A) ⇒ ArtModelBuilder

: (?seed: Integer) -> void



56
57
58
# File 'lib/rubylens/art_model_builder.rb', line 56

def initialize(seed: 0x51A7_E11A)
  @seed = seed
end

Instance Method Details

#build(snapshot) ⇒ Object

Draw order is shuffled so neighbouring stars come from unrelated parts of the codebase: adjacent points would otherwise share a package or a name prefix and read as structure the galaxy does not mean to show. Every ordinal the snapshot used is therefore remapped onto the shuffled order. : (Hash[String, untyped]) -> Hash[String, untyped]



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/rubylens/art_model_builder.rb', line 65

def build(snapshot)
  random = Random.new(@seed)
  namespaces = build_namespaces(snapshot, random)
  packages = build_packages(snapshot, random)
  dependencies = build_dependencies(snapshot, packages, namespaces, random)

  {
    "schema" => SCHEMA,
    "projectName" => snapshot.fetch("project_name"),
    "morphology" => morphology_row(MorphologyClassifier.new(snapshot).call),
    "totals" => {
      "namespaces" => namespaces.rows.length,
      "packages" => packages.rows.length,
      "dependencyStars" => dependencies.rows.length,
    },
    "domains" => signal_domains(namespaces.rows, snapshot.fetch("dependency_signal_maxima")),
    "categoryStats" => snapshot.fetch("category_stats"),
    "namespaceNames" => namespaces.names,
    "namespaces" => namespaces.rows,
    "constantReferenceLinks" => build_constant_reference_links(
      namespaces.reference_rows,
      namespaces.draw_positions,
      dependencies.index,
    ),
    "packageNames" => packages.names,
    "packages" => packages.rows,
    "packageMorphologies" => packages.morphologies,
    "dependencySystems" => packages.systems,
    "dependencyStars" => dependencies.rows,
    "dependencyWarnings" => allowed_dependency_warnings(snapshot),
    "warningCounts" => snapshot.fetch("warning_counts"),
  }
end