Class: RubyLens::ShowcaseModel

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

Constant Summary collapse

SIGNAL_FIELDS =
ArtModelBuilder::SIGNAL_FIELDS
TOTAL_FIELDS =
%w[namespaces packages dependencyStars renderedDependencyStars].freeze
CATEGORY_FIELDS =
%w[core tests].freeze

Instance Method Summary collapse

Instance Method Details

#call(model) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rubylens/showcase_model.rb', line 12

def call(model)
  {
    "schema" => "rubylens.showcase.v1",
    "projectName" => model.fetch("projectName"),
    "totals" => project_hash(model.fetch("totals"), TOTAL_FIELDS),
    "domains" => project_hash(model.fetch("domains"), SIGNAL_FIELDS),
    "categoryStats" => CATEGORY_FIELDS.to_h do |category|
      [category, numeric_row(model.fetch("categoryStats").fetch(category), 4)]
    end,
    "namespaces" => model.fetch("namespaces").map { |row| numeric_row(row, 15) },
    "packages" => model.fetch("packages").map { |row| numeric_row(row, 8) },
    "dependencyStars" => model.fetch("dependencyStars").map { |row| numeric_row(row, 8) },
  }
end